:root {
    --ink: #3e321f;
    --cream: #fff9e8;
    --honey: #f8be2d;
    --honey-dark: #d79000;
    --green: #55a85e;
    --sky: #8fd7ff;
    --panel: rgba(255,255,255,.88);
}
* { box-sizing: border-box; }
html, body, #app { margin:0; width:100%; min-height:100%; }
body {
    font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: linear-gradient(#fff3bf, #ffe6a7);
    overscroll-behavior: none;
}
button { font: inherit; }
.loading-screen {
    min-height: 100vh; display:grid; place-items:center; align-content:center; gap:12px;
    font-weight:800; font-size:1.2rem;
}
.loading-bee { font-size:4rem; animation:bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform:translateY(-12px) rotate(5deg); } }

.app-shell { min-height:100vh; }
.game-page { min-height:100vh; display:flex; flex-direction:column; }
.topbar {
    display:flex; align-items:center; justify-content:space-between;
    padding:10px clamp(12px,3vw,28px);
    background:rgba(255,255,255,.86);
    border-bottom:3px solid rgba(216,145,0,.22);
    box-shadow:0 3px 16px rgba(80,55,0,.08);
}
.brand { display:flex; align-items:center; gap:10px; min-width:0; }
.bee-logo { font-size:2.25rem; filter:drop-shadow(0 3px 2px rgba(0,0,0,.13)); }
.brand-title { font-weight:1000; font-size:clamp(1.05rem,3vw,1.55rem); line-height:1; }
.brand-subtitle { margin-top:4px; color:#756346; font-size:clamp(.7rem,1.8vw,.9rem); }
.top-actions { display:flex; gap:8px; }
.icon-button {
    border:0; width:44px; height:44px; border-radius:14px; background:#fff4c3;
    box-shadow:inset 0 0 0 2px rgba(215,144,0,.15), 0 3px 8px rgba(80,55,0,.08);
    font-size:1.25rem; cursor:pointer;
}
.icon-button:active { transform:scale(.96); }

.game-shell {
    width:min(1180px,100%); margin:0 auto; padding:10px clamp(8px,2vw,18px) 14px;
    display:flex; flex-direction:column; gap:9px; flex:1;
}
.hud { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.hud-card {
    background:var(--panel); border-radius:15px; padding:7px 11px; min-height:54px;
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    border:2px solid rgba(219,151,16,.18); box-shadow:0 4px 12px rgba(84,57,0,.08);
}
.hud-label { color:#876f49; font-size:.76rem; font-weight:800; text-transform:uppercase; letter-spacing:.05em; }
.hud-card strong { font-size:clamp(.95rem,2.5vw,1.25rem); }
.timer-card strong { color:#cf5e37; }

.canvas-wrap {
    position:relative; overflow:hidden; border-radius:24px;
    box-shadow:0 14px 32px rgba(84,57,0,.18), inset 0 0 0 4px rgba(255,255,255,.65);
    min-height:0; flex:1;
    aspect-ratio:16 / 9;
    max-height:calc(100vh - 220px);
    background:#9edfff;
    touch-action:none;
}
#gameCanvas { width:100%; height:100%; display:block; touch-action:none; }

.game-overlay {
    position:absolute; inset:0; display:grid; place-items:center;
    background:linear-gradient(rgba(71,157,211,.22), rgba(84,59,24,.28));
    backdrop-filter: blur(2px);
    padding:16px;
}
.game-overlay.hidden { display:none; }
.start-card {
    width:min(470px,92%); text-align:center; border-radius:28px; padding:clamp(16px,4vw,28px);
    background:rgba(255,252,235,.96); border:4px solid rgba(255,255,255,.9);
    box-shadow:0 18px 50px rgba(62,50,31,.25);
}
.hero-bee { font-size:clamp(3rem,9vw,5.2rem); animation:bob 1.1s ease-in-out infinite; }
.start-card h1,.start-card h2 { margin:4px 0 7px; line-height:1; }
.start-card h1 { font-size:clamp(1.8rem,6vw,3rem); }
.start-card h2 { font-size:clamp(1.7rem,5vw,2.5rem); }
.start-card p { margin:8px auto 14px; max-width:32rem; }
.difficulty-row { display:flex; justify-content:center; gap:8px; margin:12px 0; }
.difficulty {
    border:2px solid #e5c35c; background:#fff; padding:9px 18px; border-radius:999px;
    font-weight:900; color:#725d28; cursor:pointer;
}
.difficulty.active { background:#ffe48a; border-color:#dba20e; transform:scale(1.04); }
.play-button {
    border:0; border-radius:18px; padding:12px 26px; font-weight:1000; font-size:1.25rem;
    color:#47370c; background:linear-gradient(#ffdf55,#f6b619);
    box-shadow:0 7px 0 #ca8a00, 0 10px 18px rgba(83,54,0,.18); cursor:pointer;
}
.play-button:active { transform:translateY(4px); box-shadow:0 3px 0 #ca8a00; }
.tiny-note { font-size:.75rem; color:#8c7955; }
.celebrate { font-size:4rem; }

.instructions {
    display:grid; grid-template-columns:repeat(3,1fr); gap:8px;
    font-size:clamp(.72rem,1.7vw,.9rem); color:#6c5a3e;
}
.instructions > div {
    background:rgba(255,255,255,.7); border-radius:12px; padding:7px 10px; text-align:center;
}
footer {
    min-height:30px; display:flex; align-items:center; justify-content:center; gap:8px;
    color:#8a734c; font-size:.72rem; padding:5px 10px 8px;
}
#blazor-error-ui { display:none; }

@media (max-width:700px) {
    .brand-subtitle { display:none; }
    .hud-card { flex-direction:column; align-items:flex-start; justify-content:center; gap:0; min-height:48px; padding:5px 8px; }
    .instructions { grid-template-columns:1fr; }
    .instructions > div:nth-child(n+2) { display:none; }
    .canvas-wrap { max-height:none; border-radius:16px; }
    .topbar { padding:7px 9px; }
    .icon-button { width:40px;height:40px; }
}
@media (orientation:landscape) and (max-height:650px) {
    .topbar { padding-top:4px; padding-bottom:4px; }
    .brand-subtitle, footer, .instructions { display:none; }
    .game-shell { padding-top:5px; padding-bottom:5px; }
    .hud-card { min-height:40px; padding:3px 8px; }
    .canvas-wrap { max-height:calc(100vh - 105px); }
}


/* v1.1 friendly animal greeter */
.greeter-wrap {
    display:flex; align-items:center; justify-content:center; gap:12px;
    margin:0 auto 2px;
}
.speech-bubble {
    position:relative; background:#fff; border:3px solid #73512f;
    border-radius:18px; padding:10px 15px; font-weight:1000;
    font-size:clamp(.9rem,2.5vw,1.15rem); box-shadow:0 5px 0 rgba(93,65,31,.12);
}
.speech-bubble:before {
    content:""; position:absolute; left:-15px; bottom:12px; width:22px; height:22px;
    background:#fff; border-left:3px solid #73512f; border-bottom:3px solid #73512f;
    transform:rotate(45deg);
}
.greeter-dog { position:relative; width:72px; height:68px; flex:0 0 auto; animation:dogHello 1.8s ease-in-out infinite; }
.dog-head {
    position:absolute; inset:8px 7px 2px; border-radius:48% 48% 45% 45%;
    background:#d9914f; border:3px solid #654026;
}
.dog-ear {
    position:absolute; width:25px; height:42px; top:5px; background:#895431;
    border:3px solid #654026; border-radius:60% 40% 65% 35%; z-index:0;
}
.dog-ear-left { left:0; transform:rotate(26deg); }
.dog-ear-right { right:0; transform:rotate(-26deg); }
.dog-eye { position:absolute; top:19px; width:7px; height:9px; background:#2e241e; border-radius:50%; }
.dog-eye.left { left:15px; }.dog-eye.right { right:15px; }
.dog-muzzle { position:absolute; width:34px; height:23px; border-radius:50%; background:#f1c796; left:50%; bottom:7px; transform:translateX(-50%); }
.dog-nose { position:absolute; width:12px; height:8px; background:#2e241e; border-radius:50%; left:50%; bottom:22px; transform:translateX(-50%); }
.dog-smile { position:absolute; width:18px; height:10px; border-bottom:3px solid #5f3428; border-radius:50%; left:50%; bottom:10px; transform:translateX(-50%); }
@keyframes dogHello { 0%,100%{transform:rotate(-2deg)} 50%{transform:translateY(-4px) rotate(2deg)} }
.music-note { margin:12px 0 0; font-size:.78rem; font-weight:800; color:#7f672f; }


/* v1.2 preschool learning mode */
.learn-toggle {
    width:52px;
    font-size:.78rem;
    font-weight:1000;
    letter-spacing:-.04em;
}
.learn-toggle.active {
    background:#dff5c9;
    box-shadow:inset 0 0 0 2px rgba(73,145,58,.30),0 3px 8px rgba(80,55,0,.08);
}
.learning-prompt {
    display:flex;
    align-items:center;
    gap:12px;
    padding:9px 13px;
    border-radius:17px;
    background:linear-gradient(90deg,rgba(255,255,255,.94),rgba(255,247,205,.94));
    border:2px solid rgba(218,153,22,.25);
    box-shadow:0 4px 12px rgba(84,57,0,.08);
}
.learning-prompt.hidden { display:none; }
.letter-badge {
    display:grid;
    place-items:center;
    width:52px;
    height:52px;
    flex:0 0 auto;
    border-radius:16px;
    background:linear-gradient(#ffdf55,#f6b619);
    border:3px solid #fff;
    box-shadow:0 4px 0 #c98a00;
    font-size:1.85rem;
    font-weight:1000;
}
.learning-copy {
    min-width:0;
    display:grid;
    line-height:1.05;
}
.learning-kicker {
    color:#8a7247;
    font-size:.69rem;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.08em;
}
.learning-copy strong {
    font-size:1.35rem;
}
.learning-copy span:last-child {
    color:#715e3f;
    font-size:.8rem;
    margin-top:3px;
}
.repeat-button {
    margin-left:auto;
    border:0;
    border-radius:13px;
    padding:9px 13px;
    background:#e9f5ff;
    color:#365a73;
    font-size:.8rem;
    font-weight:900;
    cursor:pointer;
}
.learning-choice {
    display:flex;
    justify-content:center;
    align-items:center;
    gap:8px;
    margin:12px auto;
    font-weight:900;
    color:#655333;
}
.learning-choice input {
    width:20px;
    height:20px;
    accent-color:#e1a400;
}
@media (max-width:700px) {
    .learning-prompt { padding:7px 9px; gap:8px; }
    .letter-badge { width:44px;height:44px;font-size:1.5rem; }
    .learning-copy strong { font-size:1.05rem; }
    .repeat-button { padding:8px;font-size:0; }
    .repeat-button::after { content:"🔁";font-size:1rem; }
}
@media (orientation:landscape) and (max-height:650px) {
    .learning-prompt { min-height:42px;padding:3px 9px; }
    .letter-badge { width:36px;height:36px;border-radius:11px;font-size:1.25rem;box-shadow:none; }
    .learning-copy strong { font-size:1rem; }
    .learning-copy span:last-child,.learning-kicker { display:none; }
}

/* v1.3 waving child greeter */
.greeter-wrap{display:flex;align-items:center;justify-content:center;gap:14px;margin:0 auto 4px}
.speech-bubble{position:relative;background:#fff;border:3px solid #73512f;border-radius:20px;padding:10px 16px;font-weight:1000;font-size:clamp(.9rem,2.5vw,1.15rem);box-shadow:0 5px 0 rgba(93,65,31,.12)}
.speech-bubble:before{content:"";position:absolute;left:-15px;bottom:14px;width:22px;height:22px;background:#fff;border-left:3px solid #73512f;border-bottom:3px solid #73512f;transform:rotate(45deg)}
.big-hi{color:#e36b4b;font-size:1.35em;letter-spacing:.04em}
.waving-friend{position:relative;width:92px;height:104px;flex:0 0 auto;animation:friendBob 1.8s ease-in-out infinite}
.friend-head{position:absolute;left:22px;top:8px;width:52px;height:55px;border-radius:48% 48% 46% 46%;background:#f0bd8f;border:3px solid #70452f;z-index:3}
.friend-hair{position:absolute;left:18px;top:2px;width:60px;height:34px;border-radius:52% 52% 35% 35%;background:#6a412e;border:3px solid #4d3024;z-index:4}
.friend-hair:after{content:"";position:absolute;left:6px;bottom:-18px;width:10px;height:25px;border-radius:8px;background:#6a412e;box-shadow:36px 1px 0 #6a412e}
.friend-eye{position:absolute;top:24px;width:6px;height:8px;border-radius:50%;background:#2e241e}.friend-eye.left{left:13px}.friend-eye.right{right:13px}
.friend-smile{position:absolute;left:50%;bottom:10px;width:20px;height:10px;transform:translateX(-50%);border-bottom:3px solid #9b4e42;border-radius:50%}
.friend-body{position:absolute;left:19px;bottom:0;width:58px;height:50px;border-radius:24px 24px 12px 12px;background:#79b8e8;border:3px solid #426d8e}
.friend-arm{position:absolute;right:8px;top:48px;width:16px;height:42px;background:#f0bd8f;border:3px solid #70452f;border-radius:12px;transform-origin:bottom center;animation:waveArm .75s ease-in-out infinite alternate;z-index:2}
.friend-hand{position:absolute;right:-2px;top:28px;font-size:30px;transform-origin:bottom left;animation:waveHand .55s ease-in-out infinite alternate;z-index:5}
@keyframes friendBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@keyframes waveArm{from{transform:rotate(-18deg)}to{transform:rotate(-48deg)}}
@keyframes waveHand{from{transform:rotate(-12deg)}to{transform:rotate(18deg)}}


/* v1.9 simple pre-play greeting */
.preplay-greeter{
    display:flex;align-items:center;justify-content:center;gap:14px;
    margin:0 auto 10px;padding:8px 10px;
}
.preplay-person{position:relative;width:78px;height:92px;flex:0 0 auto}
.preplay-head{
    position:absolute;left:21px;top:6px;width:42px;height:44px;border-radius:50%;
    background:#f0bd8f;border:3px solid #70452f;z-index:2
}
.preplay-head:before{
    content:"";position:absolute;left:-3px;top:-7px;width:48px;height:22px;
    background:#6a412e;border:3px solid #4d3024;border-radius:60% 60% 35% 35%
}
.preplay-head:after{
    content:"😊";position:absolute;left:6px;top:10px;font-size:26px
}
.preplay-body{
    position:absolute;left:16px;bottom:0;width:52px;height:48px;border-radius:22px 22px 10px 10px;
    background:#79b8e8;border:3px solid #426d8e
}
.preplay-arm{
    position:absolute;right:4px;top:44px;width:14px;height:38px;border-radius:10px;
    background:#f0bd8f;border:3px solid #70452f;transform-origin:bottom center;
    animation:preplayWaveArm .7s ease-in-out infinite alternate
}
.preplay-hand{
    position:absolute;right:-5px;top:25px;font-size:28px;z-index:3;
    transform-origin:bottom left;animation:preplayWaveHand .55s ease-in-out infinite alternate
}
.preplay-message{
    display:grid;background:#fff;border:3px solid #73512f;border-radius:18px;
    padding:9px 14px;box-shadow:0 4px 0 rgba(93,65,31,.12)
}
.preplay-message strong{font-size:1.55rem;color:#e36b4b;line-height:1}
.preplay-message span{font-size:.92rem;font-weight:900;color:#59452e;margin-top:3px}
@keyframes preplayWaveArm{from{transform:rotate(-14deg)}to{transform:rotate(-46deg)}}
@keyframes preplayWaveHand{from{transform:rotate(-12deg)}to{transform:rotate(18deg)}}

/* v2.0 opening-screen fit fix */
.compact-start{
    max-height:calc(100dvh - 28px);
    overflow:hidden;
    padding-top:12px!important;
    padding-bottom:12px!important;
}
.compact-start .preplay-greeter{margin:0 auto 4px;padding:2px 6px}
.compact-start .preplay-person{width:64px;height:72px}
.compact-start .preplay-head{left:17px;top:4px;width:36px;height:37px}
.compact-start .preplay-head:after{font-size:22px;left:5px;top:8px}
.compact-start .preplay-body{left:13px;width:44px;height:38px}
.compact-start .preplay-arm{top:35px;height:31px}
.compact-start .preplay-hand{top:18px;font-size:24px}
.compact-start .preplay-message{padding:7px 12px}
.compact-start .preplay-message strong{font-size:1.3rem}
.compact-start .preplay-message span{font-size:.82rem}
.compact-start .hero-bee{margin:3px auto 4px!important;transform:scale(.82)}
.compact-start h1{font-size:clamp(2rem,7vw,3.1rem)!important;line-height:.96!important;margin:2px 0 6px!important}
.compact-start p{margin:4px auto!important;font-size:.92rem!important;line-height:1.15!important}
.compact-start .difficulty-row{margin:8px 0 6px!important}
.compact-start .learning-choice{margin:6px auto!important}
.compact-start .music-note{margin:3px 0 0!important}
.compact-start .play-button,
.compact-start .play{
    display:block!important;
    width:min(280px,82%)!important;
    margin:8px auto!important;
    min-height:54px!important;
    font-size:1.15rem!important;
    font-weight:1000!important;
    position:relative!important;
    z-index:20!important;
}
@media (max-height:760px){
    .compact-start{padding-top:6px!important;padding-bottom:6px!important}
    .compact-start .preplay-person{width:54px;height:60px}
    .compact-start .preplay-message{padding:5px 10px}
    .compact-start .hero-bee{transform:scale(.68);margin:-8px auto -6px!important}
    .compact-start h1{font-size:2rem!important}
    .compact-start p{font-size:.78rem!important}
    .compact-start .difficulty-row{margin:4px 0!important}
    .compact-start .learning-choice{margin:3px auto!important}
    .compact-start .music-note{display:none!important}
    .compact-start .play-button,
    .compact-start .play{min-height:48px!important;margin:5px auto!important}
}


/* v2.3 clearer learning target header */
.learning-prompt{
    gap:14px;
    padding:10px 14px;
    align-items:center;
}
.learning-copy{
    flex:1 1 auto;
    min-width:0;
}
.learning-copy strong#targetWord{
    display:block;
    font-size:clamp(1.9rem,5vw,3.2rem);
    line-height:.95;
    letter-spacing:.01em;
    color:#3f2f1e;
    margin-top:2px;
}
.learning-kicker{
    font-size:.72rem;
    letter-spacing:.11em;
}
.learning-copy span:last-child{
    font-size:.88rem;
    margin-top:5px;
}
.target-count-wrap{
    flex:0 0 auto;
    min-width:76px;
    min-height:68px;
    border-radius:18px;
    background:#fff2a8;
    border:3px solid #e3ab1f;
    box-shadow:0 4px 0 rgba(173,118,0,.15);
    display:grid;
    place-items:center;
    align-content:center;
    line-height:.88;
    padding:5px 10px;
}
.target-count-label{
    font-size:.60rem;
    font-weight:1000;
    letter-spacing:.13em;
    color:#8a661d;
}
.target-count-wrap strong{
    display:block;
    font-size:clamp(2.1rem,6vw,3.5rem);
    color:#4e3716;
    font-weight:1000;
}
@media (max-width:700px){
    .learning-prompt{gap:8px;padding:7px 8px}
    .learning-copy strong#targetWord{font-size:clamp(1.65rem,7vw,2.55rem)}
    .target-count-wrap{min-width:60px;min-height:58px;border-radius:14px;padding:4px 7px}
    .target-count-wrap strong{font-size:2.1rem}
    .target-count-label{font-size:.52rem}
}
@media (orientation:landscape) and (max-height:650px){
    .learning-copy strong#targetWord{font-size:1.6rem}
    .target-count-wrap{min-width:50px;min-height:40px;border-width:2px;border-radius:10px}
    .target-count-wrap strong{font-size:1.5rem}
    .target-count-label{display:none}
}


/* v2.4 footer + celebration polish */
.game-footer{
    display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:7px;
    min-height:24px;padding:4px 10px 6px;font-size:.68rem;font-weight:800;
    color:#806b45;text-align:center;
}
.game-footer .footer-sep{opacity:.45}
.game-footer .footer-link{color:#6f5a34;text-decoration:none;border-bottom:1px dotted rgba(111,90,52,.45)}
.game-footer .disabled-link{opacity:.72;cursor:default;pointer-events:none}
#levelOverlay:not(.hidden){background:rgba(255,246,204,.84);backdrop-filter:blur(3px)}
#levelOverlay .overlay-card{animation:celebrationPop .45s cubic-bezier(.2,1.4,.4,1);border:4px solid #fff;box-shadow:0 20px 60px rgba(93,62,11,.25)}
#levelOverlay h2{font-size:clamp(2rem,7vw,3.6rem);margin:.15em 0}
#levelOverlay p{font-size:clamp(1rem,3vw,1.3rem);font-weight:900}
@keyframes celebrationPop{
    0%{transform:scale(.72) rotate(-2deg);opacity:0}
    70%{transform:scale(1.06) rotate(1deg);opacity:1}
    100%{transform:scale(1) rotate(0)}
}
@media (max-height:650px){.game-footer{font-size:.58rem;padding:2px 6px 3px}}
