:root {
  --bg: #070b18;
  --bg-2: #0b1226;
  --panel: rgba(18, 26, 50, 0.86);
  --panel-solid: #121a32;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --ink: #eef2ff;
  --muted: #8f9cc4;
  --muted-2: #66739a;
  --gold: #f5c451;
  --gold-2: #ffe7ad;
  --gold-dim: rgba(245, 196, 81, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 20px;
  --radius-sm: 14px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100%;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.26); }
::-webkit-scrollbar-track { background: transparent; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(90% 50% at 15% -10%, rgba(245, 196, 81, 0.16), transparent 60%),
    radial-gradient(70% 40% at 100% 0%, rgba(34, 211, 238, 0.12), transparent 55%),
    radial-gradient(80% 45% at 50% 110%, rgba(99, 102, 241, 0.14), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot-logo { font-size: 44px; color: var(--gold); animation: pulse 1.6s infinite; }
.boot-text { letter-spacing: 0.18em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: .45; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.04); } }

/* ── layout ─────────────────────────────────────────────── */
.wrap { max-width: 620px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.wrap.no-nav { padding-bottom: 32px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  backdrop-filter: blur(16px);
  background: linear-gradient(180deg, rgba(7, 11, 24, 0.94), rgba(7, 11, 24, 0.55));
}
.topbar .brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar .brand b { font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand .mark { color: var(--gold); font-size: 18px; }
.topbar .spacer { flex: 1; }

.who {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 10px 5px 6px; font-size: 12px; color: var(--muted);
  max-width: 46vw;
}
.who .st { font-size: 16px; }
.who span.nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }

h1 { font-size: 26px; line-height: 1.15; letter-spacing: -0.03em; margin: 6px 0 4px; }
h2 { font-size: 18px; letter-spacing: -0.02em; margin: 26px 0 12px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrapflex { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.hide { display: none !important; }

/* ── cards ──────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}
.card + .card { margin-top: 12px; }
.card.tight { padding: 12px 14px; }
.card.flat { background: rgba(255, 255, 255, 0.03); box-shadow: none; }

.hero {
  position: relative; overflow: hidden;
  padding: 22px 18px 18px;
  border-radius: 26px;
  border: 1px solid rgba(245, 196, 81, 0.24);
  background:
    radial-gradient(120% 90% at 80% 0%, rgba(245, 196, 81, 0.22), transparent 60%),
    linear-gradient(160deg, #17203c, #0d1428 65%);
}
.hero .kicker { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }
.hero-icon { width: 62px; height: 62px; border-radius: 16px; flex: none; box-shadow: 0 12px 26px -14px rgba(245, 196, 81, 0.55); }
.hero h1 { font-size: 30px; margin: 8px 0 2px; }
.hero .sub { color: var(--muted); font-size: 13px; }
.hero .meta { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.hero .meta div b { display: block; font-size: 18px; }
.hero .meta div span { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.08em; }

.team-card { display: flex; align-items: center; gap: 14px; }
.team-sticker {
  width: 62px; height: 62px; flex: none; border-radius: 18px;
  display: grid; place-items: center; font-size: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-2);
}
.team-name { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.coins { color: var(--gold); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.pill.gold { color: #1a1405; background: var(--gold); border-color: transparent; font-weight: 650; }
.pill.soft-gold { color: var(--gold-2); background: var(--gold-dim); border-color: rgba(245, 196, 81, 0.3); }
.pill.ok { color: #052e21; background: var(--ok); border-color: transparent; font-weight: 650; }
.pill.warn { color: #3a2600; background: var(--warn); border-color: transparent; font-weight: 650; }
.pill.dim { opacity: 0.55; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.07em; }

/* ── buttons ────────────────────────────────────────────── */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 14px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.06); color: var(--ink);
  padding: 11px 16px; text-align: center; transition: transform .08s, background .15s, opacity .15s;
  -webkit-user-select: none; user-select: none;
}
button:active { transform: scale(0.985); }
button.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #221902; border-color: transparent; font-weight: 700;
  box-shadow: 0 10px 24px -12px rgba(245, 196, 81, 0.7);
}
button.ghost { background: transparent; }
button.sm { padding: 7px 11px; font-size: 12px; border-radius: 11px; }
button.xs, .btn.xs { padding: 5px 9px; font-size: 11.5px; border-radius: 9px; text-decoration: none; }
button.block { width: 100%; }
button:disabled { opacity: 0.45; cursor: default; }
button.danger { color: var(--bad); border-color: rgba(251, 113, 133, 0.35); }

