:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: rgba(23, 25, 29, 0.94);
  --surface-strong: #1b1d22;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f4f2;
  --muted: #a9abb1;
  --silver: #d8d9dc;
  --gold: #d9b55a;
  --gold-soft: rgba(217, 181, 90, 0.16);
  --green: #52c788;
  --red: #e16363;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% -10%, rgba(217, 181, 90, 0.13), transparent 34rem),
    linear-gradient(180deg, #0e1013 0, var(--bg) 44rem);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(217, 181, 90, 0.7); outline-offset: 2px; }

.app-shell { width: min(1120px, 100%); margin: 0 auto; padding: 18px clamp(14px, 3vw, 32px) 32px; }

.brand-header {
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #050607;
  box-shadow: var(--shadow);
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1776 / 887;
  object-fit: contain;
  object-position: center;
  background: #050607;
}

.countdown-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  padding: 13px clamp(18px, 4vw, 34px);
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(217, 181, 90, .16), #111317 38%, #17191d);
}

.countdown-kicker,
.countdown-date { margin: 0; }
.countdown-kicker { color: var(--gold); font-size: .72rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.countdown-date { color: var(--silver); font-size: .78rem; font-weight: 700; text-align: right; }
.countdown-values { display: flex; justify-content: center; gap: clamp(12px, 3.2vw, 30px); font-variant-numeric: tabular-nums; }
.countdown-values span { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 5px; }
.countdown-values strong { color: var(--text); font-size: clamp(1.2rem, 3vw, 1.8rem); line-height: 1; }
.countdown-values small { color: var(--muted); font-size: .66rem; font-weight: 750; text-transform: uppercase; }
.countdown-strip.is-live { grid-template-columns: 1fr; text-align: center; }
.countdown-strip.is-live .countdown-kicker { font-size: .9rem; }
.countdown-strip.is-live .countdown-values,
.countdown-strip.is-live .countdown-date { display: none; }

.event-strip {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 34px) 22px;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, #111317, #1b1d21 58%, #111317);
}

.eyebrow { margin: 0 0 5px; color: var(--gold); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: inherit; font-size: clamp(1.75rem, 4vw, 2.8rem); letter-spacing: -0.02em; }
h2 { margin-bottom: 8px; font-size: clamp(1.45rem, 3vw, 2rem); }
h3 { margin-bottom: 6px; }

.event-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px 18px; margin: 0; color: var(--silver); font-weight: 700; }
.event-meta span + span::before { content: "•"; margin-right: 18px; color: var(--gold); }

.surface { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }

.setup-view { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.8fr); gap: 18px; }
.setup-card { padding: clamp(22px, 4vw, 38px); }
.section-heading > p:last-child { color: var(--muted); }

.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0 22px; }
.name-fields label > span, .starter-choice legend, .mode-choice legend { display: block; margin-bottom: 8px; color: var(--silver); font-size: 0.82rem; font-weight: 750; }
.name-fields input {
  width: 100%;
  min-height: 54px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #0d0f12;
}

.starter-choice, .mode-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 24px; padding: 0; border: 0; }
.mode-choice { margin-bottom: 18px; }
.starter-choice legend, .mode-choice legend { grid-column: 1 / -1; }
.choice-pill { position: relative; }
.choice-pill input { position: absolute; opacity: 0; }
.choice-pill span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 49px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); cursor: pointer; }
.choice-pill span small { color: inherit; font-size: .72rem; font-weight: 650; }
.choice-pill input:checked + span { border-color: var(--gold); color: var(--text); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }

.primary-button, .secondary-button, .danger-button, .text-button, .icon-button, .multiplier, .dart-button {
  border: 0;
  cursor: pointer;
}

