:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #62706d;
  --line: #dce5df;
  --paper: #ffffff;
  --background: #f4f7f2;
  --green: #153c36;
  --green-2: #245b51;
  --lime: #d9f05a;
  --lime-soft: #f1fac4;
  --orange: #e97c43;
  --red: #b93737;
  --blue: #2763b0;
  --shadow: 0 14px 35px rgba(21, 60, 54, 0.10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-width: 320px; color: var(--ink); background: radial-gradient(circle at 5% -10%, #e4efdf 0, transparent 28rem), var(--background); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(39, 99, 176, .28); outline-offset: 2px; }
a { color: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.025em; }
h1 { font-size: clamp(1.85rem, 4vw, 3.6rem); line-height: 1.02; }
h2 { font-size: clamp(1.45rem, 2.4vw, 2.15rem); margin-bottom: .45rem; }
h3 { margin-bottom: .65rem; }
small { color: var(--muted); }
code { background: #eef2ef; padding: .12rem .3rem; border-radius: 5px; }

.shell { min-height: 100vh; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: 1rem clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid rgba(220, 229, 223, .85); background: rgba(255,255,255,.84); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 30; }
.brand { display: inline-flex; gap: .7rem; align-items: center; font-weight: 850; font-size: 1.1rem; text-decoration: none; color: var(--green); white-space: nowrap; }
.brand-ball { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--green); background: var(--lime); font-size: .85rem; box-shadow: inset 0 0 0 5px rgba(21,60,54,.08); }
.header-actions, .section-actions, .hero-actions, .modal-actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.button { border: 1px solid transparent; border-radius: 11px; padding: .68rem 1rem; font-weight: 750; background: var(--paper); color: var(--ink); transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; box-shadow: 0 8px 20px rgba(21,60,54,.18); }
.button.primary:hover { background: var(--green-2); }
.button.secondary { background: var(--lime); color: var(--green); }
.button.ghost { background: transparent; border-color: var(--line); }
.button.danger { background: var(--red); color: white; }
.button.danger.ghost { background: transparent; color: var(--red); border-color: #efc6c6; }
.button.large { padding: .88rem 1.2rem; }
.button-stack { display: grid; gap: .7rem; }
.text-button { border: 0; padding: .2rem; background: transparent; color: var(--green-2); font-weight: 750; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); display: inline-grid; place-items: center; font-size: 1.2rem; }
.icon-button.danger { color: var(--red); }

.dashboard-main { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 4rem; }
.hero { min-height: 480px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); align-items: center; gap: clamp(2rem, 8vw, 7rem); border-radius: 28px; padding: clamp(2rem, 6vw, 5rem); color: white; overflow: hidden; position: relative; background: linear-gradient(135deg, #11352f 0%, #1f5a4f 62%, #49745f 100%); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; right: -180px; top: -180px; border: 55px solid rgba(217,240,90,.13); }
.hero h1 { max-width: 800px; margin: .6rem 0 1.2rem; }
.hero p { font-size: 1.14rem; line-height: 1.7; color: #d8e5df; max-width: 720px; }
.hero .eyebrow { color: var(--lime); }
.eyebrow { color: var(--green-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 850; }
.hero-board { position: relative; z-index: 1; padding: 2rem; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.09); border-radius: 24px; backdrop-filter: blur(12px); transform: rotate(1deg); }
.mini-match { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: white; color: var(--ink); padding: 1rem; margin: .65rem 0; border-radius: 12px; box-shadow: 0 8px 25px rgba(0,0,0,.13); }
.mini-match.winner { border-left: 6px solid var(--lime); }
.mini-match.final { margin-left: 4rem; background: var(--lime); color: var(--green); }
.connector { width: 3.6rem; height: 2.6rem; border-right: 2px solid rgba(255,255,255,.6); border-top: 2px solid rgba(255,255,255,.6); margin: -1rem 0 -1rem auto; }
.dashboard-section { margin-top: 3.5rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.25rem; margin-bottom: 1.4rem; }
.section-heading p { margin: 0; color: var(--muted); }
.tournament-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.tournament-card { min-height: 220px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; position: relative; box-shadow: 0 5px 18px rgba(21,60,54,.05); transition: transform .15s ease, box-shadow .15s ease; }
.tournament-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-open { position: absolute; inset: 0; border: 0; background: transparent; border-radius: inherit; }
.card-kicker { font-size: .75rem; color: var(--green-2); text-transform: uppercase; font-weight: 800; letter-spacing: .08em; }
.tournament-card h3 { margin: .65rem 0 .35rem; font-size: 1.3rem; }
.tournament-card p { color: var(--muted); }
.card-stats { display: flex; gap: 1.2rem; margin-top: 1.35rem; color: var(--muted); font-size: .88rem; }
.card-stats strong { color: var(--ink); }
.card-date { position: absolute; bottom: 1.25rem; right: 1.25rem; color: var(--muted); font-size: .82rem; }
.feature-strip { margin-top: 3.5rem; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.feature-strip > div { padding: 1.2rem 1.4rem; display: grid; gap: .25rem; border-right: 1px solid var(--line); }
.feature-strip > div:last-child { border-right: 0; }
.feature-strip span { color: var(--muted); font-size: .87rem; }
.empty-state { padding: 4rem 1.5rem; text-align: center; border: 1px dashed #c7d4cd; border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.5); }
.empty-state.large { min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.empty-state h2, .empty-state h3 { color: var(--ink); }
.empty-icon { width: 62px; height: 62px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; background: var(--lime-soft); color: var(--green); font-size: 2rem; }

.tournament-header { position: relative; }
.tournament-title { flex: 1; text-align: center; }
.tournament-title h1 { font-size: 1.35rem; margin: .2rem 0 0; }
.warning-banner { padding: .8rem clamp(1rem, 4vw, 3.5rem); background: #fff3d8; color: #75511c; border-bottom: 1px solid #eedaa9; }
.tabs { position: sticky; top: 0; z-index: 25; display: flex; gap: .25rem; padding: 0 clamp(1rem, 4vw, 3.5rem); overflow-x: auto; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); }
.tab { padding: 1rem .85rem .82rem; white-space: nowrap; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 750; }
.tab.active { color: var(--green); border-bottom-color: var(--lime); }
.tab span { display: inline-flex; min-width: 21px; justify-content: center; padding: .1rem .35rem; margin-left: .25rem; border-radius: 12px; background: #edf2ef; font-size: .72rem; }
.tournament-main { width: min(1600px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.page-section { display: grid; gap: 1.25rem; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.35rem; box-shadow: 0 4px 15px rgba(21,60,54,.035); }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2, .panel-heading h3, .panel-heading p { margin-bottom: .15rem; }
.panel-heading p { color: var(--muted); }
.panel-empty { min-height: 210px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: .35rem; color: var(--muted); }
.panel-empty strong { color: var(--ink); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat-card { padding: 1.2rem; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); display: grid; gap: .2rem; }
.stat-card > span { color: var(--muted); font-size: .78rem; text-transform: uppercase; font-weight: 800; letter-spacing: .07em; }
.stat-card strong { font-size: 1.65rem; color: var(--green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two-column { display: grid; grid-template-columns: 1.35fr .65fr; gap: 1rem; }
.next-list { display: grid; gap: .55rem; }
.compact-match { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; text-align: left; gap: .8rem; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.compact-match:hover { border-color: #9eb3a8; }
.compact-match strong, .compact-match small { display: block; }
.compact-match em { color: var(--muted); font-weight: 500; font-style: normal; }
.match-number { display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 .45rem; border-radius: 8px; background: var(--green); color: white; font-weight: 850; font-size: .78rem; }
.chevron { font-size: 1.5rem; color: var(--muted); }
.summary-list { margin: 0; display: grid; gap: .2rem; }
.summary-list > div { padding: .75rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; }
.summary-list > div:last-child { border-bottom: 0; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 700; }
.podium { display: grid; gap: .65rem; }
.podium-row { display: flex; align-items: center; gap: .8rem; padding: .85rem; border-radius: 12px; background: #f7f9f7; }
.place, .rank { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--lime); color: var(--green); font-weight: 900; }
.checklist-panel { padding-bottom: .8rem; }
.checklist { display: grid; grid-template-columns: repeat(5, 1fr); gap: .7rem; }
.check-item { display: flex; gap: .7rem; padding: .9rem; border-radius: 12px; background: #f6f8f6; color: var(--muted); }
.check-item.done { background: var(--lime-soft); color: var(--green); }
.check-mark { font-size: 1.25rem; }
.check-item strong, .check-item small { display: block; }

.entry-layout { display: grid; grid-template-columns: minmax(300px, .6fr) minmax(520px, 1.4fr); gap: 1rem; align-items: start; }
.stacked-form { display: grid; gap: .95rem; }
.stacked-form label, .match-form label { display: grid; gap: .4rem; color: #33413e; font-size: .85rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd7d0; background: white; color: var(--ink); border-radius: 10px; padding: .7rem .75rem; }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.help-text { color: var(--muted); font-size: .85rem; line-height: 1.5; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: .4rem 0; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-heading { padding: 1.25rem 1.25rem 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--muted); background: #f7f9f7; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
th, td { padding: .82rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
.withdrawn { opacity: .48; text-decoration: line-through; }
.seed-input { width: 64px; padding: .42rem; }
.checkin { border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); padding: .38rem .65rem; font-size: .75rem; font-weight: 750; }
.checkin.checked { border-color: #a7c56a; background: var(--lime-soft); color: var(--green); }
.row-actions { white-space: nowrap; text-align: right; }

.bracket-page { gap: 2rem; }
.bracket-section > h3 { margin: 0 0 .85rem .25rem; }
.bracket-scroll { overflow-x: auto; padding: .2rem .2rem 1.2rem; }
.bracket-columns { display: flex; gap: 1rem; align-items: stretch; min-width: max-content; }
.bracket-round { width: 300px; min-width: 300px; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.58); }
.bracket-round h4 { position: sticky; top: 0; margin: 0 0 .8rem; padding: .25rem .1rem .65rem; border-bottom: 1px solid var(--line); color: var(--green); }
.round-matches { min-height: 100%; display: flex; flex-direction: column; justify-content: space-around; gap: 1rem; }
.match-card { width: 100%; text-align: left; padding: .7rem; border: 1px solid #cbd7d0; border-radius: 12px; background: white; box-shadow: 0 4px 10px rgba(21,60,54,.05); }
.match-card:hover { border-color: #87a397; transform: translateY(-1px); }
.match-card.status-ready { border-left: 5px solid var(--lime); }
.match-card.status-in_progress { border-left: 5px solid var(--orange); }
.match-card.status-complete { border-left: 5px solid var(--green); }
.match-card.status-advanced { opacity: .72; }
.match-meta, .match-footer { display: flex; justify-content: space-between; gap: .5rem; align-items: center; color: var(--muted); font-size: .7rem; }
.match-side { min-height: 38px; display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .55rem .45rem; border-bottom: 1px solid #edf1ee; }
.match-side.winner { background: var(--lime-soft); color: var(--green); font-weight: 800; }
.match-footer { padding: .55rem .3rem .1rem; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: .22rem .5rem; background: #edf1ee; color: var(--muted); font-size: .68rem; font-weight: 800; }
.status-pill.ready { background: var(--lime-soft); color: var(--green); }
.status-pill.in_progress { background: #fff0e7; color: #91461d; }
.status-pill.complete { background: #dfece7; color: var(--green); }
.conflict-row { background: #fff3f3; }
.muted { color: var(--muted); }
.qualifying { background: #f7fbdc; }
.standings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 1rem; }
.standings-panel { padding: 0; overflow: hidden; }
.standings-panel h3 { padding: 1.1rem 1.1rem .2rem; }

.display-page { min-height: calc(100vh - 160px); padding: clamp(1rem, 3vw, 2.5rem); border-radius: 24px; background: #102e2a; color: white; }
.display-header { display: flex; justify-content: space-between; gap: 2rem; align-items: center; padding-bottom: 1.5rem; border-bottom: 1px solid rgba(255,255,255,.16); }
.display-header h2 { margin: .2rem 0 0; font-size: clamp(1.7rem, 4vw, 3rem); }
.display-header .eyebrow { color: var(--lime); }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 7px rgba(233,124,67,.13); margin-right: .5rem; }
.display-section { margin-top: 2rem; }
.display-section h3 { color: #c5d6d0; text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; }
.court-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.court-card { padding: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: 16px; background: #17443d; color: white; text-align: left; }
.court-name { display: flex; justify-content: space-between; padding: .8rem 1rem; background: rgba(0,0,0,.18); font-weight: 850; }
.court-player { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid rgba(255,255,255,.1); font-size: 1.15rem; }
.court-player.winner { color: var(--lime); }
.court-score { padding: .75rem 1rem; color: #c5d6d0; }
.up-next-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .75rem; }
.display-empty { padding: 2rem; color: #9eb6ae; border: 1px dashed rgba(255,255,255,.2); border-radius: 16px; }

.settings-grid { display: grid; grid-template-columns: minmax(520px, 1.4fr) minmax(280px, .6fr); gap: 1rem; align-items: start; }
.settings-side { display: grid; gap: 1rem; }
.toggle-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.toggle-row label, .toggle-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.toggle-row input, .toggle-label input { width: auto; }
.danger-panel { border-color: #efc6c6; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(10,27,24,.72); backdrop-filter: blur(5px); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow: auto; background: white; border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.wide { width: min(760px, 100%); }
.modal > header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.25rem; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.modal > header h2 { margin: 0; font-size: 1.3rem; }
.modal-form, .match-form, .confirm-body { padding: 1.25rem; }
.modal-actions { justify-content: flex-end; padding-top: .4rem; }
.modal-actions.split { justify-content: space-between; }
.modal-actions.split > div { display: flex; gap: .6rem; }
.match-form { display: grid; gap: 1rem; }
.match-modal-heading { display: flex; align-items: center; gap: .8rem; }
.match-modal-heading strong, .match-modal-heading small { display: block; }
.competitor-versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: .75rem; }
.competitor-versus em { align-self: center; color: var(--muted); font-style: normal; }
.competitor { padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: #f8faf8; display: grid; gap: .35rem; }
.competitor > span { font-size: .72rem; color: var(--muted); font-weight: 850; }
fieldset { border: 1px solid var(--line); border-radius: 13px; padding: 1rem; }
legend { padding: 0 .4rem; font-weight: 800; }
.score-grid { display: grid; gap: .55rem; margin-bottom: .8rem; }
.game-score { display: grid; grid-template-columns: 1fr 70px auto 70px; align-items: center; gap: .5rem; }
.game-score input { text-align: center; font-weight: 850; }
.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); z-index: 200; padding: .8rem 1rem; color: white; background: #182b27; border-radius: 999px; box-shadow: var(--shadow); font-weight: 750; }

@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-board { max-width: 540px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column, .entry-layout, .settings-grid { grid-template-columns: 1fr; }
  .checklist { grid-template-columns: repeat(2, 1fr); }
  .tournament-title { text-align: left; }
}

@media (max-width: 720px) {
  .site-header { position: relative; align-items: flex-start; flex-wrap: wrap; }
  .tournament-header .tournament-title { order: 3; flex-basis: 100%; }
  .header-actions { margin-left: auto; }
  .header-actions .button.ghost { display: none; }
  .dashboard-main, .tournament-main { width: min(100% - 1rem, 1600px); padding-top: 1rem; }
  .hero { padding: 2rem 1.25rem; border-radius: 20px; }
  .hero-board { display: none; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .feature-strip { grid-template-columns: 1fr; }
  .feature-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .feature-strip > div:last-child { border-bottom: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card strong { font-size: 1.3rem; }
  .checklist { grid-template-columns: 1fr; }
  .standings-grid { grid-template-columns: 1fr; }
  .display-header { align-items: flex-start; flex-direction: column; }
  .modal-actions.split { align-items: stretch; flex-direction: column; }
  .modal-actions.split > div { justify-content: flex-end; }
}

@media (max-width: 470px) {
  .stats-grid { grid-template-columns: 1fr; }
  .button { padding: .62rem .78rem; }
  .competitor-versus { grid-template-columns: 1fr; }
  .competitor-versus em { text-align: center; }
  .game-score { grid-template-columns: 1fr 58px auto 58px; }
}

@media print {
  body { background: white; }
  .site-header, .tabs, .section-actions, .warning-banner, .button, .text-button, .toast { display: none !important; }
  .tournament-main { width: 100%; padding: 0; }
  .page-section > *:not(.bracket-section), .bracket-page > .section-heading { display: none; }
  .bracket-section { page-break-after: always; }
  .bracket-scroll { overflow: visible; }
  .bracket-columns { transform-origin: top left; }
  .bracket-round { break-inside: avoid; background: white; box-shadow: none; }
  .match-card { box-shadow: none; }
}
