:root {
  --ad-h: 50px;
  --ink: #e8e2d4;
  --muted: #8aa4b5;
  --brass: #c8923a;
  --brass-deep: #8a5d1e;
  --cyan: #6ee0e8;
  --bg: #071422;
  --site-panel: #0d2131;
  --site-ink: #eee8d9;
  --site-muted: #9bb2bf;
  --site-gold: #e6c37a;
  --site-page-bg:
    radial-gradient(circle at 75% 12%, rgba(30, 119, 133, 0.28), transparent 30rem),
    linear-gradient(180deg, #071422, #091a28 62%, #06101a);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Barlow, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}

html.is-desktop,
html.is-desktop body {
  background: #03080d;
}

html.is-desktop body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

html.is-desktop #app {
  position: relative;
  inset: auto;
  width: min(390px, calc(100vw - 48px), calc((100vh - 48px) * 9 / 19.5));
  height: auto;
  aspect-ratio: 9 / 19.5;
  max-height: calc(100vh - 48px);
  border-radius: 28px;
  box-shadow:
    0 0 0 8px #141414,
    0 0 0 10px #3a3224,
    0 22px 56px rgba(0, 0, 0, 0.55);
}

#promo-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: auto;
  z-index: 6;
  width: 100%;
  height: var(--ad-h, 50px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #03080d;
  pointer-events: auto;
}

#promo-rail[hidden] {
  display: none !important;
}

#promo-host {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#support-notice {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 10px;
  background: linear-gradient(90deg, #071422, #0d2a3d);
  color: var(--ink);
}

#support-notice[hidden] {
  display: none !important;
}

#support-notice p {
  min-width: 0;
  margin: 0;
  font-size: 11px;
  line-height: 1.25;
  text-align: left;
}

#support-notice strong {
  display: block;
  color: #f0c776;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#support-help {
  min-height: 32px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.75);
  color: var(--site-gold);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 360px) {
  #support-notice {
    gap: 6px;
    padding: 5px 6px;
  }

  #support-notice p {
    font-size: 10px;
  }

  #support-help {
    padding: 5px 7px;
    font-size: 10px;
    white-space: normal;
    max-width: 9.5em;
  }
}

.promo-house {
  width: min(320px, 100%);
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 45%;
  overflow: hidden;
  border: 1px solid #9a6b25;
  background: url("assets/snapsub-promo-mobile.webp?v=1") center / cover no-repeat;
  color: #f2ead8;
  font-family: "Barlow Condensed", sans-serif;
  text-decoration: none;
  box-shadow: inset 0 0 18px rgba(3, 10, 16, 0.5);
}

.promo-copy {
  min-width: 0;
  line-height: 0.9;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

.promo-copy small,
.promo-copy strong {
  display: block;
  white-space: nowrap;
}

.promo-copy small {
  margin-bottom: 3px;
  color: #79e4ec;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.promo-copy strong {
  font-size: 18px;
  letter-spacing: 0.04em;
}

.promo-cta {
  padding: 5px 6px;
  border: 1px solid #efc15c;
  border-radius: 4px;
  background: linear-gradient(#c98a28, #6f4212);
  color: #fff8df;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.promo-house:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.promo-frame {
  display: block;
  width: min(320px, 100%);
  height: 50px;
  overflow: hidden;
  background: #03080d;
}

.promo-frame img {
  display: block;
  width: 100%;
  height: 50px;
  object-fit: fill;
}

.promo-frame:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

#hud {
  position: absolute;
  top: var(--ad-h, 0px);
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  padding: 10px 22px 0;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 10px rgba(0, 0, 0, 0.35);
}

#floor-hud {
  position: absolute;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

#hull {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

#hull .hud-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

#hull-pips {
  display: flex;
  gap: 5px;
}

/* Compact instruments occupy the existing center HUD area, not a backing panel.
   Absolute positioning preserves hull/dock placement and the playable cave. */
#instruments {
  --dial-size: 50px;
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  width: 120px;
  height: var(--dial-size);
  pointer-events: none;
  color: #f5ead0;
  font-family: "Segoe UI", sans-serif;
  text-shadow: 0 1px 2px #071422, 0 0 4px #071422;
}

