:root {
  color-scheme: light;
  --ink: #163638;
  --muted: #668083;
  --surface: #ffffff;
  --line: #d8e5e3;
  --background: #eef6f3;
  --primary: #0c6b68;
  --primary-dark: #084b4b;
  --accent: #ee9b4b;
  --danger: #bb4f4f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at top right, #d7f0e8, transparent 36rem), var(--background); }
.app-shell { width: min(100% - 28px, 760px); margin: 0 auto; padding: 28px 0 48px; }
.hero { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 18px 4px 26px; }
.hero-actions { display: grid; justify-items: end; gap: 8px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 8vw, 3.5rem); letter-spacing: -0.06em; line-height: 1; }
h2 { font-size: 1.25rem; letter-spacing: -0.03em; }
.subtitle { color: var(--muted); margin-top: 10px; }
.eyebrow { color: var(--primary); font-weight: 800; font-size: .72rem; letter-spacing: .14em; margin-bottom: 8px; }
.status-chip, .count-badge { border-radius: 999px; padding: 8px 11px; font-size: .75rem; font-weight: 800; background: #d9ece6; color: var(--primary-dark); white-space: nowrap; }
.card { background: rgba(255,255,255,.94); border: 1px solid rgba(216,229,227,.9); border-radius: 24px; padding: 20px; margin-bottom: 16px; box-shadow: 0 16px 40px rgba(20, 73, 66, .07); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.muted { color: var(--muted); font-size: .8rem; text-align: right; }
textarea, select, input[type="number"] { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #fbfefd; color: var(--ink); font: inherit; }
textarea { resize: vertical; min-height: 150px; padding: 14px; line-height: 1.6; }
select, input[type="number"] { padding: 10px 10px; min-height: 42px; }
textarea:focus, select:focus, input[type="number"]:focus { outline: 3px solid rgba(12,107,104,.15); border-color: var(--primary); }
.button-row { display: flex; gap: 10px; margin-top: 12px; }
.button { border: 0; border-radius: 14px; min-height: 46px; padding: 0 16px; font: inherit; font-weight: 800; cursor: pointer; transition: transform .15s ease, opacity .15s ease; }
.button:active { transform: scale(.98); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { background: var(--primary); color: #fff; }
.button-accent { width: 100%; margin-top: 12px; background: var(--accent); color: #3d2411; }
.button-ghost { background: #edf4f2; color: var(--primary-dark); }
.preview-box { margin-top: 14px; padding: 14px; border-radius: 15px; background: #f1f8f5; border: 1px dashed #a9cbc2; }
.preview-box > strong { display: block; margin-bottom: 10px; }
.preview-list, .score-list, .match-list { display: grid; gap: 8px; }
.preview-item, .score-row, .match-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; background: #fff; }
.preview-item span:first-child { color: var(--muted); min-width: 24px; }
.score-row { display: grid; grid-template-columns: 26px 1fr 80px 54px 54px; column-gap: 8px; align-items: center; min-height: 54px; }
.score-row.score-header { min-height: 34px; background: #edf4f2; border-color: transparent; font-size: .74rem; }
.score-row.score-header .rank, .score-row.score-header .player-name, .score-row.score-header .record { font-weight: 800; color: var(--muted); }
.score-row.score-header .score { font-size: .74rem; font-weight: 800; color: var(--muted); }
.rank { width: 26px; color: var(--muted); font-weight: 800; }
.player-name { flex: 1; font-weight: 750; }
.record { color: var(--muted); font-size: .76rem; }
.score { min-width: 45px; text-align: center; font-size: 1.2rem; font-weight: 900; }
.score.positive { color: var(--primary); }
.score.negative { color: var(--danger); }
.score.zero { color: var(--muted); }
.match-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 52px; gap: 12px; }
.match-form label { display: grid; min-width: 0; gap: 6px; font-size: .82rem; font-weight: 750; color: var(--muted); }
.match-form select, .match-form input[type="number"] { min-width: 0; height: 42px; }
.match-form input[type="number"] { min-height: 42px; padding: 4px 8px; border-radius: 10px; font-size: .95rem; text-align: center; }
.match-form .button { grid-column: 1 / -1; margin-top: 4px; }
.match-row { display: grid; grid-template-columns: 34px 1fr auto auto; column-gap: 12px; align-items: center; }
.match-number { color: var(--primary); font-weight: 900; min-width: 34px; }
.match-teams { flex: 1; font-size: .9rem; line-height: 1.5; }
.team-win { color: var(--primary-dark); font-weight: 800; }
.team-loss { color: var(--danger); font-weight: 800; }
.match-score { font-size: .95rem; font-weight: 900; color: var(--primary-dark); text-align: right; min-width: 52px; }
.delete-match { border: 0; background: #fff0ed; color: var(--danger); border-radius: 10px; padding: 8px 9px; cursor: pointer; font-weight: 800; }
.empty-state { padding: 22px 4px 4px; color: var(--muted); text-align: center; }
.app-message { min-height: 24px; padding: 0 6px; color: var(--primary-dark); font-size: .9rem; text-align: center; }
.app-message.error { color: var(--danger); }
.hidden { display: none; }
/* Match the URL mode before the module and Supabase finish loading. */
html:not(.event-page) .scoreboard-card,
html:not(.event-page) .match-card,
html:not(.event-page) .history-card,
html.event-page .import-card { display: none; }
@media (max-width: 520px) {
  .app-shell { width: min(100% - 20px, 760px); padding-top: 14px; }
  .hero { padding-top: 10px; flex-direction: column; }
  .status-chip { align-self: flex-start; }
  .hero-actions { justify-items: start; }
  .card { padding: 16px; border-radius: 19px; }
  .section-heading { flex-direction: column; }
  .muted { text-align: left; }
}
