/* ธีมสีอ้างอิงจากเว็บ ร่มเมาคัพ ครั้งที่ 12 (navy / blue / green / magenta) */
:root {
  --navy-900: #04122b;
  --navy-800: #061c3f;
  --navy-700: #0a2a5e;
  --blue-600: #1565d8;
  --blue-500: #2f80ed;
  --blue-400: #3d8bfd;
  --blue-100: #e8f1fd;
  --blue-050: #f6f9ff;
  --green-600: #12653a;
  --green-500: #1b8a4b;
  --green-100: #e6f6ec;
  --pink-600: #c2185b;
  --pink-500: #e91e63;
  --pink-100: #fde7ef;
  --ink: #1b2430;
  --muted: #6b7a90;
  --line: #dfe6ef;
  --line-soft: #eef3f9;
  --surface: #ffffff;
  --bg: #f4f7fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(10, 42, 94, .08);
  --shadow-sm: 0 2px 8px rgba(10, 42, 94, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 300;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

a { color: var(--blue-600); }
a:hover { color: var(--navy-700); }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; margin: 0 0 .4rem; }
p { margin: 0 0 .5rem; }

.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.spacer { flex: 1; }
.is-hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--navy-700); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:where(a, button, input, select, textarea, .tab):focus-visible {
  outline: 3px solid var(--blue-400);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700) 60%, var(--blue-600));
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .9rem 0 .7rem; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark { font-size: 1.7rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 1.15rem; font-weight: 600; letter-spacing: .01em; }
.brand-text small { color: #9dc6ff; font-size: .8rem; }

.header-meta { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.header-meta .chip { background: rgba(255, 255, 255, .14); color: #dbe9ff; border-color: transparent; }

.tabs {
  display: flex; gap: .25rem; overflow-x: auto; padding-bottom: 0;
  scrollbar-width: thin;
}
.tab {
  appearance: none; background: transparent; border: 0; color: #a9c6ea;
  font-family: inherit; font-size: .92rem; font-weight: 400;
  padding: .65rem .95rem; cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tab.is-active { color: #fff; font-weight: 500; border-bottom-color: var(--pink-500); }
.tab-lock { font-size: .72rem; opacity: .75; }

/* หน้าผู้ดูแลใช้โทนต่างจากหน้าผู้ชม เพื่อไม่ให้สับสนว่ากำลังอยู่หน้าไหน */
body.is-admin-page .app-header {
  background: linear-gradient(135deg, #2b0b22, var(--navy-800) 45%, var(--pink-600));
}
body.is-admin-page .tab.is-active { border-bottom-color: #ffd166; }

.app-main { padding: 1.4rem 0 2.5rem; }
/* หน้าตารางแข่งต้องกว้างพอวาง 4 สนามในแถวเดียว */
body.wide-view .app-main, body.wide-view .header-inner, body.wide-view .tabs { width: min(1720px, 100% - 2rem); }
.view > *:first-child { margin-top: 0; }

.app-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.2rem 0 2rem;
  font-size: .85rem;
  color: var(--muted);
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

#visitorCounter {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  background: var(--blue-050);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--navy-700);
}

.visitor-icon {
  font-size: 1rem;
  line-height: 1;
}

.visitor-label {
  font-weight: 400;
}

.visitor-count {
  font-weight: 600;
  color: var(--blue-600);
  font-variant-numeric: tabular-nums;
}

.visitor-divider {
  margin: 0 .2rem;
  color: var(--muted);
}

.visitor-unique {
  font-weight: 600;
  color: var(--green-600);
  font-variant-numeric: tabular-nums;
}

/* ---------- building blocks ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
}

.block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .7rem; flex-wrap: wrap; margin-bottom: .8rem;
  padding-bottom: .6rem; border-bottom: 1px solid var(--line-soft);
}
.block-head h3 { margin: 0; font-size: 1.02rem; }

.section-title {
  font-size: 1.05rem; margin: 1.6rem 0 .8rem;
  padding-left: .6rem; border-left: 4px solid var(--pink-500);
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .78rem; padding: .2rem .6rem; border-radius: 999px;
  background: var(--blue-100); color: var(--navy-700); border: 1px solid #cfe0f7;
  white-space: nowrap;
}
.chip-done { background: var(--green-100); color: var(--green-600); border-color: #bfe6cd; }
.header-meta .chip-admin { background: var(--pink-500); color: #fff; font-weight: 500; }

.pill {
  display: inline-block; font-size: .78rem; padding: .15rem .55rem;
  border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
  color: #43516a; margin: .15rem .25rem .15rem 0;
}

.tag { font-size: .7rem; padding: .05rem .4rem; border-radius: 5px; }
.tag-warn { background: var(--pink-100); color: var(--pink-600); }

.note {
  border-left: 4px solid var(--blue-500);
  background: var(--blue-050);
  font-size: .88rem;
  color: #43516a;
  padding: .8rem 1rem;
}
.note-warn { border-left-color: var(--pink-500); background: var(--pink-100); color: var(--pink-600); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(10, 42, 94, .08); border-radius: 5px; padding: .05rem .35rem; font-size: .92em;
}

.empty {
  padding: 1.4rem; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}

.tick-list { margin: .4rem 0; padding-left: 1.1rem; font-size: .86rem; color: #43516a; }
.tick-list li { margin-bottom: .2rem; }

.progress {
  height: 8px; border-radius: 999px; background: var(--line-soft);
  overflow: hidden; margin: .5rem 0;
}
.progress > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-500), var(--green-500));
  transition: width .3s ease;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none; font-family: inherit; font-size: .88rem; font-weight: 500;
  padding: .48rem .95rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; background: var(--blue-100); color: var(--navy-700);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem;
}
a.btn:hover { text-decoration: none; }
.btn:hover { background: #dbe9ff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { font-size: .8rem; padding: .34rem .7rem; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-ghost { background: transparent; border-color: var(--line); color: #43516a; }
.btn-ghost:hover { background: var(--bg); border-color: #c6dbf7; color: var(--navy-700); }
.btn-danger-ghost { background: transparent; border-color: #f3c6d6; color: var(--pink-600); }
.btn-danger-ghost:hover { background: var(--pink-100); }
.header-meta .btn-ghost { border-color: rgba(255, 255, 255, .3); color: #dbe9ff; }
.header-meta .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.icon-btn {
  appearance: none; background: transparent; border: 0; font-size: 1.1rem;
  color: var(--muted); cursor: pointer; padding: .2rem .4rem; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: #43516a; margin-bottom: .6rem; }
.field > span { font-weight: 400; }
.field-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 150px; }
.field-grow { flex: 2 1 220px; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font-family: inherit; font-size: .9rem; font-weight: 300; color: var(--ink);
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; width: 100%;
}
textarea { resize: vertical; }

.filter-bar { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { flex: 1 1 160px; margin-bottom: 0; }

.form-msg { font-size: .84rem; min-height: 1.2rem; margin: .3rem 0; }
.form-msg.is-error { color: var(--pink-600); }

/* ---------- hero / stats ---------- */
.hero {
  background: linear-gradient(135deg, #fff, var(--blue-050));
  border-color: #cfe0f7;
}
.hero h1 { font-size: 1.5rem; }
.eyebrow {
  font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--blue-600); font-weight: 500; margin-bottom: .2rem;
}

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .7rem; margin: 1rem 0 .4rem;
}
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .7rem; text-align: center;
}
.stat strong { display: block; font-size: 1.5rem; font-weight: 600; color: var(--navy-700); line-height: 1.2; }
.stat span { font-size: .76rem; color: var(--muted); }

.cat-card { margin-bottom: 0; display: flex; flex-direction: column; }
.cat-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cat-card-head h3 { font-size: 1.05rem; margin: 0; }
.cat-groups { margin-top: auto; padding-top: .4rem; }

/* ---------- match card ---------- */
.match-list { display: grid; gap: .55rem; }

.match {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; padding: .6rem .8rem;
  border-left: 4px solid var(--line);
}
.match.is-done { border-left-color: var(--green-500); background: #fcfefd; }
.match.is-draw { border-left-color: var(--blue-500); background: #fcfdff; }
.match.is-partial { border-left-color: #f2a93b; }
.match.is-pending { border-left-color: #c6dbf7; }

.match-main {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: .6rem;
}
.match-side { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.match-side:last-child { justify-content: flex-end; }
.match-team { font-size: .95rem; overflow-wrap: anywhere; }
.match-side.is-winner .match-team { font-weight: 600; color: var(--green-600); }
.match-sets {
  font-weight: 600; font-size: 1.05rem; color: var(--navy-700);
  background: var(--blue-100); border-radius: 8px; padding: 0 .5rem; min-width: 1.8rem; text-align: center;
}
.match-side.is-winner .match-sets { background: var(--green-100); color: var(--green-600); }
.match-vs {
  font-size: .82rem; color: var(--muted); text-align: center;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pending { color: var(--muted); font-style: italic; }

.match-foot {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .45rem; padding-top: .4rem; border-top: 1px dashed var(--line-soft);
}
.match-foot .btn { margin-left: auto; }
.match-meta { font-size: .78rem; color: var(--muted); margin: 0; }

.badge {
  font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; font-weight: 500;
}
.badge-done { background: var(--green-100); color: var(--green-600); }
.badge-draw { background: var(--blue-100); color: var(--blue-600); }
.badge-pending { background: var(--blue-100); color: var(--navy-700); }
.badge-partial { background: #fff4e2; color: #a5670a; }

.round-title {
  font-size: .84rem; color: var(--muted); font-weight: 500;
  margin: .9rem 0 .4rem; text-transform: none;
}
.round-title:first-of-type { margin-top: 0; }

/* ---------- table ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 620px; }
.table th, .table td { padding: .45rem .55rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
.table thead th {
  background: var(--blue-050); color: var(--navy-700); font-weight: 500; font-size: .8rem;
  border-bottom: 2px solid #cfe0f7; white-space: nowrap;
}
.table td.num, .table th:not(:nth-child(2)) { text-align: center; font-variant-numeric: tabular-nums; }
.table td.team { font-weight: 400; }
.table tbody tr:hover { background: var(--blue-050); }
.table tr.is-qualified td { background: rgba(27, 138, 75, .07); }
.table tr.is-qualified td:first-child { font-weight: 600; color: var(--green-600); }

/* ---------- schedule (ฉายขึ้นจอ) ---------- */
.sched-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700) 55%, var(--blue-600));
  color: #fff; border-radius: var(--radius); padding: .9rem 1.2rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.sched-banner-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.sched-banner-sub { font-size: .82rem; color: #9dc6ff; margin: 0; }
.sched-banner-side { display: flex; align-items: center; gap: .7rem; }
.sched-progress {
  background: rgba(255, 255, 255, .16); border-radius: 999px; padding: .2rem .8rem;
  font-size: .85rem; white-space: nowrap;
}
.sched-clock { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.sched-controls { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.sched-controls .field { flex: 1 1 140px; margin-bottom: 0; }
.sched-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.sched-hint { flex-basis: 100%; margin: 0; }
.sched-foot { text-align: center; margin-top: .6rem; }

/* แถบสถานะสนาม: กำลังแข่ง / คิวถัดไป */
.court-status {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .7rem; margin-bottom: 1rem;
}
.court-status-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--blue-500);
  border-radius: var(--radius-sm); padding: .7rem .85rem; box-shadow: var(--shadow-sm);
}
.cs-court { font-size: .82rem; color: var(--muted); font-weight: 500; margin: 0; }
.cs-label { font-size: .88rem; font-weight: 600; color: var(--blue-600); margin: .1rem 0; }
.cs-label.is-live { color: var(--pink-600); }
.cs-label.is-finished { color: var(--green-600); }
.cs-meta { font-size: .78rem; color: var(--muted); margin: 0; }
.cs-match { font-size: .95rem; margin: .15rem 0; overflow-wrap: anywhere; }
.cs-match b { font-weight: 600; color: var(--navy-700); }
.cs-progress { font-size: .76rem; color: var(--muted); margin: .3rem 0 0; }

/* คิวแข่งแยกตามสนาม */
.court-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: .8rem; align-items: start; }
@media (min-width: 1400px) {
  .court-grid { grid-template-columns: repeat(4, 1fr); }
  .court-status { grid-template-columns: repeat(4, 1fr); }
}
.court-col { margin-bottom: 0; padding: .8rem .9rem; }
.court-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding-bottom: .5rem; margin-bottom: .5rem; border-bottom: 2px solid var(--blue-100);
}
.court-head h3 { margin: 0; font-size: 1.05rem; color: var(--navy-700); }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.queue-item {
  border: 1px solid var(--line-soft); border-left: 4px solid var(--line);
  border-radius: var(--radius-sm); padding: .4rem .55rem; background: #fff;
}
.queue-item.is-done { border-left-color: var(--green-500); background: rgba(27, 138, 75, .04); }
.queue-item.is-draw { border-left-color: var(--blue-500); background: rgba(47, 128, 237, .05); }
.queue-item.is-partial { border-left-color: #f2a93b; background: #fffaf2; }
.queue-item.is-pending { border-left-color: #c6dbf7; }
.queue-item.is-current {
  border-left-color: var(--pink-500);
  box-shadow: 0 0 0 2px rgba(233, 30, 99, .18);
}
.q-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: .15rem; }
.q-no { font-size: .78rem; font-weight: 600; color: var(--navy-700); white-space: nowrap; }
.q-type { font-size: .74rem; color: var(--muted); }
.q-top .badge { margin-left: auto; }
.badge-next { background: var(--pink-100); color: var(--pink-600); }
.q-teams { display: grid; gap: .1rem; }
.q-row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.q-team { font-size: .92rem; overflow-wrap: anywhere; }
.q-sets {
  font-size: 1rem; font-weight: 600; color: var(--navy-700);
  font-variant-numeric: tabular-nums; min-width: 1.1rem; text-align: right;
}
.q-row.is-winner .q-team, .q-row.is-winner .q-sets { color: var(--green-600); font-weight: 600; }
.q-sub { font-size: .74rem; color: var(--muted); margin: .15rem 0 0; font-variant-numeric: tabular-nums; }

.sched-table { min-width: 720px; }
.sched-table th, .sched-table td { padding: .5rem .6rem; vertical-align: middle; }
.sched-table th:nth-child(2), .sched-table th:nth-child(4) { text-align: center; }
.sched-no { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.sched-team { font-size: .95rem; overflow-wrap: anywhere; }
.sched-team-a { text-align: right; }
.sched-table td.sched-team { text-align: left; }
.sched-table td.sched-team-a { text-align: right; }
.sched-team.is-winner { font-weight: 600; color: var(--green-600); }
.sched-score { text-align: center; white-space: nowrap; }
.sched-score b { display: block; font-size: 1.05rem; color: var(--navy-700); font-variant-numeric: tabular-nums; }
.sched-score small { display: block; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sched-court, .sched-status { text-align: center; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.sched-row.is-done { background: rgba(27, 138, 75, .05); }
.sched-row.is-draw { background: rgba(47, 128, 237, .06); }
.sched-row.is-partial { background: #fff8ec; }
.sched-block { margin-bottom: 1rem; }

/* โหมดจอใหญ่: ซ่อนส่วนควบคุม ขยายตัวอักษรให้อ่านจากท้ายห้องได้ */
body.is-presenting .app-header,
body.is-presenting .app-footer,
body.is-presenting .sched-controls,
body.is-presenting .sched-foot { display: none !important; }
body.is-presenting .wrap { width: min(1800px, 100% - 2rem); }
body.is-presenting .app-main { padding-top: .6rem; }
body.is-presenting .sched-banner {
  position: sticky; top: 0; z-index: 30; border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 1.2rem;
}
body.is-presenting .sched-banner-title { font-size: 1.9rem; }
body.is-presenting .sched-banner-sub { font-size: 1.05rem; }
body.is-presenting .sched-progress { font-size: 1.15rem; }
body.is-presenting .sched-clock { font-size: 2rem; }
body.is-presenting .block-head h3 { font-size: 1.55rem; }
body.is-presenting .chip { font-size: 1rem; padding: .25rem .8rem; }
body.is-presenting .sched-table { font-size: 1.3rem; min-width: 0; }
body.is-presenting .sched-table th { font-size: 1.05rem; }
body.is-presenting .sched-team { font-size: 1.45rem; }
body.is-presenting .sched-no { font-size: 1.05rem; }
body.is-presenting .sched-score b { font-size: 1.7rem; }
body.is-presenting .sched-score small { font-size: 1.05rem; }
body.is-presenting .sched-court, body.is-presenting .sched-status { font-size: 1.05rem; }
body.is-presenting .badge { font-size: 1rem; padding: .2rem .7rem; }
body.is-presenting .table-scroll { overflow: visible; }
/* มุมมองสนามในโหมดจอใหญ่ */
body.is-presenting .court-grid { grid-template-columns: repeat(4, 1fr); gap: .8rem; }
body.is-presenting .court-head h3 { font-size: 1.7rem; }
body.is-presenting .q-no { font-size: 1.15rem; }
body.is-presenting .q-type { font-size: 1rem; }
body.is-presenting .q-team { font-size: 1.25rem; }
body.is-presenting .q-sets { font-size: 1.5rem; min-width: 1.6rem; }
body.is-presenting .q-sub { font-size: .98rem; }
body.is-presenting .queue { gap: .5rem; }
body.is-presenting .cs-court { font-size: 1.05rem; }
body.is-presenting .cs-label { font-size: 1.35rem; }
body.is-presenting .cs-match { font-size: 1.5rem; }
body.is-presenting .cs-meta, body.is-presenting .cs-progress { font-size: 1.05rem; }
body.is-presenting .court-status { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) {
  body.is-presenting .court-grid, body.is-presenting .court-status { grid-template-columns: repeat(2, 1fr); }
}

.present-exit {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 70;
  appearance: none; font-family: inherit; font-size: .85rem; cursor: pointer;
  background: rgba(4, 18, 43, .75); color: #fff; border: 0; border-radius: 999px; padding: .5rem 1rem;
  opacity: .35; transition: opacity .2s ease;
}
.present-exit:hover, .present-exit:focus-visible { opacity: 1; }

/* ---------- knockout ---------- */
.ko-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem; }
.ko-col h4 { font-size: .84rem; color: var(--muted); font-weight: 500; margin-bottom: .4rem; }
.ko-col { display: flex; flex-direction: column; gap: .6rem; }

.ko-match {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .7rem; background: #fff;
}
.ko-title { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.ko-slot {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .3rem .5rem; border-radius: 8px; background: var(--bg);
  margin-bottom: .3rem; font-size: .9rem;
}
.ko-slot.is-winner { background: var(--green-100); color: var(--green-600); font-weight: 600; }
.ko-slot.is-pending { color: var(--muted); font-style: italic; font-size: .82rem; }
.ko-slot b { font-variant-numeric: tabular-nums; }
.ko-score { font-size: .8rem; color: var(--muted); margin: .3rem 0; font-variant-numeric: tabular-nums; }

.podium {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--line);
}
.podium-item {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .1rem; padding: .6rem .5rem; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, var(--blue-050)); border: 1px solid var(--line);
}
.medal { font-size: 1.4rem; line-height: 1; }
.podium-label { font-size: .74rem; color: var(--muted); }
.podium-item strong { font-size: .92rem; font-weight: 600; color: var(--navy-700); overflow-wrap: anywhere; }

/* ---------- lock screen ---------- */
.lock-card {
  max-width: 460px; margin-inline: auto; text-align: center;
  padding: 1.6rem 1.3rem 1.2rem;
}
.lock-icon { font-size: 2rem; line-height: 1; display: block; margin-bottom: .3rem; }
.lock-card h2 { font-size: 1.15rem; }
.lock-form { margin: 1rem 0 .4rem; text-align: left; }
.lock-form .btn { width: 100%; }
.lock-help { margin-top: .8rem; text-align: left; font-size: .84rem; }
.lock-help summary { cursor: pointer; color: var(--blue-600); }
.lock-note { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--line); text-align: left; }

/* ---------- report ---------- */
.report-head { border-left: 5px solid var(--pink-500); }
.report-head h1 { font-size: 1.35rem; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 18, 43, .55); }
.modal-card {
  position: relative; background: #fff; border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(4, 18, 43, .3);
  width: min(480px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.1rem 1.2rem 1rem;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; margin-bottom: .8rem; }
.modal-head h2 { font-size: 1.1rem; margin: 0; }
.modal-eyebrow { font-size: .76rem; color: var(--blue-600); margin: 0; }
.modal-foot { display: flex; align-items: center; gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line-soft); }

.score-slot {
  font-size: .8rem; color: var(--blue-600); background: var(--blue-050);
  border-radius: var(--radius-sm); padding: .35rem .6rem; margin: 0 0 .5rem;
}

.score-teams {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center;
  font-size: .92rem; font-weight: 500; margin-bottom: .8rem;
  padding: .55rem .6rem; background: var(--blue-050); border-radius: var(--radius-sm);
}
.score-teams > span:last-child { text-align: right; }

.score-row { display: grid; grid-template-columns: 4.5rem 1fr auto 1fr; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.score-label { font-size: .82rem; color: var(--muted); }
.score-input { text-align: center; font-size: 1.05rem; font-weight: 500; padding: .4rem; }
.score-sep { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: var(--navy-800); color: #fff; padding: .6rem 1.1rem;
  border-radius: 999px; font-size: .86rem; box-shadow: var(--shadow); z-index: 80;
  max-width: calc(100% - 2rem); text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .sched-banner { flex-direction: column; align-items: flex-start; }
  .sched-buttons .btn { flex: 1 1 auto; }
  .match-main { grid-template-columns: 1fr; gap: .25rem; }
  .match-side:last-child { justify-content: flex-start; }
  .match-vs { text-align: left; }
  .match-foot .btn { margin-left: 0; width: 100%; }
  .hero h1 { font-size: 1.22rem; }
  .brand-text strong { font-size: 1rem; }
  .score-row { grid-template-columns: 3.8rem 1fr auto 1fr; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .app-header, .app-footer, .filter-bar, .toast, .modal, .btn, .skip-link,
  .sched-controls, .present-exit, #visitorCounter { display: none !important; }
  .sched-table { min-width: 0; font-size: .78rem; }
  .court-grid, .court-status { grid-template-columns: repeat(2, 1fr) !important; }
  .court-col, .queue-item { break-inside: avoid; page-break-inside: avoid; }
  .wrap { width: 100%; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; page-break-inside: avoid; }
  .view.is-hidden { display: none !important; }
  .section-title { break-after: avoid; }
  .table { min-width: 0; font-size: .78rem; }
  a { color: #000; text-decoration: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .footer-meta {
    flex-direction: column;
    align-items: flex-start;
  }
  
  #visitorCounter {
    width: 100%;
    justify-content: center;
  }
}
