/* v1.1.0 */
/* =============================================================
   IDSport SGS — Single Goal Sports Scoreboard
   ============================================================= */

/* -------- Fonts -------- */
@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@700;800;900&family=Figtree:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

/* -------- Design tokens -------- */
:root {
  --bg:           #0a0b0d;
  --bg-elev-1:    #14161a;
  --bg-elev-2:    #1c1f25;
  --bg-elev-3:    #252932;
  --border:       #2b2f39;
  --border-soft:  #1f222a;

  --text:         #ececee;
  --text-dim:     #9098a5;
  --text-muted:   #5c6470;

  --accent:       #4a5bb8;        /* brand blue */
  --accent-hi:    #6275d8;
  --positive:     #1fb86b;
  --positive-hi:  #27d47e;
  --negative:     #e24e4e;
  --negative-hi:  #ff6161;
  --warning:      #e8a838;
  --danger:       #ff4d4d;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-1: 0 1px 0 rgba(255,255,255,.04) inset, 0 4px 16px rgba(0,0,0,.35);
  --shadow-2: 0 12px 40px rgba(0,0,0,.55);

  --font-display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --font-ui:      'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* -------- Reset / base -------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse 1200px 600px at 50% -100px, rgba(74,91,184,0.12), transparent 60%),
    radial-gradient(ellipse 900px 500px at 100% 100%, rgba(31,184,107,0.05), transparent 60%),
    var(--bg);
  min-height: 100dvh;
}

button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
input[type=color] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  /* 3-column grid puts court name dead centre regardless of the widths
     of the brand (left) and settings cog (right). */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  background: linear-gradient(to bottom, rgba(10,11,13,.95), rgba(10,11,13,.6));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 120;   /* must be > .idle-overlay (100) so the settings menu,
                     which lives inside this stacking context, stays on top */
  border-bottom: 1px solid var(--border-soft);
}
.topbar__brand { justify-self: start;  grid-column: 1; }
.topbar__meta  { justify-self: center; text-align: center; grid-column: 2; }
.topbar > .settings { justify-self: end; grid-column: 3; }

.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.topbar__brand img { height: 22px; }

.topbar__meta {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
}
.topbar__meta strong { color: var(--text); font-weight: 600; }

/* Settings cog */
.settings {
  position: relative;
  display: inline-flex;
}
.settings__btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.settings__btn:hover { background: var(--bg-elev-2); color: var(--text); }

.settings__menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px;
  padding: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  display: none;
  z-index: 110;   /* above .idle-overlay (z-index:100) so the dropdown
                     stays visible / clickable on the "No Active Game" screen */
}
.settings__menu.is-open { display: block; }

.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
  text-align: left;
  transition: background .12s;
}
.menu-item:hover { background: var(--bg-elev-3); }
.menu-item--danger { color: var(--danger); }
.menu-item--danger:hover { background: rgba(255,77,77,.1); }
.menu-item .icon { width: 18px; height: 18px; flex: none; opacity: .85; }

.settings__version {
  margin-top: 8px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: .04em;
  user-select: none;
}

/* ============================================================
   Main scoreboard layout
   ============================================================ */
