:root {
  --ink: #10253e;
  --navy: #071a2e;
  --navy-2: #0d2b48;
  --paper: #f4f8fb;
  --white: #ffffff;
  --line: #b9c9d5;
  --muted: #53697c;
  --cyan: #18c4bf;
  --cyan-deep: #087f7b;
  --gold: #f4bd50;
  --coral: #e45e57;
  --coral-deep: #a83235;
  --focus: #1769d2;
  --shadow: 0 24px 70px rgba(4, 28, 49, .14);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(11, 44, 70, .035) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(11, 44, 70, .035) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--white);
  color: var(--navy);
  box-shadow: var(--shadow);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.offline-banner {
  min-height: 48px;
  padding: 11px clamp(18px, 5vw, 72px);
  background: #fff1ca;
  border-bottom: 1px solid #dca73a;
  color: #5e4100;
  font-weight: 700;
}
.offline-banner span {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: #c47a00;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 12px clamp(18px, 5vw, 72px);
  background: var(--navy);
  color: var(--white);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  text-decoration: none;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: .01em; }
.brand small { color: #9db3c7; font-size: .72rem; letter-spacing: .11em; text-transform: uppercase; }
.brand__signal { display: grid; grid-template-columns: repeat(3, 7px); align-items: end; gap: 3px; width: 28px; height: 28px; padding: 5px; border: 1px solid rgba(255,255,255,.28); border-radius: 7px; }
.brand__signal i { display: block; background: var(--cyan); border-radius: 2px; }
.brand__signal i:nth-child(1) { height: 7px; }
.brand__signal i:nth-child(2) { height: 15px; }
.brand__signal i:nth-child(3) { height: 11px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a, .site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 10px;
  color: #d7e4ec;
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
}
.topbar nav a:hover { background: rgba(255,255,255,.1); color: var(--white); }

main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding-bottom: 72px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: clamp(28px, 7vw, 100px);
  align-items: center;
  padding: clamp(58px, 8vw, 112px) 0 clamp(42px, 6vw, 76px);
}
.eyebrow {
  margin: 0 0 9px;
  color: var(--cyan-deep);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 760px;
  margin: 0;
  color: var(--navy);
  font-family: Rockwell, "Roboto Slab", Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: .94;
  letter-spacing: -.055em;
}
.hero h1 em { color: var(--cyan-deep); font-style: normal; }
.hero__copy > p:last-child { max-width: 690px; margin: 26px 0 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.19rem); }
.signal-board {
  position: relative;
  padding: 28px;
  overflow: hidden;
  border: 1px solid #244a68;
  border-radius: 16px;
  background: var(--navy);
  box-shadow: 14px 14px 0 var(--gold);
  color: var(--white);
  transform: rotate(1.5deg);
}
.signal-board::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(255,255,255,.025) 5px); }
.signal-board > span, .signal-board small { position: relative; z-index: 1; display: block; font-family: ui-monospace, monospace; letter-spacing: .12em; }
.signal-board > span { color: #a8bccb; font-size: .72rem; }
.signal-board small { margin-top: 14px; color: var(--gold); }
.signal-board div { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-top: 22px; }
.signal-board i { aspect-ratio: .78; border: 1px solid rgba(255,255,255,.25); border-radius: 5px; background: linear-gradient(180deg, #163d5d, #0b243a); box-shadow: inset 0 0 15px rgba(24,196,191,.22); }

.global-status {
  min-height: 44px;
  margin: 0 0 18px;
  padding: 11px 15px;
  border-left: 4px solid var(--cyan);
  background: #e5f7f6;
  color: #1c4e59;
  font-size: .88rem;
  font-weight: 700;
}

.entry-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 20px; align-items: start; }
.entry-card {
  position: relative;
  padding: clamp(24px, 4vw, 44px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.94);
  box-shadow: 0 18px 50px rgba(8, 36, 58, .08);
}
.entry-card--host { border-top: 7px solid var(--cyan-deep); }
.entry-card--join { border-top: 7px solid var(--gold); }
.entry-card__number { position: absolute; right: 22px; top: 11px; color: rgba(10, 48, 76, .07); font-family: Rockwell, Georgia, serif; font-size: clamp(3rem, 7vw, 6rem); font-weight: 900; line-height: 1; pointer-events: none; }
.entry-card__heading { position: relative; max-width: 610px; }
.entry-card h2, .host-lobby h2, dialog h2 { margin: 0; color: var(--navy); font-family: Rockwell, "Roboto Slab", Georgia, serif; font-size: clamp(1.65rem, 3vw, 2.45rem); line-height: 1.08; letter-spacing: -.025em; }
.entry-card__heading > p:last-child { margin: 14px 0 24px; color: var(--muted); }

.selection-card {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border: 1px solid #a9c8c6;
  border-left: 5px solid var(--cyan-deep);
  border-radius: 12px;
  background: #f0fbfa;
}
.selection-card > span, .identity-row span, .room-expiry span, .participant-panel header span, .code-board > span { color: var(--muted); font-family: ui-monospace, monospace; font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.selection-card strong { overflow-wrap: anywhere; font-size: 1.05rem; }
.selection-card small { color: var(--muted); }
.selection-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.selection-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--cyan-deep); font-weight: 800; }

.player-access-card {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid var(--aa-line, #a9c8c6);
  border-left: 5px solid var(--cyan-deep);
  border-radius: 12px;
  background: var(--aa-surface, #f0fbfa);
  color: var(--aa-text, var(--ink));
}
.player-access-card > div:first-child { display: grid; gap: 4px; }
.player-access-card span { color: var(--aa-muted, var(--muted)); font-family: ui-monospace, monospace; font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.player-access-card strong { font-size: 1.05rem; }
.player-access-card small { color: var(--aa-muted, var(--muted)); }
.player-access-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.admission-state {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid var(--aa-line, #8fa5b5);
  border-radius: 12px;
  background: var(--aa-surface-2, #e5f7f6);
  color: var(--aa-text, var(--ink));
}
.admission-state__signal { width: 14px; height: 14px; border: 3px solid var(--cyan-deep); border-top-color: transparent; border-radius: 50%; animation: admission-spin 900ms linear infinite; }
.admission-state strong { display: block; }
.admission-state p { margin: 4px 0 0; color: var(--aa-muted, var(--muted)); font-size: .84rem; }
.admission-state .inline-error { grid-column: 1 / -1; margin-top: 0; }
.entry-grid--admission { grid-template-columns: minmax(0, 760px); justify-content: center; }
.entry-grid--admission > .entry-card:first-child,
.entry-grid--admission .entry-card--join > .entry-card__number,
.entry-grid--admission .entry-card--join > .entry-card__heading,
.entry-grid--admission .entry-card--join > .player-access-card,
.entry-grid--admission .entry-card--join > #joinForm { display: none; }
.participant-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.participant-actions .button { min-width: 92px; }
@keyframes admission-spin { to { transform: rotate(360deg); } }

.identity-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 20px 0; padding: 14px 0; border-top: 1px solid #d8e2e8; border-bottom: 1px solid #d8e2e8; }
.identity-row strong { display: block; margin-top: 2px; }

.game-picker {
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}
.game-picker legend { padding: 0; font-size: .9rem; font-weight: 900; }
.game-picker > p { margin: 4px 0 12px; color: var(--muted); font-size: .76rem; }
.game-picker__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.game-choice { position: relative; min-width: 0; }
.game-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.game-choice span {
  display: grid;
  align-content: start;
  min-height: 82px;
  padding: 11px 12px;
  border: 1px solid #8fa5b5;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}
.game-choice strong { font-size: .82rem; line-height: 1.2; }
.game-choice small { margin-top: 4px; color: var(--muted); font-size: .67rem; line-height: 1.28; }
.game-choice input:checked + span { border: 2px solid var(--cyan-deep); background: #e5f7f6; box-shadow: 0 0 0 2px rgba(8,127,123,.14); }
.game-choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.game-choice input:disabled + span { cursor: not-allowed; opacity: .52; }

.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field, .code-field { display: grid; gap: 6px; font-weight: 800; }
.field span, .code-field > span { font-size: .83rem; }
.field small, #codeHelp { color: var(--muted); font-size: .75rem; font-weight: 500; }
input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #8fa5b5;
  border-radius: 9px;
  background: var(--white);
  color: var(--ink);
  padding: 10px 12px;
}
input[aria-invalid="true"] { border-color: var(--coral-deep); box-shadow: 0 0 0 2px rgba(168,50,53,.13); }
#roomCode {
  min-height: 76px;
  border: 2px solid #6e8496;
  border-radius: 12px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.7rem, 5vw, 2.45rem);
  font-weight: 900;
  letter-spacing: .23em;
  text-align: center;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: .48; }
.button--wide { width: 100%; margin-top: 18px; min-height: 52px; }
.button--primary { background: var(--navy-2); color: var(--white); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.button--accent { background: var(--gold); border-color: #bd8424; color: #3f2a00; box-shadow: inset 0 -3px 0 rgba(109,66,0,.15); }
.button--quiet { background: var(--white); border-color: #91a7b7; color: var(--navy); }
.button--danger { background: #fff1ef; border-color: #d36861; color: #8f292c; }
.button:not(:disabled):hover { filter: brightness(.96); transform: translateY(-1px); }

.privacy-note { display: flex; gap: 11px; margin-top: 24px; padding: 16px; border-top: 1px solid #dbe3e8; color: var(--muted); }
.privacy-note > span { color: var(--cyan-deep); font-size: 1.3rem; }
.privacy-note p { margin: 0; }
.inline-error { margin-top: 12px; padding: 12px 14px; border: 1px solid #df8881; border-radius: 9px; background: #fff1ef; color: #852d31; font-weight: 700; }

.host-lobby { margin-top: 24px; padding: clamp(24px, 5vw, 48px); border: 1px solid #24445f; border-radius: var(--radius); background: var(--navy); box-shadow: var(--shadow); color: #e6f0f5; }
.host-lobby h2 { color: var(--white); }
.host-lobby__head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.host-lobby__head > div:first-child > p:last-child { max-width: 700px; margin: 10px 0 0; color: #a9bfce; }
.room-expiry { min-width: 150px; text-align: right; }
.room-expiry span { color: #89a6ba; }
.room-expiry strong { display: block; color: var(--gold); }
.lobby-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr); gap: 18px; }
.code-board, .participant-panel { border: 1px solid #365973; border-radius: 16px; background: #0c2942; }
.code-board { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; }
.code-board > span { color: #9db5c5; }
.code-board__value { margin: 15px 0 10px; color: var(--gold); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: clamp(2.3rem, 6vw, 4.4rem); font-weight: 900; letter-spacing: .13em; line-height: 1; }
.code-board p { max-width: 390px; margin: 4px 0 20px; color: #acc0ce; font-size: .84rem; }
.join-qr { display: grid; width: min(280px, 100%); justify-items: center; gap: 10px; margin: 0 0 18px; }
.join-qr__graphic { width: min(220px, 72vw); padding: 10px; border: 1px solid #55748b; border-radius: 14px; background: #F5F0E8; }
.join-qr__graphic svg { display: block; width: 100%; height: auto; }
.join-qr .button { width: 100%; border-color: #55748b; background: #153853; color: #F5F0E8; }
.join-qr small { max-width: 34ch; color: #acc0ce; font-size: .75rem; }
.participant-panel { padding: 22px; }
.participant-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 15px; border-bottom: 1px solid #365973; }
.participant-panel h3 { margin: 2px 0 0; color: var(--white); font-size: 1.1rem; }
.participant-panel .button--quiet, .host-lobby .lobby-actions .button--quiet { border-color: #55748b; background: #153853; color: var(--white); }
.panel-status { min-height: 26px; margin: 14px 0; color: #a9bfce; font-size: .83rem; }
.participant-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.participant-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 58px; padding: 8px 10px 8px 14px; border: 1px solid #345772; border-radius: 10px; background: #102f49; }
.participant-copy { min-width: 0; }
.participant-copy strong, .participant-copy small { display: block; }
.participant-copy strong { overflow: hidden; color: var(--white); text-overflow: ellipsis; white-space: nowrap; }
.participant-copy small { color: #9eb4c3; text-transform: capitalize; }
.participant-list .button { flex: 0 0 auto; min-width: 92px; }
.participant-empty { padding: 26px 12px; color: #a9bfce; text-align: center; }
.pagination { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.lobby-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; padding-top: 22px; border-top: 1px solid #365973; }

dialog { width: min(560px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.32); color: var(--ink); }
dialog::backdrop { background: rgba(3, 18, 31, .72); backdrop-filter: blur(4px); }
.dialog__head { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 26px 26px 0; }
dialog > p, dialog > .inline-error { margin-left: 26px; margin-right: 26px; }
dialog > p { color: var(--muted); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 26px 26px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; padding: 0; border: 1px solid #a6b6c2; border-radius: 50%; background: var(--white); color: var(--ink); cursor: pointer; font-size: 1.65rem; }

.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 80px; padding: 14px clamp(18px, 5vw, 72px); background: #061523; color: #9fb3c2; font-size: .82rem; }
.site-footer > span:last-child { display: flex; flex-wrap: wrap; gap: 2px; }
.site-footer a { padding: 0 10px; }
.noscript { padding: 20px; background: #fff1ca; color: #5e4100; text-align: center; font-weight: 800; }

@media (max-width: 900px) {
  .hero, .entry-grid, .lobby-grid { grid-template-columns: 1fr; }
  .signal-board { width: min(420px, calc(100% - 16px)); transform: none; }
  .host-lobby__head { align-items: start; }
  .room-expiry { text-align: left; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 6px; }
  .topbar nav { width: 100%; }
  .topbar nav a { flex: 1 1 auto; justify-content: center; padding: 0 8px; }
  main { width: min(100% - 24px, 1240px); }
  .hero { padding-top: 42px; }
  .hero h1 { font-size: clamp(2.45rem, 14vw, 4rem); }
  .entry-card, .host-lobby { border-radius: 16px; }
  .entry-card__number { font-size: 3.8rem; }
  .form-pair { grid-template-columns: 1fr; }
  .game-picker__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-access-actions, .admission-state { grid-template-columns: 1fr; }
  .player-access-actions .button, .admission-state .button { width: 100%; }
  .admission-state__signal { margin-bottom: -4px; }
  .participant-actions { width: 100%; }
  .participant-actions .button { flex: 1 1 120px; }
  .identity-row, .host-lobby__head, .participant-panel > header, .site-footer { align-items: stretch; flex-direction: column; }
  .identity-row .button, .participant-panel > header .button { width: 100%; }
  .code-board__value { letter-spacing: .08em; }
  .lobby-actions, .dialog__actions { flex-direction: column; }
  .lobby-actions .button, .dialog__actions .button { width: 100%; }
  .site-footer > span:last-child { width: 100%; }
  .site-footer a { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .button:not(:disabled):hover { transform: none; }
  .admission-state__signal { animation: none; border-top-color: var(--cyan-deep); }
}

@media print {
  .topbar nav, .offline-banner, .button, .entry-grid, dialog, .site-footer { display: none !important; }
  body, .host-lobby, .code-board, .participant-panel { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .host-lobby { border: 1px solid #000; }
  .host-lobby * { color: #000 !important; }
}
