/* Fairway Live — components. Big targets, high contrast, still by default. */

/* The [hidden] attribute must always win, even over components that set their
   own display (.btn, .pill, .notice, flex/grid rows). Without this, toggling
   `el.hidden = true` on such elements does nothing. */
[hidden] { display: none !important; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--card-hi);
  background: var(--pine);
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: var(--fescue); }
.btn.ghost { background: transparent; color: var(--pine); border: 2px solid var(--sand); }
.btn.live { background: var(--flag); }
.btn.big { min-height: 76px; font-size: 24px; letter-spacing: 0.01em; }

/* --- Inputs ---------------------------------------------------------------- */
label { display: block; font-weight: 600; margin: 0 0 var(--space-1); color: var(--graphite); }
.field { margin-bottom: var(--space-3); }
input[type="text"], input[type="number"], select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  font-size: 18px;
  font-family: var(--font-body);
  color: var(--graphite);
  background: var(--card-hi);
  border: 2px solid var(--sand);
  border-radius: var(--radius);
}
input:focus, select:focus { border-color: var(--fescue); outline: none; }
.code-input { font-family: var(--font-mono); letter-spacing: 0.35em; text-transform: uppercase; font-size: 24px; text-align: center; }

/* --- Cards / header -------------------------------------------------------- */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--sand);
  margin-bottom: var(--space-3);
}
.masthead h1 { font-size: 28px; color: var(--pine); letter-spacing: 0.02em; }
.masthead .clock { font-family: var(--font-mono); color: var(--graphite-2); font-size: 15px; }

.card {
  background: var(--card-hi);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

.hint { color: var(--graphite-2); font-size: 15px; margin: var(--space-2) 0; }

/* Prominent code display (join code / host code). */
.codebox {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 2px solid var(--sand); border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}
.codebox-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--graphite-2); }
.codebox-val { font-size: 30px; font-weight: 500; letter-spacing: 0.2em; color: var(--pine); }
.err { color: var(--flag); font-weight: 600; min-height: 1.2em; margin: var(--space-2) 0; }

/* --- The Grounds (scorecard directory) ------------------------------------- */
.scorecard { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-1);
  border-bottom: 1px solid var(--sand);   /* sand hairline rule, like a real card */
  min-height: var(--tap);
  cursor: pointer;
}
.row.off { cursor: default; opacity: 0.72; }
.row .flagcol { width: 30px; display: flex; justify-content: center; }
.row .slot { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--pine); }
.row .title { grid-column: 2; color: var(--graphite-2); font-size: 15px; }
.row .status { justify-self: end; text-align: right; }
.row .hole { grid-column: 3; justify-self: end; font-family: var(--font-mono); font-size: 14px; color: var(--graphite-2); }
.badge-live { color: var(--flag); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 6px; }
.badge-off { color: var(--fescue); font-size: 14px; font-weight: 600; }
.watching { font-family: var(--font-mono); font-size: 14px; color: var(--graphite-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--flag); display: inline-block; }

/* --- Flagstick (the one piece of motion) ----------------------------------- */
.flag-svg { width: 22px; height: 28px; display: block; }
.flag-svg .cloth { transform-origin: left center; animation: flutter 2s ease-in-out infinite; }
@keyframes flutter {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  50%      { transform: skewY(-6deg) scaleX(0.94); }
}
@media (prefers-reduced-motion: reduce) {
  .flag-svg .cloth { animation: none; }
}