.board {
  padding: 64px 16px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.board__cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Score card */
.score-card {
  position: relative;
  background: var(--bg-elev-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: border-color .25s;
}

.score-card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 6px;
  gap: 8px;
}

.score-card__team {
  flex: 1; min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(13px, 2.2vw, 32px);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

/* ── Custom team-colour control: trigger button + swatch menu + spectrum ── */
.color-trigger {
  flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg-elev-3);
  color: var(--text);
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s;
}
.color-trigger:hover { border-color: var(--text-dim); }
.color-trigger__sw {
  width: 16px; height: 16px; border-radius: 4px; flex: none;
  border: 1px solid rgba(255,255,255,0.25);
}
.color-trigger__sw.is-empty {
  background: repeating-linear-gradient(45deg, #2b2f39 0 5px, #1c1f25 5px 10px) !important;
}
.color-trigger__chev { color: var(--text-dim); font-size: .8em; }

/* Swatch menu — centred sheet with a dark backdrop. */
.color-menu {
  border: none; padding: 0; border-radius: 16px;
  background: var(--bg-elev-1); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  width: min(92vw, 320px);
}
.color-menu::backdrop { background: rgba(0,0,0,.6); }
.color-menu__grid { display: flex; flex-direction: column; padding: 8px; }
.color-menu__item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: none; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.color-menu__item:hover    { background: var(--bg-elev-3); }
.color-menu__item.is-active { background: var(--bg-elev-2); }
.color-menu__item--custom   { border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; margin-top: 4px; }
.color-menu__sw {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  border: 1px solid rgba(255,255,255,0.25);
}
.color-menu__sw.is-empty {
  background: repeating-linear-gradient(45deg, #2b2f39 0 6px, #1c1f25 6px 12px) !important;
}

/* Spectrum picker. */
.cp-dialog { border: none; padding: 0; border-radius: 16px; background: transparent; }
.cp-dialog::backdrop { background: rgba(0,0,0,.6); }
.cp {
  width: min(92vw, 340px);
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.cp-sv {
  position: relative; width: 100%; height: 190px; border-radius: 10px;
  touch-action: none; cursor: crosshair;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0), #000),
    linear-gradient(to right, #fff, hsl(var(--cp-h, 210) 100% 50%));
}
.cp-hue {
  position: relative; width: 100%; height: 20px; margin-top: 14px;
  border-radius: 10px; touch-action: none; cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.cp-sv-thumb, .cp-hue-thumb {
  position: absolute; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5); transform: translate(-50%, -50%);
  pointer-events: none;
}
.cp-sv-thumb  { width: 18px; height: 18px; }
.cp-hue-thumb { top: 50%; width: 20px; height: 20px; }
.cp-preview {
  display: block; width: 100%; height: 38px; margin-top: 14px;
  border-radius: 8px; border: 1px solid var(--border);
}
.cp-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.cp-actions .btn { padding: 10px 20px; }

.score-card__display {
  display: grid; place-items: center;
  height: clamp(80px, 14vw, 200px);
  margin: 0 8px;
  background: #000;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(52px, 9vw, 130px);
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .08s;
}
.score-card__display:active { transform: scale(.985); }

.score-card__buttons {
  display: grid;
  grid-template-columns: 3fr 7fr;
  gap: 0;
  margin: 6px 8px 8px;
}

.score-btn {
  height: 50px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background .12s, transform .06s;
}
.score-btn:active { transform: scale(.97); }
.score-btn svg { width: 24px; height: 24px; }

.score-btn--minus {
  background: var(--negative);
  color: #fff;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.score-btn--minus:hover { background: var(--negative-hi); }

.score-btn--plus {
  background: var(--positive);
  color: #fff;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.score-btn--plus:hover { background: var(--positive-hi); }

/* ============================================================
   Period progress bar (quarters / halves)
   ============================================================ */
.periods {
  margin-top: 14px;
  display: flex;
  gap: 6px;
  counter-reset: period;
}

.period {
  flex: 1;
  position: relative;
  height: 38px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .12em;
  transition: all .25s;
  counter-increment: period;
}
.period::before {
  content: "Q" counter(period);
}
.period[data-format="2h"]::before {
  content: "H" counter(period);
}

.period.is-active {
  background: rgba(31,184,107,.15);
  border-color: var(--positive);
  color: var(--positive-hi);
}
.period.is-busy {
  background: rgba(232,168,56,.18);
  border-color: var(--warning);
  color: var(--warning);
  box-shadow: 0 0 0 3px rgba(232,168,56,.12);
}

/* ============================================================
   Timer
   ============================================================ */
.timer-wrap {
  margin-top: 14px;
  display: grid; place-items: center;
}

.timer {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-lg);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  /* overflow:hidden removed — it clips the adjust dropdown */
  overflow: visible;
}

.timer__adjust {
  position: relative;
}
.timer__adjust-btn {
  height: 100%;
  padding: 0 20px;
  display: grid; place-items: center;
  color: var(--text-dim);
  background: transparent;
  transition: background .15s, color .15s;
  border-right: 1px solid var(--border);
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}
.timer__adjust-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.timer__adjust-btn svg { width: 26px; height: 26px; transition: color .15s; }

/* Red ring on the clock icon when the menu is open */
.timer__adjust-btn.is-open {
  background: rgba(226,78,78,.12);
  color: var(--negative);
  border-right-color: rgba(226,78,78,.3);
}

/* Blue dropdown */
.timer__adjust-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 148px;
  padding: 5px;
  background: #1a6ee8;
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: none;
  z-index: 50;
  overflow: hidden;
}
.timer__adjust-menu.is-open { display: block; }

.timer__adjust-menu .menu-item {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 5px;
  letter-spacing: .01em;
}
.timer__adjust-menu .menu-item:hover { background: rgba(255,255,255,.2); }

.timer__adjust-menu .menu-divider {
  height: 1px;
  background: rgba(255,255,255,.22);
  margin: 4px 10px;
}

.timer__display {
  padding: 14px 32px;
  display: flex; align-items: center; gap: 18px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: clamp(40px, 5vw, 58px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: .04em;
  transition: background .2s;
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}
.timer__display:hover { background: var(--bg-elev-2); }
.timer__display .play-icon {
  width: 44px; height: 44px;
  color: var(--positive);
  transition: color .15s, transform .15s;
}
.timer__display:hover .play-icon { transform: scale(1.08); }

.timer[data-state="paused"] .play-icon { color: var(--warning); }

/* ============================================================
   Buttons (generic)
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  background: var(--bg-elev-3);
  color: var(--text);
  transition: background .12s, transform .06s, border-color .12s;
  border: 1px solid var(--border);
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--text-muted); }
.btn:active { transform: scale(.98); }

.btn--primary   { background: var(--accent);   border-color: var(--accent); color: #fff; }
.btn--primary:hover   { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn--success   { background: var(--positive); border-color: var(--positive); color: #fff; }
.btn--success:hover   { background: var(--positive-hi); border-color: var(--positive-hi); }
.btn--danger    { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn--danger:hover    { background: var(--negative-hi); border-color: var(--negative-hi); }
.btn--warning   { background: var(--warning);  border-color: var(--warning);  color: #1a1400; }
.btn--ghost     { background: transparent; }
.btn--block     { width: 100%; }
.btn--lg        { padding: 14px 22px; font-size: 16px; }
.btn--sm        { padding: 6px 12px; font-size: 13px; }

/* ============================================================
   Modal (native <dialog>)
   ============================================================ */
dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);

  /* Fill the viewport and center the inner .modal / .confirm on both axes.
     The dialog itself is transparent; the visible UI is the inner box,
     which has its own width/max-width/max-height below. */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: auto;
  display: grid;
  place-items: center;
}
dialog::backdrop {
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px);
}
dialog:not([open]) { display: none; }

.modal {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  width: calc(100vw - 24px);
  max-width: 720px;
  max-height: calc(100dvh - 40px);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}
.modal__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.modal__close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background .12s, color .12s;
}
.modal__close:hover { background: var(--bg-elev-3); color: var(--text); }

.modal__body { padding: 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal__foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev-2);
}

