:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #60706a;
  --line: #d8e0dc;
  --surface: #ffffff;
  --soft: #f4f7f5;
  --soft-2: #eef3ef;
  --green: #146c43;
  --green-dark: #0c4d31;
  --blue: #2454a6;
  --gold: #b7791f;
  --red: #7f1d1d;
  --focus: #2f80ed;
  --shadow: 0 12px 36px rgba(24, 33, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--ink);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--soft-2);
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

button.ghost:hover {
  background: var(--soft-2);
  color: var(--ink);
}

button.active,
.tab-button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.28);
  outline-offset: 2px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 44px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  letter-spacing: 0;
  width: 42px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.topnav {
  align-items: center;
  display: flex;
  gap: 6px;
}

.topnav a {
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
}

.topnav a:hover {
  background: var(--soft-2);
  color: var(--ink);
}

.page-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px clamp(14px, 3.5vw, 28px) 56px;
}

.band {
  margin-bottom: 28px;
}

.score-hero,
.panel,
.match-card,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.score-hero {
  overflow: hidden;
}

.score-hero-main {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  padding: clamp(20px, 4vw, 34px);
}

.club-block {
  min-width: 0;
}

.club-name {
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.05;
  margin: 0;
  overflow-wrap: anywhere;
}

.club-meta,
.muted {
  color: var(--muted);
}

.score-total {
  align-self: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 190px;
  padding: 10px 24px;
  text-align: center;
}

.score-number {
  display: block;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  font-weight: 950;
  line-height: 1;
}

.score-label {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  margin-top: 6px;
  text-transform: uppercase;
}

.score-meta {
  align-items: center;
  background: #f8faf8;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 14px clamp(20px, 4vw, 34px);
}

.pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  min-height: 30px;
  padding: 5px 10px;
  white-space: nowrap;
}

.pill.live {
  background: #e9f7ef;
  border-color: #b7e3c8;
  color: var(--green-dark);
}

.pill.finished {
  background: #edf2ff;
  border-color: #c9d7ff;
  color: var(--blue);
}

.pill.planned {
  background: #fff8eb;
  border-color: #efd39d;
  color: #7a4b08;
}

.section-heading {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2,
.section-heading h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.15;
  margin: 0;
}

.eyebrow {
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.history-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.match-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 188px;
  padding: 18px;
}

.match-card h3 {
  font-size: 1.12rem;
  margin: 0;
}

.match-card-score {
  align-items: center;
  display: flex;
  font-size: 1.8rem;
  font-weight: 950;
  gap: 8px;
  margin-top: auto;
}

.panel {
  padding: clamp(16px, 3vw, 24px);
}

.duel-groups {
  display: grid;
  gap: 18px;
}

.duel-group {
  display: grid;
  gap: 10px;
}

.duel-group h3 {
  font-size: 1rem;
  margin: 0;
}

.duel-row {
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 46px 116px minmax(0, 1fr) 116px minmax(0, 1fr) minmax(90px, auto);
  padding: 12px;
}

.duel-order {
  align-items: center;
  background: var(--soft-2);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 42px;
}

.duel-link:hover {
  background: var(--green);
  color: #fff;
}

.duel-side {
  min-width: 0;
}

.duel-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.25;
}

