@import url("/fonts.css?v=20261009-pretendard");
:root {
  --ink: #172019;
  --muted: #687169;
  --line: #cfd5cf;
  --line-dark: #9da89f;
  --paper: #fff;
  --canvas: #f3f5f2;
  --green: #176f4d;
  --green-dark: #0f5238;
  --green-soft: #eaf3ed;
  --danger: #a93232;
  --shadow: 0 12px 32px rgba(23, 32, 25, .12);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  word-break: keep-all;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
button, input, select {
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  color: var(--ink);
  background: var(--paper);
}
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(23, 111, 77, .22);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 8px max(20px, calc((100vw - 1480px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.site-header::-webkit-scrollbar { display: none; }
.header-path { flex: none; display: flex; align-items: center; gap: 10px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
}
.brand img { width: 29px; height: 29px; object-fit: contain; }
.header-separator { color: var(--line-dark); font-weight: 700; }
.site-header h1 { margin: 0; font-size: 18px; }
.header-meta { margin-left: 6px; color: var(--green); font-size: 12px; font-weight: 800; }
.header-actions { flex: none; display: flex; gap: 6px; }
.header-actions button { min-height: 38px; padding: 0 14px; font-weight: 700; }
#nextMatchButton { border-color: var(--green-dark); color: #fff; background: var(--green); }
#nextMatchButton:hover { background: var(--green-dark); }
#nextMatchButton:disabled { border-color: var(--line-dark); color: var(--muted); background: #f1f3f1; }
.next-match-label-short { display: none; }
main { min-height: calc(100vh - 64px); }

.count-setup {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 64px);
  padding: 42px 20px 80px;
}
.count-box {
  width: min(100%, 520px);
  padding: 38px 42px 42px;
  border: 1px solid var(--line-dark);
  background: var(--paper);
  box-shadow: 8px 8px 0 #dfe4df;
}
.count-box > p:first-child {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}
.count-box h2 { margin: 0 0 30px; font-size: clamp(25px, 5vw, 34px); letter-spacing: -.045em; }
.event-choice {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 0 25px;
  padding: 0;
  border: 0;
}
.event-choice legend, .count-label {
  display: block;
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 800;
}
.event-choice legend { grid-column: 1 / -1; }
.event-choice label { position: relative; }
.event-choice input { position: absolute; opacity: 0; pointer-events: none; }
.event-choice span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-weight: 800;
}
.event-choice input:checked + span { border: 2px solid var(--green); color: var(--green-dark); background: var(--green-soft); }
.count-stepper {
  display: grid;
  grid-template-columns: 54px 1fr auto 54px;
  align-items: center;
  height: 78px;
  margin-bottom: 24px;
  border: 2px solid var(--ink);
  background: #fff;
}
.count-stepper button {
  height: 100%;
  border: 0;
  border-radius: 0;
  font-size: 28px;
  background: #f3f5f2;
}
.count-stepper button:first-child { border-right: 1px solid var(--line); }
.count-stepper button:last-child { border-left: 1px solid var(--line); }
.count-stepper input {
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  text-align: right;
  font-size: 36px;
  font-weight: 900;
  -moz-appearance: textfield;
}
.count-stepper input::-webkit-inner-spin-button { appearance: none; }
.count-stepper span { padding: 0 14px 0 8px; font-size: 17px; font-weight: 800; }
.form-error { min-height: 20px; margin: 8px 0; color: var(--danger); font-size: 13px; font-weight: 700; }
.primary-button {
  width: 100%;
  min-height: 54px;
  border: 2px solid var(--line-dark);
  color: #fff;
  background: var(--green);
  font-weight: 900;
}
.primary-button:hover { background: var(--green-dark); }

.composer {
  width: min(100% - 36px, 1480px);
  margin: 0 auto;
  padding: 22px 0 100px;
}
.result-heading p { margin: 0 0 5px; color: var(--green); font-size: 13px; font-weight: 800; }
.result-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.result-heading button, .stage-section > header button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}
.configuration-panel { margin-bottom: 18px; }
.configuration-panel[data-motion-active] { transform-origin: top; }
.configuration-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 13px 0;
}
.configuration-actions button { min-height: 38px; padding: 0 13px; font-weight: 700; }
.preset-section, .stage-section, .result-panel { border: 1px solid var(--line); background: var(--paper); }
.preset-section { margin-bottom: 16px; }
.preset-section > h3, .stage-section > header, .result-heading {
  margin: 0;
  padding: 19px 22px;
  border-bottom: 1px solid var(--line);
}
.preset-section > h3 { font-size: 17px; }
.preset-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.preset-option {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-height: 145px;
  padding: 18px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}
