* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #0a1510;
  --panel: #14251b;
  --line: #304438;
  --text: #f3f8f2;
  --muted: #adbdaf;
  --lime: #d5fb69;
  --danger: #ffb8a1;
  font-family: system-ui, sans-serif;
}
body { margin: 0; background: radial-gradient(ellipse at 50% 4%, #15291c 0%, var(--bg) 60%); color: var(--text); min-height: 100vh; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, .button { cursor: pointer; border: 1px solid transparent; padding: .78rem 1.1rem; border-radius: .65rem; min-height: 46px; font-weight: 700; text-align: center; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--lime); color: #14200b; }
.primary:hover:not(:disabled) { background: #e5ff99; }
.secondary { background: #1b3023; color: var(--text); border-color: #3b5544; }
.secondary:hover:not(:disabled) { background: #253d2d; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.top, main { width: min(1080px, calc(100% - 2.5rem)); margin: 0 auto; }
.top { display: flex; align-items: center; gap: 1rem; min-height: 76px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; display: inline-flex; align-items: center; gap: .6rem; margin-right: auto; }
.mark { background: var(--lime); color: #19260c; width: 2rem; aspect-ratio: 1; display: grid; place-items: center; border-radius: .55rem; }
.room-label { color: var(--muted); font: 700 .9rem ui-monospace, monospace; letter-spacing: .1em; }
.compact { min-height: 36px; padding: .35rem .7rem; font-size: .875rem; }
.lobby { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, 1fr); gap: 1rem; margin-top: clamp(1.75rem, 7vw, 5rem); }
.hero, .panel { border: 1px solid var(--line); border-radius: 1.25rem; }
.hero { min-height: 430px; background: #153d29; position: relative; overflow: hidden; display: flex; align-items: end; }
.pitch { position: absolute; width: 82%; height: 64%; top: 2%; right: -15%; border: 2px solid #a0ce8e56; border-radius: .3rem; transform: rotate(-16deg); background: repeating-linear-gradient(90deg, #ffffff0b 0 10%, transparent 10% 20%); }
.half { position: absolute; top: 0; left: 50%; height: 100%; border-left: 2px solid #a0ce8e56; }
.circle { position: absolute; top: 50%; left: 50%; width: 24%; aspect-ratio: 1; border: 2px solid #a0ce8e56; border-radius: 50%; transform: translate(-50%, -50%); }
.box { position: absolute; top: 26%; height: 48%; width: 17%; border: 2px solid #a0ce8e56; }
.left { left: -2px; }
.right { right: -2px; }
.ball { position: absolute; left: 50%; top: 50%; font-size: clamp(2.8rem, 7vw, 5.5rem); transform: translate(-50%, -50%) rotate(16deg); filter: drop-shadow(0 10px 10px #071e15); }
.hero-copy { position: relative; z-index: 1; width: 100%; padding: clamp(1.4rem, 4vw, 2.75rem); padding-top: 6rem; background: linear-gradient(0deg, #112e20 25%, #112e2000); }
.eyebrow { color: var(--lime); font-size: .875rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 .65rem; }
h1, h2, p { margin-top: 0; }
.hero h1 { margin-bottom: 1rem; font-weight: 900; font-size: clamp(2.85rem, 7.3vw, 5.5rem); line-height: .94; letter-spacing: -.065em; }
.hero-copy > p:last-child { margin-bottom: 0; max-width: 32ch; color: #d5e6d8; line-height: 1.55; }
.panel { background: var(--panel); }
.entry { padding: clamp(1.4rem, 4vw, 2.25rem); align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.entry h2 { margin-bottom: 1.5rem; font-size: 1.75rem; letter-spacing: -.04em; }
label { display: block; font-weight: 650; margin: 0 0 .5rem; }
input { display: block; width: 100%; min-width: 0; min-height: 48px; border: 1px solid #456050; border-radius: .65rem; background: #0d1c13; color: var(--text); padding: .7rem .85rem; }
input::placeholder { color: #9cad9f; }
.entry > .primary { margin-top: .7rem; }
.mode-choice { margin-top: .85rem; position: relative; }
.mode-choice::after { content: ''; position: absolute; right: 1rem; bottom: 1.15rem; width: .45rem; height: .45rem; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.mode-choice select { appearance: none; width: 100%; min-height: 48px; border: 1px solid #456050; border-radius: .65rem; background: #0d1c13; color: var(--text); font: inherit; padding: .7rem 2rem .7rem .85rem; }
.entry input + label, .credentials input + label { margin-top: .85rem; }
.form-note { color: var(--muted); line-height: 1.45; margin: .6rem 0; }
.admin-dialog { width: min(590px, calc(100% - 2rem)); padding: clamp(1rem, 4vw, 1.5rem); }
.admin-dialog::backdrop { background: #05130bd9; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.admin-heading h2, .admin-section h3 { margin: 0; }
.admin-section { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.admin-section h3 { margin-bottom: .8rem; }
.admin-rows { list-style: none; margin: 0; padding: 0; }
.admin-rows li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .45rem .8rem; padding: .65rem 0; }
.admin-rows li + li { border-top: 1px solid var(--line); }
.admin-rows small { display: block; color: var(--muted); margin-top: .2rem; }
.credentials { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.credentials p { color: var(--muted); line-height: 1.45; }
.separator { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .875rem; margin: 1.4rem 0 .9rem; }
.separator::before, .separator::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.join-row, .action-row { display: flex; gap: .55rem; align-items: start; }
.join-row button, .action-row button { white-space: nowrap; }
footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin: 2.5rem 0 1.25rem; padding-top: 1rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .875rem; }
.match { max-width: 860px; margin: 2rem auto 0; }
.rounds { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.rounds span { padding: .55rem .35rem; background: #132319; border: 1px solid var(--line); border-radius: .5rem; color: var(--muted); text-align: center; font-weight: 700; font-size: .875rem; }
.rounds .current { border-color: var(--lime); color: var(--lime); background: #243721; }
.rounds .past { color: var(--text); background: #213628; }
.scoreboard { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 1rem; align-items: center; margin: 1rem 0; padding: 1.05rem clamp(.8rem, 5vw, 2rem); background: #0e1c13; border: 1px solid var(--line); border-radius: .9rem; }
.competitor { font-weight: 750; overflow-wrap: anywhere; }
.competitor.right { text-align: right; }
.competitor small { color: var(--muted); display: block; font-size: .875rem; font-weight: 500; }
.score { display: flex; gap: .6rem; font-size: 2.35rem; line-height: 1; font-weight: 850; font-variant-numeric: tabular-nums; }
.score-summary { display: grid; justify-items: center; gap: .35rem; }
.score-caption, #match-score { color: var(--muted); font-size: .85rem; text-align: center; }
.score-divider { color: #718579; }
.arena { padding: clamp(1.1rem, 4vw, 2.25rem); position: relative; background: linear-gradient(145deg, #1b3121, var(--panel) 60%); }
.arena-head { display: flex; gap: 1rem; justify-content: space-between; align-items: start; }
.arena h1 { margin: 0 0 .6rem; letter-spacing: -.04em; line-height: 1.08; font-size: clamp(1.8rem, 5.2vw, 3rem); overflow-wrap: anywhere; }
.clock { flex-shrink: 0; min-width: 4.25rem; text-align: center; background: #0d1b12; padding: .55rem; border: 1px solid #526541; border-radius: .7rem; color: var(--lime); font-size: 2rem; line-height: 1; font-weight: 850; font-variant-numeric: tabular-nums; }
.clock small { font-size: .75rem; color: var(--muted); display: block; margin-top: .3rem; }
.clock.urgent { color: var(--danger); border-color: #bc745c; }
.instruction { color: #c7d5ca; line-height: 1.5; margin-bottom: 1.2rem; }
.criteria { display: flex; flex-wrap: wrap; gap: .6rem; margin: .95rem 0 1.2rem; }
.criterion { min-width: 9rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .55rem; background: #102017; font-weight: 750; }
.criterion span { color: var(--muted); display: block; font-size: .82rem; font-weight: 550; margin-bottom: .18rem; }
.grid-board { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: .25rem; margin: .65rem 0 1.35rem; }
.grid-board th { font-size: .9rem; line-height: 1.2; padding: .28rem .2rem; overflow-wrap: anywhere; }
.grid-board th:first-child { text-align: left; }
.grid-board td { height: 76px; text-align: center; background: #101e15; border: 1px solid var(--line); border-radius: .55rem; padding: 0; overflow-wrap: anywhere; }
.grid-board td button { display: block; width: 100%; height: 76px; padding: .3rem; min-height: 0; color: var(--muted); background: transparent; font-size: 1.35rem; }
.grid-board td button:hover:not(:disabled), .grid-board td button[aria-pressed="true"] { color: var(--lime); background: #273b25; border-color: var(--lime); }
.grid-board td.winning { background: #354a29; border-color: var(--lime); }
.grid-board .symbol { color: var(--lime); font-size: 1.5rem; line-height: 1; display: block; font-weight: 800; }
.grid-board .symbol.circle-mark { color: #a9dbff; }
.grid-board .cell-name { display: block; padding: .18rem .2rem; font-size: .85rem; line-height: 1.15; }
.grid-board .replace { padding: .2rem .35rem; margin-top: .22rem; min-height: 29px; font-size: .75rem; }
@media (max-width: 460px) {
  .grid-board th, .grid-board .cell-name { font-size: .8rem; }
  .grid-board .replace { font-size: .68rem; padding-inline: .17rem; }
}
.lookup { flex: 1; min-width: 0; position: relative; }
#options { list-style: none; z-index: 3; background: #14271a; border: 1px solid #536e5a; border-radius: .65rem; margin: .3rem 0 0; padding: .25rem; width: 100%; position: absolute; top: 100%; max-height: min(48vh, 290px); overflow: auto; box-shadow: 0 12px 24px #05110bc2; }
#options li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .3rem .6rem; cursor: pointer; padding: .55rem .6rem; border-radius: .4rem; }
#options li:hover, #options [aria-selected=true] { background: #304734; }
#options small { color: var(--muted); font-size: .85rem; }
.chips, .actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem; align-items: center; }
.chip { display: inline-flex; align-items: center; min-height: 34px; font-size: .875rem; padding: .28rem .6rem; border: 1px solid #51684b; border-radius: .6rem; background: #233922; }
.notice, .error { margin: .85rem 0 0; line-height: 1.45; color: var(--muted); }
.error { color: var(--danger); }
.history { padding: 1.15rem 1.35rem; margin-top: 1rem; }
.history h2 { font-size: 1.1rem; margin-bottom: .65rem; }
.history ol { padding-left: 1.45rem; margin: 0; color: var(--muted); }
.history li { padding: .35rem 0; line-height: 1.45; overflow-wrap: anywhere; }
.history strong { color: var(--text); }
@media (max-width: 690px) {
  .top { flex-wrap: wrap; gap: .55rem; padding: .65rem 0; }
  .top .brand { flex-basis: 100%; }
  .lobby { grid-template-columns: 1fr; }
  .hero { min-height: 320px; }
  .pitch { width: 76%; }
}
@media (max-width: 390px) {
  .top, main { width: calc(100% - 1.25rem); }
  .top { gap: .4rem; }
  .brand { font-size: .82rem; }
  .mark { width: 1.55rem; }
  .compact { font-size: .75rem; }
  .rounds span { font-size: .75rem; }
  .action-row button { padding-inline: .6rem; }
}
