/* Same Brain — playful/cartoon styling. */

:root {
    --bg: #160a2e;
    --bg2: #24104a;
    --panel: #2c1558;
    --panel-edge: #0d0620;
    --ink: #f6f0ff;
    --muted: #b9a9e0;
    --cyan: #4de2ff;
    --pink: #ff5db1;
    --lime: #b7ff5e;
    --gold: #ffd75e;
    --violet: #a06bff;
    --shadow: 0 6px 0 rgba(0, 0, 0, 0.4);
    --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: radial-gradient(1200px 700px at 20% -10%, #3a1a6e 0%, transparent 60%),
                radial-gradient(900px 600px at 90% 110%, #12406b 0%, transparent 55%),
                linear-gradient(160deg, var(--bg) 0%, #0d0620 100%);
    color: var(--ink);
    font-family: ui-rounded, "Segoe UI Rounded", "Nunito", "Trebuchet MS", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

#stage {
    position: relative;
    flex: 1;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow: hidden;
}

/* ------------------------------------------------------------ HUD */
.hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: linear-gradient(180deg, rgba(13, 6, 32, 0.92), rgba(13, 6, 32, 0.35));
    backdrop-filter: blur(6px);
}

.hud-side { flex: 1 1 0; }
.hud-side.right { text-align: right; }
.hud-stat { display: flex; flex-direction: column; line-height: 1.05; }
.hud-side.right .hud-stat { align-items: flex-end; }
.hud-k { font-size: 10px; letter-spacing: 0.14em; color: var(--muted); font-weight: 800; }
.hud-v { font-size: 20px; font-weight: 900; }
.hud-v.sync { color: var(--lime); }

.hud-mid { flex: 1.6 1 0; text-align: center; }

.hud-type {
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: var(--cyan);
    text-transform: uppercase;
    transition: color 0.15s;
}
.hud-type.sync { color: var(--lime); }
.hud-type.jackpot { color: var(--gold); text-shadow: 0 0 14px rgba(255, 215, 94, 0.6); }
.hud-type.drift { color: #ff8fb0; }

.goal-wrap { margin-top: 6px; }
.goal-bar {
    display: flex;
    gap: 4px;
    height: 10px;
    justify-content: center;
}
.goal-bar i {
    flex: 1 1 0;
    max-width: 42px;
    border-radius: 6px;
    background: #3d2470;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
    transition: background 0.25s, transform 0.25s;
}
.goal-bar i.on {
    background: linear-gradient(180deg, var(--lime), #6fce35);
    transform: translateY(-1px);
}
.goal-label {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
}
.goal-label small { color: var(--muted); font-weight: 800; }
.goal-label .reached { color: var(--lime); }

body.meld-on #stage { animation: meldGlow 3s ease-in-out infinite; }
@keyframes meldGlow {
    0%, 100% { background: transparent; }
    50% { background: radial-gradient(600px 400px at 50% 40%, rgba(183, 255, 94, 0.08), transparent 70%); }
}

/* ------------------------------------------------------- play area */
.play-area {
    width: min(760px, 94vw);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-bottom: 76px;
    z-index: 5;
}

.prompt-card {
    background: linear-gradient(165deg, #ffffff 0%, #f0e9ff 100%);
    color: #220c45;
    border: 4px solid var(--panel-edge);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    transform: rotate(-0.5deg);
    transition: transform 0.2s, box-shadow 0.2s;
}
.prompt-card.jackpot-card {
    background: linear-gradient(165deg, #fff6d6 0%, #ffe6a8 100%);
    border-color: #7a4a00;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 215, 94, 0.45);
    transform: rotate(0deg) scale(1.01);
}
.prompt-tag {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #7a4ad0;
    text-transform: uppercase;
}
.prompt-card.jackpot-card .prompt-tag { color: #a85f00; }
.prompt-text {
    margin: 6px 0 0;
    font-size: clamp(19px, 4.6vw, 28px);
    line-height: 1.2;
    font-weight: 900;
}

.answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.answers.practice-answers { grid-template-columns: 1fr 1fr; gap: 8px; }

.answer {
    position: relative;
    appearance: none;
    border: 3px solid #190a38;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #e9dcff 100%);
    color: #220c45;
    font: inherit;
    font-weight: 800;
    font-size: clamp(14px, 2.7vw, 18px);
    line-height: 1.2;
    padding: 16px 14px;
    min-height: 74px;
    cursor: pointer;
    box-shadow: 0 5px 0 #120626;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s, border-color 0.15s;
    text-align: center;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.answer.small { min-height: 52px; padding: 10px; font-size: 13px; box-shadow: 0 4px 0 #120626; }
.answer.selectable:hover { transform: translateY(-3px); box-shadow: 0 8px 0 #120626; background: linear-gradient(180deg, #ffffff 0%, #f6efff 100%); }
.answer.selectable:active { transform: translateY(2px); box-shadow: 0 2px 0 #120626; }
.answer:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.answer .tag {
    position: absolute;
    top: 6px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}
.answer .tag-you { left: 6px; background: #2f8bff; color: #fff; }
.answer .tag-them { right: 6px; background: var(--pink); color: #3a0030; }

.answer.dimmed { opacity: 0.4; transform: scale(0.97); }

.answer.picked-you { border-color: #2f8bff; box-shadow: 0 5px 0 #14508f, 0 0 22px rgba(77, 226, 255, 0.5); }
.answer.picked-you .tag-you { opacity: 1; }

.answer.picked-them { border-color: var(--pink); box-shadow: 0 5px 0 #8f1450, 0 0 22px rgba(255, 93, 177, 0.5); }
.answer.picked-them .tag-them { opacity: 1; }

.answer.picked-both {
    border-color: #2fbf5f;
    background: linear-gradient(180deg, #d8ffe4 0%, #a7f7bf 100%);
    box-shadow: 0 5px 0 #157a37, 0 0 30px rgba(124, 242, 155, 0.7);
    animation: matchPop 0.5s ease;
    z-index: 3;
}
.answer.picked-both .tag-you, .answer.picked-both .tag-them { opacity: 1; }
@keyframes matchPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.07) rotate(-1deg); }
    100% { transform: scale(1); }
}

.partner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.partner.locked { color: var(--pink); }
.partner-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--muted);
    animation: pulse 1.2s infinite;
}
.partner.locked .partner-dot { background: var(--pink); }
@keyframes pulse { 0%, 100% { opacity: 0.4; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }

/* --------------------------------------------------------- reveal */
.flash {
    position: fixed;
    left: 50%;
    top: 17%;
    transform: translateX(-50%);
    z-index: 30;
    width: min(560px, 92vw);
    text-align: center;
    pointer-events: none;
    padding: 14px 18px;
    border-radius: 20px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    background: rgba(20, 8, 45, 0.82);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
}
.flash.pop { opacity: 1; animation: flashPop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
.flash.out { opacity: 0; transform: translateX(-50%) translateY(-12px); }
@keyframes flashPop {
    0% { transform: translateX(-50%) scale(0.6); }
    60% { transform: translateX(-50%) scale(1.06); }
    100% { transform: translateX(-50%) scale(1); }
}
.flash-word {
    font-size: clamp(26px, 8vw, 46px);
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1;
}
.flash.sync .flash-word { color: var(--lime); text-shadow: 0 3px 0 #145c26, 0 0 26px rgba(124, 242, 155, 0.7); }
.flash.jackpot .flash-word {
    color: var(--gold);
    text-shadow: 0 3px 0 #7a4a00, 0 0 30px rgba(255, 215, 94, 0.9);
    animation: jackpotShake 0.5s;
}
@keyframes jackpotShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px) rotate(-1deg); }
    40% { transform: translateX(4px) rotate(1deg); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}
.flash.drift .flash-word { color: #ff9fc0; }
.flash-line { margin-top: 6px; font-size: clamp(12px, 3vw, 15px); font-weight: 700; color: #ded3ff; }
.flash-picks { margin-top: 6px; font-size: clamp(13px, 3.4vw, 17px); font-weight: 900; color: #fff; }

.fx {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.emoji-float {
    position: absolute;
    z-index: 25;
    font-size: 34px;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translateY(14px) scale(0.6); }
    20% { opacity: 1; transform: translateY(0) scale(1.1); }
    100% { opacity: 0; transform: translateY(-70px) scale(1); }
}

/* ------------------------------------------------------- overlays */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: radial-gradient(800px 600px at 50% 30%, rgba(80, 30, 140, 0.55), rgba(8, 3, 20, 0.86));
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.panel {
    width: min(520px, 94vw);
    background: linear-gradient(165deg, #2f1760 0%, #24104a 100%);
    border: 3px solid #4a2a8c;
    border-radius: 26px;
    padding: 22px 20px;
    box-shadow: 0 12px 0 rgba(0, 0, 0, 0.4), 0 0 60px rgba(160, 107, 255, 0.25);
    text-align: center;
    animation: panelIn 0.3s ease;
    max-height: 94dvh;
    overflow-y: auto;
}
@keyframes panelIn { from { transform: translateY(14px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

.brand {
    font-size: clamp(34px, 11vw, 54px);
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 0.95;
    color: var(--cyan);
    text-shadow: 0 4px 0 #0a3b52;
}
.brand span { color: var(--pink); text-shadow: 0 4px 0 #6b1445; }
.brand.small { font-size: clamp(26px, 8vw, 38px); }

.tagline { margin-top: 6px; font-size: 15px; font-weight: 800; color: var(--muted); }

.howto {
    margin: 18px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}
.howto-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 700;
}
.howto-row b { color: var(--cyan); }
.chip {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--violet);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    box-shadow: 0 3px 0 #4a2a8c;
}
.howto-note { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.howto-note .jackpot { color: var(--gold); }

.btn {
    appearance: none;
    border: 3px solid #190a38;
    border-radius: 16px;
    background: linear-gradient(180deg, #4a2a8c, #341a68);
    color: var(--ink);
    font: inherit;
    font-weight: 900;
    font-size: 16px;
    letter-spacing: 0.03em;
    padding: 14px 18px;
    cursor: pointer;
    box-shadow: 0 5px 0 #120626;
    transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #120626; }
.btn.primary {
    background: linear-gradient(180deg, var(--cyan), #1f9fd0);
    color: #062432;
    text-shadow: none;
    box-shadow: 0 5px 0 #0a5c7d;
}
.btn.primary:active { box-shadow: 0 2px 0 #0a5c7d; }
.btn.ghost { background: transparent; border-color: #4a2a8c; box-shadow: none; color: var(--muted); }
.btn.tiny { font-size: 12px; padding: 8px 12px; border-width: 2px; border-radius: 11px; box-shadow: 0 3px 0 #120626; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

#playBtn { width: 100%; font-size: 19px; padding: 16px; margin-top: 4px; }
.lobby-hint { margin-top: 12px; font-size: 12px; color: var(--muted); font-weight: 700; }

/* -------------------------------------------------------- waiting */
.wait-title { margin-top: 14px; font-size: 20px; font-weight: 900; color: var(--ink); }
.wait-sub { margin-top: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
.dots i { animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.practice {
    margin: 16px 0;
    background: rgba(0, 0, 0, 0.22);
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    padding: 14px;
}
.practice-prompt { font-size: 15px; font-weight: 900; min-height: 38px; display: grid; place-items: center; }
.practice-result { margin-top: 10px; font-size: 13px; font-weight: 800; min-height: 18px; color: var(--lime); }
.practice-foot { margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
.practice-foot b { color: var(--cyan); }

/* -------------------------------------------------------- results */
.result-kicker { font-size: 12px; font-weight: 900; letter-spacing: 0.16em; color: var(--muted); }
.result-score {
    font-size: clamp(56px, 18vw, 84px);
    font-weight: 900;
    line-height: 1;
    margin-top: 4px;
    color: var(--lime);
    text-shadow: 0 5px 0 #145c26;
}
.result-sub { font-size: 15px; font-weight: 800; color: var(--ink); }
.result-sub span { color: var(--cyan); }
.result-summary { margin-top: 12px; font-size: 15px; font-weight: 700; color: #ded3ff; }

.recap { display: flex; gap: 7px; justify-content: center; margin: 14px 0 4px; }
.recap-dot {
    width: 20px; height: 20px;
    border-radius: 7px;
    background: #3d2470;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}
.recap-dot.ok { background: linear-gradient(180deg, var(--lime), #6fce35); }
.recap-dot.miss { background: #ff8fb0; }
.recap-dot.jack { outline: 2px solid var(--gold); outline-offset: 2px; }

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}
.stat {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat-k { font-size: 10px; letter-spacing: 0.1em; font-weight: 900; color: var(--muted); }
.stat-v { font-size: 22px; font-weight: 900; }

.result-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.result-wait { margin-top: 12px; font-size: 13px; color: var(--muted); font-weight: 800; }

.goodbye-msg { margin: 16px 0; font-size: 16px; font-weight: 700; color: #ded3ff; }

/* ----------------------------------------------------- pause/toast */
.pause-banner {
    position: fixed;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%);
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(30, 12, 60, 0.95);
    border: 2px solid var(--pink);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 800;
    max-width: 92vw;
}
.pause-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); animation: pulse 1s infinite; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    z-index: 60;
    background: rgba(0, 0, 0, 0.82);
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 800;
    max-width: 90vw;
}

/* ------------------------------------------------------- controls */
.controls {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(13, 6, 32, 0.92), rgba(13, 6, 32, 0.3));
    backdrop-filter: blur(6px);
}
.reactions { display: flex; gap: 6px; flex-wrap: wrap; }
.reaction {
    appearance: none;
    border: 2px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 19px;
    width: 40px; height: 40px;
    cursor: pointer;
    transition: transform 0.08s, background 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.reaction:hover { background: rgba(255, 255, 255, 0.18); transform: translateY(-2px); }
.reaction:active { transform: translateY(1px); }
.controls-right { display: flex; align-items: center; gap: 8px; }

@media (max-width: 560px) {
    .answers { grid-template-columns: 1fr; gap: 9px; }
    .answers.practice-answers { grid-template-columns: 1fr 1fr; }
    .answer { min-height: 58px; padding: 12px; }
    .play-area { padding-bottom: 70px; gap: 12px; }
    .flash { top: 13%; }
    .hud-v { font-size: 17px; }
}

@media (max-height: 640px) {
    .prompt-card { padding: 12px 14px; }
    .answer { min-height: 54px; padding: 10px; }
    .howto { display: none; }
}
