:root {
  --bg: #1d0b16;
  --bg2: #2c1022;
  --card: #3a1530;
  --card2: #4a1c3d;
  --line: #5d2a4f;
  --ink: #fbeef4;
  --muted: #c9a3b8;
  --wine: #b0154f;
  --wine2: #e0336f;
  --gold: #f4c34a;
  --ok: #2fbf71;
  --bad: #e5484d;
  --zero: #19a7a0;
  --t0: #e21b3c; --t1: #1368ce; --t2: #d89e00; --t3: #26890c; --t4: #864cbf; --t5: #0aa3a3;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  isolation: isolate;
  background: radial-gradient(120% 80% at 50% 0%, #4a1235 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font: 16px/1.4 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display { font-family: "Fraunces", Georgia, serif; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card2); font-size: .8rem; font-weight: 600; }
.pill.wine { background: color-mix(in srgb, var(--wine) 40%, var(--card)); }
.pill.zero { background: color-mix(in srgb, var(--zero) 40%, var(--card)); }
.pill.ok { background: color-mix(in srgb, var(--ok) 45%, var(--card)); }
.pill.bad { background: color-mix(in srgb, var(--bad) 45%, var(--card)); }
.pill.gold { background: color-mix(in srgb, var(--gold) 45%, var(--card)); }

button, .btn {
  font: inherit; font-weight: 700; color: var(--ink); background: var(--card2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer;
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; touch-action: manipulation;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: linear-gradient(180deg, var(--wine2), var(--wine)); border-color: transparent; }
button.gold { background: var(--gold); color: #2a1020; border-color: transparent; }
button.ghost { background: transparent; }
button.danger { background: color-mix(in srgb, var(--bad) 30%, var(--card)); }
button.block { width: 100%; }
button.big { font-size: 1.15rem; min-height: 60px; }
button.sm { min-height: 36px; padding: 6px 10px; font-size: .85rem; border-radius: 10px; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 48px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--wine2); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 6px; }

/* Kahoot-style answer tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles.one { grid-template-columns: 1fr; }
.tile {
  min-height: 88px; border-radius: 14px; border: 3px solid transparent; color: #fff; font-size: 1.05rem;
  justify-content: flex-start; text-align: left; padding: 14px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.25);
}
.tile .shape { font-size: 1.4rem; flex: none; width: 1.6rem; text-align: center; }
.tile.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.35), inset 0 -5px 0 rgba(0,0,0,.25); }
.tiles.has-sel .tile:not(.sel) { opacity: .55; }
.c0 { background: var(--t0); } .c1 { background: var(--t1); } .c2 { background: var(--t2); }
.c3 { background: var(--t3); } .c4 { background: var(--t4); } .c5 { background: var(--t5); }

.scale { display: grid; gap: 8px; grid-template-columns: repeat(var(--n), 1fr); }
.scale button { min-height: 64px; font-size: 1.3rem; padding: 0; }
.scale button.sel { background: var(--gold); color: #2a1020; border-color: transparent; }
.scale.many { grid-template-columns: repeat(5, 1fr); }

.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--card2); }
.progress span.on { background: var(--gold); }
.progress span.cur { background: var(--wine2); }

.qnum { font-size: .85rem; font-weight: 700; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.qtext { font-family: "Fraunces", Georgia, serif; font-size: 1.5rem; line-height: 1.2; margin: 6px 0 4px; }

.hero { text-align: center; padding: 32px 8px; }
.hero .emoji { font-size: 4rem; line-height: 1; margin-bottom: 12px; }
.bounce { animation: bounce 1.6s ease-in-out infinite; display: inline-block; }
@keyframes bounce { 50% { transform: translateY(-8px); } }

.tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trackpick { flex-direction: column; min-height: 120px; font-size: 1rem; }
.trackpick .emoji { font-size: 2.4rem; }
.trackpick.sel.wine { background: var(--wine); border-color: #fff; }
.trackpick.sel.zero { background: var(--zero); border-color: #fff; }

.list { display: flex; flex-direction: column; gap: 6px; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border-radius: 12px; }
.li .rank { width: 2rem; font-weight: 800; color: var(--gold); text-align: center; }
.li .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.mark-correct { border-left: 4px solid var(--ok); }
.mark-wrong { border-left: 4px solid var(--bad); }
.mark-pending, .mark-blank { border-left: 4px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 50; max-width: calc(100vw - 32px); }
.overlay { position: fixed; inset: 0; background: rgba(20,5,14,.92); display: grid; place-items: center; z-index: 40; padding: 24px; text-align: center; }
.footer-bar { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.conn { position: fixed; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); z-index: 60; }
.conn.off { background: var(--bad); }

/* ===================== motion ===================== */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .38s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }
::view-transition-old(root) { animation-name: vt-out; }
::view-transition-new(root) { animation-name: vt-in; }
[data-dir="fwd"]::view-transition-old(root) { animation-name: vt-out-l; }
[data-dir="fwd"]::view-transition-new(root) { animation-name: vt-in-r; }
[data-dir="back"]::view-transition-old(root) { animation-name: vt-out-r; }
[data-dir="back"]::view-transition-new(root) { animation-name: vt-in-l; }
@keyframes vt-out { to { opacity: 0; transform: scale(.97); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.03); filter: blur(4px); } }
@keyframes vt-out-l { to { opacity: 0; transform: translateX(-12%); } }
@keyframes vt-in-r { from { opacity: 0; transform: translateX(12%); } }
@keyframes vt-out-r { to { opacity: 0; transform: translateX(12%); } }
@keyframes vt-in-l { from { opacity: 0; transform: translateX(-12%); } }

/* ambient blobs and rising bubbles */
.ambience { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.blob { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(70px); opacity: .35; animation: drift 22s ease-in-out infinite alternate; }
.b1 { background: #b0154f; top: -20vmax; left: -15vmax; }
.b2 { background: #6b1d8f; bottom: -25vmax; right: -20vmax; animation-duration: 27s; animation-delay: -6s; }
.b3 { background: #f4c34a; width: 30vmax; height: 30vmax; top: 40%; left: 55%; opacity: .12; animation-duration: 31s; }
@keyframes drift { 50% { transform: translate(8vw, 6vh) scale(1.1); } 100% { transform: translate(-6vw, 10vh) scale(.95); } }
.bubble { position: absolute; bottom: -40px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.7), rgba(255,255,255,.08) 60%); border: 1px solid rgba(255,255,255,.25);
  animation: rise var(--d) linear infinite; animation-delay: var(--delay); opacity: .5; }
@keyframes rise { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: .55; } 50% { transform: translate(18px, -55vh); } 100% { transform: translate(-10px, -110vh); opacity: 0; } }

/* the pouring glass */
.glass .liquid { animation: fill 2.6s cubic-bezier(.45,.05,.3,1) infinite; }
.glass .w1 { animation: wave 1.6s linear infinite; }
.glass .w2 { animation: wave 2.3s linear infinite reverse; }
.glass .fizz { fill: rgba(255,255,255,.75); animation: fizz 1.8s ease-in infinite; }
.glass .f2 { animation-delay: .6s; } .glass .f3 { animation-delay: 1.1s; }
.glass { filter: drop-shadow(0 10px 30px rgba(224,51,111,.45)); animation: wobble 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes fill { 0% { transform: translateY(62px); } 70%, 88% { transform: translateY(6px); } 100% { transform: translateY(62px); } }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(50px); } }
@keyframes fizz { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-55px); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

.wavetext span { display: inline-block; animation: letter 1.4s ease-in-out infinite; animation-delay: calc(var(--i) * 60ms); }
@keyframes letter { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-.35em); color: var(--gold); } }

