:root {
  --pink: #ff2d95;
  --yellow: #ffd60a;
  --cyan: #00e0ff;
  --violet: #7b2cff;
  --lime: #9dff00;
  --ink: #111;
  --rainbow: linear-gradient(90deg, #ff2d95, #ff8a00, #ffd60a, #9dff00, #00e0ff, #7b2cff, #ff2d95);
  --shadow: 0 10px 30px rgba(0,0,0,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Rubik', system-ui, sans-serif;
  color: var(--ink);
  background: #fff;
  overflow-x: hidden;
  min-height: 100dvh;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* фоновые «софиты» */
body::before {
  content: '';
  position: fixed; inset: -30%;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,45,149,.18), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(0,224,255,.18), transparent 35%),
    radial-gradient(circle at 50% 85%, rgba(255,214,10,.22), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(123,44,255,.16), transparent 35%);
  animation: lights 14s ease-in-out infinite alternate;
}
@keyframes lights {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(25deg) scale(1.15); }
}

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0; background: #fff; }
#flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

body.shake { animation: shake .5s; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* ===== экраны ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}
.screen.active { display: flex; animation: screenIn .5s cubic-bezier(.2,.9,.3,1.2); }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(30px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1.05;
  text-align: center;
  margin: 8px 0 0;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: rainbowShift 4s linear infinite;
}
.title.small { font-size: clamp(22px, 6vw, 30px); }
@keyframes rainbowShift { to { background-position: 300% 0; } }
.sub { text-align: center; margin: 0; color: #555; font-size: 15px; }
.hint { text-align: center; margin: 0; color: #888; font-size: 13px; min-height: 1.4em; }

/* ===== диско-шар ===== */
.ball-wrap { height: 150px; display: grid; place-items: center; position: relative; }
.ball-wrap::before {
  content: ''; position: absolute; top: 0; width: 2px; height: 30px; background: #bbb;
}
.ball {
  width: 110px; height: 110px; border-radius: 50%;
  margin-top: 24px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.55) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 2px, transparent 2px 12px),
    radial-gradient(circle at 35% 30%, #fff, #c9d6ff 35%, #8fa3ff 60%, #5a4bd1 100%);
  box-shadow: 0 0 40px rgba(123,44,255,.45), 0 0 90px rgba(0,224,255,.35), inset -12px -12px 30px rgba(0,0,0,.25);
  animation: spin 6s linear infinite, bob 3s ease-in-out infinite;
  position: relative;
}
.ball::after {
  content: ''; position: absolute; inset: -40px;
  background: conic-gradient(from 0deg, transparent 0 20deg, rgba(255,214,10,.35) 22deg 26deg, transparent 28deg 60deg, rgba(255,45,149,.35) 62deg 66deg, transparent 68deg 130deg, rgba(0,224,255,.35) 132deg 136deg, transparent 138deg 220deg, rgba(157,255,0,.35) 222deg 226deg, transparent 228deg 300deg, rgba(123,44,255,.35) 302deg 306deg, transparent 308deg);
  border-radius: 50%;
  animation: spin 4s linear infinite reverse;
  filter: blur(1px);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { translate: 0 6px; } }

/* ===== PIN ===== */
.pin-dots { display: flex; gap: 14px; margin-top: 8px; }
.pin-dots span {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--ink); transition: .15s;
}
.pin-dots span.on { background: var(--pink); border-color: var(--pink); transform: scale(1.2); }
.pin-dots.ok span { background: var(--lime); border-color: var(--lime); animation: pop .4s; }
.pin-dots.bad span { background: #f33; border-color: #f33; }
@keyframes pop { 50% { transform: scale(1.6); } }

.keypad {
  display: grid; grid-template-columns: repeat(3, 76px); gap: 12px;
}
.keypad button {
  height: 64px; border-radius: 20px; border: 3px solid var(--ink);
  background: #fff; font-family: 'Unbounded', sans-serif; font-size: 24px; font-weight: 500;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .2s;
}
.keypad button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); background: var(--yellow); }
.keypad button.ghost { border-style: dashed; box-shadow: none; font-size: 20px; }
.keypad button.ghost:active { transform: scale(.92); }

