:root {
  color-scheme: dark;
  --bg: #02091c;
  --panel: #061b2d;
  --panel-2: #0a2639;
  --line: rgba(172, 224, 255, 0.2);
  --line-strong: rgba(105, 244, 232, 0.42);
  --text: #f3f7ff;
  --muted: #b8c8d6;
  --cyan: #10f1e7;
  --lime: #ecff00;
  --red: #f3212d;
  --pink: #f016b8;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
  background:
    radial-gradient(circle at 78% 16%, rgba(16, 241, 231, 0.09), transparent 28rem),
    linear-gradient(135deg, #021126 0%, #061c32 46%, #071866 100%);
}

button,
input,
select,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px clamp(18px, 3vw, 42px);
  background: rgba(2, 9, 28, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.input-topbar {
  position: relative;
}

.wordmark {
  display: grid;
  gap: 2px;
  width: fit-content;
  line-height: 1;
  letter-spacing: 0;
}

.wordmark span {
  font-size: 13px;
  font-weight: 900;
  color: var(--cyan);
}

.wordmark strong {
  font-size: 24px;
  font-weight: 900;
}

.top-title h1,
.toolbar h2 {
  margin: 2px 0 0;
  font-size: clamp(22px, 2vw, 34px);
  letter-spacing: 0;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mode-button,
.primary-link,
.secondary-link,
.grade-tabs button,
.section-reset-button,
.swap-button,
.source-button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(10, 38, 57, 0.82);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.mode-button,
.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 850;
}

.mode-button:hover,
.primary-link:hover,
.secondary-link:hover,
.grade-tabs button:hover,
.section-reset-button:hover,
.swap-button:hover,
.source-button:hover {
  background: rgba(16, 241, 231, 0.16);
  border-color: var(--cyan);
}

.mode-button.is-active,
.grade-tabs button.is-active {
  background: var(--cyan);
  color: #001529;
  border-color: var(--cyan);
}

.mode-button.danger {
  border-color: rgba(243, 33, 45, 0.45);
}

.competition-tabs {
  display: flex;
  gap: 8px;
  max-width: 1720px;
  margin: 14px auto 0;
  padding: 0 clamp(14px, 2vw, 32px);
  overflow-x: auto;
  scrollbar-width: thin;
}

.competition-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(6, 27, 45, 0.76);
  font-weight: 900;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.competition-tab:hover {
  color: var(--text);
  background: rgba(16, 241, 231, 0.14);
  border-color: var(--line-strong);
}

.competition-tab.is-active {
  color: #001529;
  background: var(--cyan);
  border-color: var(--cyan);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  max-width: 1720px;
  margin: 0 auto;
  padding: 20px clamp(14px, 2vw, 32px) 48px;
}

.side-panel,
.toolbar,
.panel,
.group-card,
.match-card,
.knockout-card,
.draw-panel,
.source-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 27, 45, 0.88);
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 100px;
  align-self: start;
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-heading strong {
  font-size: 24px;
}

.grade-tabs {
  display: grid;
  gap: 8px;
}

.grade-tabs button {
  min-height: 44px;
  padding: 0 14px;
  text-align: left;
  font-weight: 900;
}

.quick-info {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  color: var(--muted);
}

.quick-info div {
  display: grid;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.quick-info dt {
  font-size: 12px;
  font-weight: 900;
  color: var(--cyan);
}

.quick-info dd {
  margin: 0;
  line-height: 1.4;
}

.content {
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px;
  margin-bottom: 18px;
}

.save-state {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.score-app {
  display: grid;
  gap: 22px;
}

.grade-section {
  display: grid;
  gap: 18px;
}

.grade-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  padding: 22px;
  overflow: hidden;
}

.grade-hero .title {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 260px;
}

.grade-hero h3 {
  margin: 0;
  font-size: clamp(42px, 5vw, 76px);
  line-height: 0.95;
}

.grade-hero .meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), #fff7a4);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 128px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 38, 57, 0.62);
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  font-size: clamp(22px, 2.2vw, 32px);
}

