:root {
  color-scheme: dark;
  font-family:
    "Segoe UI",
    "Noto Sans TC",
    system-ui,
    sans-serif;
  --progress: 0;
  --pressure: 0;
  --bg: #03111f;
  --panel: rgba(7, 30, 48, 0.88);
  --panel-strong: rgba(10, 42, 62, 0.94);
  --line: rgba(136, 214, 224, 0.22);
  --text: #effaff;
  --muted: #95b6c6;
  --cyan: #61e3ed;
  --teal: #1bb89b;
  --logi-green: #00e0a4;
  --logi-green-soft: rgba(0, 224, 164, 0.2);
  --gold: #ffc857;
  --coral: #ff6b6b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  display: grid;
  place-items: center;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(6, 72, 94, 0.62), transparent 35%),
    linear-gradient(90deg, #020914 0%, #03111f 22%, #03111f 78%, #020914 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  --side-panel: clamp(270px, 18.6vw, 360px);
  --shell-gap: clamp(12px, 1.2vw, 22px);
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  overflow: hidden;
  background: #03111f;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.52);
}

.control-panel,
.leaderboard-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.control-panel {
  position: absolute;
  top: var(--shell-gap);
  bottom: var(--shell-gap);
  left: var(--shell-gap);
  z-index: 30;
  display: grid;
  width: var(--side-panel);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "brand"
    "form"
    "stats"
    "rules"
    "result";
  grid-template-rows: auto auto auto minmax(0, auto);
  align-content: start;
  gap: clamp(10px, 1.25vh, 16px);
  padding: clamp(12px, 1.35vh, 18px);
  overflow: hidden;
}

.brand-lockup {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(97, 227, 237, 0.4);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(97, 227, 237, 0.18), rgba(255, 200, 87, 0.18));
  color: var(--cyan);
  font-weight: 800;
}

.brand-name,
.eyeline {
  margin: 0;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 3px;
  font-size: clamp(1.38rem, 3.4vw, 2.05rem);
  line-height: 1.05;
  white-space: nowrap;
}

h2 {
  font-size: 1.2rem;
}

.player-form {
  grid-area: form;
  display: grid;
  gap: 8px;
}

label,
.meter-row span,
.stat-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(149, 182, 198, 0.28);
  border-radius: 8px;
  padding: 0 13px;
  background: rgba(1, 8, 14, 0.5);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(97, 227, 237, 0.14);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--gold), #ffe08f);
  color: #1d1604;
}

.secondary-button {
  border: 1px solid rgba(97, 227, 237, 0.26);
  background: rgba(97, 227, 237, 0.1);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(255, 107, 107, 0.34);
  background: rgba(255, 107, 107, 0.14);
  color: #ffd7d7;
}

.danger-button.is-armed {
  border-color: rgba(255, 200, 87, 0.7);
  background: rgba(255, 200, 87, 0.18);
  color: #fff0bd;
}

.status-block {
  position: absolute;
  top: 45%;
  left: clamp(18px, 2.2vw, 30px);
  z-index: 34;
  display: grid;
  gap: 12px;
  width: min(430px, calc(100% - 36px));
  padding: clamp(14px, 1.6vh, 22px);
  border: 1px solid rgba(97, 227, 237, 0.18);
  border-radius: 8px;
  background: rgba(1, 10, 18, 0.62);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.34),
    inset 0 0 24px rgba(97, 227, 237, 0.08);
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 220ms ease;
  backdrop-filter: blur(14px);
}

.is-unlocked .status-block {
  opacity: 0;
}

.large-number {
  display: flex;
  align-items: baseline;
  gap: 0.1em;
  max-width: 100%;
  margin: 0;
  color: #ffffff;
  font-size: clamp(3.4rem, 5.2vw, 5.5rem);
  font-weight: 900;
  line-height: 0.95;
  white-space: nowrap;
}

.depth-unit {
  font-size: 0.34em;
  line-height: 1;
}

.meter-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.meter-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(149, 182, 198, 0.2);
}

.meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cyan), var(--gold));
  transition: width 100ms linear;
}