/* ===== кнопки ===== */
.btn {
  border: 3px solid var(--ink); border-radius: 999px;
  background: #fff; padding: 14px 24px;
  font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 16px;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn.big {
  width: 100%; max-width: 340px; padding: 18px 24px; font-size: 18px;
  background: var(--rainbow); background-size: 300% 100%;
  animation: rainbowShift 3s linear infinite, wiggle 2.4s ease-in-out infinite;
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35);
}
@keyframes wiggle { 0%, 100% { rotate: -1.5deg; } 50% { rotate: 1.5deg; } }
.btn.ghost-btn { box-shadow: none; border-style: dashed; font-weight: 500; font-size: 14px; }

/* ===== голова ===== */
.head-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.face {
  --mouth: 72%;
  position: relative;
  width: min(62vw, 260px);
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  overflow: visible;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.18));
  animation: headIdle 3.2s ease-in-out infinite;
}
.head-stage.small .face { width: min(40vw, 160px); }
@keyframes headIdle { 50% { rotate: 2deg; translate: 0 -4px; } }
.face img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: 28px; user-select: none; -webkit-user-drag: none;
}
.face .top { clip-path: inset(0 0 calc(100% - var(--mouth)) 0); }
.face .bottom {
  clip-path: inset(var(--mouth) 0 0 0);
  transform-origin: 50% var(--mouth);
}
/* тёмный «рот» под нижней половиной: закрывает шов, когда челюсть уходит вниз */
.face .mouth {
  position: absolute; left: 22%; right: 22%;
  top: calc(var(--mouth) - 4%); height: 14%;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  background: radial-gradient(ellipse at 50% 30%, #5a1a2a, #22060e 70%);
}
/* веко: полоска лба над глазами, при моргании съезжает вниз на глаза */
.face .lid {
  clip-path: inset(calc(var(--eye) - var(--lid)) 0 calc(100% - var(--eye)) 0);
  transform: translateY(0);
  transition: transform .07s ease-in;
}
.face.blink .lid { transform: translateY(var(--lid)); }
.face.talking .bottom { animation: jaw .22s ease-in-out infinite alternate; }
@keyframes jaw {
  from { transform: rotate(0deg) translateY(0); }
  to { transform: rotate(6deg) translateY(4%); }
}
.face.happy { animation: happy .6s ease-in-out 3; }
@keyframes happy { 0%, 100% { rotate: 0deg; } 25% { rotate: -10deg; translate: -6px -14px; } 75% { rotate: 10deg; translate: 6px -14px; } }
.face.sad { animation: sad .8s ease-in-out 2; filter: drop-shadow(0 12px 24px rgba(0,0,0,.18)) grayscale(.6); }
@keyframes sad { 0%, 100% { rotate: 0deg; } 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
.face.spin { animation: faceSpin 1s cubic-bezier(.3,1.4,.4,1) 1; }
@keyframes faceSpin { to { transform: rotate(720deg) scale(1.1); } }

.bubble {
  position: relative;
  background: #fff; border: 3px solid var(--ink); border-radius: 22px;
  padding: 14px 18px; min-height: 60px; width: 100%; max-width: 360px;
  font-size: 17px; line-height: 1.3; text-align: center; font-weight: 600;
  box-shadow: 5px 5px 0 var(--pink);
  opacity: 0; transform: scale(.8);
  transition: .25s cubic-bezier(.2,.9,.3,1.3);
}
.bubble.show { opacity: 1; transform: none; }
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -14px;
  width: 20px; height: 20px; background: #fff;
  border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.bubble .cursor { display: inline-block; width: 3px; height: 1em; background: var(--pink); vertical-align: -2px; margin-left: 2px; animation: blink .6s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ===== квиз ===== */
.progress { display: flex; gap: 8px; }
.progress span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; transition: .3s; }
.progress span.cur { background: var(--yellow); transform: scale(1.3); }
.progress span.ok { background: var(--lime); }
.progress span.bad { background: #f55; }

.question {
  font-family: 'Unbounded', sans-serif; font-weight: 500;
  font-size: clamp(17px, 5vw, 22px); line-height: 1.25; text-align: center; margin: 4px 0;
}
.answers { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.answers button {
  border: 3px solid var(--ink); border-radius: 18px; background: #fff;
  padding: 14px 16px; font-size: 16px; font-weight: 600; text-align: left;
  box-shadow: 4px 4px 0 var(--ink);
  display: flex; align-items: center; gap: 12px;
  transition: transform .08s, box-shadow .08s, background .25s, border-color .25s;
  animation: answerIn .4s backwards;
}
.answers button:nth-child(1) { animation-delay: .05s; }
.answers button:nth-child(2) { animation-delay: .12s; }
.answers button:nth-child(3) { animation-delay: .19s; }
.answers button:nth-child(4) { animation-delay: .26s; }
@keyframes answerIn { from { opacity: 0; transform: translateX(-30px); } }
.answers button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.answers button b {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--ink); font-family: 'Unbounded', sans-serif; font-size: 14px;
}
.answers button:nth-child(1) b { background: var(--pink); color: #fff; }
.answers button:nth-child(2) b { background: var(--yellow); }
.answers button:nth-child(3) b { background: var(--cyan); }
.answers button:nth-child(4) b { background: var(--lime); }
.answers button.right { background: var(--lime); border-color: #3a8; animation: pop .4s; }
.answers button.wrong { background: #ffd5d5; border-color: #f33; animation: shake .4s; }
.answers button:disabled { cursor: default; opacity: .9; }

/* ===== отличия ===== */
.diff-wrap { display: grid; gap: 12px; width: 100%; }
.diff-pane {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; background: #fff;
  box-shadow: 5px 5px 0 var(--ink); touch-action: manipulation;
}
.diff-pane svg, .diff-pane img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.diff-pane .mark {
  position: absolute; width: 0; height: 0; border-radius: 50%;
  border: 4px solid var(--pink); box-shadow: 0 0 0 3px #fff, 0 0 14px var(--pink);
  transform: translate(-50%, -50%);
  animation: markIn .4s cubic-bezier(.2,.9,.3,1.4) forwards;
  pointer-events: none;
}
.diff-pane .mark.cheat { border-color: var(--cyan); box-shadow: 0 0 0 3px #fff, 0 0 14px var(--cyan); }
@keyframes markIn { to { width: var(--d); height: var(--d); } }
.diff-pane .miss {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,51,51,.3); transform: translate(-50%, -50%);
  animation: missOut .5s forwards; pointer-events: none;
}
@keyframes missOut { to { transform: translate(-50%, -50%) scale(2); opacity: 0; } }
@media (min-width: 560px) { .diff-wrap { grid-template-columns: 1fr 1fr; } }

/* ===== билеты ===== */
.tickets { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.ticket {
  position: relative;
  border: 3px solid var(--ink); border-radius: 22px; background: #fff;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
  animation: ticketIn .6s cubic-bezier(.2,.9,.3,1.3) backwards;
}
.ticket:nth-child(2) { animation-delay: .2s; }
.ticket:nth-child(3) { animation-delay: .4s; }
.ticket:nth-child(4) { animation-delay: .6s; }
@keyframes ticketIn { from { opacity: 0; transform: translateY(40px) rotate(-4deg); } }
.ticket .head {
  padding: 14px 18px; color: #fff;
  background: var(--rainbow); background-size: 300% 100%; animation: rainbowShift 5s linear infinite;
  font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 17px;
  text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.ticket .body { display: flex; gap: 14px; padding: 14px 18px; align-items: center; }
.ticket .meta { flex: 1; font-size: 14px; line-height: 1.5; }
.ticket .meta b { font-size: 16px; }
.ticket .qr { flex: none; width: 110px; height: 110px; display: grid; place-items: center; border: 2px dashed #ccc; border-radius: 12px; padding: 4px; background: #fff; }
.ticket .qr img, .ticket .qr canvas { width: 100% !important; height: 100% !important; }
.ticket.locked .qr { filter: blur(5px); }
.ticket.locked::after {
  content: '🔒 Только для Кори'; position: absolute; inset: auto 0 14px 0; text-align: center;
  font-weight: 600; font-size: 14px; color: var(--pink);
}
.ticket.demo::before {
  content: 'ДЕМО'; position: absolute; top: 14px; right: -34px; z-index: 2;
  transform: rotate(45deg); background: var(--ink); color: var(--yellow);
  font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 11px; letter-spacing: 2px;
  padding: 4px 40px; pointer-events: none;
}
.ticket .scratch {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, var(--yellow) 0 14px, #ffe566 14px 28px);
  font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 18px; text-align: center; padding: 20px;
  cursor: pointer; transition: .5s cubic-bezier(.6,-.3,.3,1);
}
.ticket .scratch.off { transform: translateY(-110%) rotate(-6deg); opacity: 0; pointer-events: none; }

/* ===== звук ===== */
.snd {
  position: fixed; top: 10px; right: 10px; z-index: 60;
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink);
  background: #fff; font-size: 18px; box-shadow: 3px 3px 0 var(--ink);
}

