:root {
  --bg: #f4f1ea;
  --ink: #15171a;
  --muted: #626b77;
  --panel: #fff;
  --line: #d9dde2;
  --green: #0f8a63;
  --gold: #f0c45a;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, select { font: inherit; }
button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--green);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}
.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.topbar, .control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow, .control-header p {
  margin: 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}
h1 { margin: 4px 0 0; font-size: clamp(30px, 4vw, 48px); line-height: 1; }
h2 { margin: 0; font-size: 22px; }
.pill, [data-message] {
  border-radius: 8px;
  padding: 10px 14px;
  background: #111827;
  color: white;
  font-weight: 800;
}
.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.top-actions a {
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--green);
  color: white;
  font-weight: 800;
  text-decoration: none;
}
[data-message]:empty { display: none; }
[data-message] { margin-bottom: 18px; background: var(--gold); color: #111827; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.panel, .match-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.wide { grid-column: 1 / -1; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.list-section { margin-top: 24px; }
.match-list { display: grid; gap: 12px; margin-top: 12px; }
.match-card span, .match-card small, .empty { color: var(--muted); }
.admin-details {
  margin-top: 26px;
}
.admin-details summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #ffffff;
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
}
.admin-details-grid {
  margin-top: 14px;
}
.external-link {
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}
.external-link:hover {
  text-decoration: underline;
}
.matches-page {
  display: grid;
  gap: 18px;
}
.matches-group {
  display: grid;
  gap: 10px;
}
.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.group-title span {
  border-radius: 999px;
  padding: 5px 10px;
  background: #162033;
  color: white;
  font-weight: 900;
}
.match-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.match-main {
  display: grid;
  gap: 4px;
}
.match-main strong {
  font-size: 22px;
}
.match-main small,
.match-location {
  color: var(--muted);
}
.match-location {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}
.set-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.set-strip span {
  min-width: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8fafc;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}
.set-strip .current-set {
  border-color: var(--green);
  background: #e8f6ef;
  color: var(--green);
}
.match-links {
  justify-content: flex-end;
}
.link-row { display: flex; flex-wrap: wrap; gap: 10px; }
.link-row a {
  border-radius: 8px;
  padding: 10px 12px;
  background: #162033;
  color: white;
  font-weight: 800;
  text-decoration: none;
}
.link-row button {
  min-height: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}
.link-danger {
  background: var(--danger);
}
.score-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: white;
}
.score-table th, .score-table td {
  border: 1px solid var(--line);
  padding: 16px;
  text-align: center;
}
.score-table th:first-child { text-align: left; width: 38%; }
body[data-page="control"] {
  --bg: #080b10;
  --ink: #f7fafc;
  --muted: #9aa8b8;
  --panel: #111827;
  --line: #293241;
  background: radial-gradient(circle at top, #182133 0, #080b10 44%);
  color: var(--ink);
}
body[data-page="control"] .shell {
  width: min(1500px, calc(100vw - 24px));
  padding: 16px 0 20px;
}
body[data-page="control"] [data-message] {
  background: var(--gold);
  color: #111827;
}
body[data-page="control"] .control-header {
  margin-bottom: 12px;
}
body[data-page="control"] .control-header h1 {
  color: white;
  font-size: clamp(22px, 3vw, 38px);
}
body[data-page="control"] .control-header p {
  color: var(--gold);
}
body[data-page="control"] .control-header strong {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 16px;
}
.control-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: calc(100vh - 260px);
}
.score-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #151d2a 0%, #0f1622 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 18px 40px rgba(0,0,0,0.35);
}
.score-panel h2 {
  margin: 0;
  color: white;
  font-size: clamp(24px, 3.6vw, 52px);
  line-height: 1.05;
  text-align: center;
}
.score-stepper {
  display: grid;
  grid-template-columns: minmax(82px, 0.7fr) minmax(130px, 1.1fr) minmax(82px, 0.7fr);
  align-items: stretch;
  gap: 12px;
  min-height: 320px;
}
.score-stepper strong {
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #05070b;
  color: white;
  font-size: clamp(120px, 28vh, 300px);
  line-height: 0.85;
  font-weight: 900;
  box-shadow: inset 0 0 34px rgba(255,255,255,0.04);
}
.score-stepper button {
  min-height: 260px;
  padding: 0;
  font-size: clamp(80px, 20vh, 220px);
  line-height: 1;
}
.minus-button {
  background: #2d3748;
}
.plus-button {
  background: var(--green);
}
.small-score {
  margin-top: 12px;
}
.small-score .score-table th,
.small-score .score-table td {
  border-color: #293241;
  padding: 8px 10px;
  background: #111827;
  color: #dbe4ef;
  font-size: 15px;
}
.small-score .score-table thead th {
  background: #0b111b;
  color: #94a3b8;
}
.small-score .score-table th:first-child {
  width: 34%;
}
.set-prompt {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 50%;
  width: min(720px, calc(100% - 32px));
  margin: 0;
  border: 1px solid rgba(240,196,90,0.55);
  border-radius: 8px;
  padding: 18px;
  background: rgba(13, 18, 28, 0.96);
  color: white;
  transform: translate(-50%, -50%);
  box-shadow: 0 26px 80px rgba(0,0,0,0.55);
}
.set-prompt div:first-child {
  display: grid;
  gap: 4px;
}
.set-prompt strong {
  color: var(--gold);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}
