/* Beanayahoo: the site's "Control Room" tokens (dark surfaces, amber
   accent), like the other games in /games, with bigger touch targets for
   small hands. Game-state colors (the four answer colors, right/wrong)
   stay bright and playful. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #ff9c41; --on-primary: #0a0f14; --secondary: #2a3744;
    --bg1: #0f151c; --bg2: #1b2530;
    --card-bg: rgba(18,26,34,0.92); --card-border: #223040;
    --text: #e8edf2; --muted: #8ea0ad;
    --input-bg: #1b2530;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24; --gold: #fcd34d;
    --chip-bg: #1b2530; --raised: #223040; --picked-bg: rgba(255,156,65,0.18);
    --opt-0: #ef4444; --opt-1: #3b82f6; --opt-2: #f59e0b; --opt-3: #22c55e;
}
body.light {
    --bg1: #eef1f4; --bg2: #e3e8ee;
    --card-bg: rgba(255,255,255,0.9); --card-border: rgba(0,0,0,0.08);
    --text: #15202b; --muted: rgba(21,32,43,0.65); --input-bg: rgba(255,255,255,0.9);
    --good: #16a34a; --bad: #dc2626; --warn: #d97706; --gold: #d97706;
    --chip-bg: rgba(0,0,0,0.06); --raised: rgba(0,0,0,0.07);
}
body {
    font-family: 'Segoe UI', 'Rubik', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg1), var(--bg2)); color: var(--text);
    min-height: 100vh; line-height: 1.55; transition: background .5s;
    -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; padding-top: max(.8rem, env(safe-area-inset-top)); background: rgba(0,0,0,0.25); backdrop-filter: blur(12px); }
body.light .topbar { background: rgba(255,255,255,0.5); }
.topbar .back { color: var(--text); text-decoration: none; font-weight: 600; opacity: .9; }
.topbar .title { font-weight: 800; font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: var(--raised); border: none; color: var(--text); font-size: 1.05rem; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; cursor: pointer; transition: transform .2s; }
body.light .icon-btn { background: rgba(0,0,0,0.08); }
.icon-btn:active { transform: scale(0.9); }

#app { max-width: 560px; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
.screen { display: none; animation: fadeIn .35s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

.card { background: var(--card-bg); backdrop-filter: blur(14px); border: 1px solid var(--card-border); border-radius: 24px; padding: 1.4rem 1.1rem; box-shadow: 0 18px 50px rgba(0,0,0,0.2); }
.center { text-align: center; }
.owl { font-size: 4rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.big-emoji { font-size: 4rem; line-height: 1.1; margin-bottom: .3rem; }
.game-logo { font-size: 2.2rem; margin-bottom: .1rem; }
h2 { font-size: 1.45rem; margin-bottom: .3rem; }
.subtitle { color: var(--muted); margin-bottom: 1.1rem; }
.note { color: var(--muted); font-size: .9rem; margin-top: 1rem; }

.banner { position: sticky; top: .6rem; z-index: 30; margin: 0 auto 1rem; padding: .7rem 1rem; border-radius: 14px; background: rgba(0,0,0,0.6); color: #fff; text-align: center; font-weight: 700; }
body.light .banner { background: rgba(21,32,43,0.9); }

.field-label { display: block; font-size: .9rem; color: var(--muted); font-weight: 700; margin: 1.1rem 0 .45rem; }
.text-input { width: 100%; padding: .85rem 1rem; border-radius: 14px; border: 1px solid var(--card-border); background: var(--input-bg); color: var(--text); font-size: 1.15rem; font-family: inherit; text-align: center; }
.text-input::placeholder { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { flex: 1 1 auto; min-width: 46px; padding: .6rem .5rem; border-radius: 12px; border: 2px solid transparent; background: var(--chip-bg); color: var(--text); font-size: 1.1rem; font-weight: 800; cursor: pointer; transition: transform .15s, border-color .2s; }
.chip:active { transform: scale(0.95); }
.chip.active { border-color: var(--primary); background: var(--picked-bg); }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .45rem; }
.avatar-btn { aspect-ratio: 1; font-size: 1.9rem; border-radius: 16px; border: 3px solid transparent; background: var(--chip-bg); cursor: pointer; transition: transform .15s; }
.avatar-btn.active { border-color: var(--primary); transform: scale(1.08); background: var(--picked-bg); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; padding: .95rem 1.3rem; border: none; border-radius: 16px; font-size: 1.1rem; font-weight: 800; cursor: pointer; text-decoration: none; transition: transform .15s, opacity .2s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 26px rgba(0,0,0,0.25); }
.btn-secondary { background: var(--raised); color: var(--text); border: 1px solid var(--card-border); }
body.light .btn-secondary { background: rgba(0,0,0,0.05); }
.btn-danger { background: rgba(248,113,113,0.25); color: var(--text); border: 1px solid var(--bad); }
.btn-small { width: auto; padding: .5rem .9rem; font-size: .9rem; }
.btn-stack { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.3rem; }

/* Profiles */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.profile-grid:empty { display: none; }
.profile-btn { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: 1rem .5rem; border-radius: 20px; border: 1px solid var(--card-border); background: var(--chip-bg); color: var(--text); cursor: pointer; transition: transform .15s; }
.profile-btn:active { transform: scale(0.95); }
.profile-avatar { font-size: 3rem; line-height: 1.1; }
.profile-name { font-weight: 800; font-size: 1.1rem; word-break: break-word; }
.parent-link { display: block; margin: 1.2rem auto 0; background: none; border: none; color: var(--muted); font-size: .95rem; cursor: pointer; text-decoration: underline; }