.recent-list,
.leader-list {
  display: grid;
  gap: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: 52px 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  min-width: 0;
}

.next-match-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.next-match-line strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
  line-height: 1.15;
}

.next-match-line strong:last-child {
  text-align: right;
}

.mini-row strong {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-row em {
  display: inline-flex;
  justify-content: center;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 6px;
  color: #001529;
  background: #f2f5f7;
  font-style: normal;
  font-weight: 900;
}

.leader-list .mini-row {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.leader-list .mini-row strong,
.recent-list .mini-row strong {
  font-size: 18px;
  line-height: 1.15;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h3 {
  margin: 0;
  color: var(--cyan);
  font-size: clamp(24px, 2.2vw, 34px);
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section-reset-button,
.source-button {
  min-height: 36px;
  padding: 0 12px;
  font-weight: 850;
}

.group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.group-card {
  overflow: hidden;
}

.group-card-horizontal {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(620px, 1.28fr);
  align-items: start;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.group-card-horizontal .group-title {
  grid-column: 1 / -1;
}

.group-title strong {
  font-size: 24px;
}

.team-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.standings {
  display: grid;
  gap: 0;
  min-width: 0;
  padding: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.standings::-webkit-scrollbar,
.group-card-horizontal::-webkit-scrollbar,
.top-actions::-webkit-scrollbar,
.competition-tabs::-webkit-scrollbar {
  height: 8px;
}

.standings::-webkit-scrollbar-thumb,
.group-card-horizontal::-webkit-scrollbar-thumb,
.top-actions::-webkit-scrollbar-thumb,
.competition-tabs::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(105, 244, 232, 0.42);
}

.group-card-horizontal .standings {
  border-left: 1px solid var(--line);
}

.team-pill {
  display: grid;
  grid-template-columns: 28px 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 9, 28, 0.28);
}

.team-pill strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-pill .rank {
  color: var(--muted);
  font-size: 24px;
}

.team-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

.team-logo.placeholder {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(16, 241, 231, 0.14);
  color: var(--cyan);
  font-weight: 900;
}

.standings-row {
  display: grid;
  grid-template-columns: 34px 42px minmax(150px, 1fr) repeat(8, 38px);
  align-items: center;
  gap: 8px;
  min-width: 620px;
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.standings-row strong {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standings-row > span,
.standings-row > strong {
  white-space: nowrap;
}

.standings-row > span:not(:first-child) {
  text-align: center;
}

.standings-row.header {
  min-height: 34px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
}

.standings-row.header span:nth-child(3) {
  text-align: left;
}

.draw-grid,
.prelim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}

.draw-panel {
  padding: 16px;
}

.draw-control {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.draw-control label {
  color: var(--cyan);
  font-weight: 900;
}

.draw-control select,
.winner-select {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 12px;
  color: #001529;
  background: #f2f5f7;
  font-weight: 850;
}

.match-card,
.knockout-card {
  padding: 14px;
}

.match-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.match-meta strong {
  color: var(--text);
}

.score-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.team-side {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
}

.team-side.team-away {
  justify-content: flex-end;
  text-align: right;
}

.team-side span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pair {
  display: inline-grid;
  grid-template-columns: 62px auto 62px;
  gap: 8px;
  align-items: center;
}

.score-pair input,
.score-chip {
  width: 62px;
  height: 56px;
  border: 0;
  border-radius: var(--radius);
  text-align: center;
  color: #001529;
  background: #f2f5f7;
  font-size: 24px;
  font-weight: 900;
}

.score-chip {
  display: grid;
  place-items: center;
}

.score-pair span {
  color: var(--text);
  font-weight: 900;
}

.score-pair input:disabled {
  opacity: 0.42;
}

.knockout-division {
  display: grid;
  gap: 12px;
}

.division-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 0;
}

.division-head strong {
  color: var(--cyan);
  font-size: 22px;
}

.knockout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.round-column {
  display: grid;
  align-content: start;
  gap: 12px;
}

.round-title {
  color: var(--cyan);
  font-weight: 900;
}

.knockout-card {
  display: grid;
  gap: 12px;
}

.slot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.slot-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
}

.slot-name small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.slot-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-row.pending .slot-name {
  color: var(--muted);
}

.slot-row.winner .slot-name {
  color: var(--lime);
}

.ko-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.swap-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.swap-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.swap-button::before {
  content: "\21C5";
  font-size: 22px;
  font-weight: 900;
}

.shootout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.shootout strong {
  color: var(--cyan);
}

.shootout small {
  color: var(--muted);
}

.source-panel {
  padding: 16px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.source-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 9, 28, 0.34);
}

.source-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.lightbox {
  width: min(96vw, 1280px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 44px 14px 14px;
  background: #02091c;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.lightbox img {
  width: 100%;
  height: auto;
  display: block;
}

.lightbox-close {
  position: absolute;
  right: 10px;
  top: 8px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.home {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 22px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 50px 0;
}

.home-hero {
  padding: clamp(28px, 6vw, 76px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(6, 27, 45, 0.82);
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--cyan);
  font-weight: 900;
}

.home h1 {
  max-width: 840px;
  margin: 16px 0;
  font-size: clamp(40px, 6vw, 84px);
  line-height: 1.05;
  letter-spacing: 0;
}

.home-copy {
  max-width: 680px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.home-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.home-info div {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 27, 45, 0.72);
}

.home-info span {
  color: var(--cyan);
  font-weight: 900;
}

@media (max-width: 980px) {
  .topbar {
    position: relative;
    grid-template-columns: 1fr;
  }

  .top-actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .top-actions > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .grade-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grade-tabs button {
    min-height: 46px;
    padding: 0 8px;
    white-space: nowrap;
    font-size: 14px;
    text-align: center;
  }

  .grade-hero {
    grid-template-columns: 1fr;
  }

  .grade-hero .title {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 22px 0 / 28px 28px,
      linear-gradient(135deg, #021126 0%, #052235 58%, #081a68 100%);
  }

  .topbar {
    padding: 14px;
  }

  .wordmark strong {
    font-size: 20px;
  }

  .top-title h1 {
    font-size: 22px;
  }

  .layout {
    padding: 14px 10px 36px;
  }

  .toolbar {
    display: grid;
    padding: 14px;
  }

  .save-state {
    white-space: normal;
  }

  .hero-grid,
  .home-info {
    grid-template-columns: 1fr;
  }

  .grade-hero {
    padding: 16px;
  }

  .draw-grid,
  .prelim-grid,
  .knockout-grid {
    grid-template-columns: 1fr;
  }

  .group-grid {
    grid-template-columns: 1fr;
  }

  .group-card-horizontal {
    display: block;
    overflow: hidden;
  }

  .group-card-horizontal .standings {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .standings-row {
    grid-template-columns: 34px 40px minmax(170px, 1fr) repeat(8, 44px);
    min-width: 680px;
  }

  .score-line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    row-gap: 10px;
  }

  .score-line > .team-home {
    grid-column: 1;
    grid-row: 1;
  }

  .score-line > .team-away {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    text-align: right;
  }

  .score-pair {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    grid-template-columns: 1fr auto 1fr;
  }

  .score-pair input,
  .score-chip {
    width: 100%;
    min-width: 72px;
    height: 64px;
  }

  .slot-row {
    grid-template-columns: 1fr;
  }

  .slot-row .score-chip,
  .slot-row .score-pair {
    width: 100%;
  }

  .shootout {
    grid-template-columns: 1fr;
  }

  .source-card img {
    height: 120px;
  }
}

@media print {
  .topbar,
  .side-panel,
  .source-panel,
  .section-actions,
  .draw-panel {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
  }

  .layout {
    display: block;
    max-width: none;
  }

  .panel,
  .group-card,
  .match-card,
  .knockout-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
