/* Layout: a single stacked column for setup; in play, a two-pane board
   (call it | hands + log) that collapses to bottom tabs on a phone.
   One deliberate look: a bar at night with the game on, so dark only. */
:root {
  --bg: #0e1116;
  --surface: #161a22;
  --surface-2: #1e232d;
  --surface-3: #262c38;
  --line: #2b3240;
  --fg: #f4efe4;
  --muted: #9aa3b2;
  --accent: #f6c343;        /* penalty flag */
  --accent-ink: #171206;
  --turf: #3aa655;
  --danger: #d33b3b;
  --sev-low: #e3cf85;
  --sev-mid: #f0a35a;
  --sev-high: #ea6a3d;
  --sev-max: #d33b3b;
  --font-display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 8vw, 4.5rem); text-transform: uppercase; letter-spacing: 0.01em; }
h2 { font-size: 1.75rem; text-transform: uppercase; letter-spacing: 0.02em; }
h3 { font-size: 1.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
p { margin: 0; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.85rem; color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 0.5em; }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 60ch; }
.at { font-family: var(--font-display); color: var(--muted); font-weight: 600; font-size: 1.1em; }

button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius); padding: 0.55em 0.95em; transition: background 0.12s, border-color 0.12s, transform 0.06s; }
button:hover { background: var(--surface-3); border-color: #3a4252; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; font-size: 1.05rem; }
button.primary:hover { background: #ffd163; }
button.big { padding: 0.8em 1.6em; font-size: 1.3rem; }
input[type="search"], input[type="text"], input:not([type]) { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6em 0.85em; width: 100%; min-width: 0; }
input::placeholder { color: #6c7584; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* Team chip: abbreviation on the club's primary color. */
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 2.6em; padding: 0.15em 0.45em; border-radius: 6px; background: var(--team, var(--surface-3)); color: var(--on, var(--fg)); font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.04em; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.chip.tv { background: var(--surface-3); color: var(--muted); }

/* ---------- gate / summary ---------- */
.gate, .summary { max-width: 42rem; margin: 0 auto; padding: 12vh var(--gutter) 4rem; display: grid; gap: 1.25rem; }
.gate h1 { font-size: clamp(2.4rem, 7vw, 3.8rem); }

/* ---------- setup ---------- */
.screen-setup { display: block; }
.hero { max-width: 64rem; margin: 0 auto; padding: 3.5rem var(--gutter) 1.5rem; display: grid; gap: 0.75rem; }
.hero h1 { color: var(--fg); }
.hero h1::after { content: ""; display: block; width: 4.5rem; height: 5px; background: var(--accent); margin-top: 0.6rem; }
.banner { max-width: 64rem; margin: 0 auto 1rem; padding: 0.75rem var(--gutter); display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner > span { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem; flex: 1 1 18rem; }
.step { max-width: 64rem; margin: 0 auto; padding: 1.75rem var(--gutter); display: grid; gap: 1rem; border-top: 1px solid var(--line); }
.step h2 { display: flex; align-items: center; gap: 0.6rem; }
.step h2 .n { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 0.75em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; width: fit-content; max-width: 100%; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 0.6em 1.1em; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--fg); color: var(--bg); font-weight: 600; }
.slate { display: grid; gap: 0.6rem; }
.weeknav { display: flex; align-items: center; gap: 0.6rem; }
.weeknav h4 { color: var(--fg); font-size: 0.95rem; min-width: 9ch; text-align: center; }
.weeknav button { padding: 0.3em 0.75em; font-size: 1.1rem; line-height: 1; }
.weeknav .linkish { font-size: 0.85rem; padding: 0.35em 0.7em; color: var(--muted); }
.slate-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: 0.5rem; }
.slate-game { display: grid; gap: 0.3rem; text-align: left; padding: 0.55em 0.7em; background: var(--surface); min-width: 0; }
.slate-game.on { border-color: var(--accent); background: var(--surface-2); }
.slate-teams { display: flex; align-items: center; gap: 0.4em; }
.slate-game small { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nextup { display: grid; gap: 0.4rem; justify-items: start; padding: 0.8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.nextup-line { font-size: 1.05rem; }
.slots { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 0.75rem; }
.slot { display: grid; gap: 0.2rem; text-align: left; padding: 0.7em 0.9em; min-width: 0; }
.slot small { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; }
.slot-pick { display: flex; align-items: center; gap: 0.5em; font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; min-height: 1.6em; }
.slot.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.slots .at { align-self: center; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 1rem 1.25rem; }
.division { display: grid; gap: 0.35rem; align-content: start; }
.team { display: flex; align-items: center; gap: 0.6em; text-align: left; padding: 0.45em 0.6em; background: var(--surface); position: relative; }
.team.picked { border-color: var(--accent); background: var(--surface-2); }
.team-name { font-weight: 500; }
.slot-tag { margin-left: auto; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; }
.players { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 0.4em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0.3em 0.4em 0.3em 0.9em; font-weight: 500; }
.pill button { border: 0; background: transparent; padding: 0 0.45em; line-height: 1; font-size: 1.1em; color: var(--muted); border-radius: 50%; }
.pill button:hover { color: var(--fg); background: var(--surface-3); }
.add { display: flex; gap: 0.5rem; max-width: 26rem; }
.intensity { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; }
.opt { display: grid; gap: 0.25rem; text-align: left; padding: 0.9em 1em; background: var(--surface); }
.opt b { font-family: var(--font-display); font-size: 1.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
.opt span { color: var(--muted); font-size: 0.95rem; }
.opt.on { border-color: var(--accent); background: var(--surface-2); }
.toggle { display: flex; gap: 0.7rem; align-items: flex-start; color: var(--muted); max-width: 48rem; cursor: pointer; }
.toggle input { margin-top: 0.3em; accent-color: var(--accent); width: 1.1em; height: 1.1em; flex: none; }
.start { max-width: 64rem; margin: 0 auto; padding: 1rem var(--gutter) 2rem; display: grid; gap: 0.6rem; justify-items: start; border-top: 1px solid var(--line); }
.hint { color: var(--muted); }
.foot { max-width: 64rem; margin: 0 auto; padding: 1rem var(--gutter) 3rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- game ---------- */
.gamebar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 0.6rem var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.matchup { display: flex; align-items: center; gap: 0.45em; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; text-transform: uppercase; min-width: 0; }
.mname { white-space: nowrap; }
.actions { display: flex; gap: 0.4rem; }
.actions button { padding: 0.45em 0.8em; font-size: 0.95rem; }
.game { display: grid; grid-template-columns: minmax(0, 30rem) minmax(0, 1fr); gap: 0 1.5rem; padding: 1rem var(--gutter) 5rem; max-width: 96rem; margin: 0 auto; align-items: start; }
.panel { min-width: 0; }
.panel h2 { display: flex; align-items: baseline; gap: 0.6em; flex-wrap: wrap; margin-bottom: 0.75rem; }
.panel h2 small { font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-size: 0.85rem; font-weight: 400; }
.panel-call { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: calc(3.6rem + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 4.5rem); overflow-y: auto; scrollbar-width: thin; padding-right: 0.25rem; }
.panel-hands { grid-column: 2; }
.panel-log { grid-column: 2; margin-top: 1.5rem; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.85rem; margin-bottom: 0.75rem; display: grid; gap: 0.35rem; }
.group h3 { color: var(--accent); font-size: 0.85rem; letter-spacing: 0.12em; margin-bottom: 0.2rem; }
.evrow { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem 4.2rem; gap: 0.4rem; align-items: center; }
.evname { font-weight: 500; line-height: 1.2; min-width: 0; display: grid; }
.evname small { font-size: 0.75rem; line-height: 1.25; }
.sidebtn, .evbtn { position: relative; padding: 0.5em 0.4em; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.05em; font-size: 1rem; }
.sidebtn { background: var(--team); color: var(--on); border-color: transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); opacity: 0.55; }
.sidebtn:hover { background: var(--team); filter: brightness(1.15); opacity: 0.8; }
.sidebtn.live, .evbtn.live { opacity: 1; }
.evbtn { opacity: 0.6; text-align: left; font-size: 0.95rem; line-height: 1.15; }
.evbtn.live { border-color: #3a4252; background: var(--surface-3); }
.evgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.4rem; margin-top: 0.2rem; }
.held { position: absolute; top: -0.45rem; right: -0.35rem; min-width: 1.35rem; height: 1.35rem; padding: 0 0.35rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; display: grid; place-items: center; font-family: var(--font-body); font-weight: 700; box-shadow: 0 0 0 2px var(--surface); }

.player { margin-bottom: 1.25rem; }
.player header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.player .stat { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.player .stat b { color: var(--fg); font-size: 1.05rem; }
.hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
.card { aspect-ratio: 5 / 7; border-radius: 10px; background: linear-gradient(160deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; min-width: 0; box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.3em; padding: 0.45rem 0.5rem 0; }
.card-top small { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card-title { padding: 0.35rem 0.55rem; font-family: var(--font-display); font-weight: 700; font-size: clamp(0.95rem, 1.4vw, 1.3rem); line-height: 1.05; text-transform: uppercase; align-self: center; overflow-wrap: anywhere; }
.card-drink { padding: 0.5rem 0.55rem; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: clamp(0.85rem, 1.2vw, 1.05rem); line-height: 1.1; color: #171206; background: var(--band, var(--sev-mid)); }
.band-low { --band: var(--sev-low); }
.band-mid { --band: var(--sev-mid); }
.band-high { --band: var(--sev-high); }
.band-max { --band: var(--sev-max); }
.band-max .card-drink, .band-high .card-drink { color: #fff6ef; }
.card.fresh { animation: deal 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; box-shadow: 0 0 0 2px var(--accent), 0 6px 16px rgba(0,0,0,0.25); }
@keyframes deal { from { transform: translateY(-12px) rotate(-3deg); opacity: 0; } to { transform: none; opacity: 1; } }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.log li { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0 0.6rem; padding: 0.55rem 0.7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.log .n { color: var(--muted); font-variant-numeric: tabular-nums; grid-row: 1 / span 2; }
.log .who { color: var(--muted); font-size: 0.9rem; }

.tabs { display: none; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(6, 8, 12, 0.72); display: grid; place-items: end center; padding: 1rem var(--gutter) calc(1rem + env(safe-area-inset-bottom, 0px)); }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; width: min(100%, 34rem); display: grid; gap: 1rem; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.5); animation: rise 0.25s ease-out both; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.result { border-top: 8px solid var(--band, var(--line)); }
.result.band-none { --band: var(--line); }
.result h2 { font-size: clamp(2rem, 7vw, 3rem); }
.drinkers { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; font-size: 1.2rem; }
.drinkers li { padding: 0.6rem 0.8rem; background: var(--surface-2); border-radius: 8px; }
.drinkers b { font-family: var(--font-display); text-transform: uppercase; font-size: 1.2em; margin-right: 0.3em; }
.nobody { font-size: 1.15rem; color: var(--muted); }
.rules { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.5rem; color: var(--fg); }
.standings { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings th, .standings td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); }
.standings th { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--muted); }
.standings tbody tr:first-child td { color: var(--accent); font-weight: 600; }

/* Shown on every host except production (js/env.js). Never blocks a tap. */
.dev-flag { position: fixed; right: 0.75rem; bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)); z-index: 50; pointer-events: none; padding: 0.3em 0.7em; border-radius: 6px; background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, #e0ab24 8px 16px); color: var(--accent-ink); font: 700 0.75rem/1.2 var(--font-body); letter-spacing: 0.06em; box-shadow: 0 4px 12px rgba(0,0,0,0.35); max-width: calc(100vw - 1.5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .dev-flag { top: calc(0.85rem + env(safe-area-inset-top, 0px)); bottom: auto; }
  .dev-host { display: none; }
  .game { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
  .panel-call, .panel-hands, .panel-log { grid-column: 1; grid-row: auto; position: static; max-height: none; overflow: visible; margin-top: 0; padding-right: 0; }
  .panel { display: none; }
  .tab-call .panel-call, .tab-hands .panel-hands, .tab-log .panel-log { display: block; }
  .tabs { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom, 0px)); gap: 0.3rem; }
  .tabs button { border: 0; background: transparent; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; padding: 0.65em 0.4em; }
  .tabs button.on { background: var(--accent); color: var(--accent-ink); }
  .hand { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-title { font-size: 1rem; }
  .card-drink { font-size: 0.85rem; }
  .matchup { font-size: 1.15rem; }
  .mname { display: none; }
}
@media (max-width: 560px) {
  .slots { grid-template-columns: 1fr; }
  .slots .at { display: none; }
  .evrow { grid-template-columns: minmax(0, 1fr) 3.6rem 3.6rem; }
  .hand { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hand .card { aspect-ratio: 5 / 6; }
  .hero { padding-top: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .card.fresh, .sheet { animation: none; }
  button { transition: none; }
}
