:root{--red:#e8435a;--deep:#b8233d;--pink:#f7a8b8;--blush:#fde3e8;--cream:#fff7ec;--ink:#5a2330;--line:#f2c6cf;--gold:#ffc94d}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#fbe4e4;color:var(--ink);font-family:"Trebuchet MS","Segoe UI",system-ui,sans-serif;touch-action:none;user-select:none;-webkit-user-select:none}
body{background:#fbe4e4 url(img/bg.webp) center/cover no-repeat}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none}
.hidden{display:none!important}
#app{position:fixed;inset:0;display:flex;flex-direction:column;padding:max(8px,env(safe-area-inset-top)) 10px 8px}
#hud{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;padding:6px;background:rgba(255,247,236,.92);border:2px solid var(--line);border-radius:18px;box-shadow:0 3px 0 #e9b3bd;max-width:1100px;width:100%;margin:0 auto}
.tb{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:42px;height:42px;border-radius:14px;background:#fff;border:2px solid var(--line);box-shadow:0 2px 0 #e9b3bd;color:var(--deep);padding:0 8px}
.tb svg{width:24px;height:24px}
.tb.wide{padding:0 12px;font-weight:700}
.tb.wide em{font-style:normal;font-size:12px;color:#fff;background:var(--red);border-radius:9px;padding:1px 6px}
.tb:active{transform:translateY(2px);box-shadow:none}
#tname{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.1}
#tname b{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--deep)}
#tname small{font-size:12px;opacity:.8}
.pill{display:flex;flex-direction:column;align-items:center;background:var(--blush);border-radius:12px;padding:3px 10px;min-width:58px;line-height:1.1}
.pill small{font-size:11px;opacity:.75}.pill b{font-size:17px}
#teams{display:flex;gap:6px}
.team{display:flex;flex-direction:column;align-items:center;border-radius:12px;padding:3px 10px;background:#fff;border:2px solid var(--line);line-height:1.1;opacity:.6}
.team small{font-size:11px}.team b{font-size:18px}
#teamA.on{background:#ffd9df;border-color:var(--red);opacity:1}
#teamB.on{background:#ffe6f4;border-color:#e46fb0;opacity:1}
#say{display:flex;align-items:center;gap:8px;margin:8px auto 4px;max-width:1100px;width:100%;font-size:15px}
#say img{width:34px;height:34px;object-fit:contain;flex:none}
#say span{background:rgba(255,255,255,.9);border:2px solid var(--line);border-radius:14px;padding:5px 10px}
#playArea{flex:1;min-height:0;display:flex;gap:12px;max-width:1100px;width:100%;margin:0 auto;align-items:stretch}
#boardWrap{flex:1;min-width:0;min-height:0;display:flex;align-items:center;justify-content:center;position:relative}
#board{touch-action:none;display:block;outline:none}
#wlist{list-style:none;margin:0;padding:10px;width:230px;flex:none;display:flex;flex-wrap:wrap;align-content:flex-start;gap:6px;background:rgba(255,247,236,.93);border:2px solid var(--line);border-radius:18px;overflow:auto}
#wlist li{font-weight:700;font-size:16px;letter-spacing:.04em;padding:4px 9px;border-radius:10px;background:#fff;border:2px solid var(--line);transition:all .25s}
#wlist li.f{text-decoration:line-through;text-decoration-thickness:2px;opacity:.55;background:var(--c,#ffd)}
#wlist li.pop{animation:pop .45s}
@keyframes pop{40%{transform:scale(1.25)}}
@media (max-width:760px),(max-aspect-ratio:1/1){
  #playArea{flex-direction:column;gap:6px;justify-content:center}
  #app{padding-bottom:58px}
  #wlist{width:100%;max-height:30%;justify-content:center;padding:6px}
  #wlist li{font-size:14px;padding:3px 7px}
  .pill{min-width:0;padding:3px 7px}
  #say{font-size:13px}
}
@media (max-width:520px){#tname small{display:none}.tb.wide span{display:none}#hud{gap:5px;padding:5px}.pill b{font-size:15px}#tname b{font-size:14px}}
#fx{position:fixed;inset:0;pointer-events:none;z-index:30;width:100%;height:100%}
#tools{position:fixed;right:10px;bottom:max(10px,env(safe-area-inset-bottom));display:flex;gap:6px;z-index:60}
#tools .tb{width:42px;padding:0}
#tools .x{display:none}
#tools .off .x{display:inline}#tools .off .on{display:none}
#toast{position:fixed;left:50%;top:84px;transform:translateX(-50%);background:var(--deep);color:#fff;padding:8px 16px;border-radius:14px;font-weight:700;z-index:70;box-shadow:0 4px 0 #7d1427}
.ov{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(120,30,50,.28);z-index:50;padding:12px}
.card{background:var(--cream);border:3px solid var(--line);border-radius:26px;box-shadow:0 6px 0 #e3a3b0,0 14px 40px rgba(120,30,50,.25);padding:18px;width:min(560px,100%);max-height:100%;text-align:center}
.card.scroll{overflow:auto}
.brand{display:flex;align-items:center;justify-content:center;gap:10px}
.brand img{width:92px;height:92px;object-fit:contain;animation:bob 2.4s ease-in-out infinite}
@keyframes bob{50%{transform:translateY(-6px) rotate(-3deg)}}
h1{margin:0;font-size:30px;line-height:1;color:var(--red);text-shadow:0 2px 0 #fff;text-align:left}
h1 span{display:block;font-size:36px;color:var(--deep)}
.lead{margin:8px 0 12px;font-size:15px;line-height:1.35}
.big{display:block;width:100%;background:var(--red);color:#fff;font-size:26px;font-weight:800;border-radius:20px;padding:12px;box-shadow:0 5px 0 var(--deep);margin:6px 0 12px}
.big small{display:block;font-size:13px;font-weight:600;opacity:.92}
.big:active{transform:translateY(3px);box-shadow:0 2px 0 var(--deep)}
.row2{display:flex;gap:8px;margin-bottom:10px}
.mid{flex:1;display:flex;align-items:center;justify-content:center;gap:8px;background:#fff;border:2px solid var(--line);box-shadow:0 3px 0 #e9b3bd;border-radius:16px;padding:8px;font-weight:700;text-align:left}
.mid svg{width:28px;height:28px;flex:none;color:var(--deep)}
.mid span{display:flex;flex-direction:column;line-height:1.15}
.mid small{font-weight:500;font-size:12px;opacity:.8}
.mid.on{background:#ffe1e7;border-color:var(--red)}
.opt{margin:6px 0 10px;text-align:left}
.opt label{display:flex;justify-content:space-between;font-weight:800;font-size:14px;color:var(--deep);margin-bottom:5px}
.opt label em{font-style:normal;font-weight:600;opacity:.8}
.seg{display:flex;gap:6px}
.seg button{flex:1;padding:8px 4px;border-radius:14px;background:#fff;border:2px solid var(--line);font-weight:700}
.seg button.on{background:var(--red);color:#fff;border-color:var(--deep)}
#puzzles{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:6px}
.pz{position:relative;padding:8px 6px;border-radius:14px;background:#fff;border:2px solid var(--line);font-size:13px;font-weight:700;line-height:1.2;min-height:62px}
.pz i{display:block;font-style:normal;font-size:11px;font-weight:500;opacity:.75}
.pz .st{display:block;color:var(--gold);letter-spacing:1px;font-size:14px;text-shadow:0 1px 0 #b77a00}
.pz.lock{opacity:.5}
.pz.cur{border-color:var(--red);background:#fff0f3}
.touch{font-size:12.5px;opacity:.85;margin:6px 0 0;line-height:1.7}
kbd{display:inline-block;min-width:22px;padding:0 5px;border:2px solid var(--line);border-bottom-width:3px;border-radius:6px;background:#fff;font:700 12px/18px inherit;margin:0 1px}
kbd.w{min-width:54px}
#cheer{width:130px;height:130px;object-fit:contain;margin-top:-50px;animation:bob 1.6s ease-in-out infinite}
h2{margin:4px 0;color:var(--red);font-size:28px}
.bigstars{font-size:46px;letter-spacing:6px;color:#e9cdd3;line-height:1}
.bigstars b{color:var(--gold);text-shadow:0 2px 0 #b77a00;display:inline-block;animation:pop .5s backwards}
.res{font-size:18px;font-weight:700;margin:8px 0 2px}
.bests{font-size:14px;opacity:.8;margin:0 0 6px}
.unlock{font-weight:700;color:var(--deep)}
/* class mode: bigger everything for a projector or smart board */
body.classmode #wlist li{font-size:22px;padding:6px 12px}
body.classmode #wlist{width:300px}
body.classmode #say{font-size:18px}
body.classmode #tname b{font-size:22px}
body.classmode .pill b{font-size:22px}
@media (max-width:760px),(max-aspect-ratio:1/1){body.classmode #wlist{width:100%}body.classmode #wlist li{font-size:18px}}
/* embed-fit: short frames (store page small window 794x447 / 640x360, phone landscape) */
@media (max-height:560px) and (min-aspect-ratio:5/4){
  .ov{padding:8px 60px 8px 8px}
  #tools{flex-direction:column;right:8px;bottom:8px}
  .card{padding:12px 14px;border-radius:20px}
  .card.mcard{width:min(860px,100%);display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);column-gap:16px;align-items:start;overflow:hidden;display:grid}
  .mcl{align-self:center}
  .mcr{display:flex;flex-direction:column;min-height:0;max-height:calc(100vh - 44px)}
  .mcr .opt:last-of-type{min-height:0;display:flex;flex-direction:column}
  #puzzles{overflow-y:auto;min-height:0;padding:2px 2px 4px;grid-template-columns:repeat(auto-fill,minmax(98px,1fr))}
  .brand img{width:64px;height:64px}
  h1{font-size:24px}h1 span{font-size:29px}
  .lead{font-size:13px;margin:6px 0 8px;line-height:1.3}
  .big{font-size:22px;padding:8px;margin:4px 0 8px;border-radius:16px;box-shadow:0 4px 0 var(--deep)}
  .big small{font-size:12px}
  .row2{margin-bottom:4px}
  .mid{padding:6px;font-size:14px}.mid svg{width:24px;height:24px}.mid small{font-size:11px}
  .opt{margin:2px 0 8px}.opt label{font-size:13px;margin-bottom:4px}
  .seg button{padding:6px 4px;font-size:14px}
  .pz{min-height:50px;padding:5px 4px;font-size:12px}.pz i{font-size:10px}.pz .st{font-size:12px}
  .touch{font-size:11.5px;margin:2px 0 0;line-height:1.55}
  #over .card{width:min(500px,100%)}
  #cheer{width:84px;height:84px;margin-top:-10px}
  h2{font-size:24px;margin:2px 0}.bigstars{font-size:36px}.res{font-size:16px;margin:4px 0 2px}.bests{font-size:13px;margin:0 0 4px}.unlock{margin:4px 0}
  /* play screen: keep the word list beside the grid (not under it) so the grid stays big */
  #app{padding:6px 60px 6px 8px}
  #playArea{flex-direction:row;gap:8px;justify-content:stretch}
  #wlist{width:190px;max-height:none;padding:6px;justify-content:flex-start;gap:5px}
  #wlist li{font-size:14px;padding:3px 7px}
  #hud{padding:4px 6px;gap:6px;border-radius:14px}
  .tb{height:36px;min-width:36px;border-radius:12px}.tb svg{width:21px;height:21px}
  #tools .tb{width:40px;height:40px}
  .pill{padding:2px 8px;min-width:0}.pill b{font-size:15px}.pill small{font-size:10px}
  #tname b{font-size:15px}#tname small{font-size:11px}
  #say{margin:5px auto 4px;font-size:13px}#say img{width:26px;height:26px}#say span{padding:3px 8px;border-radius:12px}
  body.classmode #wlist{width:220px}body.classmode #wlist li{font-size:17px;padding:4px 9px}
  body.classmode #tname b,body.classmode .pill b{font-size:17px}body.classmode #say{font-size:14px}
}
@media (max-height:420px) and (min-aspect-ratio:5/4){
  .brand img{width:48px;height:48px}h1{font-size:21px}h1 span{font-size:25px}
  .lead{font-size:12px;margin:4px 0 6px}
  .touch{display:none}
  #wlist{width:160px}#wlist li{font-size:13px;padding:2px 6px}
  #say{font-size:12px;margin:4px auto 3px}#say img{display:none}
  .team{padding:1px 8px}.team b{font-size:15px}
}
@media (max-height:560px) and (min-aspect-ratio:5/4) and (max-width:760px){
  #tname small{display:none}.tb.wide{padding:0 8px}.tb.wide span{display:none}
  #hud{gap:5px}.team{padding:1px 7px}.team small{font-size:10px}
  body.classmode #wlist{width:175px}body.classmode #wlist li{font-size:15px;padding:3px 8px}
}
