:root {
  color-scheme: dark;
  --bg: #101010;
  --surface: #1b1b1b;
  --surface-2: #24231f;
  --line: #343434;
  --text: #f5f5f5;
  --muted: #aaa;
  --gold: #f5c518;
  --gold-2: #ffe074;
  --danger: #ff6b6b;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(16,16,16,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.brand-icon { width: 34px; height: 34px; border-radius: 8px; }
nav { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
nav a { text-decoration: none; }
nav a:hover { color: var(--gold); }

.score-app {
  min-height: calc(100vh - 64px);
  padding: clamp(16px, 3vw, 36px);
}
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(310px, 420px) 1fr;
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2vw, 24px);
}
h1, h2, h3, p { margin-top: 0; }
h1, h2 { letter-spacing: .08em; text-transform: uppercase; }
h1 { font-size: clamp(30px, 4vw, 54px); line-height: 1.02; margin-bottom: 12px; }
h2 { font-size: clamp(22px, 2.6vw, 34px); margin-bottom: 10px; }
h3 { font-size: 16px; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.muted { color: var(--muted); line-height: 1.65; }
.section-label { color: var(--muted); text-transform: uppercase; letter-spacing: .18em; font-size: 12px; font-weight: 800; margin-bottom: 10px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0;
}
button, .link-button {
  border: 0;
  min-height: 46px;
  border-radius: var(--radius);
  padding: 0 18px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mode, .ghost {
  background: #202020;
  color: var(--text);
  border: 1px solid var(--line);
}
.mode.active, .primary {
  background: var(--gold);
  color: #101010;
}
.primary:hover { background: var(--gold-2); }
.ghost:hover, .mode:hover { border-color: var(--gold); color: var(--gold); }

.field-grid { display: grid; gap: 10px; }
.input-row { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.input-row input {
  width: 100%;
  background: #111;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  min-height: 48px;
  padding: 0 14px;
  font-size: 16px;
}
.input-row input:focus { outline: 2px solid rgba(245,197,24,.38); border-color: var(--gold); }
.actions, .entry-actions, .store-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions > *, .entry-actions > * { flex: 1; }

.board-header, .history-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}
.goal-pill {
  border: 1px solid rgba(245,197,24,.45);
  color: var(--gold);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  white-space: nowrap;
}
.score-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.score-card {
  min-height: 165px;
  background: #141414;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}
.score-card.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(245,197,24,.2), 0 14px 35px rgba(245,197,24,.09); }
.score-card.leading { background: linear-gradient(180deg, rgba(245,197,24,.11), #141414); }
.team-flag { font-size: 30px; }
.team-name { color: var(--muted); font-weight: 900; letter-spacing: .1em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { color: var(--gold); font-size: clamp(42px, 6vw, 68px); font-weight: 950; line-height: .9; }
.progress {
  height: 5px;
  background: #333;
  border-radius: 999px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--gold); width: 0; }

.entry-card, .history-card {
  margin-top: 14px;
  background: #141414;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.entry-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; color: var(--muted); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
#entryValue { color: var(--gold); font-size: 40px; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.keypad button { background: #202020; color: var(--text); border: 1px solid var(--line); font-size: 18px; }
.keypad .danger { color: var(--danger); }
.round-history {
  max-height: 260px;
  overflow: auto;
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.round-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #101010;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.round-values { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.round-values strong { color: var(--gold); }

.band, .screens {
  padding: clamp(42px, 7vw, 90px) clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
}
.content-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
}
.feature-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.feature-list article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}
.feature-list span, .screens p { color: var(--muted); line-height: 1.55; }
.screens { max-width: 1180px; margin: 0 auto; }
.screen-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}
.screen-strip img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #111;
}
.footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding: 22px clamp(16px, 4vw, 48px);
  color: var(--muted);
}

.winner-dialog {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
}
.winner-dialog::backdrop { background: rgba(0,0,0,.72); }
.winner-card { padding: 22px; position: relative; }
.close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: #101010;
  color: var(--muted);
  border: 1px solid var(--line);
}
.winner-scores { display: grid; gap: 8px; margin-top: 14px; }
.winner-score-row { display: flex; justify-content: space-between; padding: 12px; background: #111; border: 1px solid var(--line); border-radius: var(--radius); }
.domino-mark {
  width: 86px;
  height: 52px;
  border: 5px solid var(--gold);
  border-radius: 14px;
  margin-bottom: 18px;
  position: relative;
}
.domino-mark::before { content: ""; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 4px; background: var(--gold); transform: translateX(-50%); }
.domino-mark span,
.domino-mark span::before,
.domino-mark span::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 14px 0 var(--gold), 0 28px 0 var(--gold), 36px 0 0 var(--gold), 36px 14px 0 var(--gold), 36px 28px 0 var(--gold);
}
.domino-mark span { left: 18px; top: 8px; }

.legal-page { max-width: 900px; margin: 0 auto; padding: clamp(28px, 6vw, 70px) 18px; }
.legal-page h1 { font-size: clamp(28px, 5vw, 48px); }
.legal-page article { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); line-height: 1.65; }
.legal-page h2 { color: var(--gold); font-size: 16px; }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .app-shell, .content-grid { grid-template-columns: 1fr; }
  .feature-list, .screen-strip { grid-template-columns: 1fr; }
  .score-app { padding-inline: 10px; }
  .panel { padding: 14px; }
}