/* --- Watch screen ---------------------------------------------------------- */
.stage { position: fixed; inset: 0; background: #000; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.chrome-tl { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 12px; }
.chrome-tr { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px; display: flex; gap: 8px; align-items: center; }
.pill {
  background: rgba(13, 34, 28, 0.72);
  color: var(--card-hi);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  backdrop-filter: blur(6px);
}
.pill .mono { font-size: 14px; }
.iconbtn {
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  border: none;
  background: rgba(13, 34, 28, 0.72);
  color: var(--card-hi);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

/* Bottom rail of other live groups. */
.rail {
  position: absolute; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  display: flex; gap: 10px; overflow-x: auto;
  padding: 10px 12px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.rail::-webkit-scrollbar { display: none; }
.railcard {
  flex: 0 0 auto; min-width: 132px; min-height: 60px;
  scroll-snap-align: start;
  background: rgba(13, 34, 28, 0.78);
  color: var(--card-hi);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; backdrop-filter: blur(6px);
}
.railcard.active { border-color: var(--flag); }
.railcard .rl-slot { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.railcard .rl-meta { font-family: var(--font-mono); font-size: 12px; opacity: 0.85; }

.chrome-hidden .overlay { opacity: 0; transition: opacity 0.25s ease; }
.overlay { transition: opacity 0.25s ease; }

/* --- Broadcast screen ------------------------------------------------------ */
.preview-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; aspect-ratio: 16 / 9; margin-bottom: var(--space-3); }
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.hole-stepper { display: flex; align-items: center; gap: var(--space-3); }
.hole-stepper button { width: var(--tap); height: var(--tap); font-size: 26px; border-radius: var(--radius); border: 2px solid var(--sand); background: var(--card-hi); font-family: var(--font-mono); cursor: pointer; }
.hole-stepper .hole-val { font-family: var(--font-mono); font-size: 30px; min-width: 2ch; text-align: center; }

.notice {
  background: var(--pine);
  color: var(--card-hi);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: var(--space-3);
  display: block;   /* inline <strong> must flow, not become flex columns */
}
.notice.warn { background: var(--flag); }

.live-stats { display: flex; gap: var(--space-4); align-items: center; margin: var(--space-3) 0; }
.stat { text-align: center; }
.stat .n { font-family: var(--font-mono); font-size: 26px; display: block; }
.stat .l { font-size: 12px; color: var(--graphite-2); text-transform: uppercase; letter-spacing: 0.05em; }
.quality { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.quality .q-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--fescue); }
.quality.poor .q-dot { background: var(--flag); }
.quality.good .q-dot { background: #4c9a5b; }

/* Toast / connection banners. */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: var(--graphite); color: var(--card-hi);
  padding: 12px 18px; border-radius: 999px;
  font-size: 15px; z-index: 50; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
.toast.warn { background: var(--flag); }

.row-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.slot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.slot-grid .slot-btn { min-height: var(--tap); border: 2px solid var(--sand); background: var(--card-hi); border-radius: var(--radius); font-family: var(--font-display); font-weight: 600; font-size: 17px; cursor: pointer; }
.slot-grid .slot-btn.sel { background: var(--pine); color: var(--card-hi); border-color: var(--pine); }
.slot-grid .slot-btn.taken { opacity: 0.4; cursor: not-allowed; }

.center { text-align: center; }
.stack > * + * { margin-top: var(--space-3); }
.muted { color: var(--graphite-2); }

/* --- Scoreboard: the two-team total banner --------------------------------- */
.teamboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-2);
  background: var(--pine);
  color: var(--card-hi);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.teamboard .tb-team { display: flex; flex-direction: column; }
.teamboard .tb-team.b { text-align: right; align-items: flex-end; }
.teamboard .tb-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.teamboard .tb-pts { font-family: var(--font-mono); font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.teamboard .tb-dash { font-family: var(--font-mono); font-size: 24px; opacity: 0.5; }
.teamboard .tb-lead .tb-pts { color: #ffd9a0; }  /* subtle highlight on the leader */
.tb-caption { text-align: center; font-size: 12px; color: var(--graphite-2); margin: -6px 0 var(--space-3); letter-spacing: 0.03em; text-transform: uppercase; }

/* Per-session breakdown under the total banner. */
.sessboard { margin-bottom: var(--space-3); }
.sess-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--sand);
}
.sess-row.active { background: rgba(122, 139, 92, 0.12); border-radius: var(--radius); }
.sess-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--graphite); }
.sess-now { color: var(--fescue); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.sess-score { font-size: 16px; color: var(--pine); }
.sess-worth { font-size: 13px; color: var(--graphite-2); }

/* Per-group match status on the scorecard rows. */
.row .match { grid-column: 2; }
.match-status { font-family: var(--font-mono); font-size: 14px; color: var(--graphite); }
.match-status .lead-a { color: var(--pine); font-weight: 500; }
.match-status .lead-b { color: var(--fescue); font-weight: 600; }
.match-status .as { color: var(--graphite-2); }
.match-status .final-tag { color: var(--graphite-2); }

/* Watch-screen score pill (sits under the title pill). */
.chrome-tl .pill.pairpill { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; max-width: 78vw; }
.pairpill .pair-side { display: inline-flex; gap: 6px; align-items: baseline; }
.pairpill .pair-team { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.75; }
.pairpill .pair-vs { opacity: 0.6; }
.chrome-tl .pill.score { margin-top: 8px; display: inline-flex; gap: 8px; align-items: center; }
.chrome-tl .pill.score .mono { font-size: 14px; }
.mini-teams { display: flex; gap: 6px; align-items: center; font-family: var(--font-mono); font-size: 13px; }

/* --- Broadcast: score-this-hole entry -------------------------------------- */
.score-entry { background: var(--card-hi); border: 2px solid var(--sand); border-radius: var(--radius-lg); padding: var(--space-3); }
.score-entry .se-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--space-2); }
.score-entry .se-title { font-family: var(--font-display); font-weight: 600; }
.score-entry .se-status { font-family: var(--font-mono); font-size: 15px; color: var(--pine); }
.score-btns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.score-btns .halve { grid-column: 1 / -1; }
.score-btn {
  min-height: var(--tap);
  border: 2px solid var(--sand);
  background: var(--card);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--graphite);
  cursor: pointer;
  padding: 0 var(--space-2);
}
.score-btn.team-a { border-color: var(--pine); }
.score-btn.team-b { border-color: var(--fescue); }
.score-btn.picked { background: var(--pine); color: var(--card-hi); border-color: var(--pine); }
.score-btn.team-b.picked { background: var(--fescue); border-color: var(--fescue); }
.score-btn.halve.picked { background: var(--graphite); color: var(--card-hi); border-color: var(--graphite); }
.se-hint { font-size: 13px; color: var(--graphite-2); margin-top: var(--space-2); }