.stat-grid {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid > div {
  min-height: 58px;
  border: 1px solid rgba(149, 182, 198, 0.18);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(1, 10, 18, 0.38);
}

.stat-grid strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(0.98rem, 1.2vw, 1.18rem);
  white-space: nowrap;
}

.activity-rules {
  grid-area: rules;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 200, 87, 0.42);
  border-radius: 8px;
  padding: clamp(12px, 1.4vh, 16px);
  background:
    linear-gradient(135deg, rgba(255, 200, 87, 0.2), rgba(0, 224, 164, 0.12)),
    rgba(1, 10, 18, 0.58);
  box-shadow:
    inset 0 0 22px rgba(255, 200, 87, 0.1),
    0 14px 28px rgba(0, 0, 0, 0.24);
}

.activity-rules::after {
  position: absolute;
  top: -48%;
  right: -22%;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  content: "";
  background: radial-gradient(circle, rgba(255, 200, 87, 0.28), transparent 68%);
  pointer-events: none;
}

.activity-rules h2 {
  position: relative;
  margin-top: 6px;
  color: #ffffff;
  font-size: clamp(1.08rem, 1.35vw, 1.34rem);
  font-weight: 950;
  line-height: 1.18;
}

.activity-rules p:last-child {
  position: relative;
  margin: 8px 0 0;
  color: #ffe8ad;
  font-size: clamp(0.88rem, 1vw, 1rem);
  font-weight: 900;
  line-height: 1.32;
}

.result-panel {
  grid-area: result;
  margin-top: 0;
  border: 1px solid rgba(255, 200, 87, 0.32);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(255, 200, 87, 0.16), rgba(27, 184, 155, 0.09));
}

.result-panel h2 {
  margin-top: 4px;
  font-size: 1.32rem;
}

.result-panel p:last-of-type {
  margin: 7px 0 12px;
  color: #ffe8ad;
  font-weight: 750;
}

.ocean-stage {
  --sub-top: 12%;
  position: absolute;
  inset: var(--shell-gap) calc(var(--side-panel) + var(--shell-gap) * 2) var(--shell-gap) calc(var(--side-panel) + var(--shell-gap) * 2);
  overflow: hidden;
  border: 1px solid rgba(97, 227, 237, 0.18);
  border-radius: 8px;
  background: #02111e;
  box-shadow:
    inset 0 0 80px rgba(97, 227, 237, 0.06),
    0 22px 60px rgba(0, 0, 0, 0.36);
  isolation: isolate;
}

.ocean-stage::after {
  position: absolute;
  inset: 0;
  z-index: 6;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.4), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.38)),
    radial-gradient(circle at 50% 20%, rgba(97, 227, 237, 0.08), transparent 35%);
  pointer-events: none;
}

.ocean-scroll {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
}

.ocean-world {
  position: relative;
  min-height: 640vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 2%, rgba(255, 255, 255, 0.34), transparent 9%),
    linear-gradient(180deg, rgba(104, 224, 245, 0.8) 0%, rgba(22, 126, 154, 0.78) 8%, rgba(8, 72, 112, 0.86) 23%, rgba(5, 38, 72, 0.94) 46%, rgba(2, 19, 36, 0.98) 70%, #010407 100%);
  transition: transform 120ms linear;
  will-change: transform;
}

.ocean-world::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 92px,
      rgba(97, 227, 237, 0.08) 94px 96px,
      transparent 98px 180px
    ),
    linear-gradient(90deg, transparent 0 47%, rgba(97, 227, 237, 0.09) 47% 48%, transparent 48% 100%);
  pointer-events: none;
}

.ocean-world::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.16) 0 2px, transparent 3px),
    radial-gradient(circle at 76% 31%, rgba(97, 227, 237, 0.16) 0 2px, transparent 3px),
    radial-gradient(circle at 26% 62%, rgba(97, 227, 237, 0.12) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 81%, rgba(255, 200, 87, 0.13) 0 2px, transparent 3px);
  background-size: 180px 260px, 230px 310px, 260px 340px, 310px 390px;
  opacity: 0.58;
  pointer-events: none;
}