#speed-dial {
  position: absolute;
  left: 3px;
  top: 0;
  width: var(--dial-size);
  height: var(--dial-size);
  border: 2px solid #d7b371;
  border-radius: 50%;
  background: #09151c;
  box-shadow: inset 0 0 0 1px #554128;
}

#speed-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#speed-dial .speed-track { fill: none; stroke: #4e6269; stroke-width: 2; }
#speed-arc { fill: none; stroke: #75e2e8; stroke-width: 2; }
#speed-dial .speed-ticks { fill: none; stroke: #bfa468; stroke-width: 1; }

#speed-value {
  fill: currentColor;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#speed-dial .speed-unit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  color: #c5d2d5;
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.instrument-label { color: #e7c278; font-size: 11px; line-height: 1.2; font-weight: 500; }
#engine-instrument { position: absolute; left: calc(var(--dial-size) + 9px); top: 0; width: 52px; }
#engine-instrument .instrument-label { display: block; }
#engine-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 3px; height: 16px; margin-top: 2px; }
#engine-bars i { display: block; height: 100%; border-radius: 1px; background: #31434b; }
#engine-bars i:nth-child(1) { height: 45%; }
#engine-bars i:nth-child(2) { height: 65%; }
#engine-bars i:nth-child(3) { height: 82%; }
#engine-bars i.is-on { background: linear-gradient(#acf0f1, #62c5d2); }
#hull-instrument-label { position: absolute; left: calc(var(--dial-size) + 9px); bottom: -2.2px; }

/* Give the speed/engine readout 4–8px more room without moving or resizing
   the hull pips/dock. Keep the existing 8px gap below the compact dial. */
#instruments.is-compact { --dial-size: clamp(40px, calc(var(--instrument-size, 40px) + 4px), 44px); bottom: calc(100% + 8px); }
#instruments.is-compact .speed-unit { font-size: 8px; }
#instruments.is-compact .instrument-label { line-height: 11px; }
#instruments.is-compact #engine-bars { height: 12px; margin-top: 2px; }
#instruments.is-compact #hull-instrument-label { bottom: -5px; }

.pip {
  width: 26px;
  height: 11px;
  border-radius: 3px;
  background: #283b43;
  border: 0;
}

.pip.is-on {
  background: #84daca;
  box-shadow: inset 0 1px 0 #daf5e944;
}

#hull[data-hp="3"] .pip.is-on,
#hull[data-hp="2"] .pip.is-on { background: #efc568; }
#hull[data-hp="1"] .pip.is-on { background: #ff8b76; }
#hull[data-hp="1"] #hull-instrument-label { color: #ffae98; }

#hull.is-hurt .pip.is-on {
  filter: brightness(1.45);
  animation: none;
}

@keyframes hull-warn {
  0%,
  100% {
    filter: brightness(1);
    box-shadow: 0 0 8px rgba(226, 60, 40, 0.28);
  }
  50% {
    filter: brightness(1.16);
    box-shadow: 0 0 11px rgba(226, 70, 48, 0.42);
  }
}

@keyframes hull-crit {
  0%,
  40% {
    filter: brightness(1.45);
    box-shadow: 0 0 14px rgba(255, 56, 40, 0.9);
  }
  50%,
  100% {
    filter: brightness(0.42);
    box-shadow: 0 0 4px rgba(90, 16, 12, 0.28);
  }
}

#dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  pointer-events: auto;
}

.hud-block {
  display: flex;
  flex-direction: column;
}

.hud-block.center {
  align-items: center;
}

.hud-block.right {
  align-items: flex-end;
}

.hud-label {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

#score,
#level,
#best {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 36px;
  line-height: 0.95;
}

#level {
  color: #e6c37a;
}

#best {
  color: var(--cyan);
  font-size: 28px;
}

#mute,
#settings-btn {
  position: static;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(200, 160, 70, 0.45);
  background: rgba(18, 16, 12, 0.55);
  color: #e6c37a;
  border-radius: 8px;
  font-size: 15px;
}

#mute.is-off {
  color: var(--muted);
  text-decoration: line-through;
}