.primary-button { width: 100%; min-height: 54px; padding: 12px 20px; border-radius: 12px; color: #111; font-weight: 850; background: linear-gradient(135deg, #f0d286, var(--gold)); box-shadow: 0 10px 30px rgba(217, 181, 90, 0.18); }
.primary-button:hover { filter: brightness(1.07); }
.text-button { padding: 10px 3px; color: var(--gold); background: transparent; font-weight: 750; }
.setup-card > .text-button { display: block; margin: 10px auto 0; }

.rules-teaser { display: flex; align-items: center; gap: 20px; padding: 28px; background: linear-gradient(145deg, rgba(217,181,90,.11), rgba(23,25,29,.96) 45%); }
.rules-teaser p { margin-bottom: 10px; color: var(--muted); line-height: 1.55; }
.rule-number { color: transparent; font-family: Georgia, serif; font-size: clamp(5.5rem, 11vw, 8rem); font-weight: 900; line-height: 0.8; -webkit-text-stroke: 1px rgba(217, 181, 90, 0.65); }

.game-view { display: grid; gap: 16px; }
.match-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; box-shadow: none; }
.match-score { margin: 0; font-size: 1.5rem; font-weight: 900; letter-spacing: 0.08em; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); background: #101216; font-weight: 900; }

.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.player-card { position: relative; overflow: hidden; padding: 20px; box-shadow: none; transition: border-color .18s ease, transform .18s ease; }
.player-card::before { position: absolute; inset: 0 auto 0 0; width: 4px; content: ""; background: transparent; }
.player-card.active { border-color: rgba(217, 181, 90, 0.68); transform: translateY(-1px); }
.player-card.active::before { background: var(--gold); }
.player-card.eliminated { opacity: .58; border-color: rgba(225, 99, 99, .38); }
.player-card.eliminated::before { background: var(--red); }
.player-topline { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.player-index { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .11em; }
.player-card h2 { max-width: 16ch; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.07); font-size: .7rem; font-weight: 850; text-transform: uppercase; }
.active .status-badge { color: #17130a; background: var(--gold); }
.eliminated .status-badge { color: #fff; background: var(--red); }
.remaining-score { margin: 18px 0 16px; font-variant-numeric: tabular-nums; font-size: clamp(3.6rem, 10vw, 6.1rem); font-weight: 900; line-height: .86; letter-spacing: -.06em; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-row div { padding: 10px; border-radius: 10px; background: rgba(255,255,255,.045); }
.stat-row span { display: block; margin-bottom: 3px; color: var(--muted); font-size: .68rem; }
.stat-row strong { font-variant-numeric: tabular-nums; }
.check-note { margin: 13px 0 0; color: var(--muted); font-size: .75rem; }
.check-note.danger { color: #ff9b9b; }

.throw-panel { padding: clamp(18px, 3.5vw, 30px); box-shadow: none; }
.turn-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.turn-header h2 { margin-bottom: 3px; }
.turn-header p:last-child { margin: 0; color: var(--muted); }
.visit-slots { display: flex; gap: 8px; }
.visit-slots span { display: grid; place-items: center; width: clamp(48px, 7vw, 66px); height: clamp(48px, 7vw, 66px); border: 1px solid var(--line); border-radius: 12px; color: var(--silver); background: #0d0f12; font-size: 1.05rem; font-weight: 850; }
.visit-slots span.filled { border-color: rgba(217,181,90,.45); color: var(--gold); }
.live-message { min-height: 24px; margin: 20px 0 14px; padding: 10px 12px; border-left: 3px solid var(--gold); border-radius: 6px; color: var(--silver); background: rgba(217,181,90,.07); }

.multiplier-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; padding: 5px; border-radius: 13px; background: #0d0f12; }
.multiplier { min-height: 44px; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 800; }
.multiplier.active { color: #14110a; background: var(--gold); }

.number-board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; }
.dart-button { min-height: 52px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: linear-gradient(180deg, #272a30, #17191d); font-weight: 850; box-shadow: inset 0 1px rgba(255,255,255,.04); }
.dart-button:hover { border-color: rgba(217,181,90,.55); background: #292c31; }
.dart-button:active { transform: translateY(1px); }
.dart-button small { display: block; margin-top: 2px; color: var(--muted); font-size: .68rem; }
.special-darts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.special-darts .dart-button { min-height: 58px; }
.dart-button.miss { color: #d3d4d8; background: #15171a; }
.dart-button.bull { border-color: rgba(82,199,136,.35); }
.dart-button.bullseye { border-color: rgba(225,99,99,.44); }

.match-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.secondary-button, .danger-button { min-height: 48px; padding: 10px 18px; border-radius: 11px; font-weight: 800; }
.secondary-button { border: 1px solid var(--line); color: var(--silver); background: #17191d; }
.secondary-button:disabled { opacity: .38; cursor: not-allowed; }
.danger-button { color: #ffb5b5; background: rgba(225,99,99,.10); }

footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; padding: 4px 2px; color: #72757c; font-size: .72rem; }

.modal { width: min(720px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow-y: auto; padding: 0; border: 1px solid rgba(255,255,255,.16); border-radius: 20px; color: var(--text); background: #17191d; box-shadow: 0 30px 100px rgba(0,0,0,.65); }
.modal::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(5px); }
.modal form, .outcome-modal > div { position: relative; padding: clamp(22px, 5vw, 38px); }
.modal-close { position: absolute; top: 12px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.06); font-size: 1.55rem; cursor: pointer; }
.rules-list { display: grid; gap: 11px; margin: 20px 0 24px; padding-left: 22px; color: var(--muted); line-height: 1.48; }
.rules-list strong { color: var(--text); }
.outcome-modal { text-align: center; }
.outcome-modal p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.outcome-score { margin: 22px 0; color: var(--gold); font-size: clamp(3.4rem, 12vw, 5.7rem); font-weight: 950; letter-spacing: .05em; }
.outcome-modal .text-button { margin-top: 8px; }

.match-statistics { margin: 0 0 24px; padding-top: 22px; border-top: 1px solid var(--line); text-align: left; }
.statistics-heading h3 { margin-bottom: 14px; }
.statistics-list { display: grid; gap: 10px; }
.leg-stat-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); }
.leg-stat-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.leg-stat-heading h4 { margin: 0; color: var(--gold); font-size: .93rem; }
.leg-stat-heading p { margin: 0; color: var(--silver); font-size: .78rem; font-weight: 750; text-align: right; }
.stat-table-wrap { overflow-x: auto; }
.stat-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; white-space: nowrap; }
.stat-table tr:last-child th, .stat-table tr:last-child td { border-bottom: 0; }
.stat-table thead th { color: var(--muted); font-size: .66rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.stat-table tbody th { max-width: 180px; overflow: hidden; color: var(--text); font-size: .82rem; text-overflow: ellipsis; }
.stat-table tbody td { color: var(--silver); font-size: .8rem; }
.stat-status { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: .64rem; font-weight: 850; }
.stat-status.checkout { color: #0b1c12; background: var(--green); }
.stat-status.eliminated { color: #fff; background: rgba(225,99,99,.75); }
.stat-status.open { color: var(--muted); background: rgba(255,255,255,.07); }

@media (max-width: 800px) {
  .app-shell { padding-top: 10px; }
  .brand-header { border-radius: 17px; }
  .countdown-strip { grid-template-columns: auto 1fr; }
  .countdown-date { grid-column: 1 / -1; text-align: center; }
  .event-strip { align-items: start; flex-direction: column; gap: 8px; }
  .event-meta { justify-content: flex-start; }
  .setup-view { grid-template-columns: 1fr; }
  .rules-teaser { align-items: flex-start; }
  .rule-number { font-size: 5.5rem; }
  .number-board { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 580px) {
  .app-shell { padding-inline: 10px; }
  .event-strip { padding: 14px 16px 17px; }
  .countdown-strip { grid-template-columns: 1fr; gap: 8px; padding: 12px 14px 13px; text-align: center; }
  .countdown-values { gap: 14px; }
  .countdown-values span { grid-template-columns: 1fr; gap: 3px; }
  .countdown-date { grid-column: auto; text-align: center; }
  .event-meta { display: grid; gap: 3px; font-size: .8rem; }
  .event-meta span + span::before { display: none; }
  .name-fields, .player-grid { grid-template-columns: 1fr; }
  .player-card { padding: 16px; }
  .player-card:not(.active) .remaining-score { font-size: 3.1rem; }
  .remaining-score { margin-block: 13px; }
  .turn-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .visit-slots { width: 100%; }
  .visit-slots span { flex: 1; }
  .match-actions { grid-template-columns: 1fr; }
  .leg-stat-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .leg-stat-heading p { text-align: left; }
  .stat-table th, .stat-table td { padding-inline: 9px; }
  .rules-teaser { padding: 22px; }
  footer { flex-direction: column; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
