:root {
  --bg: #f3f5fb;
  --card: #ffffff;
  --ink: #101a3a;
  --muted: #5b6585;
  --line: #e1e5f0;
  --brand: #2f4bff;
  --brand-2: #00b8a3;
  --brand-ink: #ffffff;
  --ok: #13a36b;
  --bad: #e0424f;
  --warn: #f2a516;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(16, 26, 58, 0.08);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.6em; }
h2 { font-size: 1.5rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }
.row.center { justify-content: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* ---------- Шапка ---------- */
.hero {
  background: radial-gradient(1200px 500px at 85% -10%, rgba(0, 184, 163, 0.45), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(47, 75, 255, 0.65), transparent 60%), #0c1433;
  color: #fff;
  padding: 28px 0 36px;
}
.hero .topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.logo { font-weight: 800; letter-spacing: 0.02em; display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; }
.logo .mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; font-size: 18px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.8rem); margin-bottom: 8px; }
.hero .subtitle { opacity: 0.85; max-width: 760px; }
.hero .lead { font-size: 1.1rem; max-width: 760px; margin-top: 14px; opacity: 0.95; }
.hero-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }

.glass { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: var(--radius); padding: 18px; backdrop-filter: blur(6px); }
.glass input { background: rgba(255, 255, 255, 0.95); }
.glass h3 { margin-bottom: 10px; }
.stat-line { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.stat-line b { font-size: 1.4rem; display: block; }

/* ---------- Кнопки и поля ---------- */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  transition: transform 0.05s, filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: #e8ecfa; color: var(--ink); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.small { padding: 7px 12px; font-size: 0.875rem; border-radius: 9px; }
.btn.block { width: 100%; }
input[type='text'], input[type='password'], input[type='number'], input[type='search'], input[type='url'], textarea, select {
  width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
textarea.tall { min-height: 260px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9rem; }
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 3px solid rgba(47, 75, 255, 0.35); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; cursor: pointer; }
.err { color: var(--bad); font-size: 0.9rem; min-height: 1.2em; margin-top: 6px; }
.glass .err { color: #ffd0d4; }
.glass label.field > span, .glass .muted { color: rgba(255, 255, 255, 0.82); }

/* ---------- Секции и карточки ---------- */
section { padding: 32px 0 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.station-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s; }
.station-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.station-card .icon { font-size: 28px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: #eef1ff; }
.station-card .disc { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.station-card h3 { margin: 0; font-size: 1.15rem; }
.station-card .status { margin-top: auto; font-size: 0.9rem; font-weight: 600; }
.station-card.done { border-color: rgba(19, 163, 107, 0.4); }
.station-card.done .status { color: var(--ok); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #eef1ff; color: var(--brand); font-size: 0.8rem; font-weight: 700; }
.badge.ok { background: #e3f7ee; color: var(--ok); }
.badge.bad { background: #fde8ea; color: var(--bad); }
.badge.warn { background: #fff3dc; color: #9a6400; }

details.info { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
details.info > summary { cursor: pointer; padding: 18px 20px; font-weight: 700; font-size: 1.1rem; list-style: none; display: flex; gap: 12px; align-items: center; }
details.info > summary::-webkit-details-marker { display: none; }
details.info > summary::after { content: '＋'; margin-left: auto; color: var(--muted); }
details.info[open] > summary::after { content: '−'; }
details.info .md { padding: 0 20px 18px; }

.md h3 { font-size: 1.2rem; margin-top: 1em; }
.md h4 { font-size: 1.05rem; margin-top: 1em; }
.md p { margin: 0 0 0.8em; }
.md ul { margin: 0 0 0.8em; padding-left: 1.3em; }
.md li { margin-bottom: 0.3em; }
.md code { background: #eef1ff; padding: 1px 6px; border-radius: 6px; }
.md img { border-radius: 12px; display: block; margin: 8px 0; }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
tr.me td { background: #eef1ff; font-weight: 700; }

.prize { display: flex; gap: 14px; align-items: center; }
.prize img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.prize .pic { width: 64px; height: 64px; border-radius: 12px; background: linear-gradient(135deg, #ffe3a3, #ffb4c8); display: grid; place-items: center; font-size: 28px; flex: none; }

footer { padding: 32px 0 48px; color: var(--muted); font-size: 0.9rem; }

/* ---------- Станция ---------- */
.station-head { background: #0c1433; color: #fff; padding: 20px 0 26px; }
.station-head a { color: #cfd6ff; }
.station-head .disc { opacity: 0.8; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }
.task { margin-bottom: 18px; }
.task .num { font-weight: 800; color: var(--brand); margin-bottom: 6px; }
.task .body { font-weight: 600; margin-bottom: 10px; white-space: pre-line; }
.task.ok { border-left: 6px solid var(--ok); }
.task.bad { border-left: 6px solid var(--bad); }
.task .fb { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f5f7fb; }
.options { display: grid; gap: 8px; }
.opt { text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: inherit; cursor: pointer; color: var(--ink); }
.opt:hover { border-color: #b8c3ff; }
.opt.sel { border-color: var(--brand); background: #eef1ff; }
.opt.right { border-color: var(--ok); background: #e3f7ee; }
.opt.wrong { border-color: var(--bad); background: #fde8ea; }
.opt:disabled { cursor: default; }

.matrix { border-collapse: separate; border-spacing: 6px; margin: 0 auto; }
.matrix th { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.matrix button { width: 54px; height: 48px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer; color: var(--ink); }
.matrix button.sel { border-color: var(--brand); background: #eef1ff; }
.matrix button.right { border-color: var(--ok); background: #e3f7ee; }
.matrix button.wrong { border-color: var(--bad); background: #fde8ea; }
@media (max-width: 420px) { .matrix button { width: 44px; height: 42px; font-size: 0.95rem; } .matrix { border-spacing: 4px; } }

svg.diagram { width: 100%; max-width: 520px; height: auto; display: block; margin: 0 auto; background: #fafbff; border-radius: 12px; border: 1px solid var(--line); }
svg.diagram .node circle { fill: #fff; stroke: var(--ink); stroke-width: 2; }
svg.diagram .node text { font: 700 15px system-ui, sans-serif; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
svg.diagram .edge { fill: none; stroke: #6b7597; stroke-width: 1.8; }
svg.diagram .elabel { font: 700 14px system-ui, sans-serif; fill: var(--brand); text-anchor: middle; dominant-baseline: central; }
svg.diagram .elabel-bg { fill: #fafbff; }
svg.diagram .hl { stroke: var(--ok); stroke-width: 4; }
svg.diagram .node.start circle { stroke: var(--brand); }
svg.diagram .node.goal circle { stroke: var(--brand-2); }
svg.diagram .arrowhead { fill: #6b7597; }

.word { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.word code { font-size: 1.15rem; letter-spacing: 0.15em; background: #eef1ff; padding: 4px 10px; border-radius: 8px; min-width: 80px; text-align: center; }
.word .choice { display: flex; gap: 6px; margin-left: auto; }
.word .opt { padding: 8px 12px; }
.word.ok { background: #f2fbf6; }
.word.bad { background: #fff4f5; }

.dtable { border-collapse: collapse; margin: 12px auto; }
.dtable th, .dtable td { border: 1px solid var(--line); padding: 6px 14px; text-align: center; }

.resultbox { text-align: center; padding: 26px; }
.resultbox .big { font-size: 2.6rem; font-weight: 800; color: var(--brand); }

/* ---------- Тосты ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: min(92vw, 460px); }
.toast { background: #101a3a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); animation: pop 0.2s ease-out; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Админка ---------- */
.admin body, body.admin { background: #eef1f8; }
.admin-top { background: #0c1433; color: #fff; padding: 12px 0; position: sticky; top: 0; z-index: 10; }
.admin-top .wrap { display: flex; gap: 12px; align-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 0; }
.tabs button { border: 0; background: #fff; padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); box-shadow: var(--shadow); }
.tabs button.active { background: var(--brand); color: #fff; }
.list-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: #fff; }
.list-item > .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; cursor: pointer; }
.list-item > .head .t { font-weight: 700; flex: 1 1 auto; }
.list-item .editor { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.preview { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: #fafbff; min-height: 110px; max-height: 420px; overflow: auto; }
.thumb { max-width: 160px; max-height: 120px; border-radius: 10px; display: block; margin: 6px 0; }
.stat-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.stat-cards .card b { display: block; font-size: 2rem; }
.winner { font-size: 2rem; font-weight: 800; color: var(--brand); }
.login-box { max-width: 400px; margin: 10vh auto; }
.qr-img { width: 280px; max-width: 100%; background: #fff; padding: 8px; border-radius: 12px; }
.help { background: #fff8e6; border: 1px solid #ffe2a1; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; }

/* ---------- Большой экран ---------- */
body.screen { background: #070d24; color: #fff; overflow: hidden; height: 100vh; }
.screen-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 4vw; padding: 4vh 4vw; height: 100vh; }
.screen h1 { font-size: 3.2vw; margin-bottom: 1vh; }
.screen .qr-side { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.screen .qr-side img { width: min(32vw, 62vh); background: #fff; padding: 1.2vw; border-radius: 2vw; }
.screen .url { font-size: 1.8vw; margin-top: 2vh; font-weight: 700; color: #8fe9dc; word-break: break-all; }
.screen .lb { font-size: 2vw; }
.screen .lb table { width: 100%; border-collapse: collapse; }
.screen .lb td { padding: 1vh 0.6vw; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.screen .lb td.num { text-align: right; font-variant-numeric: tabular-nums; }
.screen .lb tr:nth-child(1) td { color: #ffd76a; font-weight: 800; }
.screen .lb tr:nth-child(2) td { color: #e3e8f5; font-weight: 700; }
.screen .lb tr:nth-child(3) td { color: #ffb98a; font-weight: 700; }
.screen .stats { display: flex; gap: 3vw; font-size: 1.6vw; margin-top: 3vh; opacity: 0.85; }
.screen .stats b { font-size: 3vw; display: block; }
.overlay { position: fixed; inset: 0; background: rgba(7, 13, 36, 0.94); display: grid; place-items: center; text-align: center; z-index: 50; }
.overlay .prize-name { font-size: 3vw; color: #8fe9dc; margin-bottom: 4vh; }
.overlay .spin { font-size: 7vw; font-weight: 900; min-height: 1.3em; }
.overlay .spin.final { color: #ffd76a; animation: grow 0.6s ease-out; }
.overlay .hint { font-size: 1.5vw; opacity: 0.7; margin-top: 4vh; }
@keyframes grow { from { transform: scale(0.6); } 60% { transform: scale(1.15); } to { transform: scale(1); } }
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; border-radius: 3px; z-index: 60; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