.preset-option:last-child { border-right: 0; }
.preset-option:hover:not(:disabled) { background: #f6f8f6; }
.preset-option.selected { box-shadow: inset 0 -5px 0 var(--green); background: var(--green-soft); }
.preset-option:disabled { color: #a0a6a1; background: #f7f7f7; }
.preset-option > span { display: flex; align-items: flex-start; gap: 7px; }
.preset-option b { font-size: 15px; line-height: 1.4; }
.preset-option em { flex: none; padding: 2px 5px; color: #fff; background: var(--green); font-size: 10px; font-style: normal; }
.preset-option small { color: var(--muted); font-size: 12px; line-height: 1.55; }
.preset-option > strong { justify-self: end; color: var(--green-dark); font-size: 14px; }

.stage-section { padding-bottom: 22px; }
.stage-section > header, .result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stage-section > header { padding: 17px 22px; }
.stage-section > header h3 { margin: 0 0 3px; font-size: 17px; }
.stage-section > header span { color: var(--muted); font-size: 12px; }
.stage-list { padding: 0 22px; }
.stage-row {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr) 125px 48px;
  align-items: end;
  gap: 18px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.stage-number { align-self: center; display: flex; align-items: center; gap: 10px; }
.stage-number b { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--green); }
.stage-number span { font-weight: 900; }
.stage-controls { display: flex; align-items: end; gap: 10px; }
.stage-controls label { display: grid; gap: 6px; min-width: 140px; }
.stage-controls label:first-child { min-width: 220px; flex: 1; }
.stage-controls span { color: var(--muted); font-size: 11px; font-weight: 700; }
.stage-controls select { width: 100%; height: 42px; padding: 0 32px 0 11px; }
.stage-count { align-self: center; display: grid; gap: 4px; text-align: right; }
.stage-count span { color: var(--muted); font-size: 12px; }
.stage-count strong { font-size: 17px; }
.remove-stage { align-self: center; min-height: 36px; border-color: transparent; color: var(--muted); background: transparent; font-size: 12px; }
.remove-stage:hover { color: var(--danger); text-decoration: underline; }
.stage-section > .form-error { margin: 8px 22px 0; }

.result-panel { margin-top: 0; scroll-margin-top: 78px; }
.result-heading { background: #f8f9f7; }
.result-summary { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line); }
.result-summary > div { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 70px; padding: 12px; }
.result-summary > div:first-child { border-right: 1px solid var(--line); }
.result-summary span { color: var(--muted); font-size: 12px; font-weight: 700; }
.result-summary strong { font-size: 20px; }
.stage-result-block { padding: 26px 22px 32px; }
.stage-result-block + .stage-result-block { border-top: 8px solid var(--canvas); }
.stage-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 76px;
  border-block: 8px solid var(--canvas);
  color: var(--green-dark);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
}
.stage-flow b { color: var(--green); font-size: 34px; line-height: 1; }
.stage-result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.stage-result-head > div { display: flex; align-items: center; gap: 9px; }
.stage-result-head b { display: grid; place-items: center; width: 30px; height: 30px; color: #fff; background: var(--green); }
.stage-result-head span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stage-result-head h3 { margin: 0; font-size: 21px; }
.stage-result-head > strong { color: var(--green-dark); font-size: 13px; }

.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.group-block { min-width: 0; border: 1px solid var(--line); }
.group-block > header { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); background: #f5f7f4; }
.group-block h4, .league-layout h4, .double-part > h4 { margin: 0; font-size: 16px; }
.group-block > header span { color: var(--green); font-size: 12px; font-weight: 800; }
.league-diagram { padding: 10px 12px 8px; }
.league-diagram svg { display: block; width: 100%; height: auto; min-height: 280px; }
.diagram-link-line { stroke: #7e8a81; stroke-width: 2; vector-effect: non-scaling-stroke; }
.diagram-link-hit { stroke: transparent; stroke-width: 20; vector-effect: non-scaling-stroke; }
.diagram-match { cursor: pointer; }
.diagram-match:hover .diagram-link-line, .diagram-match:focus .diagram-link-line { stroke: var(--green); stroke-width: 4; }
.diagram-match.is-next .diagram-link-line { stroke: var(--green); stroke-width: 4; }
.diagram-match:focus { outline: none; }
.diagram-score-box { fill: #fff; stroke: #7e8a81; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.diagram-score-text { fill: var(--ink); text-anchor: middle; font-size: 13px; font-weight: 900; }
.diagram-result-name { fill: var(--ink); text-anchor: middle; font-size: 11px; font-weight: 900; }
.diagram-match-number-bg { fill: #fff; }
.diagram-match-number { fill: var(--muted); text-anchor: middle; font-size: 10px; font-weight: 800; }
.diagram-match.is-resolved .diagram-score-box { fill: var(--green); stroke: var(--green-dark); }
.diagram-match.is-resolved .diagram-score-text, .diagram-match.is-resolved .diagram-result-name { fill: #fff; }
.diagram-match.is-next .diagram-score-box { fill: var(--green-soft); stroke: var(--green); stroke-width: 3; }
.diagram-match.is-next .diagram-match-number-bg { fill: var(--green-soft); }
.diagram-match.is-next .diagram-match-number { fill: var(--green-dark); font-weight: 900; }
.diagram-match.is-jump-highlight, .diagram-match.is-navigator-highlight { animation: next-match-pulse .6s ease-in-out 2; }
.diagram-node rect { fill: #fff; stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; }
.diagram-node text { fill: var(--ink); text-anchor: middle; font-size: 13px; font-weight: 800; }
.diagram-node.is-editable { cursor: pointer; }
.diagram-node.is-editable:hover rect, .diagram-node.is-editable:focus rect { fill: var(--green-soft); stroke: var(--green); stroke-width: 3; }
.diagram-node:focus { outline: none; }
.table-scroll, .bracket-scroll { max-width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 430px; border-collapse: collapse; font-size: 13px; }
th, td { height: 40px; padding: 7px 9px; border-bottom: 1px solid #e1e5e1; text-align: center; }
thead th { color: var(--muted); background: #fafbfa; font-size: 11px; }
tbody th { text-align: left; }
tr.advancing { background: var(--green-soft); }
.league-rounds {
  display: flex;
  gap: 18px;
  padding: 15px;
  overflow-x: auto;
}
.league-round { flex: 0 0 210px; min-width: 0; }
.league-round h4, .league-round h5 { margin: 0 0 9px; color: var(--muted); font-size: 12px; }
.league-round > div { display: grid; gap: 10px; }
.full-league { padding: 0 0 8px; }
.full-league .league-round { flex-basis: 230px; }
.tournament-match {
  display: block;
  width: 100%;
  min-width: 185px;
  padding: 0;
  border: 1px solid var(--line-dark);
  border-radius: 0;
  text-align: left;
  background: #fff;
}
.tournament-match:not(:disabled):hover { border-color: var(--green); box-shadow: 0 0 0 2px rgba(23, 111, 77, .12); }
.tournament-match.is-next { border: 3px solid var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.tournament-match.is-next > header { color: var(--green-dark); background: var(--green-soft); }
.tournament-match.is-jump-highlight, .tournament-match.is-navigator-highlight { animation: next-match-pulse .6s ease-in-out 2; }
.tournament-match > header { display: flex; justify-content: space-between; padding: 7px 9px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.tournament-match > header b { color: var(--green); }
.team-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; min-height: 38px; border-bottom: 1px solid #e5e8e5; }
.team-row:last-child { border-bottom: 0; }
.team-row strong { overflow: hidden; padding: 0 9px; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.team-row.winner strong { color: var(--green-dark); font-weight: 900; }
.team-row i { display: grid; place-items: center; align-self: stretch; border-left: 1px solid var(--line); background: #f7f8f7; font-style: normal; font-weight: 900; }
.tournament-match:disabled { cursor: default; color: var(--ink); }
.tournament-match.is-inactive { opacity: .58; }
.bracket { position: relative; display: grid; grid-template-columns: repeat(var(--round-count), minmax(210px, 1fr)); gap: 52px; min-width: calc(var(--round-count) * 262px); padding: 4px 2px 18px; }
.bracket-lines { position: absolute; inset: 0; z-index: 0; overflow: visible; pointer-events: none; }
.bracket-lines path { fill: none; stroke: #839087; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.bracket-round { position: relative; z-index: 1; display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.bracket-round h4 { margin: 0 0 9px; color: var(--muted); font-size: 12px; }
.bracket-matches { display: flex; flex-direction: column; justify-content: space-around; gap: 14px; }
.double-part + .double-part { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.double-part > h4 { margin-bottom: 13px; }
.match-table-panel { border-top: 8px solid var(--canvas); background: #fff; }
.section-table-panel { margin-top: 18px; border: 1px solid var(--line); background: #fff; }
.match-table-panel[data-motion-active], .section-table-panel[data-motion-active] { transform-origin: top; }
.group-block .section-table-panel { margin: 0 -1px -1px; }
.match-table-panel summary, .section-table-panel summary { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 22px; cursor: pointer; list-style: none; transition: background-color .16s ease, box-shadow .16s ease; }
.section-table-panel summary { min-height: 58px; padding: 0 14px; }
.match-table-panel summary::-webkit-details-marker, .section-table-panel summary::-webkit-details-marker { display: none; }
.match-table-panel summary::after, .section-table-panel summary::after { content: '펼치기 ↓'; display: grid; place-items: center; min-width: 74px; min-height: 32px; margin-left: auto; padding: 0 10px; border: 2px solid var(--green); border-radius: 3px; color: var(--green-dark); background: #fff; font-size: 12px; font-weight: 800; transition: color .16s ease, background-color .16s ease, border-color .16s ease, transform .12s ease; }
.match-table-panel summary:hover, .section-table-panel summary:hover { background: var(--green-soft); box-shadow: inset 4px 0 0 var(--green); }
.match-table-panel summary:hover::after, .section-table-panel summary:hover::after { border-color: var(--green-dark); color: #fff; background: var(--green); }
.match-table-panel summary:focus-visible, .section-table-panel summary:focus-visible { outline: 3px solid rgba(23, 111, 77, .25); outline-offset: -3px; background: var(--green-soft); }
.match-table-panel summary:focus-visible::after, .section-table-panel summary:focus-visible::after { color: #fff; background: var(--green); }
.match-table-panel summary:active::after, .section-table-panel summary:active::after { transform: translateY(1px); }
.match-table-panel[open] summary, .section-table-panel[open] summary { border-bottom: 1px solid var(--line); }
.match-table-panel[open] summary::after, .section-table-panel[open] summary::after { content: '접기 ↑'; }
.match-table-panel summary strong { font-size: 18px; }
.section-table-panel summary strong { font-size: 15px; }
.match-table-panel summary span, .section-table-panel summary span { color: var(--muted); font-size: 12px; }
.match-table-scroll { overflow-x: auto; }
.match-table { min-width: 1050px; }
.match-table th, .match-table td { height: 48px; }
.match-table tbody th { text-align: center; white-space: nowrap; }
.match-table td:nth-child(2) span, .match-table td:nth-child(2) small { display: block; white-space: nowrap; }
.match-table td:nth-child(2) small { margin-top: 2px; color: var(--green); }
.match-table td:nth-child(4) { color: var(--muted); font-size: 11px; }
.match-table td:nth-child(5), .match-table td:nth-child(7) { max-width: 180px; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.match-table td.winner { color: var(--green-dark); background: var(--green-soft); font-weight: 900; }
.match-table tr.is-next { background: var(--green-soft); box-shadow: inset 4px 0 0 var(--green); }
.match-table tr.is-navigator-highlight { animation: table-match-pulse .6s ease-in-out 2; }
.match-table .match-result { white-space: nowrap; font-weight: 900; }
.table-score-button { min-height: 32px; padding: 0 10px; font-size: 11px; font-weight: 800; }
.table-score-button:disabled { opacity: .45; }

@keyframes next-match-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(23, 111, 77, 0)); }
  50% { filter: drop-shadow(0 0 9px rgba(23, 111, 77, .75)); }
}

@keyframes table-match-pulse {
  0%, 100% { background: var(--green-soft); box-shadow: inset 4px 0 0 var(--green); }
  50% { background: #d3eadc; box-shadow: inset 7px 0 0 var(--green); }
}

.match-navigator {
  position: fixed;
  right: 78px;
  bottom: 18px;
  z-index: 28;
  width: min(320px, calc(100vw - 96px));
  border: 2px solid var(--green-dark);
  border-radius: 5px;
  background: #fff;
  box-shadow: 7px 7px 0 rgba(23, 32, 25, .14);
}
.match-navigator-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}
.match-navigator-toggle b { color: #111; font-size: 11px; }
.match-navigator-toggle:hover, .match-navigator-toggle:focus-visible { color: var(--ink); background: #f1f3f0; }
.match-navigator.is-collapsed .match-navigator-toggle { border-bottom-color: transparent; }
.match-navigator-list {
  max-height: min(42vh, 360px);
  overflow: auto;
  opacity: 1;
  transition: max-height .28s cubic-bezier(.22, 1, .36, 1), opacity .18s ease;
}
.match-navigator.is-collapsed .match-navigator-list { max-height: 0; opacity: 0; overflow: hidden; }
.match-navigator-item {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: #fff;
}
.match-navigator-item > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.match-navigator-item > span b { color: var(--green-dark); font-size: 12px; }
.match-navigator-item small { color: var(--muted); font-size: 10px; }
.match-navigator-item > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.match-navigator-item i { color: var(--muted); font-size: 10px; font-style: normal; }
.match-navigator-item:hover, .match-navigator-item:focus-visible { background: var(--green-soft); box-shadow: inset 4px 0 0 var(--green); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: transparent;
}
.roster-dialog, .reset-dialog, .score-dialog, .schedule-dialog {
  width: min(100%, 560px);
  max-height: min(760px, calc(100dvh - 36px));
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}
.roster-dialog { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.roster-dialog > header { display: flex; align-items: start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.roster-dialog > header p { margin: 0 0 3px; color: var(--green); font-size: 11px; font-weight: 800; }
.roster-dialog h2, .reset-dialog h2 { margin: 0; font-size: 22px; }
#closeRosterDialog { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 24px; font-weight: 400; line-height: 1; }
.roster-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 18px 22px; overflow-y: auto; }
.roster-inputs label { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; }
.roster-inputs label span { color: var(--muted); font-size: 12px; font-weight: 800; }
.roster-inputs input { min-width: 0; height: 42px; padding: 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 22px; border-top: 1px solid var(--line); }
.dialog-actions button { min-width: 88px; min-height: 42px; padding: 0 15px; font-weight: 800; }
.confirm-button { border-color: var(--green-dark); color: #fff; background: var(--green); }
.danger-button { border-color: var(--danger); color: #fff; background: var(--danger); }
.reset-dialog { padding: 24px; }
.reset-dialog p { margin: 10px 0 22px; color: var(--muted); line-height: 1.6; }
.reset-dialog .dialog-actions { padding: 0; border: 0; }
.score-dialog { width: min(100%, 440px); }
.score-dialog > header { display: flex; align-items: start; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.score-dialog > header p { margin: 0 0 3px; color: var(--green); font-size: 11px; font-weight: 800; }
.score-dialog h2 { margin: 0; font-size: 21px; }
#closeScoreDialog { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 24px; font-weight: 400; line-height: 1; }
.score-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; align-items: center; min-height: 65px; margin: 0 20px; border-bottom: 1px solid var(--line); }
.score-edit-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-edit-row input { width: 90px; height: 44px; text-align: center; font-size: 20px; font-weight: 900; }
.score-dialog > .form-error { margin: 10px 20px; }
.forfeit-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px 20px 0; }
.forfeit-actions button { min-width: 0; min-height: 38px; padding: 0 8px; overflow: hidden; color: var(--danger); text-overflow: ellipsis; white-space: nowrap; background: #fff; }
.forfeit-actions button.selected { color: #fff; background: var(--danger); }
.schedule-dialog { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; width: min(100%, 980px); }
.schedule-dialog > header { display: flex; align-items: start; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.schedule-dialog > header p { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.schedule-dialog h2 { margin: 0; font-size: 23px; }
#closeScheduleDialog { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 24px; font-weight: 400; line-height: 1; }
.schedule-controls { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.schedule-controls > label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 12px 20px; border-right: 1px solid var(--line); font-weight: 800; }
.schedule-controls > label:last-child { border-right: 0; }
.schedule-controls select, .schedule-controls input { width: 110px; height: 40px; padding: 0 10px; }
.duration-input { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.duration-input input { width: 76px; text-align: right; }
.schedule-list { padding: 0 20px 20px; overflow-y: auto; }
.schedule-match { display: grid; grid-template-columns: 112px minmax(230px, 1fr) 125px 160px 82px; align-items: center; min-width: 0; border-bottom: 1px solid var(--line); background: #fff; }
.schedule-match > header { display: grid; gap: 3px; padding: 13px 10px 13px 0; }
.schedule-match > header b { font-size: 14px; }
.schedule-match > header span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.schedule-players { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); align-items: center; min-height: 54px; padding: 7px 12px; border-inline: 1px solid var(--line); text-align: center; }
.schedule-players strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.schedule-players i { color: var(--muted); font-size: 10px; font-style: normal; }
.schedule-time { display: grid; gap: 3px; padding: 8px 12px; }
.schedule-time b { font-size: 13px; }
.schedule-time small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.schedule-court { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 7px; padding-left: 8px; font-size: 10px; font-weight: 800; }
.schedule-court select { width: 100%; height: 36px; padding: 0 7px; font-size: 11px; }
.schedule-score-button { min-height: 36px; margin-left: 8px; padding: 0 8px; border-color: var(--green-dark); color: var(--green-dark); background: #fff; font-size: 11px; font-weight: 900; }
.schedule-score-button:hover { color: #fff; background: var(--green); }
.schedule-score-button:disabled { border-color: var(--line); color: var(--muted); opacity: .55; }
.schedule-match.is-done { background: var(--green-soft); }
.schedule-match.is-next { background: var(--green-soft); box-shadow: inset 4px 0 0 var(--green); }
.schedule-match.is-next > header b, .schedule-match.is-next .schedule-time small { color: var(--green-dark); }
.schedule-actions { background: #fff; }
#scoreDialogBackdrop { z-index: 110; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 150;
  translate: -50% 16px;
  padding: 12px 18px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, translate .18s;
}
.toast.visible { translate: -50% 0; opacity: 1; }

@media (max-width: 1040px) {
  .preset-list { grid-template-columns: repeat(2, 1fr); }
  .preset-option { border-bottom: 1px solid var(--line); }
  .preset-option:nth-child(2n) { border-right: 0; }
  .preset-option:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .stage-row { grid-template-columns: 92px minmax(0, 1fr) 100px 44px; }
  .stage-controls label:first-child { min-width: 170px; }
}

@media (max-width: 720px) {
  .site-header { min-height: 52px; padding: 6px; gap: 8px; }
  .header-path { gap: 4px; }
  .brand { gap: 4px; font-size: 14px; }
  .brand strong { display: inline; }
  .brand img { width: 24px; height: 24px; }
  .site-header h1 { font-size: 15px; }
  .header-meta { display: none; }
  .header-actions { gap: 3px; }
  .header-actions button { min-height: 44px; padding: 0 12px; font-size: 13px; }
  .site-header:has(#rosterButton:not([hidden])) { height: auto; flex-wrap: wrap; gap: 0; }
  .site-header:has(#rosterButton:not([hidden])) .header-path { width: 100%; min-height: 52px; }
  .site-header:has(#rosterButton:not([hidden])) .header-actions { width: 100%; min-height: 48px; padding-bottom: 4px; overflow-x: auto; }
  .header-actions button { flex: none; }
  .roster-inputs input { min-height: 44px; font-size: 16px; }
  .next-match-label-wide { display: none; }
  .next-match-label-short { display: inline; }
  .count-setup { min-height: calc(100dvh - 52px); align-items: start; padding: 24px 14px 60px; }
  .count-box { padding: 26px 20px 28px; box-shadow: 5px 5px 0 #dfe4df; }
  .count-box h2 { margin-bottom: 24px; }
  .count-stepper { grid-template-columns: 48px 1fr auto 48px; height: 70px; }
  .composer { width: calc(100% - 24px); padding: 16px 0 70px; }
  .preset-section > h3, .stage-section > header, .result-heading { padding: 15px; }
  .preset-list { grid-template-columns: 1fr; }
  .preset-option, .preset-option:nth-child(2n), .preset-option:last-child { grid-column: auto; min-height: 112px; border-right: 0; border-bottom: 1px solid var(--line); }
  .preset-option:last-child { border-bottom: 0; }
  .stage-section > header span { display: none; }
  .stage-section > header button { padding: 0 10px; font-size: 12px; }
  .stage-list { padding: 0 15px; }
  .stage-row { grid-template-columns: 1fr auto; align-items: center; gap: 13px 8px; padding: 18px 0; }
  .stage-number { grid-column: 1; }
  .stage-count { grid-column: 2; grid-row: 1; }
  .stage-controls { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stage-controls label, .stage-controls label:first-child { min-width: 0; }
  .stage-controls label:first-child { grid-column: 1 / -1; }
  .remove-stage { grid-column: 1 / -1; justify-self: end; min-height: 26px; padding: 0; }
  .stage-section > .form-error { margin-inline: 15px; }
  .configuration-actions { padding-bottom: 0; }
  .configuration-actions button { flex: 1; padding: 0 7px; font-size: 11px; }
  .result-panel { margin-top: 0; }
  .result-heading h2 { font-size: 22px; }
  .result-heading button { padding: 0 9px; font-size: 11px; }
  .result-summary > div { display: grid; gap: 4px; min-height: 62px; text-align: center; }
  .result-summary strong { font-size: 17px; }
  .stage-result-block { padding: 21px 15px 26px; }
  .stage-flow { min-height: 64px; gap: 12px; font-size: 14px; }
  .stage-flow b { font-size: 28px; }
  .stage-result-head { align-items: flex-start; }
  .stage-result-head > div { flex-wrap: wrap; }
  .stage-result-head h3 { flex-basis: calc(100% - 39px); margin-left: 39px; font-size: 18px; }
  .group-grid { grid-template-columns: 1fr; }
  .match-table-panel summary { padding: 0 15px; }
  .section-table-panel { margin-top: 14px; }
  .section-table-panel summary { min-height: 50px; padding: 0 12px; }
  .match-table-panel summary::after, .section-table-panel summary::after { min-width: 68px; min-height: 30px; padding: 0 7px; font-size: 11px; }
  .league-diagram { padding-inline: 4px; }
  .league-diagram svg { min-height: 235px; }
  .dialog-backdrop { align-items: end; padding: 0; }
  .roster-dialog, .reset-dialog, .score-dialog, .schedule-dialog { width: 100%; max-height: min(86dvh, 760px); border-width: 2px 0 0; }
  .roster-inputs { grid-template-columns: 1fr; padding: 15px; }
  .roster-dialog > header { padding: 17px 15px 13px; }
  .dialog-actions { padding: 13px 15px calc(13px + env(safe-area-inset-bottom)); }
  .reset-dialog { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .reset-dialog .dialog-actions { padding: 0; }
  .schedule-dialog > header { padding: 15px; }
  .schedule-dialog > header p { max-width: 270px; line-height: 1.45; }
  .schedule-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .schedule-controls > label { display: grid; justify-items: stretch; gap: 5px; padding: 10px 7px; font-size: 11px; }
  .schedule-controls select, .schedule-controls input { width: 100%; height: 44px; padding: 0 6px; font-size: 16px; }
  .duration-input { gap: 3px; }
  .duration-input input { width: 100%; }
  .schedule-list { padding: 0 15px calc(15px + env(safe-area-inset-bottom)); }
  .schedule-match { grid-template-columns: 66px minmax(0, 1fr) 112px; padding: 9px 0; }
  .schedule-match > header { align-self: stretch; justify-content: center; padding: 4px 7px 4px 0; }
  .schedule-match > header span { display: none; }
  .schedule-players { min-height: 46px; padding: 5px 8px; border-left: 1px solid var(--line); border-right: 0; }
  .schedule-time { padding: 5px 8px; border-left: 1px solid var(--line); }
  .schedule-time b { font-size: 11px; }
  .schedule-court { grid-column: 2; grid-template-columns: 32px minmax(0, 1fr); padding: 7px 0 0 8px; }
  .schedule-score-button { grid-column: 3; min-height: 36px; margin: 7px 0 0 8px; }
  .match-navigator { position: static; width: 100%; margin: 0 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .diagram-match.is-jump-highlight, .diagram-match.is-navigator-highlight, .tournament-match.is-jump-highlight, .tournament-match.is-navigator-highlight, .match-table tr.is-navigator-highlight { animation: none; }
}

@media print {
  body { background: #fff; }
  .site-header, .configuration-panel, .toast, .match-navigator { display: none !important; }
  .composer { width: 100%; padding: 0; }
  .result-panel { margin: 0; border: 0; }
  .bracket-scroll, .table-scroll { overflow: visible; }
  .stage-result-block { break-inside: avoid; }
}
