:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ocean-deep: #020c1b;
  --ocean-cyan: #2cf0ff;
  --ocean-gold: #ffd86b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ocean-deep);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button, [role="button"], .ocean-btn {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#unity-container {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #01060e;
  position: relative;
  overflow: hidden;
}

#unity-canvas {
  background: #020e20;
  display: block;
  box-shadow: 0 0 36px rgba(0, 175, 255, 0.24);
  cursor: default;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   Animated Ocean Hunter Splash Screen (GPU Composite-Only: transform/opacity)
   ========================================================================== */
#unity-loading-bar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding:
    max(20px, env(safe-area-inset-top, 0px))
    max(20px, env(safe-area-inset-right, 0px))
    max(22px, env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left, 0px));
  z-index: 50;
  overflow: hidden;
  background: #041c3c;
  user-select: none;
  -webkit-user-select: none;
  opacity: 1;
  transform: scale(1);
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
}

#unity-loading-bar.fade-out {
  opacity: 0;
  transform: scale(1.025);
  pointer-events: none;
}

/* 1. Sunlit Coral Reef Backdrop */
.ocean-backdrop {
  position: absolute;
  inset: 0;
  background: #04244b url("splash_bg.webp?v=20261112d") center center / cover no-repeat;
  transform: scale(1.02);
  animation: ocean-breathe 14s var(--ease-in-out) infinite alternate;
  z-index: 0;
}

.ocean-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 34%, rgba(44, 240, 255, 0.10) 0%, rgba(2, 16, 38, 0.16) 52%, rgba(1, 9, 24, 0.62) 100%),
    linear-gradient(180deg, rgba(1, 14, 34, 0.08) 0%, rgba(1, 14, 34, 0.16) 54%, rgba(1, 8, 22, 0.78) 100%);
  z-index: 1;
  pointer-events: none;
}

@keyframes ocean-breathe {
  0% { transform: scale(1.02) translate3d(0, 0, 0); }
  100% { transform: scale(1.065) translate3d(0, -1.2%, 0); }
}

/* 2. Underwater Caustic Sunbeams (Composite-only transform + opacity) */
.sunbeam-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.sunbeam {
  position: absolute;
  top: -18%;
  left: 50%;
  width: 26vw;
  min-width: 180px;
  height: 125%;
  transform-origin: 50% 0%;
  background: linear-gradient(
    180deg,
    rgba(195, 250, 255, 0.28) 0%,
    rgba(88, 226, 255, 0.11) 48%,
    rgba(0, 170, 255, 0) 92%
  );
  clip-path: polygon(36% 0%, 64% 0%, 100% 100%, 0% 100%);
  opacity: 0.55;
}

.sunbeam.b1 {
  transform: translate3d(-72%, 0, 0) rotate(-18deg);
  animation: sunbeam-sway-1 7.5s var(--ease-in-out) infinite alternate;
}

.sunbeam.b2 {
  width: 32vw;
  transform: translate3d(-50%, 0, 0) rotate(-2deg);
  animation: sunbeam-sway-2 9s var(--ease-in-out) infinite alternate;
}

.sunbeam.b3 {
  transform: translate3d(-26%, 0, 0) rotate(16deg);
  animation: sunbeam-sway-3 8.2s var(--ease-in-out) infinite alternate;
}

@keyframes sunbeam-sway-1 {
  0% { opacity: 0.36; transform: translate3d(-74%, 0, 0) rotate(-20deg) scaleX(0.94); }
  100% { opacity: 0.68; transform: translate3d(-68%, 0, 0) rotate(-14deg) scaleX(1.06); }
}

@keyframes sunbeam-sway-2 {
  0% { opacity: 0.48; transform: translate3d(-50%, 0, 0) rotate(-4deg) scaleX(0.96); }
  100% { opacity: 0.78; transform: translate3d(-50%, 0, 0) rotate(3deg) scaleX(1.08); }
}

@keyframes sunbeam-sway-3 {
  0% { opacity: 0.34; transform: translate3d(-28%, 0, 0) rotate(13deg) scaleX(0.95); }
  100% { opacity: 0.64; transform: translate3d(-22%, 0, 0) rotate(19deg) scaleX(1.05); }
}

/* 3. Rising Ocean Bubbles (Off-Main-Thread Compositor Keyframes) */
.bubble-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.bubble {
  position: absolute;
  bottom: -48px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.88) 0%,
    rgba(165, 243, 255, 0.38) 34%,
    rgba(56, 198, 255, 0.10) 68%,
    rgba(255, 255, 255, 0.28) 100%
  );
  border: 1px solid rgba(210, 250, 255, 0.45);
  opacity: 0;
  animation: bubble-rise linear infinite;
}