/* On phones / narrow windows the New Game modal becomes a full-height sheet
   that reaches the top of the screen — more room for the fixture list, easier
   to read/tap. Breakpoint covers phones, tablets and narrow desktop windows. */
@media (max-width: 820px) {
  #dlg-newgame { place-items: stretch; }
  #dlg-newgame .modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  #dlg-newgame .modal__head { padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  #dlg-newgame .modal__body { padding: 16px; }
  #dlg-newgame .modal__foot { padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
}

/* Form fields */
.field {
  display: flex; align-items: stretch;
  margin-bottom: 10px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.field__label {
  flex: none;
  width: 110px;
  padding: 12px 14px;
  background: var(--bg-elev-3);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
  display: flex; align-items: center;
}
.field__input {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 0;
  font-size: 16px;
  outline: none;
  min-width: 0;
}
.field__input:focus { background: var(--bg-elev-1); }
.field__input[readonly], .field__input:disabled { color: var(--text-dim); }

/* Condensed read-only summary for a fixture picked from the list. */
.info-card {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.info-card__row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border-soft);
}
.info-card__row:last-child { border-bottom: 0; }
.info-card__label {
  flex: none;
  width: 110px;
  padding: 8px 14px;
  background: var(--bg-elev-3);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
  display: flex; align-items: center;
}
.info-card__value {
  flex: 1;
  min-width: 0;
  padding: 8px 14px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center;
}

