:root {
  --bg: #07070d;
  --panel: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4f8;
  --muted: #9b9bb2;
  --faint: #55556a;

  --accent: #8b7bff;
  --accent-2: #4fd1ff;
  --up: #3ee6a8;
  --down: #ff6b8b;
  --gold: #ffd166;

  --radius: 28px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.3, 1.6, 0.5, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.muted { color: var(--muted); }

/* ---------- фон ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: drift 26s ease-in-out infinite alternate;
}
.b1 { background: radial-gradient(circle, #6c4cff 0%, transparent 62%); top: -28vmax; left: -18vmax; }
.b2 { background: radial-gradient(circle, #00b4ff 0%, transparent 62%); bottom: -34vmax; right: -22vmax; animation-delay: -9s; }
.b3 { background: radial-gradient(circle, #ff4fa3 0%, transparent 62%); top: 35%; left: 50%; width: 40vmax; height: 40vmax; opacity: 0.16; animation-delay: -17s; }

@keyframes drift {
  to { transform: translate(7vmax, 5vmax) scale(1.12); }
}

.grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
}

/* ---------- каркас ---------- */

.shell {
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0b14;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 10px 28px -8px rgba(139, 123, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.4s var(--ease-spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }

.score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.score:empty { display: none; }
.score-num { font-family: var(--display); font-weight: 700; font-size: 16px; }
.score-of { color: var(--muted); font-weight: 600; font-size: 14px; }
.score-label { color: var(--muted); font-size: 13px; margin-left: 2px; }

.foot {
  margin-top: auto;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

/* ---------- дни ---------- */

.days {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}
.days:empty { min-height: 78px; }

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0 12px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  backdrop-filter: blur(12px);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, background 0.25s, color 0.25s;
}
.day:hover { transform: translateY(-2px); border-color: var(--line-strong); color: var(--text); }
.day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.day.is-active {
  color: var(--text);
  background: linear-gradient(160deg, rgba(139, 123, 255, 0.3), rgba(79, 209, 255, 0.1));
  border-color: rgba(139, 123, 255, 0.65);
  box-shadow: 0 12px 30px -14px rgba(139, 123, 255, 0.9);
}

.day-wd {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.day-num {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.day-dot {
  width: 6px;
  height: 6px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--faint);
  transition: background 0.3s, box-shadow 0.3s;
}
.day.is-in_progress .day-dot { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.day.is-solved .day-dot { background: var(--up); box-shadow: 0 0 10px var(--up); }
.day.is-failed .day-dot { background: var(--down); box-shadow: 0 0 10px var(--down); }

@media (max-width: 600px) {
  .days {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 4px 16px;
  }
  .days::-webkit-scrollbar { display: none; }
  .day { flex: 0 0 66px; scroll-snap-align: center; }
}

/* ---------- карточка ---------- */

.card {
  position: relative;
  padding: 32px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: rise 0.5s var(--ease-out);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
}

.card--skeleton {
  min-height: 520px;
  background:
    linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%) 0 0 / 200% 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0, 0 0; } }

.card--error h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 22px;
}
.card--error .btn { margin-top: 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.card-date {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.card-today {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(139, 123, 255, 0.16);
  color: #c5bcff;
  font-size: 12px;
  font-weight: 700;
}

.badge {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.badge--in_progress { color: var(--gold); background: rgba(255, 209, 102, 0.1); border-color: rgba(255, 209, 102, 0.3); }
.badge--solved { color: var(--up); background: rgba(62, 230, 168, 0.1); border-color: rgba(62, 230, 168, 0.3); }
.badge--failed { color: var(--down); background: rgba(255, 107, 139, 0.1); border-color: rgba(255, 107, 139, 0.3); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  padding: 0 28px;
  border: 0;
  border-radius: 18px;
  font: 800 16px var(--font);
  color: #0b0b14;
  text-decoration: none;
  background: linear-gradient(135deg, #cfc7ff 0%, var(--accent) 45%, var(--accent-2) 100%);
  background-size: 160% 100%;
  box-shadow: 0 14px 32px -12px rgba(139, 123, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: transform 0.15s, background-position 0.4s, filter 0.2s, opacity 0.2s;
}
.btn:hover { background-position: 100% 0; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.is-loading { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(0.8); } }

.btn--ghost {
  height: 48px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

/* ---------- угадай число ---------- */

.gn-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(30px, 6.5vw, 44px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: linear-gradient(115deg, #ffffff 30%, #bcb2ff 65%, #7fe3ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gn-sub {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
}
.gn-sub b { color: var(--text); }

/* индикатор */

.gn-oracle {
  --tone: var(--faint);
  --tone-rgb: 120, 120, 150;
  margin: 28px 0 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 22px;
  padding: 20px;
  border-radius: 24px;
  background:
    radial-gradient(120% 140% at 0% 50%, rgba(var(--tone-rgb), 0.16), transparent 60%),
    rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(var(--tone-rgb), 0.28);
  transition: background 0.5s, border-color 0.5s;
}
.gn-oracle[data-state='higher'] { --tone: var(--up); --tone-rgb: 62, 230, 168; }
.gn-oracle[data-state='lower'] { --tone: var(--down); --tone-rgb: 255, 107, 139; }
.gn-oracle[data-state='correct'] { --tone: var(--up); --tone-rgb: 62, 230, 168; }
.gn-oracle[data-state='failed'] { --tone: var(--down); --tone-rgb: 255, 107, 139; }

.gn-arrow {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  color: var(--tone);
  background: rgba(var(--tone-rgb), 0.12);
  box-shadow: inset 0 0 0 1px rgba(var(--tone-rgb), 0.35), 0 20px 44px -16px rgba(var(--tone-rgb), 0.7);
  transition: color 0.4s, background 0.4s, box-shadow 0.4s;
}
.gn-oracle[data-state='idle'] .gn-arrow { box-shadow: inset 0 0 0 1px var(--line); }
.gn-arrow.bump { animation: bump 0.6s var(--ease-spring); }
@keyframes bump {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.gn-arrow-icon { display: grid; place-items: center; }
.gn-arrow-icon svg { width: 50px; height: 50px; transition: transform 0.5s var(--ease-spring); }
.gn-oracle[data-state='higher'] .gn-arrow-icon { animation: bob-up 1.6s ease-in-out infinite; }
.gn-oracle[data-state='lower'] .gn-arrow-icon { animation: bob-down 1.6s ease-in-out infinite; }
.gn-oracle[data-state='lower'] .gn-arrow-icon svg { transform: rotate(180deg); }
@keyframes bob-up { 50% { transform: translateY(-6px); } }
@keyframes bob-down { 50% { transform: translateY(6px); } }

.gn-q {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 800;
  color: var(--muted);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.45; } }

.gn-oracle-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.gn-oracle-text {
  margin-top: 6px;
  font-family: var(--display);
  font-size: clamp(20px, 4.4vw, 27px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.gn-oracle-text em { font-style: normal; color: var(--tone); }

/* шкала */

.gn-range { margin-bottom: 26px; }

.gn-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.gn-window {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 22px rgba(139, 123, 255, 0.6);
  transition: left 0.7s var(--ease-out), width 0.7s var(--ease-out), background 0.4s;
}
.gn-window.is-point { transform: translateX(-6px); }
.gn-window[data-state='correct'] { background: var(--up); box-shadow: 0 0 22px rgba(62, 230, 168, 0.7); }
.gn-window[data-state='failed'] { background: var(--gold); box-shadow: 0 0 22px rgba(255, 209, 102, 0.6); }

.gn-ticks { position: absolute; inset: 0; pointer-events: none; }
.gn-tick {
  position: absolute;
  top: -5px;
  width: 2px;
  height: 22px;
  border-radius: 2px;
  transform: translateX(-1px);
  background: rgba(255, 255, 255, 0.5);
}
.gn-tick.is-higher { background: var(--up); }
.gn-tick.is-lower { background: var(--down); }
.gn-tick.is-correct { display: none; }

.gn-range-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 12px;
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.gn-range-text { color: var(--muted); text-align: center; }
.gn-range-text b { color: var(--text); }

/* ввод */

.gn-form { display: flex; gap: 10px; }

.gn-input {
  flex: 1;
  min-width: 0;
  height: 60px;
  padding: 0 22px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.gn-input::placeholder { color: var(--faint); font-weight: 500; }
.gn-input:focus { border-color: rgba(139, 123, 255, 0.85); box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.2); }
.gn-input::-webkit-outer-spin-button,
.gn-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.shake { animation: shake 0.4s; border-color: var(--down) !important; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.gn-done {
  padding: 18px 20px;
  border-radius: 18px;
  text-align: center;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}
.gn-done[data-state='solved'] { color: var(--up); border-color: rgba(62, 230, 168, 0.35); }

/* попытки */

.gn-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.gn-lives { display: flex; gap: 6px; }
.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(139, 123, 255, 0.55);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s var(--ease-spring);
}
.pip.is-used { background: rgba(255, 255, 255, 0.1); box-shadow: none; transform: scale(0.8); }
.pip.is-used.is-correct { background: var(--up); box-shadow: 0 0 10px var(--up); transform: none; }

.gn-lives-text { color: var(--muted); font-size: 14px; font-weight: 600; }

.gn-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.gn-history:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chip.is-new { animation: pop 0.45s var(--ease-spring); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.chip-no {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 11px;
}
.chip-ico { display: grid; place-items: center; }
.chip-ico svg { width: 15px; height: 15px; }
.chip.is-higher .chip-ico { color: var(--up); }
.chip.is-lower .chip-ico { color: var(--down); }
.chip.is-lower .chip-ico svg { transform: rotate(180deg); }
.chip.is-correct { color: #062a1d; background: var(--up); border-color: transparent; }
.chip.is-correct .chip-no { background: rgba(0, 0, 0, 0.15); color: #062a1d; }

/* ---------- всплывашки ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(24, 24, 36, 0.92);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(16px);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.35s var(--ease-spring);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; display: block; }

/* ---------- адаптив ---------- */

@media (max-width: 520px) {
  .shell { padding-top: 20px; gap: 18px; }
  .card { padding: 24px 18px; border-radius: 24px; }
  .card-head { margin-bottom: 18px; }
  .gn-oracle { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 14px; }
  .gn-arrow { width: 80px; height: 80px; border-radius: 24px; }
  .gn-form { flex-direction: column; }
  .gn-input { flex: none; }
  .btn { width: 100%; }
  .score-label { display: none; }
}

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