#dev-toggle {
  position: absolute;
  top: calc(var(--ad-h, 0px) + 8px);
  right: 56px;
  z-index: 7;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #5dcf6e;
  background: rgba(13, 32, 18, 0.7);
  color: #9ef0a8;
  border-radius: 999px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.12em;
}

#dev {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  top: calc(64px + env(safe-area-inset-top));
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#dev button {
  min-width: 110px;
  min-height: 36px;
  border: 1px solid rgba(232, 226, 212, 0.28);
  background: rgba(7, 20, 34, 0.72);
  color: var(--ink);
  border-radius: 8px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
}

#dev button.is-on {
  border-color: #5dcf6e;
  color: #9ef0a8;
}

#fire,
#field {
  position: absolute;
  isolation: isolate;
  z-index: 4;
  bottom: 0;
  width: 64px;
  height: 96px;
  border: 0;
  border-radius: 16px;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  color: #e6c37a;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 11px;
  line-height: 1;
  pointer-events: auto;
}

/* Symmetric controls flank the existing HUD, sharing its safe-area anchor.
   Their original 2:3 artwork stays uncropped, with no tray over the cave. */
#fire {
  left: calc(100% + 12px);
  --control-art: url("assets/fire-hud.png?v=40");
}

#field {
  right: calc(100% + 12px);
  --control-art: url("assets/shield-hud.png?v=40");
}

/* Preserve the original riveted frames and icons, with the HUD's quieter brass.
   Only the artwork is toned: inventory counts keep their full contrast. */
#fire::before,
#field::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--control-art) center / contain no-repeat;
  filter: saturate(0.68) brightness(0.92) contrast(0.94);
  pointer-events: none;
}

#fire #ammo,
#field #field-ammo {
  margin: 0 0 1px;
  min-width: 2.1em;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #e7c278;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
}

#field.is-on {
  box-shadow: 0 0 12px rgba(132, 218, 202, 0.38);
}

#fire:focus-visible,
#field:focus-visible {
  outline: 2px solid #75e2e8;
  outline-offset: 2px;
}

#field.is-on::before {
  filter: saturate(0.85) brightness(1.02) contrast(0.96);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(var(--ad-h, 0px) + 16px);
  background: linear-gradient(180deg, rgba(7, 20, 34, 0.18), rgba(7, 20, 34, 0.55));
  text-align: center;
}

.menu {
  background: linear-gradient(180deg, rgba(7, 20, 34, 0.12), rgba(7, 20, 34, 0.48));
  pointer-events: none;
  padding-bottom: calc(24px + 64px);
}

.menu button,
.menu .best-line,
.menu .hint,
.menu h1,
.menu h2,
.menu .kicker,
.menu .board-actions,
.menu .player-chip {
  pointer-events: auto;
}

.menu .best-line {
  background: rgba(7, 20, 34, 0.55);
  padding: 6px 18px;
  border-radius: 999px;
}

.overlay[hidden],
#hud[hidden],
#hull[hidden],
#fire[hidden],
#field[hidden],
#dev[hidden],
#dev-toggle[hidden],
#promo-rail[hidden],
#settings[hidden],
#board[hidden],
#join[hidden],
#signin[hidden],
#leave[hidden],
#local-top[hidden],
#rotate[hidden] {
  display: none !important;
}

.kicker {
  margin: 0 0 8px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  font-size: clamp(64px, 12vw, 110px);
  line-height: 0.85;
}

#title-wordmark {
  display: block;
  width: min(84vw, 560px);
  height: auto;
  max-height: 20vh;
  object-fit: contain;
  margin: 0 auto;
  transform: translateX(-10px);
  filter: drop-shadow(0 6px 10px rgba(3, 10, 16, 0.72))
    drop-shadow(0 2px 3px rgba(3, 10, 16, 0.45));
}

h2 {
  font-size: clamp(72px, 16vw, 120px);
  line-height: 0.85;
}

.best-line {
  margin: 14px 0 28px;
  color: var(--cyan);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
}

button.best-line {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  box-shadow: none;
  outline: none;
  background: rgba(7, 20, 34, 0.55);
  font: inherit;
  color: inherit;
  cursor: pointer;
}