select.field__input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%239098a5' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.pill-group {
  display: flex;
  gap: 6px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.pill {
  padding: 10px 18px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: all .15s;
}
.pill:hover { color: var(--text); border-color: var(--text-muted); }
.pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* League games list */
.games-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 6px;
}
.games-list { display: flex; flex-direction: column; gap: 8px; }
.games-list__heading {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 2px 2px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.games-list__heading:first-child { margin-top: 0; }
.game-row {
  display: flex; align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  transition: background .14s, border-color .14s, transform .06s;
}
.game-row:hover { background: var(--bg-elev-3); border-color: var(--accent-hi); }
.game-row:active { transform: scale(.99); }

/* Upcoming-row internals */
.game-row__main { flex: 1; min-width: 0; }
.game-row__teams {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
  font-weight: 700; font-size: 16px; line-height: 1.25; color: var(--text);
}
.game-row__team { white-space: nowrap; }
.game-row__vs {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: lowercase; letter-spacing: .02em;
}
.game-row__time {
  flex: none;
  font-family: var(--font-mono);
  font-size: 14px; font-weight: 700;
  padding: 5px 11px;
  color: var(--positive-hi);
  background: rgba(31,184,107,.14);
  border: 1px solid rgba(31,184,107,.32);
  border-radius: 999px;
  letter-spacing: .02em;
}
.game-row__chev {
  flex: none;
  display: grid; place-items: center;
  width: 16px; font-size: 20px; line-height: 1;
  color: var(--text-muted);
  transition: color .14s, transform .14s;
}
.game-row:hover .game-row__chev { color: var(--text-dim); transform: translateX(2px); }

/* Locked rows — game already live, or its court is busy. Not startable here. */
.game-row--locked { cursor: not-allowed; opacity: .72; border-style: dashed; }
.game-row--locked:hover { background: var(--bg-elev-2); border-color: var(--border); }
.game-row--locked:active { transform: none; }
.game-row__live {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--positive-hi);
}
.game-row__live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.game-row__live--court { color: var(--warning); }

/* In-progress / live game rows */
.game-row--live {
  border-color: var(--positive);
  background: rgba(31,184,107,.07);
}
.game-row--live:hover { background: rgba(31,184,107,.14); }

.game-row__scores {
  display: flex;
  align-items: center;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.game-row__resume {
  flex: none;
  padding: 8px 18px;
  background: var(--positive);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Three-action button group on in-progress rows */
.game-row--no-click { cursor: default; }
.game-row--no-click:active { transform: none; }
.game-row__actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: none;
}
.game-row__actions .btn--sm { min-width: 76px; }

/* Divider between new-game sections */
.divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0 6px;
  position: relative;
}
.divider::after {
  content: attr(data-label);
  position: absolute;
  left: 50%; top: -10px;
  transform: translateX(-50%);
  padding: 2px 12px;
  background: var(--bg-elev-1);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* Game-completed modal */
.final-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 20px 0;
  text-align: center;
}
.final-score__team {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.final-score__value {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}
.final-score__sep {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text-muted);
}

/* ============================================================
   Login page
   ============================================================ */
.login-shell {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: var(--shadow-2);
  text-align: center;
}
.login-card__logo { height: 70px; margin-bottom: 16px; }
.login-card__title {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.login-card__sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}
.login-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 18px;
  text-align: center;
  letter-spacing: .3em;
  outline: none;
  margin-bottom: 14px;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .err {
  margin-top: 10px;
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast-host {
  position: fixed;
  top: 70px; left: 0; right: 0;
  z-index: 999;
  /* Centre children horizontally with flex instead of transform — a
     non-none transform on this element would turn it into a containing
     block for its position:fixed descendants, breaking the bottom-bar
     update toast (which wants to be viewport-relative). */
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 260px;
  max-width: 90vw;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .28s ease-out;
  pointer-events: auto;
}
.toast--warn    { border-color: var(--warning); color: var(--warning); }
.toast--error   { border-color: var(--danger);  color: var(--danger); }
.toast--success { border-color: var(--positive);color: var(--positive); }
.toast.is-leaving { animation: toastOut .22s ease-in forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-10px); } }

/* Full-width bottom bar — specifically for the "Updated to v…" toast.
   Uses position: fixed to escape the centered toast-host container so
   it spans the viewport edge-to-edge. env(safe-area-inset-bottom) keeps
   it clear of the iOS home indicator. */
