/* Gem Rush — lamp-lit cave, warm earth + gem colours */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0b0807;
  color: #f4ece2;
  font-family: "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; z-index: 0;
  image-rendering: pixelated;
}

/* ── HUD ─────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.hud-top {
  position: absolute; top: calc(8px + env(safe-area-inset-top));
  left: 8px; right: 8px;
  display: flex; justify-content: space-between; align-items: stretch; gap: 6px;
}
.hud-panel {
  background: rgba(20, 13, 10, .82); border: 1px solid rgba(255, 196, 120, .2);
  border-radius: 12px; padding: 6px 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
}
.hud-gems { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 900; }
.hud-gems .hud-of { font-size: 15px; color: #c9ab8c; font-weight: 700; }
.gem-ico {
  width: 18px; height: 18px; display: inline-block;
  background: linear-gradient(135deg, #e9fdff 0 22%, #7ff3ff 22% 50%, #2fc6f0 50% 75%, #127aa8 75%);
  clip-path: polygon(30% 0, 70% 0, 100% 35%, 50% 100%, 0 35%);
}
.hud-exit {
  font-size: 10px; letter-spacing: .12em; font-weight: 800; padding: 3px 7px;
  border-radius: 999px; background: rgba(120, 100, 90, .35); color: #b6a294;
}
.hud-exit.open {
  background: linear-gradient(90deg, #ffd84a, #7dff8a); color: #13240d;
  animation: exit-pulse 1s ease-in-out infinite;
}
@keyframes exit-pulse { 50% { box-shadow: 0 0 14px rgba(125, 255, 138, .8); } }
.hud-cave { text-align: center; min-width: 70px; }
.hud-time { text-align: right; min-width: 80px; }
.tr-label { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #c9a47e; }
.tr-value { font-size: 22px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tr-value.warn { color: #ff6b5a; }
.tr-sub { font-size: 12px; color: #ffb0a0; letter-spacing: .1em; }

/* the race board sits IN the top bar, between the gem counter and the cave
   number, so it never covers the cave; on a phone it wraps to its own row */
.hud-board {
  flex: 1 1 auto; min-width: 0; align-self: center;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
}
.hud-board:empty { visibility: hidden; }
.hb-row { max-width: 190px; }
.hb-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
  gap: 6px; font-size: 12px; padding: 3px 8px; border-radius: 8px;
  background: rgba(20, 13, 10, .72); color: #f1e3d3;
}
.hb-row .hb-dot { width: 10px; height: 10px; border-radius: 3px; }
.hb-row .hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-row .hb-val { font-weight: 800; font-variant-numeric: tabular-nums; }
.hb-row.me { outline: 1px solid rgba(255, 220, 160, .55); }
.hb-row.dead { opacity: .5; }
.hb-row.out { background: rgba(40, 70, 30, .75); }