#local-top {
  z-index: 7;
  justify-content: flex-start;
  padding-top: calc(var(--ad-h, 0px) + 36px);
  background: none;
  pointer-events: auto;
}

#local-top .kicker {
  text-shadow: 0 2px 10px rgba(3, 10, 16, 0.8);
}

#local-top-player {
  margin: 0 0 8px;
}

#local-top-list {
  list-style: none;
  margin: 8px 0 18px;
  padding: 0;
  width: min(220px, 72%);
}

#local-top-list li {
  display: grid;
  grid-template-columns: 2em 1fr;
  gap: 16px;
  padding: 3px 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(3, 10, 16, 0.75);
}

#local-top-list li span:first-child {
  color: #e6c37a;
  text-align: left;
}

#local-top-list li span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#local-top-list li.is-empty {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

#local-top-close {
  margin-top: 8px;
}

#dive,
#retry,
#home {
  width: 176px;
  height: 58px;
  padding: 0;
  border: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  color: transparent;
  font-size: 0;
}

#dive {
  background-image: url("assets/dive-button.png?v=36");
}

#retry {
  background-image: url("assets/again-button.png?v=45");
}

#home {
  margin-top: 12px;
  background-image: url("assets/home-button.png?v=45");
}

.ghost {
  margin-top: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(232, 226, 212, 0.28);
}

.pill {
  margin-top: 0;
  box-sizing: border-box;
  min-height: 42px;
  min-width: min(230px, 86vw);
  padding: 10px 18px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.75);
  color: var(--site-gold, #e6c37a);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#settings {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 20, 34, 0.55);
  pointer-events: auto;
}

.settings-card {
  width: min(300px, 84%);
  max-height: 90%;
  overflow-y: auto;
  padding: 18px 18px 16px;
  border: 1px solid #6a5228;
  border-radius: 14px;
  background: #14110e;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-card h3 {
  margin: 0 0 6px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 20px;
  color: #e6c37a;
}

.vol-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}

.vol-row input[type="range"] {
  width: 100%;
  accent-color: #c8923a;
}

#leave-switch,
#leave-unlink,
#leave-remove,
#leave-close,
#board-close,
#join-close,
#join-signin,
#signin-close,
#signin-back,
#join-submit,
#join-verify button[type="submit"],
#otp-send,
#signin-form button[type="submit"],
#signin-verify button[type="submit"] {
  width: 100%;
  margin-top: 0;
  min-height: 40px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #2a2218;
  color: #e6c37a;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#signin-close,
#signin-back {
  border-color: rgba(232, 226, 212, 0.28);
  background: transparent;
  color: var(--ink);
}

#leave-remove {
  border-color: #8f463d;
  background: #3a1b18;
  color: #ffb0a6;
}

#settings-close,
#settings-board,
#settings-join,
#settings-link,
#settings-switch,
#settings-forget,
#settings-out,
#settings-reset-local {
  width: 100%;
  margin-top: 0;
  min-height: 40px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #2a2218;
  color: #e6c37a;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#settings-reset-local {
  border-color: #8f463d;
  background: #3a1b18;
  color: #ffb0a6;
}

.settings-note {
  margin: 0;
  color: #7ee0a8;
  font-size: 12px;
  line-height: 1.3;
}

.settings-stat {
  margin: -4px 0 4px;
  color: var(--cyan);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.settings-action-group,
.panel-actions-stack,
.over-account-actions {
  display: grid;
  gap: 8px;
}

.settings-action-group {
  margin-top: 4px;
}

.settings-data-group {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(106, 82, 40, 0.65);
}

#settings-close {
  margin-top: 4px;
}

.panel-actions-stack {
  margin-top: 12px;
}

.panel-actions-stack button,
.over-account-actions button {
  width: 100%;
  margin: 0;
}

.board-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.board-actions .pill,
.board-actions .ghost {
  margin-top: 0;
}

.board-actions .ghost {
  min-height: 42px;
  min-width: min(230px, 86vw);
  padding: 10px 18px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 15px;
}

.over-account-actions {
  width: min(230px, 86vw);
  margin-top: 12px;
}

