/*
 * ECE Badminton visual system
 * Concept: a badminton umpire's scorecard — ruled, direct, and built for fast scanning.
 * This file is intentionally an override layer so it can be removed without touching app logic.
 */
:root {
  --navy: #294f73;
  --blue: #356d9b;
  --cyan: #507fa8;
  --green: #287657;
  --red: #b43d3d;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #cbd5e1;
  --line-strong: #aab9c9;
  --bg: #f8fafc;
  --card: #ffffff;
  --paper-tint: #eaf0f6;
  --shadow: none;
  --display-face: "DIN Alternate", "Arial Narrow", "Roboto Condensed", "Noto Sans TC", sans-serif;
  --body-face: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

html[data-theme="dark"] {
  --navy: #8ec1ff;
  --blue: #69a9f5;
  --cyan: #73c4ff;
  --green: #55c890;
  --red: #ff7b7b;
  --ink: #edf3fa;
  --muted: #a6b2c1;
  --line: #33465a;
  --line-strong: #526b84;
  --bg: #0d1722;
  --card: #152231;
  --paper-tint: #192838;
  --shadow: none;
}

body {
  font-family: var(--body-face);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(80, 127, 168, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 127, 168, .03) 1px, transparent 1px);
  background-size: 32px 32px;
}

html[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(142, 193, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142, 193, 255, .025) 1px, transparent 1px);
}

.topbar {
  height: 74px;
  background: #294f73;
  border-bottom: 3px solid #6f9bbe;
  box-shadow: none;
}

html[data-theme="dark"] .topbar {
  background: #0a315f;
  border-bottom-color: #2d8de4;
}

.topbar strong {
  font-family: var(--display-face);
  font-size: 18px;
  font-stretch: condensed;
  letter-spacing: .11em;
}

.topbar span { font-size: 12px; letter-spacing: .16em; }

.brand-mark {
  height: 42px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 5px;
  box-shadow: none;
}

.theme-toggle,
.theme-toggle[aria-pressed="true"] {
  border-radius: 5px;
  box-shadow: none;
}

.badge {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 4px;
  font-family: var(--display-face);
  font-weight: 700;
  letter-spacing: .04em;
}

.badge.online { background: #137a4b; }
.badge.offline { background: #bd3434; }

main { padding-top: 32px; }

.card {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--card);
  box-shadow: none;
}

.hero,
html[data-theme="dark"] .hero {
  position: relative;
  overflow: hidden;
  border-top: 5px solid var(--blue);
  background: var(--card);
}

.hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 26%;
  bottom: 0;
  width: 1px;
  background: var(--line);
  pointer-events: none;
}

h1,
h2,
.stat strong,
.court-label,
.queue-summary strong,
.room-code,
.quick-score-input {
  font-family: var(--display-face);
  font-stretch: condensed;
}

h1 {
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -.025em;
}

h2 { letter-spacing: -.01em; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  letter-spacing: .18em;
  font-size: 12px;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  background: currentColor;
}

.stats { gap: 10px; }

.stat {
  position: relative;
  min-height: 116px;
  border-top: 4px solid var(--line-strong);
}

.stat::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 28px;
  height: 28px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat strong {
  color: var(--navy);
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.section-title { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.card > .section-title:last-child { margin-bottom: 0; }

button,
.button-link {
  min-height: 44px;
  border-radius: 5px;
  box-shadow: none;
  letter-spacing: .02em;
}

button:hover,
.button-link:hover { filter: none; transform: translateY(-1px); }
button:active,
.button-link:active { transform: translateY(0); }

button.secondary,
.button-link.secondary,
html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .button-link.secondary {
  border-color: var(--line-strong);
  border-radius: 5px;
  background: var(--card);
  color: var(--blue);
}

input,
select,
textarea {
  min-height: 44px;
  border-color: var(--line-strong);
  border-radius: 4px;
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-color: var(--blue);
}

.list { gap: 0; }

.list-row,
html[data-theme="dark"] .list-row {
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.list-row:first-child { border-top: 1px solid var(--line); }

.avatar,
.player-avatar {
  border: 1px solid color-mix(in srgb, var(--blue) 34%, var(--line));
  border-radius: 4px;
  background: color-mix(in srgb, var(--blue) 13%, var(--card));
  color: var(--blue);
}

.action,
.player-presence,
.session-rule,
.court-state,
.match-timer,
.admin-match-timer,
.stat #adminSessionState {
  border: 1px solid currentColor;
  border-radius: 4px;
  box-shadow: none;
  letter-spacing: .04em;
}

.player-list { gap: 8px; }
.player-row { border-left: 4px solid var(--line-strong); }
.player-row:first-child { border-left-color: var(--blue); }
.player-rank { font-family: var(--display-face); font-size: 22px; }
.player-record strong { font-family: var(--display-face); font-variant-numeric: tabular-nums; }

.table-card { overflow: hidden; }
.table-wrap { border: 1px solid var(--line); }
table { background: var(--card); }
th {
  background: var(--paper-tint);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: .055em;
  font-size: 12px;
}
th,
td { border-right: 1px solid var(--line); }
th:last-child,
td:last-child { border-right: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--blue) 5%, var(--card)); }