.bubble:nth-child(1)  { left: 7%;  width: 14px; height: 14px; animation-duration: 7.4s; animation-delay: 0.2s; }
.bubble:nth-child(2)  { left: 15%; width: 9px;  height: 9px;  animation-duration: 6.2s; animation-delay: 1.8s; }
.bubble:nth-child(3)  { left: 23%; width: 18px; height: 18px; animation-duration: 8.6s; animation-delay: 0.7s; }
.bubble:nth-child(4)  { left: 31%; width: 11px; height: 11px; animation-duration: 6.9s; animation-delay: 2.9s; }
.bubble:nth-child(5)  { left: 40%; width: 7px;  height: 7px;  animation-duration: 5.8s; animation-delay: 1.1s; }
.bubble:nth-child(6)  { left: 48%; width: 16px; height: 16px; animation-duration: 8.1s; animation-delay: 3.4s; }
.bubble:nth-child(7)  { left: 56%; width: 10px; height: 10px; animation-duration: 6.5s; animation-delay: 0.5s; }
.bubble:nth-child(8)  { left: 64%; width: 20px; height: 20px; animation-duration: 9.2s; animation-delay: 2.1s; }
.bubble:nth-child(9)  { left: 73%; width: 12px; height: 12px; animation-duration: 7.1s; animation-delay: 1.4s; }
.bubble:nth-child(10) { left: 82%; width: 8px;  height: 8px;  animation-duration: 6.0s; animation-delay: 3.0s; }
.bubble:nth-child(11) { left: 89%; width: 15px; height: 15px; animation-duration: 7.9s; animation-delay: 0.9s; }
.bubble:nth-child(12) { left: 94%; width: 10px; height: 10px; animation-duration: 6.7s; animation-delay: 2.4s; }

@keyframes bubble-rise {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.75);
  }
  12% {
    opacity: 0.78;
  }
  55% {
    opacity: 0.68;
    transform: translate3d(14px, -56vh, 0) scale(0.96);
  }
  88% {
    opacity: 0.45;
  }
  100% {
    opacity: 0;
    transform: translate3d(-10px, -112vh, 0) scale(1.12);
  }
}

/* Top Edition Pill */
.splash-top-badge {
  position: relative;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(3, 22, 48, 0.58);
  border: 1px solid rgba(110, 232, 255, 0.36);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #dffaff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  animation: splash-enter 380ms var(--ease-out) both;
}

.splash-top-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3dffb5;
  box-shadow: 0 0 8px rgba(61, 255, 181, 0.9);
}

/* 4. Centerpiece 3D Crest (iFISH 3D: OCEAN HUNTER) */
.splash-centerpiece {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 6px 0;
  animation: splash-enter 440ms var(--ease-out) 60ms both;
}

.logo-float-wrap {
  position: relative;
  width: min(560px, 78vw, 82vh);
  aspect-ratio: 2 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logo-buoyancy 3.8s var(--ease-in-out) infinite alternate;
}

.logo-glow-halo {
  position: absolute;
  inset: 8% 12%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(44, 240, 255, 0.42) 0%,
    rgba(255, 212, 92, 0.22) 45%,
    rgba(0, 120, 255, 0) 74%
  );
  animation: halo-pulse 3.2s var(--ease-in-out) infinite alternate;
  pointer-events: none;
}

#unity-logo {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(1, 12, 32, 0.68));
  pointer-events: none;
}

.sr-only-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes logo-buoyancy {
  0% { transform: translate3d(0, 4px, 0) scale(0.992); }
  100% { transform: translate3d(0, -7px, 0) scale(1.012); }
}

@keyframes halo-pulse {
  0% { opacity: 0.62; transform: scale(0.94); }
  100% { opacity: 1; transform: scale(1.08); }
}

@keyframes splash-enter {
  0% {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* 5. Bottom Progress HUD with Bespoke Twin-Marlin Frame */
.splash-hud {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  animation: splash-enter 440ms var(--ease-out) 120ms both;
}

.marlin-bar-shell {
  position: relative;
  width: min(500px, 88vw);
  aspect-ratio: 3 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Exact inner slot geometry aligned behind splash_bar_frame.webp (100% vertical & horizontal cavity fill, 0 exterior bleed) */
#unity-progress-bar-empty {
  position: absolute;
  left: 8.5%;
  width: 83.0%;
  top: 35.5%;
  height: 36.5%;
  border-radius: 14px;
  background: linear-gradient(180deg, #020e22 0%, #072347 52%, #03152f 100%);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.88);
  overflow: hidden;
  z-index: 1;
}

#unity-progress-bar-full {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0 12px 12px 0;
  transform: translate3d(-98%, 0, 0);
  transition: transform 200ms var(--ease-out);
  background: linear-gradient(
    90deg,
    #0068e8 0%,
    #00c8ff 46%,
    #36ffe2 80%,
    #ffe27a 100%
  );
  box-shadow: 0 0 16px rgba(54, 255, 226, 0.60);
  overflow: hidden;
}

#unity-progress-bar-full::before {
  content: "";
  position: absolute;
  inset: 0 0 52% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.04) 100%);
  border-radius: 0 12px 0 0;
  pointer-events: none;
}

