:root{font-family:system-ui,-apple-system,Segoe UI,sans-serif;color:#171321;background:#f6f4f8}*{box-sizing:border-box}body{margin:0}header{position:sticky;top:0;z-index:5;background:#4e086d;color:white;display:flex;align-items:center;justify-content:space-between;padding:12px max(14px,calc((100vw - 920px)/2));font-weight:900;letter-spacing:.06em}button,input,select,textarea{font:inherit}button{cursor:pointer;border:0;border-radius:12px;background:#0caaa7;color:#061c20;padding:12px 16px;font-weight:800;min-height:44px}button:hover{filter:brightness(.94)}button:disabled{opacity:.48;cursor:not-allowed}.quiet{background:transparent;color:inherit;padding:8px}.purple{background:#5b117d;color:white}.danger{background:#a62d46;color:white}.outline{background:white;color:#491068;border:2px solid #6e2888}.muted{color:#625c6c}.small{font-size:.87rem}main{max-width:920px;margin:0 auto;padding:20px 14px 45px;min-height:76vh}.panel{background:white;border-radius:20px;padding:22px;margin:15px 0;box-shadow:0 4px 16px #28093a12}.hero{position:relative;overflow:hidden;text-align:center;background:#e8e8eb;border-radius:20px;padding:22px 12px 28px}.hero img{display:block;position:relative;z-index:1;max-width:min(410px,88%);max-height:235px;object-fit:contain;margin:auto}.hero h1,.hero p{position:relative;z-index:1;margin:8px 0}.hero h1{color:#490b6b;font-size:clamp(1.9rem,6vw,3rem)}.hero p{font-weight:800}.star{position:absolute;animation:twinkle 2.3s infinite alternate;font-size:clamp(17px,3vw,33px)}@keyframes twinkle{from{opacity:.3;transform:scale(.7) rotate(-15deg)}to{opacity:1;transform:scale(1.3) rotate(15deg)}}h1,h2{line-height:1.2}h2{color:#4e086d}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:13px}.tile{background:white;border-radius:18px;padding:20px;border:2px solid #e5deea}.tile button,.full{width:100%}.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.between{justify-content:space-between}.stack{display:grid;gap:12px}.field{display:grid;gap:5px;font-weight:700}input,select,textarea{width:100%;border:2px solid #c8bfd0;border-radius:10px;padding:11px;background:white;color:#171321}textarea{min-height:84px;resize:vertical}input:focus,textarea:focus,select:focus{outline:3px solid #7fd9d4}.wordrow{display:grid;grid-template-columns:1fr 2fr;gap:10px;margin:12px 0}.pill{display:inline-block;border-radius:30px;background:#e4d7ee;color:#490b6b;padding:6px 12px;font-size:.82rem;font-weight:800}.card{border:3px solid #16aaa7;border-radius:22px;min-height:220px;display:grid;place-content:center;text-align:center;padding:30px;background:#f0ffff;cursor:pointer;font-size:clamp(1.3rem,4vw,2rem);font-weight:800;overflow-wrap:anywhere}.choice{display:block;width:100%;text-align:left;margin:8px 0;background:#f2eaf7;color:#26102e;border:2px solid transparent}.choice.selected{border-color:#0caaa7;background:#d5f8f5}.feedback{border-radius:12px;padding:12px;background:#e8f8ef;margin:10px 0}.bad{background:#ffe5e8}.bar{height:11px;background:#eee;border-radius:20px;overflow:hidden}.bar div{height:100%;background:#0caaa7}footer{text-align:center;padding:18px;color:#61576b}footer button{margin:4px}.note{border-left:4px solid #0caaa7;padding:10px;background:#effafa}.hidden{display:none!important}@media(max-width:500px){.wordrow{grid-template-columns:1fr}.panel{padding:16px}header{font-size:.84rem}}
#toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#281033;color:white;padding:13px 20px;border-radius:12px;opacity:0;pointer-events:none;transition:opacity .2s;z-index:20;max-width:90vw}label:has(input[type=checkbox]){display:flex;align-items:center;gap:10px}input[type=checkbox]{width:auto}

.header-actions{display:flex;align-items:center;gap:4px}.pin-input{-webkit-text-security:disc} .hero img{background:#e8e8eb;border-radius:18px;padding:12px;max-width:min(78vw,330px)} .hero{background:#e8e8eb!important;color:#3d075c!important}.hero h1,.hero p{color:#3d075c!important}#mute{font-size:1.3rem} .note[role=status]{font-weight:800;border-left:5px solid #08aaa9;margin:14px 0;padding:12px;background:#effcfc} 

.hero h1,.hero p{color:#000!important}#mute{display:inline-flex;align-items:center;justify-content:center;color:#fff}#mute svg{display:block}

.creator-credit{font-size:.85rem;margin-top:14px;color:#61576b}

.sound-wrap{position:relative}.sound-menu{position:absolute;right:0;top:100%;background:white;color:#25112f;border:1px solid #ddd;border-radius:12px;box-shadow:0 6px 20px #0002;z-index:100;padding:15px;width:230px}.sound-menu[hidden]{display:none}.sound-menu label{display:block;margin-top:13px;font-size:14px}.coin-counter{display:flex;align-items:center;gap:5px;color:white;font-size:17px}.coin-counter[hidden]{display:none}.coin-counter img{width:30px;height:30px;border-radius:50%}.coin-overlay{position:fixed;inset:0;display:grid;place-items:center;background:#0009;z-index:1000;animation:coinFade .3s ease}.coin-party{background:#fff8d8;padding:35px;border-radius:25px;text-align:center;color:#8e5c00;box-shadow:0 0 80px #ffc93c}.coin-party img{width:min(50vw,220px);border-radius:50%;animation:coinPop 1.1s ease-in-out infinite alternate}.coin-party h1{font-size:clamp(30px,7vw,60px);margin:10px}@keyframes coinPop{from{transform:scale(.8) rotate(-12deg)}to{transform:scale(1.13) rotate(12deg)}}@keyframes coinFade{from{opacity:0}to{opacity:1}}

/* V6: Word Reveal tiles, teacher history and reward modal. */
.reveal-board{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px;background:#184b4d;border-radius:16px;padding:22px 10px;margin:18px 0}
.letter-tile{background:#1c9699;color:white;border:3px solid white;border-radius:4px;width:clamp(29px,7vw,49px);height:clamp(43px,10vw,60px);font-size:clamp(20px,5vw,30px);padding:0;transition:transform .25s,background .25s}
.letter-tile.shown{background:#fdfdfd;color:#171321;transform:rotateY(360deg);opacity:1}
.letter-tile:disabled:not(.shown){opacity:.8}.tile-space{width:17px}.tile-symbol{color:white;font-size:25px;min-width:18px;text-align:center}
.coin-trigger{background:transparent;color:white;padding:3px 5px;display:flex;align-items:center;gap:5px}
.coin-info{position:relative;max-width:min(420px,90vw);background:white;color:#241530}.coin-info img{width:85px;animation:none}.coin-info p{line-height:1.5}
.close-dialog{position:absolute;right:8px;top:8px;border-radius:50%;background:white;color:#341044;font-size:23px;padding:5px 12px}
#reward-display{max-width:450px;margin:auto}#reward-display button{margin:6px}
.history-panel{width:100%;padding-top:10px}.history-panel[hidden]{display:none}.history-session{padding:12px;margin:7px 0;background:#f3f0f7;border-radius:10px}.history-session p{margin:5px 0}

/* V7: Word Search board, swipe selection and admin sound preview. */
.word-search-scroll{max-width:100%;overflow:auto;border-radius:14px;background:#174d51;padding:10px;margin:15px 0;-webkit-overflow-scrolling:touch}
.word-search-board{position:relative;display:grid;grid-template-columns:repeat(var(--ws-size),29px);width:max-content;touch-action:none;user-select:none;-webkit-user-select:none;gap:1px}
.ws-cell{display:grid;place-items:center;width:29px;height:29px;background:#fff;color:#192b30;font-size:16px;font-weight:800;border:2px solid transparent;border-radius:3px}
.ws-cell.ws-select{background:#92e6df;border-color:#087d79}.ws-cell.ws-found{background:#d0f8f4;border:3px solid #079d96;color:#005c59}
.word-search-bank{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 23px}.ws-bank-word{padding:8px 12px;border:1px solid #b9a9c9;border-radius:10px;font-weight:700}.ws-bank-word.ws-done{background:#d1f6ee;border-color:#079d96;text-decoration:line-through;color:#12665e}
.sound-preview-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.sound-preview-list button{width:auto;min-height:36px;padding:8px 12px;font-size:13px}

.ws-outline{position:absolute;inset:0;pointer-events:none;overflow:visible;z-index:2}

/* V8: centered word-search board and directly-below answer bank. */
.word-search-scroll{max-width:100%;overflow-x:auto;overflow-y:hidden;display:block;text-align:center}
.word-search-board{margin-left:auto;margin-right:auto;text-align:initial}
.word-search-bank{justify-content:center;margin-top:8px}
/* Put the teacher's bonus control immediately below the history control. */
.student-actions{display:flex;flex-direction:column;align-items:stretch;gap:5px;min-width:min(245px,100%)}
.student-actions button{width:100%;min-height:42px}
.reward-button{background:#e9b53d;color:#362407;border:2px solid #b98919}
.reward-button:disabled{background:#e8e4dc;color:#655e4e}
.teacher-reward-history{border-left:5px solid #c69525;background:#fff6d9}
.special-reward{max-width:min(490px,94vw);animation:coinFade .3s ease}
.special-reward h2{color:#9a6600}.special-reward p{line-height:1.5;color:#60451d}
@media(max-width:600px){.student-actions{width:100%}.special-reward{padding:20px}}

/* V9: No horizontal scrolling; boards scale to each device's available content width. */
.panel{min-width:0} .word-search-scroll{overflow:visible;max-width:100%;padding:clamp(3px,1.5vw,10px);background:#174d51}
.word-search-board{display:grid;grid-template-columns:repeat(var(--ws-size),minmax(0,1fr));gap:0;width:min(100%,calc(var(--ws-size) * 34px));max-width:100%;min-width:0;margin:0 auto;touch-action:none}
.ws-cell{width:auto;height:auto;min-width:0;min-height:0;aspect-ratio:1;font-size:clamp(8px,2.7vw,16px);border-width:1px;border-radius:2px;padding:0}
.ws-cell.ws-found{border-width:2px}
.ws-outline{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:2}
.word-search-bank{justify-content:center}
.tiny-gold-coin{height:22px;width:22px;object-fit:cover;border-radius:50%;vertical-align:middle;display:inline-block;flex:0 0 auto}
.reward-button{display:flex;align-items:center;justify-content:center;gap:7px}
.crossword-wrap{background:#174d51;border-radius:12px;padding:clamp(3px,1.4vw,12px);max-width:100%;min-width:0}
.crossword-board{display:grid;grid-template-columns:repeat(var(--cw-cols),minmax(0,1fr));gap:1px;width:min(100%,calc(var(--cw-cols) * 38px));max-width:100%;margin:0 auto;touch-action:manipulation}
.cw-cell,.cw-blank{position:relative;display:grid;place-items:center;min-height:0;min-width:0;aspect-ratio:1;border-radius:0;padding:0;line-height:1}
.cw-cell{background:white;color:#243134;border:1px solid #9eb3b5;font-size:clamp(9px,2.5vw,19px);font-weight:900}
.cw-cell.cw-active{background:#c5f3ef;border-color:#078c8b}.cw-cell.cw-solved{color:#084b4c}
.cw-blank{background:transparent}
.cw-number{position:absolute;top:1px;left:2px;font-size:clamp(5px,1vw,9px);font-weight:900;line-height:1}
.cw-entry{margin-top:14px;padding:14px;border-radius:12px;background:#edf9f8}.cw-entry input{margin:7px 0 10px}
.cw-clues{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:12px;margin:14px 0}
.cw-clue{display:block;width:100%;text-align:left;margin:5px 0;padding:10px;background:#f4f1f7;color:#24202b;font-weight:500;overflow-wrap:anywhere}
.cw-clue.cw-current{background:#c5f3ef;outline:2px solid #0caaa7}
@media(max-width:500px){main{padding:9px 8px 35px}.panel{padding:10px}.word-search-scroll{margin:10px 0}.crossword-wrap{padding:3px}.cw-clues{grid-template-columns:minmax(0,1fr)}}

/* V10 stage 1: teacher sections and livelier three-color banner stars. */
.teacher-section{margin:14px 0;border:2px solid #d8c8e2;border-radius:16px;background:#fff;overflow:hidden}
.teacher-section>summary{display:list-item;cursor:pointer;padding:16px 18px;color:#4e086d;font-size:1.08rem;font-weight:800;background:#f3ebf9}
.teacher-section>summary:focus-visible{outline:3px solid #0caaa7;outline-offset:-3px}
.teacher-section-body{padding:16px;display:grid;gap:12px;min-width:0}
.hero .star{animation-duration:1.25s}

/* V10 Word Scramble: readable, responsive lettering without sideways scrolling. */
.scramble-letters{margin:15px 0;padding:18px 10px;background:#164b4f;color:#fff;border-radius:14px;text-align:center;font-size:clamp(1.2rem,5vw,2rem);font-weight:900;letter-spacing:.14em;overflow-wrap:anywhere;white-space:pre-wrap}

/* V10 stage 3: private class leaderboards. */
.leaderboard-card{border:2px solid #d7c4e4;border-radius:16px;padding:clamp(10px,3vw,20px);margin:16px 0;min-width:0}
.leaderboard-rows{display:grid;gap:6px}
.leaderboard-entry{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;padding:10px;border-radius:10px;background:#f6f0f9}
.leaderboard-entry strong{overflow-wrap:anywhere}
.leaderboard-entry span{white-space:nowrap;display:inline-flex;align-items:center;gap:6px;font-weight:900;color:#69420a}
.leaderboard-me{border:2px solid #0caaa7;background:#e6faf7}

/* V10 stage 17: unavoidable incoming duel invitation without changing game DOM. */
.duel-invite-overlay{position:fixed;inset:0;z-index:10000;background:rgba(19,13,31,.72);display:grid;place-items:center;padding:16px}
.duel-invite-dialog{width:min(100%,440px);max-height:90dvh;overflow:auto;background:#fff;color:#24202b;border:3px solid #d4a23c;border-radius:18px;padding:clamp(18px,5vw,30px);box-shadow:0 18px 65px #110b2299;text-align:center}
.duel-invite-dialog h2{color:#580b76;margin-top:0}.duel-invite-actions{display:flex;gap:12px;justify-content:center;flex-wrap:wrap}.duel-invite-actions button{min-width:125px}
.duel-declined-notice{position:fixed;z-index:10001;left:50%;bottom:24px;transform:translateX(-50%);width:min(460px,calc(100vw - 28px));background:#fff5d6;border:2px solid #d4a23c;box-shadow:0 9px 30px #110b2240;border-radius:12px;padding:12px;display:flex;justify-content:space-between;align-items:center;gap:10px}


/* V10 RC2: make the live Bonus Challenge unmistakably special. */
.bonus-preview{position:relative;overflow:hidden;border:4px solid #d4a23c!important;background:linear-gradient(135deg,#fffdf2,#fff4bd);box-shadow:0 0 0 2px #fff inset,0 7px 24px #d4a23c55;animation:bonusGlow 1.8s ease-in-out infinite alternate}
.bonus-preview::before,.bonus-preview::after{content:"✦";position:absolute;color:#d4a23c;font-size:28px;animation:bonusSpark 1.2s ease-in-out infinite alternate;pointer-events:none}.bonus-preview::before{right:16px;top:8px}.bonus-preview::after{left:14px;bottom:8px;animation-delay:.45s}
.bonus-preview h2{color:#855500}.bonus-preview button{box-shadow:0 3px 0 #8f6712}
@keyframes bonusGlow{from{box-shadow:0 0 0 2px #fff inset,0 5px 18px #d4a23c44}to{box-shadow:0 0 0 2px #fff inset,0 8px 32px #d4a23c99}}
@keyframes bonusSpark{from{opacity:.35;transform:scale(.75) rotate(-12deg)}to{opacity:1;transform:scale(1.25) rotate(12deg)}}