.bottom-nav,
html[data-theme="dark"] .bottom-nav {
  height: 76px;
  border: 0;
  border-top: 3px solid var(--blue);
  border-radius: 0;
  background: var(--card);
  box-shadow: none;
}

.bottom-nav button {
  position: relative;
  min-height: 72px;
  border-right: 1px solid var(--line);
}

.bottom-nav button:last-child { border-right: 0; }
.bottom-nav button.active { background: color-mix(in srgb, var(--blue) 8%, var(--card)); }
.bottom-nav button.active::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 25%;
  width: 50%;
  height: 3px;
  background: var(--blue);
}

.bottom-nav span { font-size: 12px; }

/* Keep the app navigation beside wide or landscape layouts instead of
   visually cutting the content in half at the bottom of the viewport. */
@media (min-width: 761px), (orientation: landscape) and (min-width: 640px) {
  body.member-site { --member-nav-rail: 96px; }

  body.member-site #memberApp:not([hidden]) {
    max-width: calc(1180px + var(--member-nav-rail));
    padding-right: 20px;
    padding-bottom: 42px;
    padding-left: calc(var(--member-nav-rail) + 20px);
  }

  body.member-site .member-nav:not([hidden]) {
    top: 74px;
    bottom: 0;
    left: 0;
    width: var(--member-nav-rail);
    height: auto;
    padding: 12px 0;
    transform: none;
    flex-direction: column;
    justify-content: flex-start;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: var(--card);
  }

  body.member-site .member-nav button {
    flex: 0 0 78px;
    width: 100%;
    min-height: 78px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.member-site .member-nav button:last-child { border-bottom: 0; }
  body.member-site .member-nav button.active::before {
    top: 20%;
    left: 0;
    width: 3px;
    height: 60%;
  }

  body.member-site #toast { bottom: 20px; }
}

.nav-icon {
  display: block;
  width: 21px;
  height: 21px;
  margin: 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

#toast {
  max-width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  box-shadow: none;
}

.queue-progress-track,
.queue-progress-track span { border-radius: 2px; }
.queue-progress-track span,
.request-progress-bar { background: var(--blue); }

.requeue-prompt,
.continue-registration,
.court-card.available,
html[data-theme="dark"] .requeue-prompt,
html[data-theme="dark"] .continue-registration,
html[data-theme="dark"] .court-card.available {
  border-left: 5px solid var(--green);
  border-radius: 6px;
  background: var(--card);
}

.team-choice,
.pass-required,
.selection-bar,
.quick-score-team,
.quick-score-side,
.score-step,
.score-validity,
.first-server,
.danger-confirm-panel,
.initial-rating-options span {
  border-radius: 5px;
}