.over-account-actions .pill,
.over-account-actions .ghost {
  min-width: 0;
  width: 100%;
}

#board,
#join,
#signin,
#leave {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

#leave {
  background: rgba(7, 20, 34, 0.62);
}

.board-card {
  width: min(340px, 90%);
  max-height: min(78vh, 640px);
  overflow: auto;
  padding: 16px 16px 14px;
  border: 1px solid #6a5228;
  border-radius: 14px;
  background: #14110e;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: #c8923a #0c1014;
}

.board-card::-webkit-scrollbar {
  width: 8px;
}

.board-card::-webkit-scrollbar-track {
  background: #0c1014;
  border-radius: 8px;
}

.board-card::-webkit-scrollbar-thumb {
  background: #c8923a;
  border-radius: 8px;
}

.board-card::-webkit-scrollbar-thumb:hover {
  background: #e6c37a;
}

#board .board-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.board-card h3,
.join-card h3 {
  margin: 8px 0 8px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 20px;
  color: #e6c37a;
}

#board-logo {
  display: block;
  width: min(280px, 100%);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  margin: 0 auto 4px;
}

.join-mark {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 auto 4px;
}

.board-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.board-note a,
.board-card a {
  color: var(--cyan);
  text-decoration: underline;
}

.board-note a:hover,
.board-card a:hover {
  color: #9aecf0;
}

.board-error {
  margin: 0 0 8px;
  color: #ff8a7a;
  font-size: 13px;
}

#board-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin: 0 0 12px;
  text-align: left;
}

#board-search label {
  display: grid;
  gap: 4px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#board-search input,
#board-search button {
  min-height: 40px;
}

#board-search input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #0c1014;
  color: var(--ink);
  font-size: 15px;
}

#board-search button {
  margin: 0;
  padding: 0 12px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #2a2218;
  color: #e6c37a;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#board-list {
  list-style: none;
  flex: 1 1 auto;
  min-height: 120px;
  margin: 0 0 12px;
  padding: 0 4px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: #c8923a #0c1014;
}

#board-list::-webkit-scrollbar {
  width: 8px;
}

#board-list::-webkit-scrollbar-track {
  background: #0c1014;
  border-radius: 8px;
}

#board-list::-webkit-scrollbar-thumb {
  background: #6a5228;
  border-radius: 8px;
  border: 1px solid #8a6a32;
}

#board-list::-webkit-scrollbar-thumb:hover {
  background: #c8923a;
}

#board .board-card > :not(#board-list) {
  flex-shrink: 0;
}

#board-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 2.2em;
  gap: 4px 8px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(200, 160, 70, 0.16);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.name-icon {
  --icon: 22px;
  display: inline-block;
  width: var(--icon);
  height: var(--icon);
  margin-right: 6px;
  flex: 0 0 var(--icon);
  border-radius: 50%;
  background-image: url("assets/name-icons.png?v=2");
  background-repeat: no-repeat;
  background-size: calc(var(--icon) * 8) calc(var(--icon) * 4);
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(232, 226, 212, 0.12);
}

.player-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: -12px 0 18px;
  color: var(--ink);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 18px;
  max-width: 100%;
  flex-wrap: wrap;
}

.player-medal {
  display: inline-block;
  max-width: 28px;
  max-height: 28px;
  margin-left: 3px;
  object-fit: contain;
  vertical-align: middle;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.player-chip[hidden] {
  display: none !important;
}

#settings-player {
  margin: 0 0 14px;
  justify-content: flex-start;
}

#board-status .name-icon {
  margin-right: 8px;
}

#board-list .board-rank {
  flex: 0 0 1.15em;
  text-align: right;
}

#board-list .board-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

#board-list .board-name .name-icon {
  margin-right: 0;
}

#board-list .board-medals {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
  gap: 2px;
  min-height: 20px;
}

#board-list .board-medals .player-medal {
  margin-left: 0;
  max-width: 20px;
  max-height: 20px;
}

#board-list .board-player-name {
  min-width: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#board-list .board-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.otp-show {
  margin: 0 0 12px;
  padding: 10px 8px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #0c1014;
  color: #e6c37a;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 22px;
}