.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px;
  outline: none;
}
.input:focus { border-color: rgba(245, 196, 81, 0.55); }
select.input { appearance: none; background-image: none; }
input[type="file"].input { padding: 8px 10px; color: var(--muted); font-size: 13px; }
input[type="file"].input::file-selector-button {
  font: inherit; font-size: 13px; margin-right: 10px; cursor: pointer;
  background: rgba(245, 196, 81, 0.16); color: var(--gold-2);
  border: 1px solid rgba(245, 196, 81, 0.35); border-radius: 10px; padding: 7px 12px;
}
textarea.input { min-height: 74px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

/* ── quest cards ────────────────────────────────────────── */
.quest {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quest:active { background: rgba(255, 255, 255, 0.07); }
.quest .time { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.quest .title { font-weight: 620; letter-spacing: -0.01em; margin: 2px 0 3px; }
.quest .hint { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.quest .side { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.quest .rew { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.quest.done { border-color: rgba(52, 211, 153, 0.35); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.04); color: var(--muted);
  cursor: pointer;
}
.chip.on { background: var(--ink); color: #0b1020; border-color: transparent; font-weight: 650; }

/* ── feed ───────────────────────────────────────────────── */
.feed-item { overflow: hidden; padding: 0; }
.feed-item .ph { height: 168px; background: linear-gradient(135deg, #1b2444, #0e1428); display: grid; place-items: center; font-size: 34px; }
.feed-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-item .body { padding: 12px 14px 14px; }
.feed-item .note { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── leaderboard ────────────────────────────────────────── */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-place { width: 26px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted-2); font-size: 13px; }
.lb-row.top1 .lb-place { color: var(--gold); font-weight: 700; }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 3px; }

/* ── nav ────────────────────────────────────────────────── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: var(--safe-b);
  background: linear-gradient(180deg, rgba(7, 11, 24, 0.4), rgba(7, 11, 24, 0.98) 45%);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.nav-in { display: flex; width: 100%; max-width: 620px; }
.nav a {
  flex: 1; padding: 9px 2px 10px; text-align: center; text-decoration: none;
  color: var(--muted-2); font-size: 10.5px; display: grid; gap: 3px; justify-items: center;
}
.nav a .ic { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .75; }
.nav a.on { color: var(--gold); }
.nav a.on .ic { filter: none; opacity: 1; }

/* ── sheet / modal ──────────────────────────────────────── */
.sheet-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 16, 0.66);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--line-2);
  border-radius: 24px 24px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(30px) } to { transform: translateY(0) } }
.sheet .grab { width: 42px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 6px auto 14px; }
.sheet h2 { margin-top: 0; }
.sheet .close { position: absolute; }

/* ── misc ───────────────────────────────────────────────── */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.notice {
  border-radius: 14px; padding: 11px 13px; font-size: 13px;
  border: 1px solid rgba(245, 196, 81, 0.28); background: rgba(245, 196, 81, 0.09); color: var(--gold-2);
}
.notice.err { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.1); color: #ffd0d8; }
.notice.ok { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); color: #c7ffe9; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--safe-b));
  transform: translateX(-50%); z-index: 90;
  background: #1b2547; border: 1px solid var(--line-2); color: var(--ink);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 20px 40px -18px #000;
  animation: fade .15s ease;
  max-width: 88vw;
}
.map-box { height: 58vh; min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.leaflet-container { background: #0c1326; font: inherit; }
.leaflet-control-attribution { background: rgba(11, 18, 38, 0.7) !important; color: #8f9cc4 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #8f9cc4 !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #17203c; color: var(--ink); border-radius: 12px; }
.pin {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg); background: var(--gold); color: #1a1405; font-size: 11px; font-weight: 800;
  border: 2px solid #0b1226; box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}
.pin > span { transform: rotate(45deg); }
.dice { font-size: 40px; text-align: center; }
@keyframes roll { from { transform: rotate(0) } to { transform: rotate(360deg) } }

/* анимация броска кубика в карточке */
.dice-stage { text-align: center; padding: 12px 0 6px; }
.dice-roll { font-size: 48px; line-height: 1; display: inline-block; animation: diceSpin 0.45s linear infinite; }
.dice-name { font-size: 20px; font-weight: 650; color: var(--gold); margin-top: 8px; letter-spacing: -0.01em; min-height: 26px; }
@keyframes diceSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.18); }
  100% { transform: rotate(360deg) scale(1); }
}
/* ── QR ─────────────────────────────────────────────────── */
.qr-badge {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px;
  display: grid; place-items: center; font-size: 30px; color: var(--gold);
  background: var(--gold-dim); border: 1px solid rgba(245, 196, 81, 0.35);
}
.qr { width: 200px; height: 200px; background: #fff; border-radius: 16px; padding: 8px; display: inline-block; }
.qr-sm { width: 104px; height: 104px; padding: 6px; border-radius: 12px; }
.qr-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.qr-row:last-child { border-bottom: 0; }
.qr-row img { width: 46px; height: 46px; background: #fff; border-radius: 8px; padding: 3px; flex: none; }

/* сканер */
.scan {
  position: fixed; inset: 0; z-index: 120; background: #04060d;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px;
}
.scan-video { position: relative; width: min(84vw, 380px); aspect-ratio: 1; border-radius: 24px; overflow: hidden; background: #000; }
.scan-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 14%; border: 3px solid var(--gold); border-radius: 18px; box-shadow: 0 0 0 999px rgba(4, 6, 13, 0.45); }
.scan-hint { font-size: 13px; color: var(--muted); text-align: center; }

/* бейджи */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge {
  border: 1px dashed var(--line-2); border-radius: 14px; padding: 10px; text-align: center;
  background: rgba(255, 255, 255, 0.03); break-inside: avoid;
}
.badge img { width: 100%; max-width: 150px; height: auto; background: #fff; border-radius: 8px; padding: 4px; display: block; margin: 6px auto; }
.badge-team { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.badge-name { font-size: 13px; font-weight: 600; }
.badge-foot { font-size: 9px; color: var(--muted-2); margin-top: 2px; }

@media print {
  body::before, .nav, .topbar, .no-print { display: none !important; }
  body { background: #fff !important; color: #111 !important; }
  .wrap { max-width: none; padding: 0; }
  .badge { border: 1px solid #bbb; background: #fff; color: #111; }
  .badge-team, .badge-foot { color: #555; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  @page { size: A4; margin: 10mm; }
}

.badge-day { font-size: 11px; color: var(--muted-2); }

table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th { text-align: left; color: var(--muted-2); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 6px 4px; }
table.simple td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: middle; }

.search { position: relative; }
.search .input { padding-left: 36px; }
.search::before { content: "🔎"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .7; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 520px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