.queue-mode-chooser { gap: 10px; border: 0; }
.mode-picker,
.join-mode-picker { gap: 0; border: 1px solid var(--line-strong); }
.queue-mode-chooser .mode-picker { margin: 0; }
.queue-mode-chooser button,
html[data-theme="dark"] .queue-mode-chooser button {
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-radius: 0;
}
.queue-mode-chooser button { background: var(--card); color: var(--blue); }
.queue-mode-chooser button.active { background: var(--blue); color: #fff; }
.mode-picker button:last-child,
.join-mode-picker button:last-child { border-right: 0; }

.court-card { border-top: 4px solid var(--line-strong); }
.court-card.occupied { border-top-color: var(--blue); }
.court-card.pending { border-top-color: #b47a16; }

.quick-score-board {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  gap: 0;
  min-width: 0;
}

.quick-score-team,
html[data-theme="dark"] .quick-score-team {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.quick-score-vs { margin: 0; padding: 5px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quick-score-input { font-size: 36px; }
.quick-score-card { container-type: inline-size; min-width: 0; }
.quick-score-player,
.quick-score-player > div,
.quick-score-controls { min-width: 0; }
.quick-score-player strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.match-found-card p:not(.eyebrow) { overflow-wrap: anywhere; }

@container (max-width: 560px) {
  .quick-score-team { grid-template-columns: minmax(0, 1fr); }
  .quick-score-controls {
    grid-template-columns: 48px minmax(64px, 1fr) 48px;
    width: 100%;
  }
  .score-step { width: 48px; }
  .quick-score-input { width: 100%; }
}

@media (min-width: 761px) and (max-width: 1240px) {
  .courts-grid { grid-template-columns: minmax(0, 1fr); }
}

.match-found-overlay,
.confirm-overlay,
.initial-rating-overlay {
  background: rgba(7, 18, 31, .82);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.match-found-card,
html[data-theme="dark"] .match-found-card,
.confirm-card,
.initial-rating-card {
  border: 2px solid var(--line-strong);
  border-top: 7px solid var(--blue);
  border-radius: 7px;
  background: var(--card);
  box-shadow: none;
}

.match-found-shuttle {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  color: var(--blue);
}
.match-found-shuttle svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.request-progress { backdrop-filter: none; -webkit-backdrop-filter: none; }
.request-progress strong,
html[data-theme="dark"] .request-progress strong {
  border-radius: 4px;
  box-shadow: none;
}

.activity-history-toolbar { border: 1px solid var(--line); padding: 12px; }
.danger-zone { border-width: 2px; }

@media (max-width: 760px) {
  main { padding-top: 20px; }
  .hero::after { display: none; }
  .hero { gap: 22px; }
  .stats { gap: 6px; }
  .stat { min-height: 100px; padding: 12px; }
  .stat::after { width: 20px; height: 20px; right: 9px; bottom: 9px; }
  .stat strong { font-size: 34px; }
  .card { border-radius: 6px; }
  .player-row { border-radius: 4px; }
}

@media (max-width: 520px) {
  body { background-size: 24px 24px; }
  main { padding: 18px 10px 100px; }
  .topbar {
    height: 70px;
    gap: 7px;
    padding: 0 10px;
  }
  .topbar > div:nth-child(2) {
    min-width: 0;
    flex: 1 1 auto;
  }
  .topbar strong {
    overflow: hidden;
    font-size: 14px;
    letter-spacing: .075em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar span {
    overflow: hidden;
    font-size: 9px;
    letter-spacing: .08em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand-mark {
    width: 56px;
    height: 34px;
    padding: 4px 5px;
  }
  .topbar-actions { flex: 0 0 auto; gap: 5px; }
  .topbar-actions .badge {
    max-width: 88px;
    padding: 7px 8px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .theme-toggle {
    width: 34px;
    height: 34px;
  }
  .hero { flex-direction: column; }
  .hero button { width: 100%; }
  #adminContent > .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #adminContent > .stats .stat:first-child {
    grid-column: 1 / -1;
    min-height: 86px;
  }
  #adminContent > .stats .stat {
    min-width: 0;
    min-height: 88px;
    padding: 13px 14px;
  }
  #adminContent > .stats .stat span { min-height: 0; }
  #adminContent > .stats .stat strong {
    margin-top: 9px;
    font-size: 30px;
  }
  #adminContent > .stats .stat #adminSessionState {
    padding: 6px 9px;
    font-size: 20px;
    white-space: nowrap;
  }
  #adminContent > .section-title .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  #adminContent > .section-title .button-row > * { width: 100%; }
  .admin-grid { gap: 12px; }
  .admin-grid > .card { padding: 18px 14px; }
  .session-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .session-actions button { min-width: 0; padding-inline: 10px; }
  .table-card {
    min-width: 0;
    padding: 18px 14px;
    overflow: hidden;
  }
  .table-card .section-title { width: 100%; }
  .table-card .section-title > * { min-width: 0; }
  .table-card .section-title span {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .table-wrap {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .section-title { gap: 8px; }
  .bottom-nav span { letter-spacing: .04em; }
  #activityHistoryTable tr {
    border-radius: 4px;
    background: var(--paper-tint);
  }
  #activityHistoryTable td::before { font-size: 12px; }
}

@media (max-width: 360px) {
  .topbar .brand-copy span,
  .topbar > div:nth-child(2) span { display: none; }
  .topbar-actions .badge { max-width: 72px; }
  #adminContent > .section-title h1 { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .button-link { transform: none !important; }
}
