:root {
  --bg: #0b0b0d;
  --surface: #141417;
  --surface-2: #1c1c20;
  --line: rgba(255, 255, 255, 0.07);
  --text: #f2f2f3;
  --muted: #8b8b94;
  --faint: #55555e;
  --accent: #7fd3ff;
  --accent-ink: #06202c;
  --danger: #ff7a7a;
  --radius: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

:root[data-scheme="light"] {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #eeeef1;
  --line: rgba(0, 0, 0, 0.08);
  --text: #121214;
  --muted: #6b6b75;
  --faint: #a2a2ab;
  --accent: #1a9bd7;
  --accent-ink: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 500 15px/1.4 Manrope, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- шапка ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; margin: 4px 2px 18px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.brand-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.nick {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px;
  transition: transform 160ms var(--ease-out), color 160ms;
}
.nick:active { transform: scale(0.96); }
.nick[data-many="1"]::after { content: " ▾"; color: var(--faint); }

/* ---------- переключатель сервера ---------- */
.seg {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 16px;
}
.seg-btn {
  position: relative; z-index: 1; height: 38px; border-radius: 10px; font-weight: 700; font-size: 14px;
  color: var(--muted); transition: color 220ms var(--ease-out);
}
.seg-btn.is-on { color: var(--text); }
.seg-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 10px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 340ms var(--ease-out), width 340ms var(--ease-out);
}

/* ---------- вью ---------- */
.views { position: relative; }
.view { display: flex; flex-direction: column; gap: 12px; }
.view.enter > * { animation: rise 420ms var(--ease-out) both; }
.view.enter > *:nth-child(2) { animation-delay: 40ms; }
.view.enter > *:nth-child(3) { animation-delay: 80ms; }
.view.enter > *:nth-child(4) { animation-delay: 120ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- кнопки ---------- */
.btn {
  width: 100%; height: 50px; border-radius: 14px; font-weight: 800; font-size: 15px;
  background: var(--accent); color: var(--accent-ink);
  transition: transform 160ms var(--ease-out), opacity 200ms, background 200ms;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn .spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot 700ms linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- серия ---------- */
.streak-head { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 16px; }
.streak-num { font-size: 56px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.streak-unit { color: var(--muted); font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.day {
  position: relative; aspect-ratio: 1 / 1.15; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--faint);
  transition: background 300ms var(--ease-out), color 300ms;
}
.day.done { background: var(--accent); color: var(--accent-ink); }
.day.today { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.day.today::after {
  content: ""; position: absolute; inset: -1px; border-radius: 11px; box-shadow: 0 0 0 0 var(--accent);
  animation: halo 2.4s var(--ease-out) infinite;
}
@keyframes halo { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
.reward-line { display: flex; justify-content: space-between; margin-bottom: 14px; font-weight: 700; }
.reward-line .muted { font-weight: 600; }

/* ---------- задания ---------- */
.quest { padding: 14px 0; border-top: 1px solid var(--line); }
.quest:first-of-type { border-top: 0; padding-top: 12px; }
.quest-title { font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; }
.quest-title .mono { color: var(--muted); font-size: 13px; white-space: nowrap; }
.quest.is-done .quest-title > span:first-child { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit;
  transform-origin: left; transform: scaleX(0); transition: transform 900ms var(--ease-out);
}

/* ---------- бонус ---------- */
.bonus { display: flex; flex-direction: column; gap: 14px; }
.bonus-title { font-size: 18px; font-weight: 800; }
.lock { display: inline-flex; align-items: center; gap: 6px; }
.lock svg { width: 16px; height: 16px; }

/* ---------- ивенты ---------- */
.server-head { margin: 10px 2px 2px; }
.ev { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; padding-top: 2px; }
.ev-name { font-weight: 700; }
.ev-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ev-right { text-align: right; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; color: var(--accent); }
.live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  animation: blink 1.6s var(--ease-in-out) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
.empty { color: var(--muted); padding: 6px 0 2px; }
.mine-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 8px 0 12px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); color: var(--muted); }
.kv b { color: var(--text); }

/* ---------- кейс ---------- */
.reel {
  position: relative; height: 112px; margin: 14px -18px 18px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.reel-track { position: absolute; top: 12px; left: 0; display: flex; gap: 10px; will-change: transform; }
.tile {
  flex: 0 0 96px; height: 88px; border-radius: 14px; background: var(--surface-2);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  font-weight: 800; font-size: 14px; color: var(--faint);
}
.tile small { font-size: 11px; font-weight: 700; color: var(--muted); }
.tile.win { background: var(--accent); color: var(--accent-ink); }
.tile.win small { color: color-mix(in srgb, var(--accent-ink) 70%, transparent); }
.reel-marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; opacity: 0.9; }
.odds { display: grid; gap: 8px; margin-bottom: 16px; }
.odds .row { font-size: 14px; }

/* ---------- гейт ---------- */
.gate { min-height: 62dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: left; }
.gate-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
.gate-icon svg { width: 24px; height: 24px; color: var(--accent); }
.gate h1 { font-size: 26px; line-height: 1.15; margin: 6px 0 0; letter-spacing: -0.02em; }
.gate p { margin: 0 0 8px; color: var(--muted); }
.gate .actions { display: grid; gap: 10px; margin-top: 8px; }

/* ---------- нижние вкладки ---------- */
.tabs {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(448px, calc(100% - 32px)); display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line);
  border-radius: 20px; padding: 6px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tab {
  height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 700; transition: color 200ms var(--ease-out), background 200ms;
}
.tab svg { width: 21px; height: 21px; transition: transform 260ms var(--ease-out); }
.tab.is-on { color: var(--text); background: var(--surface-2); }
.tab:active svg { transform: scale(0.88); }

/* ---------- шторка ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 260ms var(--ease-out); }
.sheet-back.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto;
  background: var(--surface); border-top-left-radius: 24px; border-top-right-radius: 24px; border: 1px solid var(--line);
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); transform: translateY(100%);
  transition: transform 380ms var(--ease-out);
}
.sheet.on { transform: none; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.code {
  font-family: var(--mono); font-size: 24px; letter-spacing: 0.12em; text-align: center; padding: 16px; margin-bottom: 14px;
  border-radius: 14px; background: var(--surface-2);
}
.sheet .actions { display: grid; gap: 10px; }
.pick { display: grid; gap: 8px; margin-bottom: 12px; }
.pick button { text-align: left; padding: 14px; border-radius: 12px; background: var(--surface-2); font-weight: 700; }
.pick button.is-on { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; padding: 10px 14px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease-out), transform 260ms var(--ease-out); max-width: calc(100% - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- скелет ---------- */
.sk { height: 96px; border-radius: var(--radius); background: var(--surface); position: relative; overflow: hidden; }
.sk-lg { height: 220px; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.pop { animation: pop 420ms var(--ease-out); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
