:root {
  color-scheme: dark;
  --bg: #071121;
  --panel: #0b192c;
  --band: #10243c;
  --border: #246477;
  --text: #f2f7ff;
  --muted: #b1c6db;
  --accent: #32e6ef;
  --easy: #8ae894;
  --medium: #ffdb6b;
  --hard: #ff8790;
  --radius: 14px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
button, input { font: inherit; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: .62rem .9rem; background: var(--accent); color: #082431; font-weight: 750; min-height: 42px; }
button:hover:not(:disabled) { filter: brightness(1.14); }
button:disabled { opacity: .55; cursor: default; }
button.secondary { color: var(--text); background: #162a42; border-color: #39617a; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
input { border-radius: 8px; border: 1px solid #52718e; background: #081523; color: var(--text); min-height: 44px; min-width: 0; padding: .55rem .7rem; }
label { display: block; color: var(--muted); font-weight: 670; margin: 0 0 .4rem; }
h1, h2, p { margin: 0; }
h2 { font-size: clamp(1rem, 1.65vw, 1.65rem); line-height: 1.14; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .7rem; min-height: 59px; padding: .5rem clamp(12px, 1.75vw, 34px); border-bottom: 2px solid var(--accent); background: #0a172a; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none; font-weight: 850; font-size: clamp(1.03rem, 2.4vw, 2.35rem); letter-spacing: -.04em; }
.brand svg { color: var(--accent); width: clamp(23px, 3vw, 42px); height: auto; flex: none; }
#nav { display: flex; align-items: center; gap: .65rem; flex: none; font-size: .85rem; }
#nav a, #nav button { text-decoration: none; white-space: nowrap; }
#nav button { min-height: 32px; padding: .36rem .6rem; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); min-width: 0; overflow: hidden; }
.board { padding: clamp(10px, 1.45vw, 26px); display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(0, 1fr); grid-template-areas: "race active" "free active" "done active"; grid-template-rows: auto auto 1fr; gap: clamp(8px, 1vw, 16px); }
.race-panel { grid-area: race; }
.free-panel { grid-area: free; }
.active-panel { grid-area: active; }
.done-panel { grid-area: done; align-self: start; }
.race-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .5rem; padding: .6rem clamp(10px, 2vw, 31px); background: var(--band); }
.metric { display: flex; align-items: baseline; gap: .45rem; }
.metric span { color: var(--text); font-size: clamp(1.45rem, 3.4vw, 3.4rem); font-variant-numeric: tabular-nums; font-weight: 850; line-height: 1; white-space: nowrap; }
.metric small { color: var(--muted); font-size: clamp(.65rem, 1vw, .95rem); }
.race-status { text-align: center; font-size: clamp(.75rem, 1.3vw, 1.15rem); color: var(--muted); font-weight: 730; }
.race-status.won { color: var(--easy); }
.race-status.lost { color: var(--hard); }
.track-wrap { padding: 6px 12px 0; }
#track { width: 100%; height: auto; max-height: min(32vh, 480px); display: block; }
.race-legend { display: flex; justify-content: center; gap: 1.1rem; color: var(--muted); font-size: clamp(.75rem, 1.14vw, 1rem); padding: .35rem .8rem .6rem; }
.race-legend span { display: flex; align-items: center; gap: .35rem; }
.race-legend i { width: .64rem; height: .64rem; border-radius: 2px; }
.class-dot { background: var(--accent); }
.rival-dot { background: #edf6ff; }
.section-head { padding: .65rem .85rem; display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; justify-content: space-between; background: var(--band); }
.active-panel .section-head { background: var(--accent); color: #072332; }
.small-count { min-width: 1.6rem; text-align: center; background: #082c3a; color: #e1ffff; border-radius: 5px; font-weight: 800; padding: .12rem .35rem; }
.difficulty-legend { display: flex; flex-wrap: wrap; gap: .7rem; color: var(--muted); font-size: clamp(.68rem, 1vw, .85rem); }
.difficulty-legend span { display: flex; gap: .28rem; align-items: center; }
.difficulty-legend span::before { content: ""; display: block; width: .58rem; height: .58rem; border-radius: 2px; background: var(--difficulty); }
.easy { --difficulty: var(--easy); }
.medium { --difficulty: var(--medium); }
.hard { --difficulty: var(--hard); }
.free-list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-content: start; gap: clamp(4px, .5vw, 9px); padding: .6rem .8rem; }
.free-list .empty { grid-column: 1 / -1; padding: .25rem 0; }
.number, .tag { display: inline-flex; justify-content: center; align-items: center; border-radius: 7px; color: #081722; background: var(--difficulty, #b3c8df); font-weight: 850; font-variant-numeric: tabular-nums; }
.number { min-height: clamp(24px, 4vh, 55px); font-size: clamp(.88rem, 1.85vw, 1.95rem); line-height: 1; }
.board a.number, .board .active-item { text-decoration: none; }
.board a.number:hover { filter: brightness(1.12); }
.board .active-item { color: var(--text); }
.board .active-item:hover { background: #1f3b58; }
.board a.number:focus-visible, .board .active-item:focus-visible { outline-offset: -3px; outline-color: var(--bg); }
.board .active-item:focus-visible { outline-color: var(--text); }
.active-list { display: grid; gap: .42rem; padding: .65rem; }
.active-list .empty { padding: .6rem .25rem; }
.active-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .58rem; min-width: 0; padding: .35rem .48rem; background: #142843; border-radius: 8px; }
.active-item .number { min-width: 2.15em; min-height: 1.57em; font-size: clamp(.95rem, 1.55vw, 1.75rem); }
.active-item .names { font-size: clamp(.82rem, 1.42vw, 1.55rem); font-weight: 710; overflow-wrap: anywhere; line-height: 1.2; }
.active-list.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.active-list.dense .names { font-size: clamp(.76rem, 1.02vw, 1.1rem); }
.active-list.dense .number { font-size: clamp(.75rem, 1.18vw, 1.4rem); }
.done-panel { display: flex; align-items: baseline; gap: .55rem; padding: .45rem .8rem; }
.done-panel h2 { font-size: clamp(.9rem, 1.4vw, 1.25rem); }
.done-list { display: flex; flex-wrap: wrap; gap: .25rem; }
.done-list .number { min-height: 1.32rem; padding: .16rem .36rem; font-size: .8rem; background: #263d55; color: var(--text); }
.muted, .empty, .task-status { color: var(--muted); }
.empty { font-size: .92rem; }
.notice { font-size: .93rem; margin-top: .65rem; color: var(--accent); font-weight: 660; }
.notice:empty { display: none; }
.notice.error { color: var(--hard); }
#board-notice { margin: 0 1rem 1rem; }
.focus-panel { width: min(100% - 24px, 640px); margin: clamp(18px, 5vw, 70px) auto; padding: clamp(16px, 4vw, 34px); }
.focus-panel h1, .admin h1 { font-size: clamp(1.65rem, 4vw, 2.5rem); line-height: 1.12; margin: .65rem 0; }
.focus-panel form { margin-top: 1.25rem; }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.tag { padding: .25rem .5rem; font-size: .82rem; }
.question { font-size: clamp(1.02rem, 2vw, 1.21rem); line-height: 1.55; margin: .65rem 0; }
.entry-line { display: flex; gap: .5rem; align-items: stretch; }
.entry-line input, .number-input { flex: 1; }
#task-form > label:not(:first-child) { margin-top: 1rem; }
.number-input { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.number-input span { color: var(--muted); }
.hint { font-size: .84rem; margin-top: .45rem; line-height: 1.45; }
.admin { width: min(100% - 24px, 1120px); margin: 1.25rem auto; }
.admin-heading, .admin-control { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.admin-control { padding: .9rem; margin-top: .5rem; }
#duration { width: 5.4rem; flex: none; }
.admin-actions { display: grid; gap: .6rem; align-content: start; }
.admin-tasks { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: .8rem; margin-top: .8rem; }
.admin-picker h2 { margin: .8rem .8rem 0; }
.admin-picker .number { min-height: 42px; padding: 0; font-size: 1.05rem; }
.admin-picker .number.selected { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.admin-picker .number.solved { background: #233c55; color: var(--text); }
.admin-detail { padding: .8rem; }
.answer { color: var(--accent); font-weight: 800; margin-bottom: .8rem; }
.admin-names { display: flex; flex-wrap: wrap; gap: .35rem; margin: .7rem 0; }
.admin-names button { min-height: 30px; padding: .3rem .55rem; font-size: .85rem; }
@media (max-width: 780px) {
  .board { grid-template-columns: 1fr; grid-template-areas: "race" "active" "free" "done"; }
  .race-head { padding: .6rem; }
  .metric { display: grid; gap: .15rem; }
  .score { text-align: right; }
  .active-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .active-list .empty { grid-column: 1 / -1; }
  .admin-control { flex-direction: column; }
  .admin-tasks { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  .topbar { padding-inline: 8px; }
  #nav { font-size: .75rem; gap: .4rem; }
  #nav button { display: none; }
  .entry-line button { padding-inline: .55rem; }
}

.free-group { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
