:root {
  color-scheme: light;
  --navy-950: #081426;
  --navy-900: #0c1d35;
  --navy-800: #132b4d;
  --blue-600: #2563eb;
  --cyan-500: #06b6d4;
  --green-500: #10b981;
  --amber-500: #f59e0b;
  --red-500: #ef4444;
  --slate-900: #172033;
  --slate-600: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --surface: #ffffff;
}

html.scoreboard-loading body {
  visibility: hidden;
  animation: reveal-fallback 0s 3s forwards;
}

@keyframes reveal-fallback {
  to { visibility: visible; }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.scoreboard-app {
  margin: 0;
  min-width: 320px;
  color: var(--slate-900);
  background:
    radial-gradient(circle at 15% -10%, rgba(37, 99, 235, .14), transparent 34rem),
    #f4f7fb;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.55;
}

a { color: var(--blue-600); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }

.scoreboard-hero {
  position: relative;
  overflow: hidden;
  padding: 34px max(24px, calc((100vw - 1440px) / 2));
  color: #fff;
  background: linear-gradient(125deg, var(--navy-950), var(--navy-800));
}

.scoreboard-hero::after {
  position: absolute;
  inset: -80% -5% auto auto;
  width: 420px;
  height: 420px;
  border: 80px solid rgba(6, 182, 212, .12);
  border-radius: 50%;
  content: "";
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #67e8f9;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
}

.scoreboard-hero h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 1.22;
  letter-spacing: -.025em;
}

.live-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(255,255,255,.08);
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 5px rgba(52, 211, 153, .16);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } }

.scoreboard-main {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.info-card {
  min-width: 0;
  padding: 17px 19px;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 8px 25px rgba(15, 23, 42, .05);
  font-size: 14px;
}

.info-card p { margin: 0; }
.info-card br { line-height: 1.9; }
.info-card span[style*="red"] { color: #dc2626 !important; font-weight: 800; }
.info-card span[style*="blueviolet"] {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  color: #6d28d9 !important;
  background: #ede9fe;
  font-family: ui-monospace, monospace;
  font-weight: 900;
}

.board-panel {
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 16px 42px rgba(15, 23, 42, .08);
}

.board-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--slate-200);
}

.search-wrap { position: relative; flex: 1 1 340px; max-width: 520px; }
.search-wrap::before {
  position: absolute;
  top: 50%; left: 14px;
  transform: translateY(-50%);
  color: var(--slate-600);
  content: "⌕";
  font-size: 22px;
}

.team-search {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--slate-300);
  border-radius: 11px;
  outline: none;
  color: var(--slate-900);
  background: var(--slate-100);
  font: inherit;
}

.team-search:focus {
  border-color: var(--blue-600);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}

.board-stats { margin-left: auto; color: var(--slate-600); font-size: 14px; font-weight: 700; white-space: nowrap; }

.refresh-button {
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--blue-600);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.refresh-button:hover { background: #1d4ed8; }
.refresh-button:focus-visible { outline: 3px solid rgba(37,99,235,.3); outline-offset: 2px; }

.table-scroll {
  max-height: none;
  overflow: visible;
}

.score-table {
  width: 100% !important;
  min-width: 900px;
  border: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.score-table tr { font-size: 14px !important; }

.score-table td {
  height: 52px;
  padding: 9px 12px;
  border: 0 !important;
  border-bottom: 1px solid var(--slate-200) !important;
  background: #fff;
  vertical-align: middle;
}

.score-table tr:first-child td {
  position: sticky;
  z-index: 4;
  top: 0;
  height: 48px;
  color: #fff;
  border-bottom: 0 !important;
  background: var(--navy-900);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-decoration: none;
}

.score-table tr:first-child u { text-decoration: none; }
.score-table tr:not(:first-child) td { background: #fff; }
.score-table tr.is-even-row td { background: #f1f5f9; }
.score-table tr:not(:first-child):hover td { background: #e8f1ff; }
.score-table tr.is-hidden { display: none; }

.score-table td:nth-child(1) { width: 86px !important; font-weight: 900; }
.score-table td:nth-child(2) {
  width: 270px !important;
  text-align: left !important;
  font-weight: 800;
  overflow-wrap: anywhere;
  white-space: normal;
}
.score-table td:nth-child(3) { width: 220px !important; text-align: left !important; color: var(--slate-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-table td:nth-child(n+4) { width: 68px !important; }

.score-table tr:not(:first-child) td:nth-child(n+4) span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: #047857 !important;
  background: #d1fae5;
  font-size: 16px;
  font-weight: 900;
}

.rank-badge {
  display: inline-grid;
  min-width: 36px;
  height: 28px;
  padding: 0 7px;
  place-items: center;
  border-radius: 9px;
  background: var(--slate-100);
}

.empty-state { display: none; padding: 48px 20px; color: var(--slate-600); text-align: center; }
.empty-state.is-visible { display: block; }

@media (max-width: 860px) {
  .scoreboard-hero { padding: 25px 20px; }
  .hero-inner { align-items: flex-start; flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
  .scoreboard-main { width: min(100% - 20px, 1440px); margin-top: 10px; }
  .board-toolbar { align-items: stretch; flex-wrap: wrap; }
  .search-wrap { max-width: none; flex-basis: 100%; }
  .board-stats { margin: auto 0; }
  .table-scroll { overflow-x: auto; overflow-y: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation: none !important; }
  html.scoreboard-loading body { animation: reveal-fallback 0s 3s forwards !important; }
}