/* Host scoreboard mini-grid. */
.host-match { padding: var(--space-3) 0; border-bottom: 1px solid var(--sand); }
.host-match .hm-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.host-match .hm-slot { font-family: var(--font-display); font-weight: 700; color: var(--pine); }
.host-match .hm-status { font-family: var(--font-mono); font-size: 14px; }

/* Streaming on/off toggle + final. */
.hm-stream { display: flex; gap: var(--space-2); margin: var(--space-2) 0; flex-wrap: wrap; }
.hm-stream .toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 var(--space-3);
  border-radius: 999px; border: 2px solid var(--sand);
  background: var(--card); font-family: var(--font-body); font-weight: 600; font-size: 15px;
  color: var(--graphite); cursor: pointer;
}
.hm-stream .toggle .dot2 { width: 10px; height: 10px; border-radius: 50%; background: var(--fescue); }
.hm-stream .toggle.on { border-color: var(--flag); color: var(--flag); }
.hm-stream .toggle.on .dot2 { background: var(--flag); }
.hm-stream .hm-final { width: auto; min-height: 48px; padding: 0 var(--space-3); font-size: 15px; }

/* 18-hole strip. */
.hole-strip { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin: var(--space-2) 0; }
.hcell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1; min-height: 40px; border: 1px solid var(--sand); border-radius: 8px;
  background: var(--card); cursor: pointer; padding: 2px;
}
.hcell .hn { font-family: var(--font-mono); font-size: 10px; color: var(--graphite-2); line-height: 1; }
.hcell .hr { font-family: var(--font-mono); font-size: 14px; font-weight: 500; line-height: 1.1; }
.hcell.a { background: var(--pine); border-color: var(--pine); }
.hcell.a .hn, .hcell.a .hr { color: var(--card-hi); }
.hcell.b { background: var(--fescue); border-color: var(--fescue); }
.hcell.b .hn, .hcell.b .hr { color: var(--card-hi); }
.hcell.h { background: var(--sand); }
.hcell.cur { outline: 3px solid var(--flag); outline-offset: 1px; }

.hm-entry { margin-top: var(--space-2); }
.hm-entry-label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
