:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #131c2e;
  --accent: #ff2635;
  --text: #f2f5f9;
  --muted: #8ea0b8;
  --penalty: #ff5b5b;
  --font-heavy: 'Arial Black', Impact, 'Franklin Gothic Heavy', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.05rem;
  font-family: var(--font-heavy);
}

button:hover {
  filter: brightness(1.1);
}

input[type='text'] {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--muted);
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
}

/* Admin */
.admin-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.admin-heading {
  margin: 0 0 0.3rem;
  font-family: var(--font-heavy);
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  letter-spacing: 0.02em;
}

.admin-clock {
  font-family: var(--font-heavy);
  font-size: clamp(2rem, 4vw, 3rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  font-weight: 700;
}

.theme-toggle span {
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.theme-toggle button {
  background: var(--accent);
  color: #ffffff;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.panel.admin-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 1.75rem;
}

.admin-card h2 {
  margin: 0 0 1.4rem;
  font-family: var(--font-heavy);
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.game-links {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--muted);
}

.game-links h3 {
  margin: 0 0 0.9rem;
  font-size: 1.15rem;
}

.game-links-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.link-button {
  display: block;
  text-align: center;
  padding: 0.7rem 1rem;
  border-radius: 11px;
  border: 1px solid var(--muted);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}

.link-button:hover {
  filter: brightness(1.15);
}

.games-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
}

.games-list-empty {
  color: var(--muted);
  font-size: 1rem;
}

.games-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  flex-wrap: wrap;
}

.games-list-main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.games-list-id {
  font-family: var(--font-heavy);
  letter-spacing: 0.06em;
  color: var(--accent);
  font-size: 1.05rem;
}

.games-list-teams {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.games-list-score {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.games-list-meta {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.games-list-links {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.games-list-links a {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--muted);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
}

.games-list-links a:hover {
  filter: brightness(1.2);
}

.buzzer-card {
  margin-top: 1.5rem;
}

.buzzer-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.buzzer-row button,
.buzzer-upload-label {
  width: auto;
}

.buzzer-status {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Admin light theme: pure white background, pure black text, no color tinting */
body[data-theme='light'] {
  --bg: #ffffff;
  --panel: #ffffff;
  --accent: #000000;
  --text: #000000;
  --muted: #555555;
  color-scheme: light;
}

body[data-theme='light'] .panel.admin-card {
  border: 2px solid #000000;
}

body[data-theme='light'] input[type='text'] {
  border: 2px solid #000000;
}

body[data-theme='light'] button {
  background: #000000;
  color: #ffffff;
}

body[data-theme='light'] .link-button,
body[data-theme='light'] .games-list-item,
body[data-theme='light'] .games-list-links a {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
}

body[data-theme='light'] .theme-toggle {
  border: 2px solid #000000;
}

body[data-theme='light'] .theme-toggle button {
  background: #000000;
  color: #ffffff;
}

/* Control page */
.control-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.status {
  color: var(--muted);
}

.clock-section {
  text-align: center;
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.period-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.period-row .theme-toggle {
  margin-left: auto;
}

.clock-display {
  font-size: 3.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.clock-buttons {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.clock-adjust-row {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.clock-adjust-btn {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  background: transparent;
  border: 2px solid var(--muted);
  color: var(--muted);
}

.clock-adjust-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.control-page .clock-display {
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.15s;
}

.control-page .clock-display:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Only ever shown while actively editing — the [hidden] attribute must win
   over the display:block below, or the input stays visible (and empty)
   the whole time, which is confusing clutter on the panel. */
.clock-edit-input[hidden] {
  display: none;
}

.clock-edit-input {
  display: block;
  margin: 0 auto;
  width: 8ch;
  text-align: center;
  font-size: 3.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-family: var(--font-heavy);
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 12px;
  color: var(--text);
}

.start-pause-toggle {
  font-size: 1.3rem;
  padding: 0.8rem 2.2rem;
  background: #1fae63;
}

.start-pause-toggle[data-running='true'] {
  background: var(--accent);
}

.teams-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.team-panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-left: 6px solid var(--muted);
}

.team-header-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.team-header-row .team-name-input {
  flex: 1;
  min-width: 0;
}

.team-color-input {
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.score {
  font-size: 3rem;
  font-weight: 800;
  min-width: 2ch;
  text-align: center;
}

.score-plus {
  background: #1fae63;
  font-size: 1.15rem;
  padding: 0.9rem 1.6rem;
}

.score-minus {
  background: transparent;
  border: 2px solid var(--muted);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
}

.score-minus:hover {
  border-color: var(--text);
  color: var(--text);
}

.penalty-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.penalty-add {
  font-size: 1.05rem;
  padding: 0.8rem 1rem;
}

.penalty-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.penalty-list li {
  background: var(--penalty);
  color: #1a0000;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.penalty-list li.penalty-waiting {
  background: transparent;
  border: 1px dashed var(--muted);
  color: var(--muted);
}

.penalty-time {
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
}

.penalty-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.penalty-actions {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
}

.penalty-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

/* HDMI / game page */
.game-page {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scoreboard {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(2rem, 4vw, 6rem);
  padding: clamp(2rem, 4vh, 5rem) clamp(2rem, 4vw, 6rem);
}

.team-block {
  text-align: center;
  min-width: 0;
}

.team-name {
  /* vw + vh together so a wide-but-short monitor still gets real vertical
     scale instead of plateauing at the vw-only cap. */
  font-size: clamp(3.5rem, 3.5vw + 2.5vh, 9rem);
  font-weight: 800;
  font-family: var(--font-heavy);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-score {
  font-size: clamp(11rem, 9vw + 9vh, 26rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.jersey {
  display: inline-flex;
  width: 1.6em;
  height: 1.6em;
  flex-shrink: 0;
}

.jersey svg {
  width: 100%;
  height: 100%;
}

.jersey-chip {
  width: clamp(5rem, 5vw + 3.5vh, 13rem);
  height: clamp(5rem, 5vw + 3.5vh, 13rem);
  margin: 1.5rem auto 0;
  opacity: 0.95;
}

/* Stacked, unboxed penalty readout — mirrors the two-slot penalty-box
   display on a real rink scoreboard, sized to read from across the arena. */
.penalty-list-hdmi {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.penalty-list-hdmi li {
  color: var(--penalty);
  font-size: clamp(3rem, 3vw + 2.5vh, 7rem);
  font-weight: 800;
  font-family: var(--font-heavy);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.center-block {
  text-align: center;
}

.period-label {
  display: inline-block;
  font-size: clamp(2rem, 2vw + 1.5vh, 4.5rem);
  font-family: var(--font-heavy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg);
  background: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 1.6rem;
  margin-bottom: 1.5rem;
}

.center-block .clock-display {
  font-size: clamp(9rem, 8vw + 8vh, 22rem);
  font-family: var(--font-heavy);
}