.toast[data-toast-key="app-updated"] {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 14px 18px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-elev-2);
  color: var(--text);
  justify-content: center;
  font-weight: 500;
  animation: toastUpIn .3s ease-out;
}
.toast[data-toast-key="app-updated"].is-leaving {
  animation: toastDownOut .22s ease-in forwards;
}
@keyframes toastUpIn    { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastDownOut { to   { opacity: 0; transform: translateY(100%); } }

/* ============================================================
   Confirm dialog (Swal replacement)
   ============================================================ */
.confirm {
  max-width: 420px;
}
.confirm__body {
  padding: 24px 24px 8px;
  text-align: center;
}
.confirm__icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(232,168,56,.15);
  color: var(--warning);
}
.confirm__icon svg { width: 32px; height: 32px; }
.confirm__title { font-size: 18px; margin-bottom: 6px; }
.confirm__msg   { color: var(--text-dim); font-size: 14px; }
.confirm__foot  {
  display: flex; gap: 10px; justify-content: center;
  padding: 16px 24px 22px;
}

/* ============================================================
   Helpers
   ============================================================ */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 680px) {
  .board { padding: 62px 12px 24px; }
  /* Single column, cards stacked — just compact */
  .board__cards { grid-template-columns: 1fr; gap: 10px; }
  .score-card__display { height: 110px; font-size: clamp(56px, 14vw, 90px); }
  .score-card__team { font-size: clamp(14px, 4vw, 20px); }
  .score-btn { height: 54px; }
  .periods { margin-top: 10px; gap: 6px; }
  .period { height: 36px; font-size: 15px; }
  .timer-wrap { margin-top: 10px; }
  .timer__display { padding: 10px 22px; gap: 12px; font-size: 42px; }
  .timer__display .play-icon { width: 36px; height: 36px; }
  .topbar__meta { display: none; }
  .field__label { width: 90px; font-size: 12px; padding: 10px 12px; }
  .modal__foot .btn { padding: 10px 14px; }
}

@media (min-width: 1100px) {
  .score-card__display { height: 200px; font-size: 130px; }
}

/* ============================================================
   Break / Halftime overlay
   ============================================================ */
.break-overlay {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
  background: rgba(8, 9, 12, 0.96);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.break-overlay.hidden { display: none; }

.break-overlay__inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  padding: 40px 30px;
  text-align: center;
  width: 100%;
}

/* Soft glowing circle behind the clock */
.break-overlay__glow {
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,91,184,.22) 0%, transparent 70%);
  pointer-events: none;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.break-overlay__label {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0;
}

.break-overlay__clock {
  font-family: var(--font-mono);
  font-size: clamp(72px, 18vw, 120px);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: .04em;
  margin: 10px 0 6px;
}

.break-overlay__next {
  font-family: var(--font-display);
  font-size: clamp(16px, 3.5vw, 22px);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-hi);
  margin: 0;
}

/* Thin progress bar showing time elapsed */
.break-overlay__bar-wrap {
  width: min(320px, 80vw);
  height: 4px;
  background: var(--bg-elev-3);
  border-radius: 2px;
  margin: 20px 0 10px;
  overflow: hidden;
}
.break-overlay__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  border-radius: 2px;
  transition: width .9s linear;
  width: 100%;
}

.break-overlay__skip {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  border-color: var(--border);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.break-overlay__skip:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ---- Checkbox row (used in new-game form) ---- */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 10px;
  transition: border-color .15s, color .15s;
}
.checkbox-row:hover { border-color: var(--text-muted); color: var(--text); }
.checkbox-row input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--positive);
  cursor: pointer;
  flex: none;
}

/* ============================================================
   Idle overlay — shown when no game is active
   ============================================================ */
.idle-overlay {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.idle-overlay.hidden { display: none; }

.idle-overlay__inner {
  text-align: center;
  padding: 40px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.idle-overlay__label {
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
}
.idle-overlay__sub {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 280px;
  line-height: 1.55;
  margin: 0;
}

/* ============================================================
   Game completed dialog — done banner
   ============================================================ */
.done-banner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 20px;
  background: #000;
  text-align: center;
}
.done-banner__team { display: flex; flex-direction: column; gap: 6px; }
.done-banner__name {
  font-family: var(--font-display);
  font-size: clamp(14px, 3vw, 20px);
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.done-banner__score {
  font-family: var(--font-mono);
  font-size: clamp(52px, 10vw, 80px);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.done-banner__score.is-winner { color: var(--positive-hi); }
.done-banner__sep {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text-muted);
  font-weight: 700;
}

.done-result {
  text-align: center;
  padding: 10px 20px 4px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--positive);
}
