:root {
  --bg: #031028;
  --ink: #e8f4ff;
  --muted: #8eb6dc;
  --cyan: #3ad0ff;
  --line: rgba(80, 186, 255, 0.45);
  --gold: #ffd15c;
  --font: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --num: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100vh;
  height: 100vh;
  padding: 12px 16px 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  background:
    radial-gradient(900px 280px at 50% 0%, rgba(40, 130, 255, 0.28), transparent 70%),
    linear-gradient(180deg, #062048 0%, #031028 42%, #020816 100%);
  overflow: hidden;
}
body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(70, 150, 230, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 150, 230, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 30%, #000 40%, transparent 80%);
}

.mast { position: relative; z-index: 30; }
.bottom { display: flex; flex-direction: column; min-height: 0; height: 100%; position: relative; z-index: 1; }
.event-chart { flex: 1; width: 100%; height: auto; min-height: 0; }
.mast {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  align-items: center;
  min-height: 78px;
}
.banner { text-align: center; }
.banner p { margin: 0; color: var(--cyan); letter-spacing: 0.22em; font-size: 13px; }
.banner h1 {
  margin: 2px 0 0;
  font-family: var(--num);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px rgba(58, 208, 255, 0.55);
}
.clock-box { text-align: right; }
time { font-family: var(--num); font-size: 32px; letter-spacing: 0.04em; }

.event-btn, .ranges button, .sex-switch button, .grade-switch button {
  font-family: inherit;
  color: var(--ink);
  background: rgba(6, 32, 72, 0.8);
  border: 1px solid var(--line);
  cursor: pointer;
  min-height: 40px;
}
.event-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: 22px;
  font-weight: 700;
  box-shadow: inset 0 0 16px rgba(58, 208, 255, 0.18);
}
.event-btn em { font-style: normal; color: var(--cyan); font-size: 14px; font-weight: 500; }
.event-btn:hover, .ranges button:hover, .sex-switch button:hover, .grade-switch button:hover { border-color: var(--gold); }
.event-btn:focus-visible, .ranges button:focus-visible, .sex-switch button:focus-visible, .grade-switch button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.brand { position: relative; }
.event-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  max-height: min(440px, 70vh);
  overflow: auto;
  padding: 6px;
  background: #071833;
  border: 1px solid var(--cyan);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.event-menu button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.event-menu button[aria-selected="true"], .event-menu button:hover { background: rgba(58, 208, 255, 0.16); }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.kpis article {
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(16, 70, 140, 0.45), rgba(6, 24, 58, 0.2));
  box-shadow: inset 0 0 18px rgba(30, 120, 220, 0.16);
}
.kpis span { display: block; color: var(--muted); font-size: 13px; letter-spacing: 0.08em; }
.kpis strong { font-family: var(--num); font-size: 34px; font-weight: 600; color: var(--gold); line-height: 1; }

.stage { display: grid; grid-template-columns: 320px minmax(0, 1fr) 360px; gap: 10px; min-height: 0; }
.panel {
  position: relative;
  min-height: 0;
  height: 100%;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(10, 42, 92, 0.72), rgba(4, 16, 42, 0.88));
  border: 1px solid rgba(70, 170, 240, 0.38);
  box-shadow: inset 0 0 28px rgba(20, 110, 210, 0.16), 0 0 18px rgba(0, 90, 180, 0.18);
  overflow: hidden;
}
.corners::before, .corners::after, .panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--cyan);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.corners::before { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.corners::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.rate-note { margin: 0 0 2px; color: var(--gold); font-size: 12px; letter-spacing: 0.02em; white-space: nowrap; }
.ranges, .sex-switch, .grade-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.ranges button, .sex-switch button, .grade-switch button { padding: 4px 10px; }
.ranges button[aria-pressed="true"], .sex-switch button[aria-pressed="true"], .grade-switch button[aria-pressed="true"] {
  background: linear-gradient(180deg, #1f6dff, #0a3e9a);
  border-color: #8fd4ff;
  box-shadow: 0 0 10px rgba(58, 208, 255, 0.35);
}
.center, .hero, .rank-panel { display: flex; flex-direction: column; min-height: 0; }
.sex-chart { height: 148px; flex: none; }
.dist-head { margin-top: 4px; }
.dist-chart { flex: 1; min-height: 120px; }
.grow { flex: 1; min-height: 0; }
.level-chart { height: 220px; flex: none; }
.rank { flex: 1; max-height: none; }
.digits { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.digits i {
  min-width: 42px;
  padding: 6px 4px 2px;
  text-align: center;
  font-family: var(--num);
  font-style: normal;
  font-size: 68px;
  line-height: 1;
  color: var(--gold);
  background: linear-gradient(180deg, #0c3f7a, #07162e);
  border: 1px solid rgba(120, 200, 255, 0.55);
  box-shadow: inset 0 0 12px rgba(40, 150, 255, 0.35), 0 0 12px rgba(255, 196, 70, 0.15);
}
.digits i.sep { min-width: 12px; border: 0; background: none; box-shadow: none; }
.unit { margin: 6px 0 0; text-align: center; color: var(--muted); letter-spacing: 0.2em; }
.grade-switch { margin-top: 8px; }

.chart { width: 100%; min-height: 0; }
.level-chart { height: 220px; flex: none; }

.rank {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
}
.rank::-webkit-scrollbar { display: none; }
.rank:hover { overflow: auto; }
.rank li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border-bottom: 1px solid rgba(90, 170, 230, 0.18);
}
.rank .pos {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-family: var(--num);
  font-size: 16px;
  color: #082038;
  background: #8eb6dc;
}
.rank li.top1 .pos { background: #ffd15c; }
.rank li.top2 .pos { background: #d5e4f2; }
.rank li.top3 .pos { background: #e0a06a; }
@media (prefers-reduced-motion: no-preference) {
  .banner h1 { animation: title-glow 3.6s ease-in-out infinite; }
  .digits i:not(.sep) { animation: digit-in 0.45s ease both; }
}
@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 12px rgba(58, 208, 255, 0.35); }
  50% { text-shadow: 0 0 22px rgba(58, 208, 255, 0.85); }
}
@keyframes digit-in {
  from { transform: translateY(8px); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}
.rank small { display: block; color: var(--muted); font-size: 12px; }
.rank .mark { font-family: var(--num); font-size: 26px; color: var(--gold); }

@media (max-width: 1200px) {
  body { grid-template-rows: auto auto auto auto; }
  .mast, .stage { grid-template-columns: 1fr; }
  .clock-box, .banner { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