#otp-form,
#join-form,
#join-verify,
#signin-form,
#signin-verify {
  display: grid;
  gap: 8px;
  text-align: left;
}

#join-form[hidden],
#join-verify[hidden],
#signin-form[hidden],
#signin-verify[hidden] {
  display: none !important;
}

#otp-form label,
#join-form label,
#join-verify label,
#signin-form label,
#signin-verify label {
  display: grid;
  gap: 4px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#otp-form input,
#join-form input,
#join-verify input,
#signin-form input,
#signin-verify input {
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: #0c1014;
  color: var(--ink);
  font-size: 15px;
}

#rotate {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #071422;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 22px;
}

button {
  cursor: pointer;
}

button:active {
  transform: scale(0.97);
}

body.is-portrait #hud {
  padding: 8px 14px 0;
}

body.is-portrait #score,
body.is-portrait #level,
body.is-portrait #best {
  font-size: 28px;
}

body.is-portrait #best {
  font-size: 22px;
}

body.is-portrait #floor-hud {
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

body.is-portrait .pip {
  width: 20px;
  height: 9px;
}

body.is-portrait #mute,
body.is-portrait #settings-btn {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

body.is-portrait #dev-toggle {
  top: calc(var(--ad-h, 0px) + 6px);
  right: 54px;
}

body.is-portrait #dev {
  top: calc(104px + env(safe-area-inset-top));
}

body.is-portrait #fire,
body.is-portrait #field {
  width: 52px;
  height: 78px;
  padding-bottom: 7px;
}

body.is-portrait #fire #ammo,
body.is-portrait #field #field-ammo {
  font-size: 10px;
  min-width: 1.8em;
}

body.is-portrait h1 {
  font-size: clamp(52px, 18vw, 88px);
}

body.is-portrait #title-wordmark {
  width: min(88vw, 480px);
  max-height: 16vh;
  transform: translateX(-8px);
}

body.is-portrait h2 {
  font-size: clamp(56px, 20vw, 96px);
}

body.is-portrait #dive,
body.is-portrait #retry,
body.is-portrait #home {
  width: min(176px, 62vw);
  height: calc(min(176px, 62vw) * 0.33);
}

body.is-portrait .hint {
  font-size: 13px;
  padding: 0 16px;
}

body.is-portrait .menu {
  padding-bottom: calc(var(--floor-h, 64px) + 28px);
}

/* OBrien Games shell design; gameplay geometry remains unchanged. */
.overlay {
  background:
    radial-gradient(circle at 75% 12%, rgba(30, 119, 133, 0.22), transparent 24rem),
    linear-gradient(180deg, rgba(7, 20, 34, 0.34), rgba(9, 26, 40, 0.68) 62%, rgba(6, 16, 26, 0.78));
}

.menu {
  background:
    radial-gradient(circle at 75% 12%, rgba(30, 119, 133, 0.18), transparent 22rem),
    linear-gradient(180deg, rgba(7, 20, 34, 0.2), rgba(9, 26, 40, 0.56) 62%, rgba(6, 16, 26, 0.68));
}

#local-top {
  background:
    radial-gradient(circle at 75% 12%, rgba(30, 119, 133, 0.24), transparent 22rem),
    linear-gradient(180deg, rgba(7, 20, 34, 0.52), rgba(9, 26, 40, 0.78) 62%, rgba(6, 16, 26, 0.86));
}

#settings,
#leave {
  background: rgba(6, 16, 26, 0.78);
}

#board,
#join,
#signin {
  background: var(--site-page-bg);
}

#board .board-card,
#join .board-card,
#signin .board-card {
  background: rgba(13, 33, 49, 0.78);
  box-shadow: none;
}

.settings-card,
.board-card {
  border-color: rgba(106, 82, 40, 0.72);
  border-radius: 10px;
  background: rgba(13, 33, 49, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
  color: var(--site-ink);
}

.settings-card h3,
.board-card h3,
.join-card h3 {
  color: var(--site-gold);
}

.board-note,
.vol-row {
  color: var(--site-muted);
}

.menu .best-line {
  border: 1px solid rgba(106, 82, 40, 0.55);
  background: rgba(13, 33, 49, 0.72);
  color: var(--cyan);
}

.pill,
#settings-close,
#settings-board,
#settings-join,
#settings-link,
#settings-switch,
#settings-forget,
#settings-out,
#leave-switch,
#leave-unlink,
#leave-close,
#board-close,
#join-close,
#join-signin,
#signin-close,
#signin-back,
#otp-send {
  border-color: #6a5228;
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.75);
  color: var(--site-gold);
  font-weight: 800;
}