.depth-scale {
  position: absolute;
  inset: 32px auto 32px 18px;
  left: 18px;
  z-index: 3;
  color: #effaff;
  font-size: clamp(1.08rem, 1.45vw, 1.62rem);
  font-weight: 900;
}

.depth-scale span {
  position: absolute;
  top: var(--marker-top);
  min-width: clamp(156px, 12vw, 220px);
  border: 1px solid rgba(97, 227, 237, 0.28);
  border-left: clamp(18px, 2vw, 28px) solid rgba(97, 227, 237, 0.58);
  border-radius: 8px;
  padding: clamp(8px, 1.2vh, 13px) clamp(10px, 2vw, 16px);
  background: rgba(1, 10, 18, 0.4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%);
  white-space: nowrap;
}

.current-layer {
  position: absolute;
  top: clamp(18px, 2.4vh, 30px);
  right: clamp(16px, 2.6vw, 28px);
  z-index: 7;
  min-width: 116px;
  border: 1px solid rgba(97, 227, 237, 0.28);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(1, 10, 18, 0.46);
  color: #d9fbff;
  font-weight: 800;
  text-align: center;
}

.pressure-lines {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: calc(0.18 + var(--pressure) * 0.55);
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 20px,
      rgba(97, 227, 237, 0.14) 21px 22px,
      transparent 23px 58px
    );
  animation: pressure-run 680ms linear infinite;
  pointer-events: none;
}

.creature-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.sea-creature {
  position: absolute;
  top: var(--creature-top);
  display: grid;
  gap: 8px;
  width: clamp(104px, 12vw, 210px);
  margin: 0;
  opacity: 0.62;
  transform: translateY(-50%);
  animation: creature-drift 10s ease-in-out infinite alternate;
}

.sea-creature-left {
  left: 12%;
}

.sea-creature-right {
  right: 8%;
  animation-delay: -3s;
}

.sea-creature img {
  width: 100%;
  height: auto;
  filter:
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 18px rgba(97, 227, 237, 0.18));
}

.sea-creature figcaption {
  display: inline-grid;
  width: max-content;
  max-width: 160px;
  border: 1px solid rgba(97, 227, 237, 0.22);
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(1, 10, 18, 0.42);
  color: rgba(239, 250, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 750;
}

.submersible-rig {
  position: absolute;
  top: var(--sub-top);
  left: 50%;
  z-index: 8;
  width: min(27vw, 430px);
  min-width: 178px;
  height: min(46vh, 560px);
  transform: translate3d(-50%, 0, 0);
  transition: top 1120ms cubic-bezier(0.33, 0, 0.67, 1);
  pointer-events: none;
  will-change: top, transform;
}

.submersible {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  width: min(74%, 310px);
  min-width: 152px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.45));
  will-change: transform;
}

.is-running .submersible-rig {
  animation: engine-shake 620ms ease-in-out infinite;
}

.sub-spotlights {
  position: absolute;
  top: clamp(42px, 6.4vw, 78px);
  left: 50%;
  z-index: 1;
  width: 112%;
  height: min(42vh, 540px);
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 180ms ease;
  pointer-events: none;
}

.sub-spotlights::before {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 42%;
  height: 16px;
  border-radius: 999px;
  content: "";
  background:
    radial-gradient(circle at 22% 50%, rgba(121, 242, 255, 0.95) 0 3px, transparent 5px),
    radial-gradient(circle at 50% 50%, rgba(121, 242, 255, 0.95) 0 4px, transparent 7px),
    radial-gradient(circle at 78% 50%, rgba(121, 242, 255, 0.95) 0 3px, transparent 5px);
  filter: blur(0.4px) drop-shadow(0 0 10px rgba(121, 242, 255, 0.72));
  transform: translateX(-50%);
}

.is-running .sub-spotlights,
.is-unlocked .sub-spotlights {
  opacity: 0.88;
}

