:root {
  --bg-1: #170a2c;
  --bg-2: #2a0f4a;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 215, 90, 0.25);
  --fg: #fbf6ff;
  --muted: #c3b5d8;
  --gold: #ffcf3d;
  --gold-2: #ffe58a;
  --gold-dark: #b37800;
  --red: #ff4d6d;
  --green: #3ddc97;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--fg);
  background: radial-gradient(120% 70% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 60%) fixed, var(--bg-1);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  max-width: 560px; margin: 0 auto;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand-star { color: var(--gold); text-shadow: 0 0 10px rgba(255, 207, 61, .7); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--card-border); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: var(--gold-2);
}
.icon-btn svg { width: 22px; height: 22px; }
.link-btn {
  background: none; border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; color: var(--muted); min-height: 40px;
}

main { max-width: 560px; margin: 0 auto; padding: 0 16px 40px; }
.loading { text-align: center; color: var(--muted); padding: 80px 0; }

/* ---------- вход/регистрация ---------- */
.hero { text-align: center; padding: 12px 4px 18px; }
.hero h1 {
  font-size: clamp(26px, 7.5vw, 36px); line-height: 1.1; margin: 8px 0 10px;
  background: linear-gradient(180deg, #fff6d0, var(--gold) 55%, #e09a00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); margin: 0; }
.hero b { color: var(--fg); }

.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 18px 16px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button {
  border: 0; background: none; padding: 10px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); min-height: 44px;
}
.tabs button[aria-selected="true"] { background: var(--gold); color: #3a2400; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; font-size: 17px; padding: 12px 14px; min-height: 48px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.3); color: var(--fg);
}
.field input:focus { border-color: var(--gold); outline: none; }
.vk-card { text-align: center; margin-bottom: 14px; }
.vk-card .small { margin: 12px 0 0; }
.vk-card .error:empty { display: none; }
.btn-vk {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  border-radius: 14px; background: #0077ff; color: #fff; text-decoration: none;
  font-size: 18px; font-weight: 800; box-shadow: 0 4px 0 #0052b0, 0 8px 20px rgba(0, 119, 255, .35);
}
.btn-vk svg { width: 30px; height: 30px; }
.btn-vk:active { transform: translateY(2px); box-shadow: 0 2px 0 #0052b0; }
.center { text-align: center; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.error { color: var(--red); min-height: 1.4em; margin: 0 0 8px; font-size: 15px; }
.small { font-size: 13px; color: var(--muted); }

.btn-primary {
  width: 100%; min-height: 52px; border: 0; border-radius: 14px; cursor: pointer;
  font-size: 18px; font-weight: 800; color: #3a2400;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 50%, #f0a800);
  box-shadow: 0 4px 0 var(--gold-dark), 0 8px 20px rgba(255, 190, 0, .25);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--gold-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---------- игра ---------- */
.attempts {
  text-align: center; font-weight: 700; margin: 4px 0 10px; font-size: 16px;
}
.attempts .pill {
  display: inline-flex; gap: 6px; align-items: center; padding: 6px 14px; border-radius: 999px;
  background: rgba(0,0,0,.3); border: 1px solid var(--card-border);
}
.attempts .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.attempts .dot.used { background: rgba(255,255,255,.18); box-shadow: none; }

.wheel-wrap {
  position: relative; width: min(92vw, 440px); aspect-ratio: 1; margin: 18px auto 0;
}
.wheel-wrap canvas { width: 100%; height: 100%; display: block; }
.pointer {
  position: absolute; left: 50%; top: -14px; width: 13%; z-index: 2;
  transform-origin: 50% 30%; transform: translateX(-50%);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.5));
}
.pointer svg { width: 100%; height: auto; display: block; }

.btn-spin {
  display: block; margin: 22px auto 0; width: min(80vw, 320px); min-height: 64px;
  border: 0; border-radius: 999px; cursor: pointer;
  font-size: 26px; font-weight: 900; letter-spacing: 2px; color: #fff;
  background: linear-gradient(180deg, #ff7a93, #ff3d64 45%, #c4153f);
  box-shadow: 0 6px 0 #7d0b28, 0 10px 30px rgba(255, 61, 100, .45);
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  animation: spinPulse 1.6s ease-in-out infinite;
}
.btn-spin:active { transform: translateY(3px); box-shadow: 0 3px 0 #7d0b28; }
.btn-spin:disabled { font-size: 19px; letter-spacing: 1px; animation: none; opacity: .55; cursor: default; filter: grayscale(.4); }
@keyframes spinPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

.game-msg { text-align: center; min-height: 1.4em; margin: 16px 0; color: var(--muted); font-size: 15px; }
.game-msg.final { color: var(--fg); background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 12px 14px; }

.profile h2 { margin: 0 0 4px; font-size: 20px; }
.wins { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.wins .empty { color: var(--muted); font-size: 15px; }
.win {
  border-radius: 12px; padding: 12px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.1);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
}
.win-name { font-weight: 700; }
.win-meta { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.win-code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 22px; font-weight: 800;
  letter-spacing: 3px; color: var(--gold-2);
}
.copy-btn {
  border: 1px solid var(--card-border); background: var(--card); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; color: var(--fg); min-height: 40px; font-size: 14px;
}
.win.jackpot { background: linear-gradient(135deg, rgba(255, 207, 61, .25), rgba(255, 120, 0, .15)); border-color: var(--gold); }
.win-instr { grid-column: 1 / -1; font-size: 14px; color: var(--gold-2); }
.win-instr a, .cel-note a { color: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }
.badge.done { background: rgba(61, 220, 151, .2); color: var(--green); }
.rules { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; margin-bottom: 0; }

/* ---------- праздничный экран ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  padding: 24px 16px; overflow: hidden;
  animation: fadeIn .35s ease-out both;
}
.cel-bg { position: absolute; inset: 0; background: rgba(8, 2, 20, .82); }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cel-rays, .cel-frame { position: absolute; pointer-events: none; display: none; }
.cel-content {
  position: relative; z-index: 3; text-align: center; width: min(100%, 420px); min-width: 0;
  padding: 24px 18px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(60, 20, 110, .92), rgba(25, 8, 50, .95));
  border: 2px solid var(--gold); box-shadow: 0 0 40px rgba(255, 207, 61, .35);
  animation: popIn .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.cel-title {
  font-size: clamp(26px, 9vw, 54px); font-weight: 900; line-height: 1; letter-spacing: 1px;
  background: linear-gradient(180deg, #fffbe6, var(--gold) 50%, #ff9d00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.35));
}
.cel-prize { font-size: clamp(22px, 6.5vw, 30px); font-weight: 800; margin: 14px 0 16px; line-height: 1.15; }
.cel-code-label { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.cel-code {
  display: inline-block; margin: 6px 0 10px; padding: 8px 16px; border-radius: 12px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: clamp(26px, 8vw, 34px);
  font-weight: 900; letter-spacing: 4px; color: #3a2400;
  background: linear-gradient(180deg, #fff6c8, var(--gold));
  user-select: all;
}
.cel-note { font-size: 15px; color: var(--fg); margin: 6px 0 18px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- ДЖЕКПОТ ---- */
.celebrate.jackpot .cel-bg {
  background: radial-gradient(circle at 50% 45%, #fff3b0 0%, #ffcf3d 30%, #e08a00 65%, #6b3200 100%);
  animation: goldGlow 1.2s ease-in-out infinite alternate;
}
.celebrate.jackpot .cel-rays {
  display: block; left: 50%; top: 50%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255, 255, 255, .28) 0 8deg, rgba(255, 255, 255, 0) 8deg 20deg);
  animation: rays 14s linear infinite; will-change: transform;
}
.celebrate.jackpot .cel-frame {
  display: block; inset: 8px; border-radius: 18px; border: 6px solid #fff6c8;
  box-shadow: 0 0 30px 6px #fff2a0, inset 0 0 30px 6px #fff2a0;
  animation: framePulse .7s ease-in-out infinite alternate;
}
.celebrate.jackpot .cel-content {
  background: linear-gradient(180deg, rgba(120, 30, 0, .92), rgba(70, 10, 0, .95));
  border: 3px solid #fff6c8; box-shadow: 0 0 60px 10px rgba(255, 240, 150, .8);
  animation: popIn .8s cubic-bezier(.2, 1.6, .4, 1) both, contentPulse 1.4s ease-in-out .8s infinite;
}
.celebrate.jackpot .cel-title {
  font-size: clamp(34px, 11.5vw, 84px);
  background: linear-gradient(90deg, #fff 0%, #ffe066 20%, #ff9d00 40%, #fff 50%, #ffe066 60%, #ff9d00 80%, #fff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite, titleBeat .9s ease-in-out infinite;
}
.celebrate.jackpot .cel-prize { color: #fff6c8; font-size: clamp(26px, 8vw, 36px); }
.celebrate.jackpot .cel-note { color: #fff6c8; font-weight: 600; }
@keyframes rays { to { transform: rotate(360deg); } }
@keyframes goldGlow { from { filter: brightness(1); } to { filter: brightness(1.18); } }
@keyframes framePulse { from { opacity: .55; transform: scale(.995); } to { opacity: 1; transform: scale(1); } }
@keyframes contentPulse { 0%, 100% { box-shadow: 0 0 50px 8px rgba(255, 240, 150, .7); } 50% { box-shadow: 0 0 90px 22px rgba(255, 240, 150, 1); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes titleBeat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ---------- «уменьшить движение» ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .btn-spin { animation: none; }
  .celebrate.jackpot .cel-rays { display: none; }
  .celebrate.jackpot .cel-title { transform: none; }
}

/* ---------- компьютер ---------- */
@media (min-width: 900px) {
  .top, main { max-width: 1040px; }
  #game:not([hidden]) {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 0 40px; align-items: start;
  }
  #game > .attempts, #game > .wheel-wrap, #game > .btn-spin, #game > .game-msg { grid-column: 1; }
  #game > .profile { grid-column: 2; grid-row: 1 / span 4; margin-top: 10px; }
  .wheel-wrap { width: min(44vw, 480px); }
  #auth:not([hidden]) { max-width: 460px; margin: 30px auto 0; }
}