.duel-side strong {
  display: block;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.duel-side small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.duel-points {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: center;
}

.point-box {
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  font-weight: 950;
  min-width: 42px;
  padding: 9px 8px;
  text-align: center;
}

.result-text {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 800;
  justify-content: flex-end;
  min-width: 0;
}

.admin-shell {
  display: grid;
  gap: 18px;
}

.admin-actions,
.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button {
  min-height: 38px;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, 1fr);
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.check-field {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
select,
input,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.admin-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.edit-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.table-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-row {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(140px, 1.2fr) minmax(80px, 0.4fr) minmax(170px, 1fr) minmax(140px, 0.8fr) 110px;
  padding: 10px;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row.header {
  background: var(--soft-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.check-field {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 40px;
}

.check-field input {
  min-height: auto;
  width: auto;
}

.notice {
  background: #edf2ff;
  border: 1px solid #c9d7ff;
  border-radius: 8px;
  color: #24417d;
  font-weight: 700;
  padding: 12px 14px;
}

.notice.warn {
  background: #fff8eb;
  border-color: #efd39d;
  color: #7a4b08;
}

.notice.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #8a1f1f;
}

.login-wrap {
  display: grid;
  min-height: calc(100vh - 160px);
  place-items: center;
}

.login-panel {
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-panel h1 {
  margin: 0 0 16px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.match-selector {
  max-width: 440px;
}

.duel-admin-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 48px minmax(150px, 1fr) minmax(150px, 1fr) 108px 86px 110px 110px 110px 112px;
  padding: 12px;
}

.mini-label {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.player-slot {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
}

.player-slot.single-slot {
  grid-template-columns: 1fr;
}

.swatch {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  display: inline-block;
  height: 14px;
  margin-right: 7px;
  vertical-align: -2px;
  width: 14px;
}

.save-state {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.duel-detail-panel {
  display: grid;
  gap: 16px;
}

.score-detail-summary,
.score-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.scorecard-scroll {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.scorecard-table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.scorecard-table th,
.scorecard-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

.scorecard-table th:first-child {
  left: 0;
  min-width: 210px;
  position: sticky;
  text-align: left;
  z-index: 2;
}

.scorecard-table thead th {
  background: var(--soft-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.scorecard-table tbody th {
  background: #fff;
}

.scorecard-table th strong,
.scorecard-table th small,
.scorecard-table thead th span,
.scorecard-table thead th small {
  display: block;
}

.scorecard-table th small {
  color: var(--muted);
  font-weight: 800;
  margin-top: 3px;
}

.scorecard-table select {
  min-height: 34px;
  min-width: 58px;
  padding: 5px 6px;
}

.scorecard-table .stroke-cell {
  background: #fff7d6;
}

.scorecard-result-row th,
.scorecard-result-row td,
.scorecard-running-row th,
.scorecard-running-row td {
  background: #f8faf8;
  font-weight: 900;
}

.voice-score-dock {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  bottom: 10px;
  box-shadow: 0 14px 34px rgba(24, 33, 31, 0.12);
  display: grid;
  gap: 10px;
  padding: 12px;
  position: sticky;
  z-index: 12;
}

.voice-error {
  border-left-color: var(--red);
}

.voice-saved {
  border-left-color: var(--blue);
}

.voice-listening-score,
.voice-listening-confirmation {
  border-left-color: var(--gold);
}

.voice-score-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.voice-score-status {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.voice-score-status strong {
  font-size: 1rem;
  line-height: 1.2;
}

.voice-score-status span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.voice-score-kicker {
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.voice-score-buttons {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.voice-rec-dot {
  background: #9aa6a1;
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.voice-listening-score .voice-rec-dot,
.voice-listening-confirmation .voice-rec-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(127, 29, 29, 0.14);
}

.voice-transcript {
  background: var(--soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 9px 10px;
}

.voice-proposal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.voice-proposal span {
  align-items: center;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 34px;
  padding: 6px 9px;
}

.voice-proposal strong {
  color: var(--ink);
  font-size: 0.85rem;
}

.voice-proposal b {
  background: var(--ink);
  border-radius: 7px;
  color: #fff;
  min-width: 30px;
  padding: 4px 7px;
  text-align: center;
}

body.tv-mode {
  background: #07120f;
  color: #fff;
  height: 100vh;
  overflow: hidden;
}

body.tv-mode .topbar {
  display: none;
}

body.tv-mode .page-shell {
  height: 100vh;
  max-width: none;
  padding: clamp(18px, 2.6vw, 34px);
}

body.tv-mode .band {
  margin: 0;
}

.tv-board {
  display: grid;
  gap: clamp(16px, 2vw, 28px);
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100vh - clamp(36px, 5.2vw, 68px));
  min-height: 0;
}

.tv-header,
.tv-scoreline,
.tv-duel-row,
.tv-summary-tile {
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--ink);
}

.tv-header {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: clamp(14px, 1.8vw, 22px) clamp(18px, 2.5vw, 30px);
}

.tv-header h1,
.tv-header p {
  margin: 0;
}

.tv-header h1 {
  font-size: clamp(2rem, 4vw, 4.8rem);
  font-weight: 950;
  line-height: 1;
}

.tv-header p:not(.tv-kicker) {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.5rem);
  font-weight: 800;
  margin-top: 6px;
}

.tv-kicker {
  color: var(--green-dark);
  font-size: clamp(0.9rem, 1.2vw, 1.25rem);
  font-weight: 950;
  text-transform: uppercase;
}

.tv-progress {
  align-items: flex-end;
  display: grid;
  gap: 4px;
  justify-items: end;
  min-width: 160px;
}

.tv-progress span {
  color: var(--green-dark);
  font-size: clamp(1.7rem, 3vw, 3.4rem);
  font-weight: 950;
  line-height: 1;
}

.tv-progress small {
  color: var(--muted);
  font-size: clamp(0.78rem, 1vw, 1rem);
  font-weight: 800;
}

.tv-scoreline {
  align-items: center;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  padding: clamp(18px, 2.5vw, 30px);
}

.tv-club {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.tv-club span {
  color: var(--muted);
  font-size: clamp(0.82rem, 1vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
}

.tv-club strong {
  font-size: clamp(1.9rem, 4.2vw, 5rem);
  font-weight: 950;
  line-height: 1;
  overflow-wrap: anywhere;
}

.tv-club-b {
  text-align: right;
}

.tv-total {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-size: clamp(3.5rem, 7.5vw, 9rem);
  font-weight: 950;
  line-height: 0.95;
  min-width: clamp(270px, 28vw, 560px);
  padding: 0 clamp(18px, 2.4vw, 38px);
  text-align: center;
}

.tv-slide-body {
  min-height: 0;
}

.tv-overview-grid {
  display: grid;
  gap: clamp(14px, 1.6vw, 22px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 100%;
}

.tv-summary-tile {
  align-content: center;
  display: grid;
  gap: clamp(10px, 1.3vw, 18px);
  padding: clamp(20px, 3vw, 42px);
}

.tv-summary-tile span {
  color: var(--muted);
  font-size: clamp(1.1rem, 1.7vw, 2rem);
  font-weight: 950;
  text-transform: uppercase;
}

.tv-summary-tile strong {
  font-size: clamp(3.2rem, 6vw, 7.5rem);
  font-weight: 950;
  line-height: 0.95;
}

.tv-summary-tile small {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.5rem);
  font-weight: 900;
}

.tv-duel-list {
  display: grid;
  gap: clamp(10px, 1.2vw, 16px);
  height: 100%;
}

.tv-duel-row {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: clamp(56px, 5vw, 92px) minmax(120px, 0.8fr) minmax(0, 1.4fr) clamp(98px, 8vw, 142px) minmax(0, 1.4fr) minmax(132px, 0.8fr);
  min-height: 0;
  padding: clamp(12px, 1.3vw, 18px);
}

.tv-duel-order,
.tv-duel-points,
.tv-duel-result {
  align-items: center;
  display: grid;
}

.tv-duel-order {
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  font-size: clamp(1.6rem, 2.5vw, 3.2rem);
  font-weight: 950;
  justify-content: center;
}

.tv-duel-meta {
  align-content: center;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.tv-duel-meta strong {
  font-size: clamp(1rem, 1.3vw, 1.45rem);
  font-weight: 950;
  line-height: 1.1;
}

.tv-duel-meta span {
  color: var(--muted);
  font-size: clamp(0.78rem, 0.95vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
}

.tv-duel-side {
  align-self: center;
  font-size: clamp(1.15rem, 2vw, 2.6rem);
  font-weight: 900;
  line-height: 1.08;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tv-duel-points {
  gap: 6px;
  grid-template-columns: 1fr 1fr;
}

.tv-duel-points span {
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  font-size: clamp(1.3rem, 2.1vw, 2.6rem);
  font-weight: 950;
  padding: 10px 8px;
  text-align: center;
}

.tv-duel-result {
  justify-items: end;
  min-width: 0;
  text-align: right;
}

.tv-duel-result strong {
  font-size: clamp(1.2rem, 2vw, 2.6rem);
  font-weight: 950;
  line-height: 1;
}

.tv-duel-result span {
  color: var(--muted);
  font-size: clamp(0.8rem, 1vw, 1.05rem);
  font-weight: 900;
  margin-top: 5px;
  text-transform: uppercase;
}

.tv-duel-result.live strong {
  color: var(--green-dark);
}

.tv-duel-result.final strong {
  color: var(--blue);
}

@media (max-width: 840px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    position: static;
  }

  .score-hero-main,
  .duel-row,
  .duel-admin-row,
  .table-row {
    grid-template-columns: 1fr;
  }

  .score-total {
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 18px 0;
  }

  .result-text,
  .duel-points {
    justify-content: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-8,
  .span-12 {
    grid-column: auto;
  }

  .table-row.header {
    display: none;
  }

  .voice-score-row {
    align-items: stretch;
    flex-direction: column;
  }

  .voice-score-buttons {
    justify-content: stretch;
  }

  .voice-score-buttons button {
    flex: 1 1 150px;
    white-space: normal;
    width: auto;
  }
}

@media (max-width: 540px) {
  .topbar {
    flex-direction: column;
  }

  .topnav {
    width: 100%;
  }

  .topnav a {
    flex: 1;
    text-align: center;
  }

  .score-meta,
  .section-heading,
  .admin-actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .button {
    width: 100%;
  }

  .voice-score-buttons button {
    width: auto;
  }
}