.set-prompt span {
  color: #dbe4ef;
  font-size: 18px;
}
.set-prompt-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 8px;
}
.set-prompt-actions button {
  min-height: 68px;
  font-size: 24px;
}
.set-prompt-actions .secondary {
  background: #384253;
}
.control-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.control-actions button {
  min-height: 42px;
  padding: 8px 10px;
  background: #263244;
  font-size: 14px;
}
.control-actions button:first-child {
  background: var(--green);
}
.danger { background: var(--danger); }
body[data-page="control"] .danger {
  background: var(--danger);
}
.match-finished {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  border: 1px solid rgba(240,196,90,0.55);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(240,196,90,0.12);
}
.match-finished strong {
  color: var(--gold);
  font-size: 26px;
}
.match-finished span {
  color: #dbe4ef;
}
.no-match {
  display: grid;
  gap: 8px;
  min-height: calc(100vh - 80px);
  place-content: center;
  border: 1px solid #293241;
  border-radius: 8px;
  padding: 28px;
  background: #111827;
  color: white;
  text-align: center;
}
.no-match strong {
  color: var(--gold);
  font-size: clamp(28px, 5vw, 54px);
  line-height: 1.05;
}
.no-match span {
  color: #cbd5e1;
  font-size: 18px;
}
.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top, #182133 0, #080b10 52%);
}
.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid #293241;
  border-radius: 8px;
  padding: 22px;
  background: #111827;
  color: white;
  box-shadow: 0 24px 80px rgba(0,0,0,0.38);
}
.login-card h1 {
  font-size: 32px;
}
.login-card label {
  color: #cbd5e1;
}
.login-card input {
  border-color: #293241;
  background: #080b10;
  color: white;
}

body[data-page="overlay"] {
  background: transparent;
}
.overlay-shell {
  width: fit-content;
  max-width: 680px;
  min-width: 460px;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: white;
}
.overlay-shell .score-table {
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(12, 16, 24, 0.9);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.overlay-shell .score-table th,
.overlay-shell .score-table td {
  height: 38px;
  border: 1px solid rgba(255,255,255,0.14);
  padding: 5px 10px;
  color: white;
  font-size: 24px;
  line-height: 1;
}
.overlay-shell .score-table th {
  width: 220px;
  background: rgba(255,255,255,0.08);
  font-size: 22px;
  white-space: nowrap;
}
.overlay-shell .score-table td {
  width: 58px;
  color: var(--gold);
  font-weight: 900;
}
.overlay-meta {
  display: inline-block;
  margin: 4px 0 0;
  border-radius: 0 0 6px 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.92);
  color: #111827;
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 760px) {
  .topbar, .control-header { align-items: flex-start; flex-direction: column; }
  .grid, .form-grid, .control-actions { grid-template-columns: 1fr; }
  .match-row { grid-template-columns: 1fr; align-items: stretch; }
  .match-links { justify-content: flex-start; }
  .set-prompt { grid-template-columns: 1fr; }
  .control-board {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .score-stepper {
    grid-template-columns: 72px 1fr 72px;
    min-height: 190px;
  }
  .score-stepper button {
    min-height: 180px;
  }
}