.boot { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80; background: var(--bg); }
.boot .splash-in { text-align: center; }
.splash { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, #6d1240, #1d0b16 70%); }
.splash-title { font-family: "Fraunces", Georgia, serif; font-size: clamp(2rem, 8vw, 6rem); font-weight: 700; margin-top: 18px; }
.splash-sub { color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.8rem); margin-top: 6px; }
.splash-icon { font-size: clamp(5rem, 16vw, 12rem); line-height: 1; animation: ring .9s ease-in-out infinite; display: inline-block; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } 60% { transform: rotate(0); } }

/* playful buttons: 3D press and a shine sweep */
button, .btn { transition: transform .15s cubic-bezier(.3,1.6,.5,1), box-shadow .2s, background-color .2s, opacity .2s; position: relative; overflow: hidden; }
button.primary, button.gold { box-shadow: 0 5px 0 rgba(0,0,0,.35), 0 10px 24px rgba(224,51,111,.25); }
button.gold { box-shadow: 0 5px 0 #a8801c, 0 10px 24px rgba(244,195,74,.25); }
button.primary:active, button.gold:active { transform: translateY(4px) scale(.99); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
button.primary::after, button.gold::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%); transform: translateX(-120%); animation: shine 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@media (hover: hover) { button:hover:not(:disabled), .btn:hover { transform: translateY(-2px); } }
.tile { transition: transform .18s cubic-bezier(.3,1.6,.5,1), opacity .25s, border-color .2s; }
.tile:active { transform: scale(.94); }
.tile .shape { transition: transform .5s cubic-bezier(.3,1.6,.5,1); }
.tile.sel .shape { transform: rotate(360deg) scale(1.25); }
.scale button.sel { animation: jelly .5s; }
@keyframes jelly { 30% { transform: scale(1.25, .8); } 40% { transform: scale(.8, 1.2); } 60% { transform: scale(1.1, .9); } 100% { transform: scale(1); } }
.trackpick { transition: transform .2s cubic-bezier(.3,1.6,.5,1), background .25s; }
.trackpick.sel { transform: scale(1.04); }
.trackpick.sel .emoji { animation: jelly .6s; }
.progress span { transition: background .3s, transform .3s; }
.progress span.cur { transform: scaleY(1.6); }
.card { transition: transform .3s, box-shadow .3s; box-shadow: 0 12px 40px rgba(0,0,0,.25); backdrop-filter: blur(6px); background: color-mix(in srgb, var(--card) 88%, transparent); }
input, textarea, select { transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 6px rgba(224,51,111,.18); }

/* animated check */
.check { width: 110px; height: 110px; }
.check circle { stroke: var(--ok); stroke-width: 6; fill: none; stroke-dasharray: 300; stroke-dashoffset: 300; animation: draw .7s ease-out forwards; }
.check path { stroke: #fff; stroke-width: 8; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw .45s .55s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.float { animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(1deg); } }
.glow { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { text-shadow: 0 0 24px rgba(244,195,74,.8); } }
.pulse-dot { display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(47,191,113,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 .6em rgba(47,191,113,0); } 100% { box-shadow: 0 0 0 0 rgba(47,191,113,0); } }
.typing i { display: inline-block; width: .35em; height: .35em; margin: 0 .06em; border-radius: 50%; background: currentColor; animation: typing 1.2s infinite; opacity: .4; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 30% { transform: translateY(-.3em); opacity: 1; } }
.shimmer { background: linear-gradient(90deg, var(--ink), var(--gold), var(--ink)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

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