#settings-close,
#join-submit,
#join-verify button[type="submit"],
#signin-form button[type="submit"],
#signin-verify button[type="submit"] {
  border-color: var(--brass);
  background: var(--brass);
  color: #071422;
}

.ghost,
#signin-close,
#signin-back {
  border-color: rgba(238, 232, 217, 0.28);
  background: transparent;
  color: var(--site-ink);
}

#settings-reset-local,
#leave-remove {
  border-color: #8f463d;
  background: #3a1b18;
  color: #ffb0a6;
}

#board-search input,
#join-form input,
#join-verify input,
#signin-form input,
#signin-verify input {
  border-color: #6a5228;
  background: rgba(7, 20, 34, 0.86);
  color: var(--site-ink);
}

#board-search input:focus-visible,
#join-form input:focus-visible,
#join-verify input:focus-visible,
#signin-form input:focus-visible,
#signin-verify input:focus-visible,
.settings-card button:focus-visible,
.board-card button:focus-visible,
.pill:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

#board-search button {
  border-color: #6a5228;
  background: rgba(20, 17, 14, 0.75);
  color: var(--site-gold);
}

#board-list li,
#local-top-list li {
  color: var(--site-ink);
}

#rotate {
  background:
    radial-gradient(circle at 75% 12%, rgba(30, 119, 133, 0.28), transparent 24rem),
    linear-gradient(180deg, #071422, #091a28 62%, #06101a);
  color: var(--site-gold);
}

#board-btn,
#join-btn,
#link-btn,
#switch-btn,
#unlink-btn,
#over-join,
#over-link,
#over-switch,
#over-unlink,
#join-signin,
#join-close,
#leave-switch,
#leave-unlink,
#leave-close,
#settings-board,
#settings-join,
#settings-link,
#settings-switch {
  min-height: 42px;
  min-width: min(230px, 86vw);
  padding: 10px 18px;
  border: 1px solid #6a5228;
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.75);
  color: var(--site-gold);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-actions-stack #leave-switch,
.panel-actions-stack #leave-unlink,
.panel-actions-stack #leave-close,
.settings-action-group #settings-board,
.settings-action-group #settings-join,
.settings-action-group #settings-link,
.settings-action-group #settings-switch {
  min-width: 0;
  width: 100%;
}

#otp-send:disabled {
  opacity: 0.72;
  cursor: wait;
}

/* Brass controls: menu/panel buttons only. Original Fire and Shield are excluded.
   Keep the dock's flow height unchanged so instruments do not rise into the cave. */
#app :is(#title, #over, #local-top, #settings, #board, #join, #signin, #leave) :where(button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #8d7143;
  border-radius: 24px;
  background: #0e252f;
  color: #e7c278;
  box-shadow: inset 0 1px 0 #ead29815;
  font-family: "Barlow Condensed", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  touch-action: manipulation;
}

#app :is(#title, #over, #local-top, #settings, #board, #join, #signin, #leave) button[hidden] {
  display: none !important;
}

#app :is(#dive, #retry, #home) {
  width: 176px;
  height: 58px;
  padding: 0 16px;
  background-image: none;
  font-family: "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
}

#app #dive {
  border: 3px solid #c9a35e;
  border-radius: 30px;
  background: linear-gradient(155deg, #28414a, #112630 52%, #0a1a22);
  color: #fae5b6;
  box-shadow: inset 0 0 0 1px #f1cf8560, inset 0 3px 9px #0007, 0 3px 0 #554127;
  font-size: 22px;
  font-weight: 600;
}

#app :is(#retry, #home) {
  height: 44px;
  font-size: 15px;
  font-weight: 600;
}

.control-icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

#dive .control-icon { width: 22px; height: 22px; }