.hud-toast {
  position: absolute; top: calc(70px + env(safe-area-inset-top)); right: 8px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end; max-width: 60vw;
}
.toast {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(20, 13, 10, .85); color: #f4e4d2;
  border: 1px solid rgba(255, 196, 120, .2);
  animation: toast-in .18s ease-out, toast-out .4s ease-in 2.6s forwards;
}
@keyframes toast-in { from { transform: translateX(16px); opacity: 0; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

.hud-center {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; width: min(92vw, 560px);
}
.hud-center .big {
  font-size: clamp(26px, 7vw, 46px); font-weight: 900; color: #fff6e0;
  text-shadow: 0 0 24px rgba(255, 200, 90, .45), 0 3px 0 rgba(0, 0, 0, .6);
  letter-spacing: .05em;
}
.hud-center .small {
  font-size: 15px; color: #f2d8b8; margin-top: 6px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .7);
}
.hud-center .banner {
  display: inline-block; padding: 12px 22px; border-radius: 16px;
  background: rgba(14, 9, 7, .78); border: 1px solid rgba(255, 200, 120, .25);
}

/* touch controls — shown only on coarse pointers */
#touchLayer { display: none; }
@media (pointer: coarse) { #touchLayer { display: block; } }
.dpad {
  position: absolute; left: calc(14px + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 156px; height: 156px; pointer-events: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  touch-action: none;
}
.dbtn {
  border: 2px solid rgba(255, 210, 150, .35); background: rgba(30, 20, 14, .62);
  color: #ffe2b8; font-size: 20px; border-radius: 12px; touch-action: none;
  padding: 0;
}
.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 3; }
.dbtn.held { background: rgba(255, 190, 90, .5); color: #2a1606; }
.grab-btn {
  position: absolute; right: calc(16px + env(safe-area-inset-right));
  bottom: calc(40px + env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid #7ff3ff; background: rgba(47, 198, 240, .16);
  color: #d4fbff; font-size: 14px; font-weight: 900; letter-spacing: .08em;
  pointer-events: auto; touch-action: none;
}
.grab-btn.held { background: rgba(47, 198, 240, .55); color: #04202b; }

/* audio strip in the HUD: tucked behind a small toggle so it never covers play */
.hud-gear {
  position: absolute; right: calc(8px + env(safe-area-inset-right));
  bottom: calc(8px + env(safe-area-inset-bottom));
  pointer-events: auto;
}
@media (pointer: coarse) { .hud-gear { bottom: auto; top: 46%; } }
.hud-gear summary {
  list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: rgba(20, 13, 10, .82); border: 1px solid rgba(255, 196, 120, .3);
}
.hud-gear summary::-webkit-details-marker { display: none; }
/* site_audio.css pins #hudAudio fixed bottom-centre; inside the gear it sits
   in normal flow instead, so restate ALL four placement properties. */
#hudAudio {
  position: absolute; bottom: 40px; right: 0; left: auto; transform: none;
  background: rgba(20, 13, 10, .92); border-radius: 12px; padding: 6px 8px;
  width: max-content; max-width: 86vw;
}
@media (pointer: coarse) { #hudAudio { bottom: auto; top: -60px; right: 42px; } }
.audio-controls {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  justify-content: center; padding: 4px 0;
}
.audio-controls button {
  background: #2a1c14; color: #f1d9bd; border: 1px solid #5a3d2a;
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.audio-controls input[type="range"] { width: 86px; accent-color: #ffb648; }
/* web/style.css pins .volume-slider position:fixed top:12px — undo it here
   or every slider lands in the corner of the screen (CLAUDE.md item 5). */
.volume-slider { position: static !important; top: auto !important; }

.spectator-flag {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 9; padding: 4px 12px;
  background: rgba(20, 13, 10, .85); border: 1px solid #5a3d2a;
  border-radius: 999px; font-size: 12px; letter-spacing: .1em; color: #f1d9bd;
}

/* ── overlays / lobby card ───────────────────────────────────────── */
#lobbyOverlay {
  position: fixed; inset: 0; display: flex; align-items: flex-start;
  justify-content: center; z-index: 10; overflow-y: auto;
  padding: 24px 0;
  background:
    radial-gradient(900px 520px at 18% 8%, rgba(255, 170, 60, .16), transparent 60%),
    radial-gradient(800px 520px at 85% 92%, rgba(80, 210, 255, .14), transparent 60%),
    radial-gradient(600px 400px at 70% 20%, rgba(240, 79, 184, .10), transparent 60%),
    #0b0807;
}
.card {
  width: min(460px, 94vw); padding: 20px 20px 14px; margin: auto 0;
  background: rgba(22, 15, 11, .94); border: 1px solid rgba(255, 196, 120, .22);
  border-radius: 18px; box-shadow: 0 16px 60px rgba(0, 0, 0, .6);
  text-align: center;
}
.gem-title {
  margin: 4px 0 6px; font-size: clamp(34px, 9vw, 52px); font-weight: 900;
  letter-spacing: .06em; color: #ffe3b0;
  text-shadow: 0 3px 0 #5a3418, 0 0 22px rgba(255, 190, 90, .3);
}
.gem-title span {
  margin-left: .15em;
  background: linear-gradient(180deg, #e9fdff, #7ff3ff 40%, #2fc6f0 60%, #b46bff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
}
.gem-title.small { font-size: clamp(24px, 6vw, 36px); }
.tagline { margin: 0 0 14px; color: #d6bfa4; font-size: 14px; }
.instructions { margin: 12px 0 4px; font-size: 12.5px; color: #b89e83; display: grid; gap: 4px; }
.muted { color: #a98f75; }

input#nameInput {
  width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 15px;
  border: 1px solid #5a3d2a; background: #1d130d; color: #f4e6d4;
  outline: none; margin-bottom: 10px;
}
button.primary, button.secondary {
  width: 100%; padding: 12px; border: 0; border-radius: 10px;
  font-size: 16px; font-weight: 800; letter-spacing: .04em; cursor: pointer;
}
button.primary {
  background: linear-gradient(180deg, #ffcf5a, #f29a24); color: #2a1404;
  box-shadow: 0 6px 22px rgba(242, 154, 36, .3);
}
button.secondary {
  margin-top: 8px; background: #2a1c14; color: #ffdcae; border: 1px solid #6a4a32;
}
button.primary:active, button.secondary:active { filter: brightness(.9); }
.link-btn {
  margin-top: 10px; background: none; border: 0; color: #ffd27a; cursor: pointer;
  font-size: 14px; font-weight: 700;
}
.back-link { display: block; margin-top: 10px; color: #a98f75; font-size: 13px; }

.squad-count { color: #ffcf5a; font-weight: 700; margin-bottom: 8px; }
.player-list { max-height: 150px; overflow-y: auto; margin-bottom: 10px; }
.player-row {
  display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 5px 8px; border-radius: 8px; background: #23170f;
  margin-bottom: 4px; font-size: 14px;
}
.player-row .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.player-row .tag { margin-left: auto; font-size: 11px; color: #c9a47e; }

.settings { margin: 8px 0 10px; text-align: left; }
.settings-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.settings-label { width: 60px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #c9a47e; }
.seg { display: inline-flex; border-radius: 9px; overflow: hidden; border: 1px solid #5a3d2a; }
.seg button {
  background: #1d130d; color: #e9d2b4; border: 0; padding: 7px 12px; font-size: 13px;
  cursor: pointer;
}
.seg button.on { background: linear-gradient(180deg, #ffcf5a, #f29a24); color: #2a1404; font-weight: 800; }
.seg.locked button { cursor: default; }
.mode-hint { font-size: 12.5px; color: #b89e83; margin: 4px 0 0; }

.briefing { text-align: left; margin: 10px 0; font-size: 13px; color: #d6bfa4; }
.briefing ul { margin: 6px 0 0 18px; padding: 0; }
.briefing li { margin-bottom: 4px; }

.leaderboard { margin-top: 12px; text-align: left; }
.leaderboard, .lb-panel, .lb-card {
  --lb-accent: #ffcf5a;
  --lb-text: #f4e6d4;
  --lb-dim: rgba(244, 230, 212, .55);
  --lb-edge: rgba(255, 196, 120, .18);
  --lb-panel: rgba(40, 26, 18, .7);
}
.lb-card { max-width: min(560px, 94vw) !important; width: min(560px, 94vw) !important; }

.load-bar {
  height: 10px; border-radius: 6px; background: #1d130d; overflow: hidden;
  border: 1px solid #5a3d2a; margin: 12px 0 6px;
}
#loadBar { height: 100%; width: 100%; background: linear-gradient(90deg, #ffcf5a, #7ff3ff); }
.peers { min-height: 16px; font-size: 12px; }
.countdown { font-size: 84px; font-weight: 900; color: #ffe3b0; text-shadow: 0 0 30px rgba(255, 200, 90, .55); }

/* ── results ─────────────────────────────────────────────────────── */
.card.results-wide { width: min(760px, 96vw); }
#resultTable { overflow-x: auto; scrollbar-width: thin; }
#resultTable .fs-table { width: max-content; min-width: 100%; font-size: .86rem; }
#resultTable .fs-table th, #resultTable .fs-table td { padding: 6px 9px; }
@media (max-width: 560px) {
  #resultTable .fs-table { font-size: .78rem; }
  .hud-top { flex-wrap: wrap; }
  .hud-board { order: 10; flex-basis: 100%; justify-content: flex-start; }
  .hb-row { max-width: 46vw; }
  .hud-gems { font-size: 18px; }
  .tr-value { font-size: 18px; }
  .hud-panel { padding: 5px 9px; }
}
