/* The game page. The stage fills the window; the menu and the match display lie on top of it. */
:root {
  color-scheme: dark;
  --bg: #0c0f0d;
  --panel: rgba(17, 21, 18, .86);
  --panel-solid: #141916;
  --line: rgba(222, 204, 160, .17);
  --line-strong: rgba(222, 204, 160, .36);
  --text: #ece6d6;
  --dim: #aaa38f;
  --olive: #8d9d55;
  --brass: #e0b85a;
  --rust: #cf7a3d;
  --danger: #e2674f;
  --amber: #ffbb6a;
  --mono: Consolas, "Cascadia Mono", monospace;
  font: 16px/1.45 Bahnschrift, "DIN Alternate", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--text); background: var(--bg); }
h2, h3, p { margin: 0; }
a { color: var(--brass); }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; font: 12px var(--mono); color: var(--text); }
code { font: 13px var(--mono); color: var(--brass); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

button, select, input { font: inherit; color: var(--text); }
button, select { font-size: 14px; font-weight: 600; line-height: 1.2; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(40, 46, 38, .9); }
button { cursor: pointer; padding: 9px 14px; }
button:hover { background: rgba(62, 70, 54, .95); border-color: var(--brass); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { color: #14170f; background: var(--brass); border-color: #f2d68a; }
button.primary:hover { background: #f0cd72; }
button.big { font-size: 18px; letter-spacing: .06em; text-transform: uppercase; padding: 13px 34px; }
select { padding: 8px 10px; min-width: 0; max-width: 100%; }
input[type="number"] { width: 84px; padding: 7px 10px; font-size: 14px; font-weight: 600; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(40, 46, 38, .9); }
label { display: grid; gap: 4px; color: var(--dim); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
label.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); }

/* ---- Stage ---- */
.screen { position: fixed; inset: 0; container-type: inline-size; background: radial-gradient(ellipse at 50% 30%, #1b211a 0%, var(--bg) 70%); }
#field { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(96vw, calc((100vh - 200px) * 2.165)); height: auto; aspect-ratio: 840/388; background: #15231b; outline: none; }
#field.aiming { cursor: crosshair; touch-action: none; }
body[data-view="setup"] .screen:not(.has-3d) #field, body[data-view="lobby"] .screen:not(.has-3d) #field { visibility: hidden; }
/* With the 3D view the flat canvas only catches clicks, across the whole stage. */
.screen.has-3d #field { left: 0; top: 0; transform: none; width: 100%; height: 100%; aspect-ratio: auto; opacity: 0; }
.stage3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stage3d canvas { display: block; width: 100%; height: 100%; }
.scrim { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s; background: radial-gradient(ellipse at 50% 22%, rgba(10, 12, 10, .42) 0%, rgba(8, 10, 8, .72) 55%, rgba(6, 8, 6, .9) 100%); }
body:not([data-view="match"]) .scrim { opacity: 1; backdrop-filter: blur(2px); }

.match-banner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 92%; padding: .5em 1.1em; text-align: center; font-size: clamp(18px, 2.2vw, 30px); font-weight: 700; letter-spacing: .02em; color: var(--text); background: rgba(14, 17, 14, .9); border: 1px solid var(--line-strong); border-radius: 8px; pointer-events: none; }
.match-banner.victory-banner { top: 132px; transform: translateX(-50%); }
.match-banner.countdown-banner { font: 900 clamp(4rem, 15cqw, 11rem)/1 var(--mono); letter-spacing: -.06em; padding: 0; color: #f6eccb; border: 0; background: transparent; text-shadow: 0 4px 10px #000, 0 0 .2em rgba(224, 184, 90, .55); transform-origin: center; }
body:not([data-view="match"]) .match-banner { display: none; }

/* ---- Title and match setup ---- */
#selection { position: fixed; inset: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 2.5vh 20px 18px; }
.title { position: relative; display: grid; justify-items: center; padding: 1vh 0 0; }
.title::before { content: ""; position: absolute; inset: -18% -30% -10%; background: radial-gradient(ellipse at 50% 55%, rgba(255, 190, 110, .2) 0%, rgba(255, 170, 90, .07) 38%, transparent 68%); pointer-events: none; }
.logo { position: relative; width: min(60vw, 680px, 118vh); height: auto; filter: drop-shadow(0 20px 22px rgba(0, 0, 0, .72)) drop-shadow(0 2px 2px rgba(0, 0, 0, .8)); animation: logo-in .7s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes logo-in { from { opacity: 0; transform: translateY(-26px) scale(1.08); } to { opacity: 1; transform: none; } }
.tagline { position: relative; margin-top: 2px; padding: 5px 22px; color: var(--dim); font-size: 14px; letter-spacing: .34em; text-transform: uppercase; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); background: repeating-linear-gradient(135deg, transparent 0 9px, rgba(224, 184, 90, .07) 9px 18px); }
#connection { min-height: 1.4em; color: var(--dim); font-size: 15px; text-align: center; }
.setup { display: grid; justify-items: center; gap: 16px; padding: 18px 20px 20px; width: min(100%, 880px); }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; }
.slot { --team: var(--dim); display: grid; gap: 7px; padding: 10px 10px 12px; border: 1px solid var(--line); border-top: 4px solid var(--team); border-radius: 7px; background: rgba(10, 13, 11, .55); }
.slot span { color: var(--dim); font: 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.slot select { width: 100%; }
.slot[data-team="0"] { --team: #a3b86a; } .slot[data-team="1"] { --team: #d98452; }
.slot[data-team="2"] { --team: #7fa3cc; } .slot[data-team="3"] { --team: #cdb968; }
.slot[data-kind="closed"] { --team: rgba(222, 204, 160, .2); opacity: .62; }
.option-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: end; gap: 12px 18px; }
#invite-note { max-width: 46rem; color: var(--dim); font-size: 14px; text-align: center; }
#invite-note:empty { display: none; }
.lobby { display: grid; gap: 12px; padding: 20px; width: min(100%, 640px); }
.lobby p { color: var(--dim); line-height: 1.5; }
.lobby input { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(8, 10, 8, .7); }
.invite-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rules { width: min(100%, 880px); padding: 10px 16px; }
.rules summary { cursor: pointer; color: var(--dim); font-size: 14px; letter-spacing: .06em; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; padding: 12px 0 6px; }
.rules h3 { font-size: 14px; color: var(--brass); margin-bottom: 4px; }
.rules p { font-size: 14px; line-height: 1.55; color: var(--dim); }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 18px; align-items: center; font-size: 13px; }
.foot select { font-size: 13px; padding: 5px 8px; }
body[data-view="match"] #selection { display: none; }

/* ---- Match display ---- */
#match { position: fixed; inset: 0; pointer-events: none; }
#match button, #match .summary { pointer-events: auto; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 12px; padding: 10px 14px 0; }
.players { display: flex; gap: 8px; min-width: 0; }
#players-left { justify-content: flex-end; }
.hud-mid { display: grid; justify-items: center; gap: 2px; padding-top: 2px; }
.hud-logo { width: clamp(120px, 15vw, 210px); height: auto; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .7)); }
.round-info { display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 13px; letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 1px 4px #000; }
#round-note:not(:empty) { color: #14170f; background: var(--brass); padding: 1px 8px; border-radius: 3px; letter-spacing: .1em; font-weight: 700; }
.player { --team: var(--dim); flex: 0 1 218px; min-width: 132px; display: grid; gap: 5px; padding: 7px 10px 8px; border-radius: 7px; border: 1px solid var(--line); border-top: 4px solid var(--team); background: var(--panel); }
.player-head { display: flex; align-items: baseline; gap: 8px; }
.player-name { font-weight: 700; letter-spacing: .05em; color: color-mix(in srgb, var(--team) 62%, white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-kills { color: var(--dim); font: 12px var(--mono); white-space: nowrap; }
.player-score { margin-left: auto; font: 700 26px/1 var(--mono); color: var(--text); }
.player-load { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 20px; color: var(--dim); font: 12px var(--mono); }
.player-load svg { width: 15px; height: 15px; vertical-align: -3px; }
.pips { display: inline-flex; gap: 3px; align-items: center; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(224, 184, 90, .5); }
.pips i.on { background: var(--brass); border-color: #f4dc98; }
.pips.mines i { border-radius: 2px; transform: rotate(45deg); width: 7px; height: 7px; border-color: rgba(226, 103, 79, .55); margin: 0 1px; }
.pips.mines i.on { background: var(--danger); border-color: #f3a091; }
.chip { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.chip.ready, .chip.active { color: var(--text); }
.chip.ready svg { color: var(--brass); } .chip.shield.active svg { color: #73d2ff; }
.chip.special.active svg { color: #c98aff; }
.player.out { opacity: .5; filter: saturate(.35); }
.player.out .player-name { text-decoration: line-through; }
.player.me { box-shadow: 0 0 0 1px color-mix(in srgb, var(--team) 55%, transparent); }

.biome-card { position: absolute; left: 50%; top: calc(50% + clamp(60px, 11vw, 150px)); transform: translateX(-50%); width: min(92vw, 560px); padding: 10px 18px 12px; text-align: center; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--panel); }
.biome-card strong { display: block; font-size: 20px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
.biome-card p { color: var(--dim); font-size: 14px; line-height: 1.45; }

.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; gap: 12px; padding: 0 14px 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions.end { justify-content: flex-end; }
.hud-bottom button { font-size: 13px; padding: 7px 11px; background: rgba(24, 28, 24, .82); }
.hud-bottom button.primary { background: var(--brass); }
#feedback { min-height: 1.4em; text-align: center; color: var(--text); font-size: 15px; text-shadow: 0 1px 5px #000, 0 0 2px #000; }
.touch-only, .touch { display: none; }

.summary { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(94vw, 620px); padding: 20px 22px 22px; display: grid; gap: 14px; text-align: center; }
.summary h2 { font-size: 26px; letter-spacing: .04em; color: var(--brass); }
.summary table { width: 100%; border-collapse: collapse; font-size: 15px; }
.summary th { color: var(--dim); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; }
.summary td { padding: 7px 6px; border-top: 1px solid var(--line); font-family: var(--mono); }
.summary td.name { font-family: inherit; font-weight: 700; text-align: left; }
.summary td.name::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; background: var(--team); }
.summary th:nth-child(2) { text-align: left; }
.summary-actions { display: flex; justify-content: center; gap: 10px; }

.game-sound-toggle { font-size: 13px; padding: 7px 11px; }

@media (pointer: coarse) {
  .touch-only { display: inline-block; touch-action: none; user-select: none; min-height: 44px; }
  .touch { position: absolute; left: 14px; bottom: 64px; display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 6px; pointer-events: auto; }
  .touch button { touch-action: none; user-select: none; font-size: 20px; }
  .touch button:nth-child(1) { grid-column: 2; grid-row: 1; }
  .touch button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .touch button:nth-child(3) { grid-column: 2; grid-row: 2; }
  .touch button:nth-child(4) { grid-column: 3; grid-row: 2; }
}
@media (max-width: 900px) {
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player { min-width: 104px; padding: 5px 7px 6px; }
  .player-score { font-size: 20px; }
  .hud-bottom { grid-template-columns: 1fr; justify-items: center; }
  .actions.end { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }
.name-field { justify-items: center; }
.name-field input { width: min(100%, 18rem); padding: 9px 12px; text-align: center; font-size: 16px; font-weight: 600; letter-spacing: .04em; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(8, 10, 8, .7); }
.chip.heat.active { color: #ffb070; } .chip.heat.active svg { color: #ff6a2c; }
#special { margin-top: 5px; color: var(--text); font-weight: 600; }
#special:empty { display: none; }
.biomes { width: 100%; }
.biomes summary { cursor: pointer; color: var(--dim); font-size: 14px; letter-spacing: .06em; text-align: center; }
.biome-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding-top: 12px; }
.biome { display: grid; gap: 6px; padding: 8px; text-align: left; font-weight: 400; border: 1px solid var(--line); border-radius: 7px; background: rgba(10, 13, 11, .55); }
.biome[aria-pressed="true"] { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.biome canvas { width: 100%; height: auto; aspect-ratio: 840/388; border-radius: 4px; background: #1a1f1b; }
.biome strong { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); }
.biome span { font-size: 13px; line-height: 1.4; color: var(--dim); white-space: normal; }