.spotlight-beam {
  position: absolute;
  top: 0;
  left: 50%;
  width: 48%;
  height: 100%;
  opacity: 0.62;
  background: linear-gradient(180deg, rgba(121, 242, 255, 0.4), rgba(121, 242, 255, 0.16) 46%, transparent 100%);
  clip-path: polygon(45% 0, 55% 0, 100% 100%, 0 100%);
  filter: blur(4px);
  transform-origin: 50% 0;
  mix-blend-mode: screen;
}

.spotlight-left {
  transform: translateX(-62%) rotate(16deg);
  animation: spotlight-left-sweep 2200ms ease-in-out infinite alternate;
}

.spotlight-center {
  width: 38%;
  opacity: 0.72;
  transform: translateX(-50%);
  animation: spotlight-center-pulse 1800ms ease-in-out infinite;
}

.spotlight-right {
  transform: translateX(-38%) rotate(-16deg);
  animation: spotlight-right-sweep 2400ms ease-in-out infinite alternate;
}

.treasure-site {
  position: absolute;
  top: 96.5%;
  left: 50%;
  z-index: 4;
  width: min(20vw, 340px);
  min-width: 172px;
  opacity: 0.18;
  transform: translate(-50%, -50%) scale(0.86);
  transform-origin: bottom center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.treasure-reward {
  position: absolute;
  top: 54%;
  left: 50%;
  z-index: 48;
  display: grid;
  justify-items: center;
  gap: clamp(12px, 2vh, 20px);
  width: min(88%, 880px);
  opacity: 0;
  transform: translate(-50%, 34%) scale(0.3) rotate(-4deg);
  transform-origin: center bottom;
  pointer-events: none;
}

.reward-product {
  position: relative;
  z-index: 2;
  display: block;
  width: min(100%, 840px);
  max-height: min(34vh, 420px);
  object-fit: contain;
  filter:
    drop-shadow(0 30px 32px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 42px rgba(0, 224, 164, 0.46));
}

.reward-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(3px, 0.5vh, 7px);
  width: min(100%, 820px);
  border: 1px solid rgba(0, 224, 164, 0.48);
  border-radius: 8px;
  padding: clamp(12px, 1.55vw, 20px) clamp(18px, 3vw, 36px);
  background:
    linear-gradient(90deg, transparent 0%, rgba(0, 224, 164, 0.16) 22%, rgba(0, 224, 164, 0.16) 78%, transparent 100%),
    rgba(1, 10, 18, 0.74);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.38),
    inset 0 0 28px rgba(0, 224, 164, 0.12);
  color: #ffffff;
  text-align: center;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.62);
}

.reward-copy p {
  margin: 0;
}

.reward-title {
  color: #ffffff;
  font-size: clamp(2.85rem, 5.2vw, 5.35rem);
  font-weight: 950;
  line-height: 0.92;
}

.reward-title span,
.reward-title strong {
  display: block;
}

.reward-title span {
  color: var(--logi-green);
  font-weight: 900;
}

.reward-title strong {
  color: #ffffff;
  font-size: 0.58em;
  font-weight: 950;
}

.reward-tagline {
  color: var(--logi-green);
  font-size: clamp(1.4rem, 2.7vw, 2.7rem);
  font-weight: 900;
  line-height: 1;
}

.animated-chest {
  position: relative;
  z-index: 4;
  width: 100%;
  aspect-ratio: 1.38;
  transform-style: preserve-3d;
  width: 100%;
  filter:
    drop-shadow(0 22px 28px rgba(0, 0, 0, 0.46))
    drop-shadow(0 0 calc(12px + var(--progress) * 26px) rgba(255, 200, 87, 0.42));
}

.animated-chest::before {
  position: absolute;
  right: 16%;
  bottom: 42%;
  left: 16%;
  z-index: 2;
  height: 28%;
  border-radius: 999px;
  content: "";
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 245, 168, 0.95), rgba(255, 200, 87, 0.58) 42%, transparent 72%);
  filter: blur(8px);
  transform: translateY(10px) scaleX(0.78);
  transition:
    opacity 280ms ease,
    transform 520ms ease;
}

.chest-base,
.chest-lid,
.chest-lock {
  position: absolute;
  left: 50%;
  display: block;
  transform: translateX(-50%);
}