#unity-progress-bar-full::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #ffffff 0%, #fff2a6 50%, #7affea 100%);
  box-shadow: 0 0 10px rgba(255, 246, 180, 0.95);
  border-radius: 0 12px 12px 0;
  pointer-events: none;
}

.bar-liquid-shimmer {
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translate3d(-120%, 0, 0) skewX(-20deg);
  animation: bar-shimmer-sweep 1.85s linear infinite;
  pointer-events: none;
}

@keyframes bar-shimmer-sweep {
  0% { transform: translate3d(-130%, 0, 0) skewX(-20deg); }
  100% { transform: translate3d(320%, 0, 0) skewX(-20deg); }
}

.marlin-bar-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(0, 10, 28, 0.68));
}

/* Status & Tabular Percentage Pill */
.splash-status-row {
  margin-top: -2px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(2, 17, 38, 0.72);
  border: 1px solid rgba(102, 224, 255, 0.34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 8, 22, 0.55);
  z-index: 4;
}

#unity-status {
  color: #d6f5ff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.status-divider {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(125, 228, 255, 0.65);
}

#unity-progress-text {
  color: var(--ocean-gold);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

/* Rotating Gameplay Tip */
.splash-tip {
  margin-top: 8px;
  color: #eafbff;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  background: rgba(2, 16, 36, 0.58);
  border: 1px solid rgba(110, 226, 255, 0.22);
  border-radius: 999px;
  padding: 4px 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  opacity: 1;
  transition: opacity 220ms var(--ease-out);
}

.splash-tip.tip-swapping {
  opacity: 0;
}

/* Compact landscape phones (e.g. iPhone SE / Android 360px height landscape) */
@media (max-height: 460px) {
  #unity-loading-bar {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .splash-top-badge {
    padding: 3px 12px;
    font-size: 10px;
  }
  .logo-float-wrap {
    width: min(390px, 56vw, 50vh);
  }
  .marlin-bar-shell {
    width: min(350px, 68vw);
  }
  .splash-status-row {
    margin-top: -8px;
    padding: 4px 14px;
  }
  .splash-tip {
    display: none;
  }
}

/* ==========================================================================
   Orientation Prompt & Non-Blocking Ocean Diagnostic Modal
   ========================================================================== */
#orientation-warning {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(2, 12, 28, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  text-align: center;
  padding: 28px;
}

.rotate-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: rotate-phone 2.2s var(--ease-in-out) infinite;
}

@keyframes rotate-phone {
  0%, 20% { transform: rotate(0deg); }
  50%, 80% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

.rotate-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  max-width: 320px;
  color: #d8f4ff;
}

#unity-warning {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 90%;
  display: none;
}

.banner-error {
  background: rgba(190, 24, 60, 0.92);
  border: 1px solid rgba(255, 130, 155, 0.5);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.banner-warning {
  background: rgba(245, 178, 28, 0.94);
  color: #141c28;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

#ocean-error-modal {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 95;
  background: rgba(2, 12, 28, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#ocean-error-modal.visible {
  display: flex;
}

.ocean-error-card {
  width: min(440px, 92vw);
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(8, 38, 78, 0.96) 0%, rgba(3, 18, 42, 0.98) 100%);
  border: 1.5px solid rgba(92, 222, 255, 0.45);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  color: #eaf9ff;
  text-align: center;
  animation: splash-enter 240ms var(--ease-out) both;
}

.ocean-error-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ocean-gold);
  margin-bottom: 10px;
}

.ocean-error-body {
  font-size: 13.5px;
  line-height: 1.5;
  color: #c6eaff;
  margin-bottom: 18px;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.ocean-error-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.ocean-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), opacity 120ms var(--ease-out);
}

.ocean-btn.primary {
  background: linear-gradient(180deg, #2ef2a8 0%, #09b875 100%);
  color: #032217;
  box-shadow: 0 4px 14px rgba(18, 218, 138, 0.4);
}

.ocean-btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #dff6ff;
  border: 1px solid rgba(145, 228, 255, 0.35);
}

.ocean-btn:active {
  transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
  .ocean-btn:hover {
    transform: scale(1.03);
  }
  .ocean-btn:active {
    transform: scale(0.97);
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .ocean-backdrop,
  .sunbeam,
  .logo-float-wrap,
  .logo-glow-halo,
  .bar-liquid-shimmer,
  .rotate-icon {
    animation: none !important;
  }
  .bubble-layer {
    display: none !important;
  }
  #unity-loading-bar,
  .splash-top-badge,
  .splash-centerpiece,
  .splash-hud {
    animation: none !important;
    transition: opacity 200ms ease !important;
  }
}