/* Map */
.map-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.who { display: flex; align-items: center; gap: .4rem; background: var(--chip-bg); border: none; color: var(--text); font-size: 1.1rem; font-weight: 800; padding: .35rem .9rem .35rem 1rem; border-radius: 999px; cursor: pointer; }
.who span:first-child { font-size: 1.6rem; }
.stars-pill { background: rgba(252,211,77,0.25); color: var(--text); font-weight: 900; padding: .4rem .9rem; border-radius: 999px; font-size: 1.05rem; }
.domain-tabs { display: flex; gap: .45rem; margin-bottom: .9rem; }
.domain-tab { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .55rem .3rem; border-radius: 14px; border: 2px solid transparent; background: var(--chip-bg); color: var(--text); font-weight: 800; font-size: .98rem; }
.domain-tab.active { border-color: var(--primary); background: var(--picked-bg); }
.domain-tab.soon { opacity: .55; }
.domain-tab small { font-size: .7rem; font-weight: 600; color: var(--muted); }
.play-btn { font-size: 1.35rem; padding: 1.1rem; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.025); } }
.play-hint { text-align: center; color: var(--muted); font-weight: 700; margin: .5rem 0 1rem; }

.skill-path { list-style: none; display: flex; flex-direction: column; gap: .5rem; padding: .3rem 0 1rem; }
.node { padding-inline-start: var(--offset); transition: padding .3s; }
.node-btn { display: flex; align-items: center; gap: .7rem; width: max-content; min-width: 78%; max-width: 100%; padding: .5rem .8rem .5rem .6rem; border-radius: 999px; border: none; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text); cursor: pointer; text-align: start; transition: transform .15s; }
.node-btn:active { transform: scale(0.97); }
.node-dot { flex: 0 0 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.15rem; background: var(--raised); }
.node-title { flex: 1; font-weight: 800; font-size: 1.02rem; white-space: nowrap; }
.node-due { font-size: 1.1rem; }
.node.locked .node-btn { opacity: .5; }
.node.known .node-btn { opacity: .75; }
.node.known .node-dot { background: rgba(74,222,128,0.25); color: var(--good); }
.node.mastered .node-dot { background: rgba(252,211,77,0.35); font-size: 1.5rem; }
.node.open .node-dot { background: var(--primary); color: var(--on-primary); }
.node.progress .node-dot { font-size: .85rem; background: conic-gradient(var(--good) calc(var(--pct) * 1%), var(--raised) 0); }
.node.focus .node-btn { border: 2px solid var(--primary); box-shadow: 0 0 22px rgba(255,156,65,0.35); }

.side-card { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-radius: 18px; background: var(--chip-bg); color: var(--text); text-decoration: none; margin-top: .5rem; }
.side-card small { color: var(--muted); }
.side-emoji { font-size: 2rem; }

