:root,
[data-theme="dark"] {
  color-scheme: dark;
  --hu-red: #e04456;
  --hu-red-hover: #c93345;
  --hu-red-soft: rgba(224, 68, 86, 0.16);
  --hu-red-border: rgba(224, 68, 86, 0.42);
  --hu-white: #ffffff;
  --hu-green: #4e9f63;
  --hu-green-deep: #3d8550;
  --hu-green-text: #8dd4a0;
  --hu-green-soft: rgba(78, 159, 99, 0.16);
  --bg: #0c110e;
  --surface: #141c17;
  --surface-subtle: #1a241e;
  --surface-elevated: #1e2a23;
  --border: #28362d;
  --ink: #edf3ee;
  --ink-muted: #9eb0a3;
  --chung: #4b83f2;
  --chung-soft: rgba(75, 131, 242, 0.14);
  --hong: #e04456;
  --hong-soft: rgba(224, 68, 86, 0.14);
  --ongoing-grad: linear-gradient(180deg, rgba(224, 68, 86, 0.14) 0%, var(--surface) 100%);
  --badge-upcoming-border: rgba(78, 159, 99, 0.42);
  --badge-done-bg: #1e2822;
  --table-head-bg: #18211b;
  --backdrop: rgba(4, 8, 6, 0.72);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  --radius: 12px;
}

[data-theme="light"] {
  color-scheme: light;
  --hu-red: #cd2a3e;
  --hu-red-hover: #a81f30;
  --hu-red-soft: #fdf2f3;
  --hu-red-border: #f3bcc3;
  --hu-white: #ffffff;
  --hu-green: #436f4d;
  --hu-green-deep: #2b5335;
  --hu-green-text: #2b5335;
  --hu-green-soft: #eef5f0;
  --bg: #f6f8f6;
  --surface: #ffffff;
  --surface-subtle: #f0f4f1;
  --surface-elevated: #ffffff;
  --border: #dfe7e1;
  --ink: #162019;
  --ink-muted: #4a5a4f;
  --chung: #1d4ed8;
  --chung-soft: #eff6ff;
  --hong: #cd2a3e;
  --hong-soft: #fdf2f3;
  --ongoing-grad: linear-gradient(180deg, #fffafb 0%, #ffffff 100%);
  --badge-upcoming-border: #b7d3bd;
  --badge-done-bg: #eef1ef;
  --table-head-bg: #f0f4f1;
  --backdrop: rgba(16, 24, 18, 0.55);
  --shadow-sm: 0 1px 2px rgba(22, 32, 25, 0.06);
  --shadow-md: 0 6px 20px rgba(22, 32, 25, 0.08);
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: rgba(205, 42, 62, 0.2);
}

@media (pointer: fine) {
  html {
    overscroll-behavior: none;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  overflow-x: clip;
}

.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: -9999px;
  top: 0;
  background: var(--hu-red);
  color: var(--hu-white);
  padding: 0.6rem 1rem;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  border-radius: 6px;
}

:focus-visible {
  outline: 3px solid var(--hu-green);
  outline-offset: 2px;
}

.tricolor-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  height: 4px;
  width: 100%;
}

.tricolor-red {
  background: var(--hu-red);
}

.tricolor-white {
  background: var(--hu-white);
}

.tricolor-green {
  background: var(--hu-green);
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.45rem 0.75rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0.5rem 1.25rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-crest {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .brand-title {
    font-size: 1.1rem;
  }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--hu-green);
  background: var(--hu-green-soft);
  color: var(--hu-green-text);
}

.icon-btn.active {
  border-color: var(--hu-green);
  background: var(--hu-green-soft);
  color: var(--hu-green-text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  border-color: var(--hu-green);
  background: var(--hu-green-soft);
  color: var(--hu-green-text);
}

.btn-sm {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--hu-green);
  color: var(--hu-white);
  border-color: var(--hu-green);
}

.btn-primary:hover {
  background: var(--hu-green-deep);
  border-color: var(--hu-green-deep);
  color: var(--hu-white);
}

