:root {
  color-scheme: dark;
  --bg: #000714;
  --panel: rgba(2, 22, 39, 0.84);
  --panel-strong: rgba(4, 31, 55, 0.94);
  --cyan: #00cfff;
  --cyan-soft: rgba(0, 207, 255, 0.32);
  --gold: #ffd766;
  --violet: #c05cff;
  --green: #92f75d;
  --coral: #ff6b57;
  --text: #eefbff;
  --muted: rgba(226, 246, 255, 0.66);
  --line: rgba(110, 220, 255, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 8%, rgba(0, 207, 255, 0.18), transparent 28%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 34, 58, 0.2), rgba(0, 3, 10, 0.86)),
    #00101f;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  pointer-events: none;
}

.brand,
.readouts,
.controls,
.meters,
.state-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 64% 32%, #fff8bb 0 12%, transparent 13%),
    radial-gradient(circle at 48% 48%, #ffbb2e 0 48%, #bd6b00 50% 70%, transparent 72%);
  box-shadow: 0 0 18px rgba(255, 213, 82, 0.45);
}

.readouts {
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 1px;
  overflow: hidden;
  min-width: min(560px, 100%);
  margin: 0;
  border-radius: 8px;
}

.readouts div {
  min-width: 0;
  padding: 9px 13px 8px;
  background: rgba(0, 24, 43, 0.5);
}

.readouts dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.readouts dd {
  margin: 0;
  color: var(--text);
  font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.controls {
  justify-self: end;
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  pointer-events: auto;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: rgba(0, 207, 255, 0.1);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(0, 207, 255, 0.22);
  outline: 2px solid rgba(0, 207, 255, 0.45);
  outline-offset: 2px;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mute-slash {
  opacity: 0;
}

.is-muted .sound-wave {
  opacity: 0;
}

.is-muted .mute-slash {
  opacity: 1;
}

.meters {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 5;
  display: grid;
  width: min(360px, calc(100vw - 28px));
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  pointer-events: none;
}

.meters label {
  display: grid;
  grid-template-columns: auto 46px;
  gap: 6px 10px;
  align-items: center;
}

.meters span,
.meters b {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.meters span {
  color: var(--muted);
}

.meters b {
  justify-self: end;
  color: var(--text);
  font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

.meters i {
  grid-column: 1 / -1;
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(190, 238, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meters em {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 140ms linear, background 140ms linear;
}

#oxygenBar {
  background: linear-gradient(90deg, #23f2ff, #2f7cff);
}

#pressureBar {
  background: linear-gradient(90deg, #ffbd4b, #ff4e33);
}

.toast {
  position: fixed;
  left: 50%;
  top: 78px;
  z-index: 7;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%) translateY(-8px);
  padding: 9px 16px;
  border: 1px solid rgba(0, 207, 255, 0.36);
  border-radius: 999px;
  background: rgba(0, 18, 34, 0.86);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.state-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 54% 38%, rgba(0, 207, 255, 0.13), transparent 32%),
    rgba(0, 8, 18, 0.72);
  backdrop-filter: blur(8px);
}

.state-overlay[hidden] {
  display: none;
}

.state-panel {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 8px;
  background: var(--panel-strong);
}

.state-kicker {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.state-panel h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(34px, 6vw, 62px);
  line-height: 0.95;
  letter-spacing: 0;
}

.state-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.best-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.best-stats span {
  padding: 10px;
  border: 1px solid rgba(154, 228, 255, 0.14);
  border-radius: 8px;
  background: rgba(0, 207, 255, 0.06);
}

.best-stats b,
.best-stats small {
  display: block;
}

.best-stats b {
  color: var(--text);
  font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
}

.best-stats small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.upgrade-grid[hidden] {
  display: none;
}

.upgrade-card {
  min-height: 116px;
  padding: 12px;
  border: 1px solid rgba(154, 228, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 207, 255, 0.07);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.upgrade-card:hover,
.upgrade-card:focus-visible {
  border-color: rgba(0, 207, 255, 0.58);
  background: rgba(0, 207, 255, 0.14);
  outline: none;
}

.upgrade-card[disabled] {
  cursor: not-allowed;
  opacity: 0.46;
}

.upgrade-card strong,
.upgrade-card span,
.upgrade-card small {
  display: block;
}

.upgrade-card strong {
  font-size: 13px;
  line-height: 1.2;
}

.upgrade-card span {
  margin-top: 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
}

.upgrade-card small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.play-button,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.play-button {
  color: #00121c;
  background: linear-gradient(135deg, var(--gold), #ff9a2f);
  box-shadow: 0 12px 30px rgba(255, 182, 54, 0.28);
}

.secondary-button {
  color: var(--text);
  border: 1px solid rgba(154, 228, 255, 0.2);
  background: rgba(0, 207, 255, 0.08);
}

.play-button:hover,
.play-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
  transform: translateY(-1px);
  outline: 2px solid rgba(0, 207, 255, 0.36);
  outline-offset: 2px;
}

.how-to {
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px;
  }

  .brand {
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }

  .readouts {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }

  .readouts div {
    padding: 7px 8px 6px;
  }

  .readouts dt {
    font-size: 9px;
  }

  .readouts dd {
    font-size: 13px;
  }

  .controls {
    grid-column: 2;
    grid-row: 1;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .meters {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    padding: 10px;
  }

  .toast {
    top: 112px;
  }

  .state-panel {
    padding: 18px;
  }

  .best-stats,
  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .menu-actions {
    display: grid;
  }
}

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