:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #05070b;
  --surface: #141923;
  --surface-raised: #263349;
  --surface-soft: #1b2432;
  --text: #f6f7f2;
  --muted: #cfd6df;
  --accent: #f5c542;
  --danger: #ff5a4f;
  --focus: #8ec5ff;
  --success: #67d391;
  --radius: 1.1rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.eyebrow { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.82rem; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; }
.button { min-height: 2.75rem; border: 1px solid transparent; border-radius: 0.8rem; padding: 0.7rem 1rem; color: var(--text); background: var(--surface-raised); font-weight: 850; cursor: pointer; text-decoration: none; }
a.button, a.button:visited, a.button:hover, a.button:active { color: var(--text); text-decoration: none; }
a.button-primary, a.button-primary:visited, a.button-primary:hover, a.button-primary:active { color: var(--bg); }
.button:hover:not(:disabled) { filter: brightness(1.12); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { background: var(--accent); color: var(--bg); }
.button-secondary { border-color: #465570; background: var(--surface-raised); }
.button-quiet { border-color: #3b4658; background: transparent; }
.button-danger { background: var(--danger); color: #130504; }
.button-small { min-height: 2.5rem; padding: 0.5rem 0.75rem; }
dialog { width: min(calc(100% - 2rem),30rem); border: 1px solid #465570; border-radius: 1.2rem; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 2rem 7rem rgba(0,0,0,0.7); }
dialog::backdrop { background: rgba(0,0,0,0.72); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 0.75rem; padding: 1rem; }
.dialog-card h2, .dialog-card p { margin: 0; }
.dialog-copy, .dialog-hint { color: var(--muted); }
.dialog-hint { font-size: 0.82rem; }
.choice-dialog { width: min(calc(100% - 2rem),42rem); }
.choice-dialog-header { min-width: 0; display: flex; align-items: start; justify-content: space-between; gap: 0.75rem; }
.choice-dialog-header > div { min-width: 0; }
.dialog-close { width: 2.75rem; height: 2.75rem; min-width: 2.75rem; display: grid; place-items: center; border: 1px solid #465570; border-radius: 0.8rem; padding: 0; background: transparent; color: var(--muted); cursor: pointer; }
.dialog-close-icon { width: 1.45rem; height: 1.45rem; overflow: visible; }
.dialog-close-icon path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.dialog-close:hover { border-color: #7084a5; background: var(--surface-raised); color: var(--text); }
.serve-badge { width: max-content; border-radius: 999px; padding: 0.35rem 0.65rem; background: var(--accent); color: var(--bg); font-size: 0.76rem; font-weight: 1000; letter-spacing: 0.08em; text-transform: uppercase; }
.connection { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.connection-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0.2rem rgba(245,197,66,0.12); }
.connection.online .connection-dot { background: var(--success); box-shadow: 0 0 0 0.2rem rgba(103,211,145,0.12); }
.connection.offline .connection-dot { background: var(--danger); box-shadow: 0 0 0 0.2rem rgba(255,90,79,0.12); }
.account-menu { position: relative; }
.account-menu > summary { display: flex; align-items: center; gap: 0.5rem; list-style: none; font-size: 0.82rem; white-space: nowrap; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu-chevron { width: 0.8rem; height: 0.55rem; flex: 0 0 auto; margin-left: 0.1rem; overflow: visible; color: var(--muted); transition: transform 120ms ease; }
.account-menu-chevron path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-menu[open] > summary { border-color: #7084a5; background: var(--surface-raised); }
.account-menu[open] > summary .account-menu-chevron { transform: rotate(180deg); }
.account-menu-short { display: none; }
.account-menu-popover { width: max-content; min-width: 14rem; position: absolute; z-index: 20; top: calc(100% + 0.55rem); right: 0; display: grid; gap: 0.35rem; border: 1px solid #465570; border-radius: 1rem; padding: 0.55rem; background: var(--surface); font-size: 0.82rem; box-shadow: 0 2rem 7rem rgba(0,0,0,0.7); }
.account-menu-identity { display: grid; gap: 0.1rem; border-bottom: 1px solid #34425a; padding: 0.55rem 0.65rem 0.7rem; }
.account-menu-identity strong { overflow: hidden; text-overflow: ellipsis; }
.account-menu-identity span { color: var(--muted); font-size: 0.78rem; }
.account-menu-popover a, .account-menu-popover button { width: 100%; min-height: 3rem; display: flex; align-items: center; border: 0; border-radius: 0.7rem; padding: 0.65rem 0.75rem; background: transparent; color: var(--text); font-weight: 800; text-align: left; text-decoration: none; cursor: pointer; }
.account-menu-popover a:hover, .account-menu-popover button:hover { background: var(--surface-raised); }
.alert { border: 1px solid rgba(255,90,79,0.55); border-radius: 0.8rem; padding: 0.85rem 1rem; background: rgba(255,90,79,0.12); color: #ffd5d1; font-weight: 750; }
label { display: grid; gap: 0.4rem; color: var(--muted); font-weight: 750; }
input, select {
  width: 100%;
  height: 3.25rem;
  min-height: 3.25rem;
  border: 1px solid #465570;
  border-radius: 0.7rem;
  padding: 0.65rem 0.8rem;
  background-color: #0d121b;
  color: var(--text);
  line-height: 1.25;
}
select {
  appearance: none;
  padding-right: 2.6rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.1rem) calc(50% - 0.15rem),
    calc(100% - 0.75rem) calc(50% - 0.15rem);
  background-repeat: no-repeat;
  background-size: 0.4rem 0.4rem;
}
[hidden] { display: none !important; }

/* Active intervals must be obvious from court distance without changing scoring rules. */
.display-page.interval-active .display-shell { filter: brightness(0.42) saturate(0.72); }
.display-page #intervalBanner.interval-banner {
  width: min(84vw,80rem);
  min-height: clamp(12rem,34vh,24rem);
  top: 11vh;
  left: 50%;
  z-index: 15;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: clamp(0.2rem,0.35vw,0.4rem) solid #05070b;
  border-radius: clamp(1.2rem,2vw,2.4rem);
  padding: clamp(1rem,3vh,2.5rem) clamp(1.25rem,3vw,3rem);
  background: rgba(245,197,66,0.98);
  color: #05070b;
  box-shadow: 0 2rem 7rem rgba(0,0,0,0.72);
  font-size: clamp(3rem,7vw,6rem);
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 0.95;
  overflow-wrap: normal;
  text-align: center;
  text-wrap: balance;
  text-transform: uppercase;
  white-space: normal;
}

/* Keep counter controls stationary through intervals and match completion. */
.umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #screenWakeStatus.screen-wake-status {
  min-height: 1.25rem;
  margin: 0;
  line-height: 1.25rem;
}
.umpire-page[data-view-state="finished"] #screenWakeStatus.screen-wake-status[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}
.umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #controlBoard.control-board {
  position: relative;
  padding-bottom: calc(clamp(0.8rem,1.8vw,1.2rem) + clamp(3.8rem,9vh,5.5rem) + 0.65rem);
}
.umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #statusRow.status-row {
  position: absolute;
  right: clamp(0.8rem,1.8vw,1.2rem);
  bottom: clamp(0.8rem,1.8vw,1.2rem);
  left: clamp(0.8rem,1.8vw,1.2rem);
  min-height: clamp(3.8rem,9vh,5.5rem);
  margin: 0;
}
.umpire-page[data-view-state="active"] #statusRow.status-row[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}
.umpire-page #statusRow.status-row:has(#intervalLabel:not([hidden])) {
  display: grid;
  place-items: center;
  border: 2px solid #05070b;
  border-radius: clamp(0.8rem,1.2vw,1.1rem);
  padding: clamp(0.45rem,1vh,0.8rem) clamp(0.8rem,2vw,1.5rem);
  background: rgba(245,197,66,0.98);
  box-shadow: 0 0.8rem 2.5rem rgba(0,0,0,0.36);
}
.umpire-page #statusRow.status-row:has(#intervalLabel:not([hidden])) #statusLabel { display: none !important; }
.umpire-page #statusRow.status-row:has(#intervalLabel:not([hidden])) #intervalLabel.status-pill {
  max-width: 100%;
  display: block;
  padding: 0;
  background: transparent;
  color: #05070b;
  font-size: clamp(1.8rem,4.5vw,3.4rem);
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.umpire-page[data-view-state="finished"] #statusRow.status-row {
  display: grid;
  place-items: center;
  border: 1px solid #465570;
  border-radius: clamp(0.8rem,1.2vw,1.1rem);
  padding: clamp(0.45rem,1vh,0.8rem) clamp(0.8rem,2vw,1.5rem);
  background: rgba(38,51,73,0.78);
  box-shadow: none;
}
.umpire-page[data-view-state="finished"] #statusLabel.status-pill {
  width: 100%;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(1.15rem,2.4vw,1.8rem);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}
.umpire-page[data-view-state="finished"] #scoringControls[hidden] {
  display: grid !important;
}
.umpire-page[data-view-state="finished"] #scoringControls .point-button {
  pointer-events: none;
}
.umpire-page[data-view-state="finished"] #quickActions.quick-actions {
  grid-template-columns: repeat(3,minmax(0,1fr));
}
.umpire-page[data-view-state="finished"] #undoButton { grid-column: 1; }
.umpire-page[data-view-state="finished"] #startNewMatchButton { grid-column: 2 / 4; }

@media (max-height: 850px) {
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) .umpire-shell {
    grid-template-rows: auto auto auto clamp(16rem,44vh,22rem) minmax(5.5rem,14vh) auto !important;
  }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) .umpire-header { grid-row: 1 !important; }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #message { grid-row: 2 !important; }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #screenWakeStatus { grid-row: 3 !important; }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) .control-board { grid-row: 4 !important; }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) .scoring-controls { grid-row: 5 !important; }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) .quick-actions { grid-row: 6 !important; }
}

@media (max-width: 720px) {
  .display-page #intervalBanner.interval-banner {
    width: calc(100vw - 1.1rem);
    min-height: 30vh;
    top: 8vh;
    font-size: clamp(3.2rem,12vw,6rem);
    white-space: normal;
  }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #controlBoard.control-board {
    padding-bottom: calc(0.65rem + 3.5rem + 0.5rem);
  }
  .umpire-page:is([data-view-state="active"],[data-view-state="finished"]) #statusRow.status-row {
    right: 0.65rem;
    bottom: 0.65rem;
    left: 0.65rem;
    min-height: 3.5rem;
  }
  .umpire-page #statusRow.status-row:has(#intervalLabel:not([hidden])) #intervalLabel.status-pill {
    font-size: clamp(1.45rem,7vw,2.4rem);
    white-space: normal;
  }
}