.chest-base {
  bottom: 0;
  z-index: 1;
  width: 92%;
  height: 55%;
  border: 6px solid #2a130c;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 15%, #ffc857 15% 24%, transparent 24% 76%, #ffc857 76% 85%, transparent 85%),
    linear-gradient(180deg, #8b4a24 0%, #5a2a17 58%, #2b140e 100%);
}

.chest-lid {
  bottom: 45%;
  z-index: 3;
  width: 92%;
  height: 48%;
  border: 6px solid #2a130c;
  border-bottom: 0;
  border-radius: 90px 90px 8px 8px;
  background:
    linear-gradient(90deg, transparent 0 15%, #ffc857 15% 24%, transparent 24% 76%, #ffc857 76% 85%, transparent 85%),
    linear-gradient(180deg, #b86a2a 0%, #6f3219 100%);
  transform: translateX(-50%) rotateX(0deg);
  transform-origin: bottom center;
  transition: transform 650ms cubic-bezier(0.18, 0.84, 0.32, 1.18);
}

.chest-lock {
  bottom: 28%;
  z-index: 4;
  width: 19%;
  height: 24%;
  border-radius: 4px;
  background: linear-gradient(180deg, #fff0a8, #ffc857 50%, #8d5b14);
}

.is-unlocked .chest-lid {
  transform: translateX(-50%) translateY(-62%) rotate(-17deg) scaleY(0.62);
}

.is-unlocked .animated-chest::before {
  opacity: 1;
  transform: translateY(-6px) scaleX(1.08);
}

.is-unlocked .treasure-reward {
  animation: prize-pop 920ms 180ms cubic-bezier(0.17, 0.84, 0.32, 1.2) both;
}

.is-unlocked .reward-product {
  animation: product-glow 2100ms 1100ms ease-in-out infinite;
}

.is-unlocked .chest-lock {
  animation: lock-pop 520ms ease-out both;
}

.unlock-beam {
  position: absolute;
  right: 12%;
  bottom: 48%;
  left: 12%;
  height: 190px;
  opacity: 0;
  background: linear-gradient(0deg, rgba(255, 200, 87, 0.7), transparent);
  clip-path: polygon(42% 100%, 58% 100%, 100% 0, 0 0);
  filter: blur(8px);
}

.is-unlocked .unlock-beam {
  opacity: 1;
  animation: beam-rise 900ms ease-out both;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(1, 7, 13, 0.58);
  color: var(--gold);
  font-size: clamp(5rem, 15vw, 11rem);
  font-weight: 950;
}

.leaderboard-panel {
  position: absolute;
  top: var(--shell-gap);
  right: var(--shell-gap);
  bottom: var(--shell-gap);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: var(--side-panel);
  padding: clamp(12px, 1.35vh, 18px);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ranking-count {
  border: 1px solid rgba(97, 227, 237, 0.28);
  border-radius: 8px;
  padding: 7px 9px;
  color: #d9fbff;
  font-size: 0.82rem;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 9px;
  margin: 0;
  min-height: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  grid-template-areas:
    "rank name score"
    "rank status score";
  align-items: center;
  column-gap: 10px;
  min-height: 54px;
  border: 1px solid rgba(149, 182, 198, 0.16);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(1, 10, 18, 0.38);
}

.leaderboard-item.is-highlighted {
  border-color: rgba(255, 200, 87, 0.7);
  background: rgba(255, 200, 87, 0.12);
}

.rank-number {
  grid-area: rank;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(97, 227, 237, 0.13);
  color: var(--cyan);
  font-weight: 900;
}

.rank-name {
  grid-area: name;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  grid-area: score;
  color: var(--gold);
  font-weight: 900;
  text-align: right;
}

.rank-status {
  grid-area: status;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 92px;
  place-items: center;
  border: 1px dashed rgba(149, 182, 198, 0.22);
  border-radius: 8px;
  color: var(--muted);
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 0;
}

@keyframes pressure-run {
  from {
    transform: translateY(-48px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes engine-shake {
  0%,
  100% {
    transform: translate3d(-50%, 0, 0) rotate(-0.18deg);
  }
  25% {
    transform: translate3d(-50.2%, -0.8px, 0) rotate(0.14deg);
  }
  50% {
    transform: translate3d(-49.9%, 0.9px, 0) rotate(0.18deg);
  }
  75% {
    transform: translate3d(-50.1%, 0.2px, 0) rotate(-0.12deg);
  }
}

@keyframes spotlight-left-sweep {
  from {
    opacity: 0.48;
    transform: translateX(-68%) rotate(9deg);
  }
  to {
    opacity: 0.7;
    transform: translateX(-54%) rotate(23deg);
  }
}

@keyframes spotlight-right-sweep {
  from {
    opacity: 0.46;
    transform: translateX(-32%) rotate(-24deg);
  }
  to {
    opacity: 0.7;
    transform: translateX(-46%) rotate(-10deg);
  }
}

@keyframes spotlight-center-pulse {
  0%,
  100% {
    opacity: 0.5;
    transform: translateX(-50%) scaleX(0.9);
  }
  50% {
    opacity: 0.78;
    transform: translateX(-50%) scaleX(1.08);
  }
}

@keyframes drift-left {
  from {
    transform: translateX(-18px);
  }
  to {
    transform: translateX(64px);
  }
}

@keyframes drift-right {
  from {
    transform: translateX(36px) scaleX(-1);
  }
  to {
    transform: translateX(-48px) scaleX(-1);
  }
}

@keyframes creature-drift {
  from {
    transform: translate(-18px, -50%);
  }
  to {
    transform: translate(34px, -50%);
  }
}

@keyframes beam-rise {
  from {
    transform: translateY(28px) scaleY(0.2);
  }
  to {
    transform: translateY(0) scaleY(1);
  }
}

@keyframes lock-pop {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-42px) rotate(18deg);
  }
}

@keyframes prize-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 44%) scale(0.3) rotate(-4deg);
  }
  54% {
    opacity: 1;
    transform: translate(-50%, -57%) scale(1.06) rotate(1.5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1) rotate(0deg);
  }
}

@keyframes product-glow {
  0%,
  100% {
    filter:
      drop-shadow(0 24px 26px rgba(0, 0, 0, 0.42))
      drop-shadow(0 0 30px rgba(0, 224, 164, 0.42));
  }
  50% {
    filter:
      drop-shadow(0 26px 30px rgba(0, 0, 0, 0.46))
      drop-shadow(0 0 54px rgba(0, 224, 164, 0.68));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }

  .submersible-rig {
    transition-duration: 1120ms !important;
    transition-timing-function: cubic-bezier(0.33, 0, 0.67, 1) !important;
  }

  .chest-lid {
    transition-duration: 650ms !important;
  }

  .is-unlocked .treasure-reward {
    animation-duration: 920ms !important;
    animation-iteration-count: 1 !important;
  }

  .is-unlocked .reward-product {
    animation-duration: 2100ms !important;
    animation-iteration-count: infinite !important;
  }

  .is-running .spotlight-beam,
  .is-unlocked .spotlight-beam {
    animation-duration: 2200ms !important;
    animation-iteration-count: infinite !important;
  }

  .is-unlocked .chest-lock {
    animation-duration: 520ms !important;
  }

  .is-unlocked .unlock-beam {
    animation-duration: 900ms !important;
  }
}

@media (min-width: 1101px) and (max-height: 760px) {
  .app-shell {
    --side-panel: clamp(248px, 18.2vw, 310px);
    --shell-gap: 12px;
  }

  .control-panel,
  .leaderboard-panel {
    padding: 14px;
  }

  .control-panel {
    gap: 10px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 1.38rem;
  }

  .input-row {
    gap: 8px;
  }

  input,
  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 40px;
  }

  .status-block {
    gap: 8px;
    padding: 11px;
  }

  .large-number {
    font-size: 3.05rem;
  }

  .stat-grid {
    gap: 8px;
  }

  .stat-grid > div {
    min-height: 58px;
    padding: 8px 10px;
  }

  .stat-grid strong {
    margin-top: 4px;
    font-size: 1rem;
  }

  .result-panel {
    padding: 10px;
  }

  .result-panel h2 {
    font-size: 1.16rem;
  }

  .result-panel p:last-of-type {
    margin: 5px 0 8px;
  }
}

@media (orientation: portrait) {
  .app-shell {
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
  }
}

@media (max-width: 900px) {
  .app-shell {
    --side-panel: clamp(180px, 28vw, 240px);
    --shell-gap: 8px;
  }

  .control-panel {
    gap: 9px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: clamp(1.22rem, 4.3vw, 1.62rem);
  }

  .input-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  input,
  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 40px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-grid > div {
    min-height: 50px;
    padding: 8px 9px;
  }

  .status-block {
    top: 46%;
    width: min(320px, calc(100% - 32px));
  }

  .large-number {
    font-size: clamp(2.65rem, 5.4vw, 3.5rem);
  }

  .current-layer {
    top: 12px;
  }

  .depth-scale {
    left: 12px;
    font-size: clamp(1.08rem, 3.7vw, 1.46rem);
  }

  .depth-scale span {
    min-width: 168px;
    border-left-width: 20px;
    padding: 7px 10px;
  }

  .submersible-rig {
    width: min(25vw, 260px);
    min-width: 148px;
    height: min(40vh, 340px);
  }

  .sub-spotlights {
    top: clamp(34px, 9vw, 54px);
  }

  .leaderboard-panel {
    gap: 8px;
  }

  .reward-product {
    max-height: min(28vh, 280px);
  }

  .reward-copy {
    padding: 12px 14px;
  }

  .reward-title {
    font-size: clamp(2.1rem, 5vw, 3.1rem);
  }

  .reward-tagline {
    font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  }
}

@media (max-width: 520px) {
  .input-row,
  .admin-actions {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-block {
    width: min(300px, calc(100% - 28px));
  }

  .large-number {
    font-size: clamp(2.82rem, 13vw, 3.55rem);
  }

  .leaderboard-item {
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-areas:
      "rank name"
      "rank score"
      "rank status";
  }

  .rank-score {
    text-align: left;
  }
}

/* iPad + MX Master 4 compatibility layer: invisible real scroll surface. */
.ipad-scroll-catcher {
  position: absolute; inset: 0; z-index: 5; overflow-y: scroll; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: none;
  background: transparent; touch-action: pan-y;
}
.ipad-scroll-catcher::-webkit-scrollbar { display: none; }
.ipad-scroll-space { width: 1px; height: 900vh; pointer-events: none; }
/* Keep original HUD/submersible above the input catcher. */
.status-block, .current-layer, .countdown, .submersible-rig, .treasure-reward { z-index: 7; }

/* iPad patch: ensure sea creatures remain visible even when original asset files are unavailable */
.creature-layer .sea-creature{width:150px;transform:translateX(-50%);}
.creature-layer .creature-visual{display:grid;place-items:center;width:92px;height:64px;font-size:52px;line-height:1;color:rgba(166,238,244,.9);text-shadow:0 0 14px rgba(97,227,237,.6),0 0 32px rgba(97,227,237,.28);filter:drop-shadow(0 10px 15px rgba(0,0,0,.4));}
.creature-layer .sea-creature:nth-child(even) .creature-visual{transform:scaleX(-1);}

/* V3: embedded sea-life artwork — no external image files required */
.creature-layer { pointer-events:none; }
.creature-layer .sea-creature { width:clamp(115px, 13vw, 205px); transform:translate(-50%,-50%); opacity:.78; }
.creature-layer .creature-visual { display:block; width:100%; height:auto; color:rgba(130,236,244,.88); filter:drop-shadow(0 0 12px rgba(97,227,237,.35)); }
.creature-layer .creature-visual svg { display:block; width:100%; height:auto; overflow:visible; }
.creature-layer .sea-creature:nth-child(even) .creature-visual { transform:scaleX(-1); }
.creature-layer .sea-creature figcaption { margin-inline:auto; }