/* Slide-out Hamburger Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 150;
  display: flex;
  justify-content: flex-end;
}

.config-drawer {
  width: min(320px, 88vw);
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 4px solid var(--hu-red);
  box-shadow: var(--shadow-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  color: var(--ink);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.drawer-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
}

.seg-btn {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.seg-btn:hover {
  color: var(--ink);
  background: var(--surface-subtle);
}

.seg-btn.active {
  background: var(--hu-green);
  color: var(--hu-white);
  border-color: var(--hu-green);
}

.drawer-actions {
  margin-top: 0.4rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.drawer-refresh-btn {
  width: 100%;
  min-height: 44px;
  font-size: 0.92rem;
}

.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem;
}

@media (min-width: 768px) {
  .main-container {
    padding: 1.25rem;
  }
}

.top-search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--hu-green);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .top-search-panel {
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
  }
}

.search-primary-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-main-input {
  flex: 1 1 auto;
  min-width: 0;
}

.filter-toggle-btn {
  position: relative;
}

.filter-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--hu-red);
  color: var(--hu-white);
  font-size: 0.68rem;
  line-height: 18px;
  text-align: center;
}

.advanced-filters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
  .advanced-filters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

.search-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.match-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  background: var(--hu-green-soft);
  color: var(--hu-green-text);
  border: 1px solid var(--badge-upcoming-border);
  font-size: 0.8rem;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.field label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0.48rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

@media (min-width: 768px) {
  .input,
  .select {
    font-size: 0.92rem;
  }
}

.discipline-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .discipline-panel {
    padding: 1rem;
  }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.8rem;
  border-bottom: 2px solid var(--hu-green);
}

.panel-header.kyorugi {
  border-bottom-color: var(--hu-red);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.02rem;
  text-wrap: balance;
}

@media (min-width: 768px) {
  .panel-header h2 {
    font-size: 1.12rem;
  }
}

.section-heading {
  margin: 0 0 0.55rem 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  }
}

.cards-grid-compact {
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .cards-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.ongoing-courts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .ongoing-courts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .ongoing-courts-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.upcoming-courts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: start;
}

@media (min-width: 640px) {
  .upcoming-courts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .upcoming-courts-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.upcoming-courts-grid.single-court {
  grid-template-columns: 1fr;
}

.court-column {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
}

.court-col-head {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--hu-green-text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.court-col-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.match-card {
  width: 100%;
  text-align: left;
  background: var(--surface-elevated);
  color: var(--ink);
  border: 1px solid var(--border);
  border-left: 4px solid var(--hu-green);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.match-card.ongoing {
  border-left-color: var(--hu-red);
  background: var(--ongoing-grad);
}

.match-card:hover {
  border-color: var(--hu-red);
  box-shadow: var(--shadow-md);
}

.match-card.compact {
  padding: 0.45rem 0.6rem;
  gap: 0.3rem;
  border-radius: 9px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.compact-meta {
  font-size: 0.74rem;
}

.compact-id {
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem 0.48rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge-live {
  background: var(--hu-red);
  color: var(--hu-white);
}

.badge-upcoming {
  background: var(--hu-green-soft);
  color: var(--hu-green-text);
  border: 1px solid var(--badge-upcoming-border);
}

.badge-done {
  background: var(--badge-done-bg);
  color: var(--ink-muted);
}

.card-category {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competitor-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 7px;
}

.match-card.compact .competitor-row {
  grid-template-columns: 6px minmax(0, 1fr);
  gap: 0.45rem;
  padding: 0.22rem 0.4rem;
}

.competitor-row.blue {
  background: var(--chung-soft);
}

.competitor-row.red {
  background: var(--hong-soft);
}

.corner-bar {
  width: 6px;
  height: 28px;
  border-radius: 4px;
}

.match-card.compact .corner-bar {
  width: 4px;
  height: 22px;
}

.corner-bar.blue {
  background: var(--chung);
}

.corner-bar.red {
  background: var(--hong);
}

.competitor-info {
  min-width: 0;
}

.competitor-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-card.compact .competitor-name {
  font-size: 0.88rem;
  line-height: 1.2;
}

.competitor-club {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-card.compact .competitor-club {
  font-size: 0.72rem;
  line-height: 1.15;
}

.score-box {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.penalties-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--hu-red);
  background: var(--hu-red-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.table-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-btn {
  min-height: 38px;
  padding: 0.4rem 0.72rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn.active {
  background: var(--hu-green);
  color: var(--hu-white);
  border-color: var(--hu-green);
}

.results-mobile-cards {
  display: block;
}

.results-desktop-table {
  display: none;
}

@media (min-width: 768px) {
  .results-mobile-cards {
    display: none;
  }

  .results-desktop-table {
    display: block;
  }
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--table-head-bg);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.text-muted {
  color: var(--ink-muted);
}

.num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.row-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--hu-green-text);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.row-btn:hover {
  background: var(--hu-green-soft);
  border-color: var(--hu-green);
}

.winner-name {
  text-decoration: underline;
  text-decoration-color: var(--hu-green);
  text-decoration-thickness: 2px;
}

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

.status-pill.err {
  display: inline-flex;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  background: var(--hu-red-soft);
  border: 1px solid var(--hu-red-border);
  color: var(--hu-red);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  z-index: 200;
}

.modal-dialog {
  width: 100%;
  max-width: 720px;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-top: 5px solid var(--hu-red);
  box-shadow: var(--shadow-md);
  padding: 1rem;
}

@media (min-width: 768px) {
  .modal-dialog {
    padding: 1.15rem 1.25rem;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