/* Secondary navigation stays visibly subordinate to Dive. */
#app :is(#title, #over) :is(.board-actions, .over-account-actions) {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 8px;
  width: min(290px, 100%);
}

#app :is(#title, #over) :is(.board-actions, .over-account-actions) button {
  min-width: 0;
  width: auto;
  padding: 10px 12px;
  border-color: transparent;
  background: rgba(8, 25, 35, 0.55);
  color: #c4d3d8;
  box-shadow: none;
  font-size: 14px;
  letter-spacing: 0.04em;
}

#app :is(#title-best, #over-best) {
  min-height: 44px;
  padding: 6px 18px;
  color: #75e2e8;
  background: rgba(13, 33, 49, 0.72);
  border-color: #8d714366;
  font-size: 16px;
  letter-spacing: 0.12em;
}

#app :is(#settings-close, #join-submit, #otp-send),
#app :is(#join-verify, #signin-verify) button[type="submit"] {
  border: 2px solid #c9a35e;
  background: linear-gradient(155deg, #28414a, #112630 60%, #0a1a22);
  color: #fae5b6;
  box-shadow: inset 0 1px 0 #f1cf8540;
}

/* Destructive actions retain their warning color and existing confirmations. */
#app :is(#settings-reset-local, #leave-remove) {
  border-color: #a26659;
  background: #321e20;
  color: #ffb9a8;
}

#app :is(#board-search) button { min-width: 58px; padding: 8px 12px; }
#app #board-search input { min-height: 44px; }

/* 44px hit areas around 30/34px faces, with no extra height in #floor-hud. */
#app #dock { gap: 14px; }
#app :is(#mute, #settings-btn) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: -5px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #e7c278;
  text-decoration: none;
  touch-action: manipulation;
}

#app :is(#mute, #settings-btn)::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 1px solid #977644;
  border-radius: 50%;
  background: #10232c;
  box-shadow: inset 0 1px 0 #ead29825;
}

#app :is(#mute, #settings-btn) .control-icon { width: 17px; height: 17px; }
#app #mute.is-off { color: #9bacb5; }
#app #mute.is-off::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 2px;
  background: #e7c278;
  box-shadow: 0 0 0 1px #10232c;
  transform: rotate(-45deg);
}

body.is-portrait #app :is(#mute, #settings-btn) { margin: -7px; }
body.is-portrait #app :is(#mute, #settings-btn)::before { inset: 7px; }

#app :is(#title, #over, #local-top, #settings, #board, #join, #signin, #leave) button:focus-visible,
#app :is(#mute, #settings-btn):focus-visible {
  outline: 2px solid #75e2e8;
  outline-offset: 3px;
}

#app :is(#title, #over, #local-top, #settings, #board, #join, #signin, #leave) button:disabled {
  opacity: 0.55;
}

@media (hover: hover) {
  #app :is(#title, #over, #local-top, #settings, #board, #join, #signin, #leave) button:not(:disabled):hover {
    border-color: #e7c278;
    background-color: #193641;
  }
  #app :is(#mute, #settings-btn):hover::before { border-color: #e7c278; background: #193641; }
  #app :is(#settings, #leave) :is(#settings-reset-local, #leave-remove):hover {
    border-color: #e2a38d;
    background: #45262a;
  }
}

/* Native scrolling and range controls, recolored to match the brass instruments. */
#app :is(.settings-card, .board-card, #board-list) {
  scrollbar-width: thin;
  scrollbar-color: #b79658 #081923;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
#app :is(.settings-card, .board-card, #board-list)::-webkit-scrollbar { width: 8px; height: 8px; }
#app :is(.settings-card, .board-card, #board-list)::-webkit-scrollbar-track { background: #081923; border-radius: 8px; }
#app :is(.settings-card, .board-card, #board-list)::-webkit-scrollbar-thumb {
  border: 2px solid #081923;
  border-radius: 8px;
  background: #b79658;
}
#app :is(.settings-card, .board-card, #board-list)::-webkit-scrollbar-thumb:hover { background: #e7c278; }
#app .vol-row input[type="range"] { accent-color: #d7b371; min-height: 28px; touch-action: pan-x; }
