:root {
  --bg: #121213;
  --bg-soft: #1b1b1d;
  --card: #191a1c;
  --line: #2c2d30;
  --text: #ececee;
  --muted: #93949a;
  --accent: #c23a4b;        /* lighter red, better contrast */
  --accent-soft: rgba(194, 58, 75, 0.18);
  --gold: #b08d2d;          /* deep antique gold (not yellow) */
  --gold-soft: rgba(176, 141, 45, 0.14);
  --danger: #d64a3f;
  --radius: 4px;            /* minimal */
  --radius-sm: 3px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f4;
    --bg-soft: #ececea;
    --card: #ffffff;
    --line: #e3e3e0;
    --text: #1a1a1a;
    --muted: #6b6b6b;
    --accent: #b23241;
    --accent-soft: rgba(178, 50, 65, 0.12);
    --gold: #8a6d1f;
    --gold-soft: rgba(138, 109, 31, 0.12);
    --danger: #a52834;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  }
  .text-input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

.svg-sprite { position: absolute; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.spacer { flex: 1; }

/* SVG icons */
.ic {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.14em;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.leader-badge .ic { stroke: var(--accent); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}
.brand .ic {
  width: 1.15em;
  height: 1.15em;
  stroke: var(--accent);
}

/* Buttons */
.ghost-btn, .primary-btn, .danger-btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.ghost-btn {
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.ghost-btn:hover { background: var(--bg-soft); }
.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary-btn:hover { filter: brightness(1.08); }
.danger-btn {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.danger-btn:hover { background: var(--accent-soft); }
.ghost-btn:active, .primary-btn:active, .danger-btn:active { transform: scale(0.98); }

/* Scoreboard */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
}
.player-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 22px 34px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}
.player-card.leader { border-color: var(--accent); }
.leader-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.leader-badge span { color: var(--accent); }
.player-card.leader .leader-badge { display: flex; }
.player-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
}
.player-score {
  font-size: 4.6rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}
.vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 4px;
}
.tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 4px 0 0;
}
.tagline .pt {
  font-size: 0.48rem;
  margin-left: 3px;
  opacity: 0.8;
  vertical-align: middle;
}
.tagline .dot { margin: 0 4px; }

/* Dashboard */
.dashboard { margin-top: 38px; }
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0 0 14px;
}
.dash-actions { display: flex; gap: 8px; }
.filters { display: flex; gap: 6px; }
.filter-chip {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.filter-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Breakdown */
.breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.bd-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.bd-name { font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; }
.bd-total { color: var(--accent); }
.bd-stats { display: grid; gap: 7px; }
.bd-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--muted);
}
.bd-stat b { color: var(--text); font-weight: 600; }

/* Events list */
.events-list { display: grid; gap: 12px; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}
.event-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: pop 0.16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.event-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.event-title { font-weight: 700; font-size: 1.02rem; }
.event-meta { color: var(--muted); font-size: 0.8rem; margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.owner-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.event-pts {
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.event-actions { display: flex; gap: 6px; margin-top: 4px; }
.mini-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.mini-btn:hover { color: var(--text); background: var(--bg-soft); }
.people-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ptag {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: inline-flex;
  gap: 7px;
  align-items: center;
}
.ptag .badges {
  display: inline-flex;
  gap: 5px;
  color: var(--accent);
}
.ptag .badges .ic { width: 14px; height: 14px; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
  animation: fade 0.12s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  animation: rise 0.16s ease;
}
.modal-wide { max-width: 540px; max-height: 90vh; overflow-y: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal h2 { margin: 0 0 4px; font-size: 1.2rem; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.points-preview {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-weight: 800;
  color: var(--accent);
}
.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 22px;
}

/* Form fields */
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.text-input {
  width: 100%;
  font: inherit;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.text-input:focus { border-color: var(--accent); }
.text-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.75);
  cursor: pointer;
}
.field-row { display: flex; gap: 12px; }
.field { flex: 1; }
.field-date { flex: 0 0 150px; }

.segmented {
  display: flex;
  gap: 6px;
  background: var(--bg-soft);
  padding: 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.seg-btn {
  flex: 1;
  font: inherit;
  font-weight: 700;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn.active { background: var(--accent); color: #fff; }

.people-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 8px;
}
.people-head .field-label { margin: 0; }
.people-list { display: grid; gap: 10px; }
.person-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  animation: pop 0.14s ease;
}
.person-row .person-name { grid-column: 1; }
.person-row .chips { grid-column: 1 / -1; order: 3; }
.person-row .row-remove { grid-column: 2; grid-row: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s ease;
}
.chip .pt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.62rem;
  margin-left: 1px;
}
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.row-remove {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.row-remove:hover { color: var(--danger); border-color: var(--danger); }
.add-person-btn {
  margin-top: 10px;
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.add-person-btn:hover { color: var(--accent); border-color: var(--accent); }

.error { color: var(--danger); font-size: 0.85rem; margin: 8px 0 0; }

@media (max-width: 480px) {
  .player-score { font-size: 3.6rem; }
  .breakdown { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; }
  .field-date { flex: 1; }
  .manage-label { display: none; }
}