/* Play */
.play-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.progress-track { flex: 1; height: 14px; border-radius: 999px; background: rgba(0,0,0,0.22); overflow: hidden; }
body.light .progress-track { background: rgba(0,0,0,0.1); }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--good), var(--primary)); transition: width .4s ease; }
.round-tag { font-size: .85rem; font-weight: 800; background: var(--chip-bg); padding: .25rem .6rem; border-radius: 999px; white-space: nowrap; }
.play-card { min-height: 420px; }
.prompt-row { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: .8rem; }
.prompt { font-size: 2.3rem; font-weight: 900; text-align: center; flex: 1; line-height: 1.3; }
.speak-btn { font-size: 1.2rem; }
.prompt.long { font-size: 1.6rem; }
.math { unicode-bidi: isolate; white-space: nowrap; }

.visual { display: flex; justify-content: center; margin-bottom: 1rem; }
.visual:empty { display: none; }
.emoji-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; direction: ltr; max-width: 330px; }
.emoji { font-size: 2.6rem; line-height: 1.15; animation: popIn .35s ease backwards; }
.emoji-row.dense .emoji { font-size: 2.1rem; }
.emoji-row .emoji:nth-child(2) { animation-delay: .05s; } .emoji-row .emoji:nth-child(3) { animation-delay: .1s; }
.emoji-row .emoji:nth-child(4) { animation-delay: .15s; } .emoji-row .emoji:nth-child(5) { animation-delay: .2s; }
.emoji.gone { opacity: .25; filter: grayscale(1); position: relative; }
.emoji.gone::after { content: '✕'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--bad); font-size: 2rem; font-weight: 900; }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }
.equation { display: flex; align-items: center; gap: .5rem; direction: ltr; flex-wrap: wrap; justify-content: center; }
.equation .emoji-row { max-width: 150px; }
.equation .op { font-size: 2.2rem; font-weight: 900; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; width: 100%; direction: ltr; }
.compare-side { min-height: 170px; display: flex; align-items: center; justify-content: center; padding: .7rem .4rem; border-radius: 20px; border: 3px solid var(--card-border); background: var(--chip-bg); cursor: pointer; transition: transform .15s, border-color .2s; }
.compare-side:active { transform: scale(0.97); }
.compare-side .emoji { font-size: 1.9rem; }
.compare-side.right { border-color: var(--good); box-shadow: 0 0 24px var(--good); }
.compare-side.picked:not(.right) { border-color: var(--bad); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.option { padding: 1.2rem .6rem; border: none; border-radius: 18px; font-size: 1.9rem; font-weight: 900; color: #fff; cursor: pointer; direction: ltr; box-shadow: 0 5px 0 rgba(0,0,0,0.18); transition: transform .12s, opacity .25s, box-shadow .2s; }
.option:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }
.option[data-i="0"] { background: var(--opt-0); }
.option[data-i="1"] { background: var(--opt-1); }
.option[data-i="2"] { background: var(--opt-2); }
.option[data-i="3"] { background: var(--opt-3); }
.option:disabled { cursor: default; }
.option.dimmed { opacity: .3; }
.option.picked { box-shadow: 0 0 0 4px var(--text) inset; }
.option.right { box-shadow: 0 0 0 4px #fff inset, 0 0 26px var(--good); animation: tada .5s ease; }
@keyframes tada { 30% { transform: scale(1.08) rotate(-3deg); } 60% { transform: scale(1.05) rotate(2deg); } }
.hint-btn { display: block; margin: .9rem auto 0; background: none; border: 1px dashed var(--card-border); color: var(--muted); padding: .35rem .9rem; border-radius: 999px; font-weight: 700; cursor: pointer; }
.hint-btn:disabled { opacity: .4; }

.answer-display { min-height: 3.8rem; border-radius: 16px; background: rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; font-size: 2.3rem; font-weight: 900; margin-bottom: .7rem; direction: ltr; border: 3px solid transparent; }
body.light .answer-display { background: rgba(0,0,0,0.06); }
.answer-display.good { border-color: var(--good); }
.answer-display.bad { border-color: var(--bad); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; direction: ltr; }
.key { padding: .85rem 0; border: none; border-radius: 16px; background: var(--raised); color: var(--text); font-size: 1.6rem; font-weight: 900; cursor: pointer; transition: transform .12s; }
body.light .key { background: rgba(0,0,0,0.07); }
.key:active { transform: scale(0.94); }
.key.wide { font-size: 1.25rem; }
.key.ok { background: var(--good); color: #06331b; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.match-col { display: flex; flex-direction: column; gap: .55rem; }
.match-card { padding: .9rem .4rem; border-radius: 16px; border: 3px solid transparent; background: var(--raised); color: var(--text); font-size: 1.45rem; font-weight: 900; cursor: pointer; transition: transform .12s, background .2s; }
.match-card.picked { border-color: var(--primary); transform: scale(1.04); }
.match-card.right { cursor: default; color: #fff; }
.match-card.pair-0 { background: var(--opt-0); } .match-card.pair-1 { background: var(--opt-1); }
.match-card.pair-2 { background: var(--opt-2); } .match-card.pair-3 { background: var(--opt-3); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { text-align: center; margin-top: 1rem; animation: fadeIn .25s ease; }
.feedback-title { font-size: 1.6rem; font-weight: 900; color: var(--good); }
.feedback.bad .feedback-title { color: var(--warn); }
.feedback-explain { font-size: 1.15rem; font-weight: 700; margin: .3rem 0 .8rem; }
.feedback:not(.bad) .feedback-explain:empty { display: none; }

/* End */
.end-stars { font-size: 1.25rem; font-weight: 900; color: var(--gold); margin: .3rem 0 .8rem; }
.achievements { list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.achievement { padding: .6rem .9rem; border-radius: 14px; background: rgba(252,211,77,0.2); font-weight: 800; animation: popIn .4s ease backwards; }

/* Parents */
.parent-list { list-style: none; display: flex; flex-direction: column; gap: .7rem; }
.parent-item { padding: .9rem; border-radius: 16px; background: var(--chip-bg); }
.parent-who { font-weight: 900; font-size: 1.1rem; }
.parent-line { color: var(--muted); font-size: .92rem; }
.parent-actions { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }

@media (max-width: 380px) {
    .prompt { font-size: 1.9rem; }
    .option { font-size: 1.55rem; padding: 1rem .4rem; }
    .node-btn { min-width: 84%; }
    .avatar-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Family sync (parent area) */
.sync-box { margin-top: 1.1rem; padding: 1rem; border-radius: 16px; background: var(--chip-bg); display: flex; flex-direction: column; gap: .6rem; }
.sync-box h3 { font-size: 1.1rem; }
.sync-box .note { margin-top: 0; }
.family-code { font-size: 2rem; font-weight: 900; letter-spacing: .25rem; text-align: center; direction: ltr; user-select: all; }
.sync-status { text-align: center; font-weight: 800; }
.code-input { letter-spacing: .2rem; text-transform: uppercase; }
.code-input::placeholder { letter-spacing: normal; text-transform: none; }
.join-row { display: flex; gap: .5rem; }
.join-row .text-input { flex: 1; min-width: 0; }
.join-row .btn { width: auto; white-space: nowrap; }

/* Phase 3: letters, words, pictures, rectangles, voices */
.big-text { font-weight: 900; line-height: 1.1; padding: .3rem 1.2rem; border-radius: 18px; background: var(--chip-bg); }
.big-text.letter { font-size: 5rem; min-width: 7rem; text-align: center; }
.big-text.word { font-size: 3.2rem; letter-spacing: .08rem; }
.big-picture { font-size: 5.5rem; line-height: 1.1; }
.prompt-word { color: var(--primary); }
.option.picture, .match-card.picture { font-size: 2.6rem; line-height: 1.2; padding-top: .8rem; padding-bottom: .8rem; }
.rect-grid { display: grid; grid-template-columns: repeat(var(--w), 1fr); gap: 2px; width: calc(var(--w) * 26px); max-width: 100%; direction: ltr; }
.rect-cell { aspect-ratio: 1; background: rgba(255,156,65,0.35); border: 1px solid rgba(255,156,65,0.7); border-radius: 3px; }
.key.minus { grid-column: 1 / -1; font-size: 1.4rem; }
.voice-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.voice-lang { font-weight: 800; min-width: 4.2rem; }
.voice-select { flex: 1; min-width: 0; padding: .5rem; border-radius: 10px; border: 1px solid var(--card-border); background: var(--input-bg); color: var(--text); font-family: inherit; font-size: .9rem; }
.voice-row .chips { flex: 1; }
