:root {
    --ink: #070d24;
    --surface: rgba(255, 255, 255, 0.05);
    --line: rgba(196, 206, 255, 0.16);
    --text: #c9d0ea;
    --muted: #8b95b8;
    --white: #f3f5ff;
    --accent: #8f9cff;
    --accent-2: #b8a6ff;
    --mint: #6ee7c4;
    --red: #ff6b7a;
    --gold: #ffd166;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --display: "Bricolage Grotesque", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
    font-family: "Instrument Sans", system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(900px 600px at 85% -10%, rgba(143, 156, 255, 0.2), transparent 60%),
        radial-gradient(800px 600px at -10% 110%, rgba(255, 209, 102, 0.1), transparent 60%),
        var(--ink);
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

button { font: inherit; touch-action: manipulation; }

/* ---------- top bar ---------- */
.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px clamp(14px, 3vw, 28px);
}

.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.back:hover { color: var(--white); }

.hud { display: flex; align-items: center; gap: 14px; color: var(--white); font-weight: 600; }
.score-box strong { font-family: var(--display); font-size: 1.3rem; margin-left: 4px; }
.lives { letter-spacing: 2px; font-size: 1.1rem; }
.heart { color: var(--red); transition: opacity 0.4s, transform 0.4s; display: inline-block; }
.heart.lost { opacity: 0.2; transform: scale(0.7); filter: grayscale(1); }
.combo {
    padding: 3px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff9f43, #ff6b7a);
    color: #2a0a00;
    font-weight: 800;
    animation: pop 0.4s var(--ease);
}

.icon-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    font-size: 1.05rem;
}

/* ---------- screens ---------- */
main { flex: 1; display: grid; place-items: center; padding: 10px clamp(14px, 4vw, 40px) 30px; }
.screen { width: min(900px, 100%); text-align: center; animation: fade 0.5s var(--ease); }
.screen[hidden] { display: none; }

@keyframes fade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

.kicker { color: var(--accent); font-weight: 600; margin: 0 0 8px; }

h1 {
    margin: 0 0 16px;
    font-family: var(--display);
    font-size: clamp(2.8rem, 9vw, 5.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--white);
}

h1 span { color: var(--gold); font-size: 0.6em; vertical-align: middle; }

.lead { max-width: 34em; margin: 0 auto 22px; font-size: 1.1rem; line-height: 1.6; }
.lead strong { color: var(--white); }

.rules { list-style: none; padding: 0; margin: 0 auto 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.rules li { padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.rules b { color: var(--white); }

.best-line { margin-top: 18px; color: var(--muted); }
.best-line strong { color: var(--gold); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 52px; padding: 0 26px;
    border: 1px solid transparent; border-radius: 999px;
    font-weight: 700; font-size: 1.05rem;
    cursor: pointer; text-decoration: none;
    transition: transform 0.25s var(--ease), box-shadow 0.25s, filter 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b1233; box-shadow: 0 12px 30px rgba(143, 156, 255, 0.35); }
.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--white); }
.btn-up { background: linear-gradient(135deg, #6ee7c4, #2bb38f); color: #04261c; }
.btn-down { background: linear-gradient(135deg, #ff8a96, #e0475a); color: #2b0309; }

/* ---------- game ---------- */
.timer { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin: 0 auto 14px; max-width: 760px; }
.timer span { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--accent)); transform-origin: left; }
.timer span.low { background: linear-gradient(90deg, var(--red), #ff9f43); }

.round-line { color: var(--muted); margin: 0 0 16px; }
.round-line strong { color: var(--white); }

.arena { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: clamp(12px, 3vw, 28px); perspective: 1000px; }

.card {
    position: relative;
    min-height: 320px;
    padding: 28px 20px 24px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025));
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.emoji { font-size: clamp(3.6rem, 9vw, 5.4rem); line-height: 1; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }

.card h2 { margin: 8px 0 0; font-family: var(--display); color: var(--white); font-size: clamp(1.1rem, 2.4vw, 1.45rem); line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; }
.price { margin: 2px 0 0; font-family: var(--display); font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.card-b .price { color: var(--white); }

.choices { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 240px; margin-top: 12px; transition: opacity 0.25s; }
.choices.hide { opacity: 0; pointer-events: none; }

.vs {
    width: 58px; height: 58px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gold), #ff9f43);
    color: #2a1500; font-family: var(--display); font-weight: 800;
    box-shadow: 0 0 0 8px rgba(255, 209, 102, 0.12);
}

.card-b.reveal .price { color: var(--gold); }
.card-b.good { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(110, 231, 196, 0.35), 0 30px 60px rgba(0, 0, 0, 0.35); }
.card-b.bad { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 122, 0.35), 0 30px 60px rgba(0, 0, 0, 0.35); animation: shake 0.45s; }
.card-b.slide-in { animation: slide 0.55s var(--ease); }

@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes slide { from { opacity: 0; transform: translateX(60px) rotateY(-25deg); } to { opacity: 1; transform: none; } }

.hint { color: var(--muted); font-size: 0.9rem; margin: 18px 0 0; }
.toast { min-height: 1.6em; margin: 10px 0 0; font-family: var(--display); font-size: 1.4rem; font-weight: 800; color: var(--white); }

/* ---------- game over ---------- */
.final { font-size: clamp(3rem, 10vw, 5.5rem); }
.final span { color: var(--gold); }
.new-record { color: var(--gold); font-weight: 800; font-size: 1.3rem; margin: 0 0 18px; animation: pop 0.6s var(--ease); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 560px; margin: 0 auto 26px; }
.stats div { padding: 16px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stats strong { display: block; font-family: var(--display); font-size: 2rem; color: var(--white); }
.stats span { color: var(--muted); font-size: 0.88rem; }
.over-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 16px 18px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
    .arena { grid-template-columns: 1fr; }
    .vs { margin: -8px auto; width: 46px; height: 46px; position: relative; z-index: 2; }
    .card { min-height: 0; padding: 20px 16px; }
    .card-b .choices { flex-direction: row; max-width: none; }
    .card-b .choices .btn { flex: 1; padding: 0 12px; }
    .hint { display: none; }
    .back { font-size: 0.85rem; }
    .hud { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
