@font-face{font-family:"Baloo 2";font-style:normal;font-weight:400 800;font-display:swap;src:url(../fonts/baloo2-latin-ext.woff2) format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Baloo 2";font-style:normal;font-weight:400 800;font-display:swap;src:url(../fonts/baloo2-latin.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
/* VOICE: cheerful, encouraging, for two girls of 8 and 10
   IDEA: a piano music stand: sheet of paper above, keys below
   PICTURE: big staff with clef and one note; real keyboard to answer
   COLOUR and TYPE: piano black + white paper, raspberry accent, sunny yellow stars; Baloo 2
   LAYOUT: one column: players, settings, staff, keys, score; stacks the same on phone */
:root{color-scheme:light dark;--bg:#f3f0fa;--ink:#1d1a26;--soft:#6b6580;--card:#fff;--line:#e2ddef;--acc:#e8336d;--acc2:#ffc531;--ok:#1fa463;--bad:#e8336d;--piano:#16131c}
@media(prefers-color-scheme:dark){:root{--bg:#16131f;--ink:#f4f1fb;--soft:#b6afc8;--card:#221e2e;--line:#3a344a}}
*{box-sizing:border-box;min-width:0}
html,body{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;-webkit-text-size-adjust:100%;overscroll-behavior:none}
body{margin:0;background:var(--bg);color:var(--ink);font:17px/1.45 "Baloo 2",system-ui,sans-serif;overflow-x:clip}
.wrap{max-width:640px;margin:0 auto;padding:calc(16px + env(safe-area-inset-top)) max(4vw,12px,env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(4vw,12px,env(safe-area-inset-left))}
h1{font-size:clamp(30px,7vw,42px);line-height:1.05;margin:4px 0 2px;font-weight:800}
h1 span{color:var(--acc)}
.sub{color:var(--soft);margin:0 0 14px;font-size:16px}
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:10px}
.lbl{font-size:14px;color:var(--soft);width:100%;margin-bottom:-4px}
button{font:inherit;cursor:pointer;color:inherit;touch-action:manipulation}
.chip{min-height:44px;padding:6px 16px;border-radius:999px;border:2px solid var(--line);background:var(--card);font-weight:700;font-size:16px}
.chip[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.chip:focus-visible,.key:focus-visible,.big:focus-visible{outline:3px solid var(--acc2);outline-offset:2px}
.pl{display:inline-flex;align-items:center;gap:6px}
.pl input{font:inherit;font-size:16px;font-weight:700;border:0;background:transparent;color:inherit;width:6.2em;padding:0;-webkit-user-select:text;user-select:text}
.pl input:focus{outline:none;text-decoration:underline}
.stage{position:relative;background:#fff;border-radius:22px;box-shadow:0 10px 30px -12px rgba(40,20,80,.35);padding:10px 10px 4px;margin-top:6px}
.stage svg{display:block;width:100%;height:auto}
.hud{display:flex;justify-content:space-between;gap:8px;color:#4a4560;font-size:15px;padding:0 8px 4px;font-weight:700}
.hud b{color:#1d1a26}
.bar{height:8px;background:#ece8f6;border-radius:9px;margin:0 8px 8px;overflow:hidden}
.bar i{display:block;height:100%;width:0;background:var(--acc);border-radius:9px;transition:width .3s}
.msg{min-height:34px;text-align:center;font-weight:800;font-size:20px;margin:8px 0 4px}
.msg.ok{color:var(--ok)}.msg.bad{color:var(--bad)}
.kb{position:relative;display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;background:var(--piano);padding:10px 8px 8px;border-radius:16px 16px 20px 20px;height:min(46vw,210px);touch-action:none}
.key small{display:block;font-size:12px;font-weight:700;color:#7a7390;line-height:1}
.key{position:relative;border:0;border-radius:0 0 10px 10px;background:linear-gradient(#fff 70%,#ebe7f3);display:flex;flex-direction:column;align-items:center;justify-content:flex-end;line-height:1.15;padding-bottom:8px;font-weight:800;font-size:clamp(15px,4vw,20px);color:#1d1a26;box-shadow:inset 0 -6px 0 #d8d2e6}
.key:active,.key.down{transform:translateY(2px);box-shadow:inset 0 -2px 0 #d8d2e6}
.key.good{background:#c9f3dc}.key.wrong{background:#ffd0de}.key.show{background:#c9f3dc;animation:pulse .5s 2}
.blk{position:absolute;top:10px;width:calc((100% - 16px)/7*.56);height:58%;background:linear-gradient(#3a3546,#121016);border:0;padding:0;border-radius:0 0 6px 6px;transform:translateX(-50%);z-index:1;box-shadow:inset 0 -4px 0 #000}
.blk:active{filter:brightness(1.5)}.blk.good,.blk.show{background:#1fa463}.blk.wrong{background:#e8336d}.blk.show{animation:pulse .5s 2}.blk:focus-visible{outline:3px solid var(--acc2)}
.foot{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between;margin-top:12px}
.big{min-height:48px;padding:8px 22px;border-radius:14px;border:0;background:var(--acc);color:#fff;font-weight:800;font-size:18px}
.ghost{background:var(--card);color:var(--ink);border:2px solid var(--line)}
.end{position:absolute;inset:0;background:rgba(255,255,255,.96);border-radius:22px;display:none;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:#1d1a26;padding:12px}
.end.on{display:flex}
.end h2{margin:0;font-size:30px;line-height:1.1}
.stars{font-size:44px;letter-spacing:4px;color:#ddd;line-height:1.1}.stars .y{color:var(--acc2)}
.end p{margin:4px 0}
.note{font-size:13px;color:var(--soft);margin-top:14px}
.shake{animation:sh .35s}
@keyframes sh{25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
@keyframes pulse{50%{filter:brightness(.88)}}
.duel{position:fixed;inset:0;background:var(--bg);display:flex;flex-direction:column;z-index:10;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
body:has(.duel:not([hidden])){overflow:hidden}
.half{position:relative;flex:1;display:flex;flex-direction:column;gap:6px;padding:8px max(2vw,8px);min-height:0}
.half.top{transform:rotate(180deg)}
.dhead{display:flex;justify-content:space-between;align-items:center;font-weight:800;font-size:18px;gap:8px}
.dhead b{font-size:26px;color:var(--acc);line-height:1}
.dmsg{font-size:16px;color:var(--soft);text-align:center;flex:1}
.dmsg.ok{color:var(--ok)}.dmsg.bad{color:var(--bad)}
.dstage{flex:1;min-height:70px;background:#fff;border-radius:16px;display:flex;align-items:center;justify-content:center;overflow:hidden}
.dstage svg{width:100%;height:100%;max-height:100%}
.half .kb{height:auto;flex:0 0 40%;min-height:110px;padding-top:6px}
.half .blk{top:6px}
.mid{display:flex;justify-content:center;align-items:center;gap:10px;padding:2px 8px;font-size:14px;color:var(--soft)}
.mid button{min-height:40px;padding:4px 14px;border-radius:999px;border:2px solid var(--line);background:var(--card);font-weight:800}
.dend{position:absolute;inset:0;display:none;flex-direction:column;align-items:center;justify-content:center;background:rgba(255,255,255,.95);color:#1d1a26;text-align:center;border-radius:16px;z-index:2}
.dend.on{display:flex}.dend h2{margin:0;font-size:clamp(24px,6vw,34px)}.dend p{margin:4px 0 10px}
@media(prefers-reduced-motion:reduce){.shake,.key.show{animation:none}.bar i{transition:none}}
[hidden]{display:none!important}
.topbar{display:flex;justify-content:space-between;align-items:center;gap:8px}
.iconbtn{min-width:44px;min-height:44px;border-radius:999px;border:2px solid var(--line);background:var(--card);font-size:20px;line-height:1}
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:12px;margin:12px 0}
.card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:16px 8px;min-height:150px;border-radius:20px;border:2px solid var(--line);background:var(--card);font-weight:800;font-size:18px}
.card .av{font-size:56px;line-height:1.1}
.card .sm{font-size:14px;color:var(--soft);font-weight:700}
.card.add{border-style:dashed;color:var(--soft)}
.card[aria-pressed=true]{border-color:var(--acc);box-shadow:inset 0 0 0 2px var(--acc)}
.card .badge{position:absolute;top:8px;right:10px;min-width:26px;height:26px;border-radius:13px;background:var(--acc);color:#fff;font-size:15px;line-height:26px}
.wide{width:100%;margin:4px 0 12px}
.dark{background:var(--ink);color:var(--bg)}
.field{display:block;margin:12px 0;font-weight:700;color:var(--soft)}
.field input{display:block;width:100%;margin-top:4px;font:inherit;font-size:22px;font-weight:700;padding:10px 14px;border-radius:14px;border:2px solid var(--line);background:var(--card);color:var(--ink);-webkit-user-select:text;user-select:text}
.avatars{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;margin:8px 0 16px}
.avatars button{font-size:32px;aspect-ratio:1;border-radius:16px;border:2px solid var(--line);background:var(--card);padding:0}
.avatars button[aria-pressed=true]{border-color:var(--acc);background:rgba(232,51,109,.14)}
.ghead{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px}
.who{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:4px 14px 4px 6px;border-radius:999px;border:2px solid var(--line);background:var(--card);font-weight:800;font-size:17px}
.who .av{font-size:28px;line-height:1}
.who .sw{font-size:13px;color:var(--soft);font-weight:700}
.tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:10px 0}
.tile{background:var(--card);border:2px solid var(--line);border-radius:16px;padding:10px 4px;text-align:center}
.tile b{display:block;font-size:26px;line-height:1.15}
.tile span{font-size:13px;color:var(--soft)}
table.rec{width:100%;border-collapse:collapse;background:var(--card);border-radius:14px;overflow:hidden;font-size:14px}
.rec th,.rec td{padding:6px 4px;text-align:center;border-bottom:1px solid var(--line)}
.rec th:first-child,.rec td:first-child{text-align:left;padding-left:10px}
.rec small{display:block;color:var(--soft);font-size:11px}
.weak{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
.weak figure{margin:0;background:#fff;border-radius:14px;padding:4px;text-align:center;color:#1d1a26}
.weak svg{display:block;width:100%;height:auto}
.weak figcaption{font-size:13px;font-weight:700}
.gate{text-align:center}
.gate .q{font-size:40px;font-weight:800;margin:12px 0 4px}
.gate .ans{font-size:32px;font-weight:800;min-height:48px;letter-spacing:4px}
.keypad{display:grid;grid-template-columns:repeat(3,72px);gap:8px;justify-content:center;margin:12px 0}
.keypad button{height:60px;border-radius:14px;border:2px solid var(--line);background:var(--card);font-size:24px;font-weight:800}
.prow{display:flex;align-items:center;gap:8px;padding:8px 0;border-bottom:1px solid var(--line)}
.prow .av{font-size:28px}
.prow .nm{flex:1;font-weight:800}
.small{min-height:40px;padding:4px 14px;font-size:15px}
.danger{background:var(--bad);color:#fff;border-color:var(--bad)}
h2{margin:6px 0;font-size:26px;line-height:1.15}
h3{margin:18px 0 6px;font-size:18px}
.muted{color:var(--soft)}
/* Tablets and big windows */
@media (min-width:700px){
  body{font-size:19px}
  .wrap{max-width:880px}
  .kb{height:min(30vw,300px)}
  .key{font-size:clamp(18px,2.6vw,26px)}
  .key small{font-size:14px}
  .cards{grid-template-columns:repeat(auto-fill,minmax(170px,1fr))}
  .card .av{font-size:68px}
  .avatars{gap:12px}
  .avatars button{font-size:clamp(32px,5.2vw,64px)}
  .field input{font-size:26px}
}
/* Duel on a wide window: keep the staff readable and the keyboard reachable */
@media (min-width:900px){
  .half{padding:8px max(4vw,16px)}
  .half .kb{flex-basis:44%}
}

/* Game screen: always exactly one screen tall, never scrolls; the staff takes what is left */
section.game{display:flex;flex-direction:column;height:100vh;height:100dvh;overflow:hidden;
  padding-top:calc(8px + env(safe-area-inset-top));padding-bottom:calc(8px + env(safe-area-inset-bottom))}
.game .gside{flex:none}
.game .gplay{flex:1;min-height:0;display:flex;flex-direction:column}
.game .ghead{margin-bottom:8px}
.game .row{margin-bottom:6px;gap:6px}
.game .chip{min-height:38px;padding:4px 12px;font-size:15px}
.game .stage{flex:1;min-height:0;display:flex;flex-direction:column;margin-top:2px}
.game #staff{flex:1;min-height:0;width:100%;height:100%;max-height:none}
.game .msg{flex:none;min-height:28px;line-height:28px;margin:4px 0;font-size:18px}
.game .kb{flex:none;height:clamp(120px,25vh,300px)}
#whoName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.menuwrap{position:relative}
.menu{position:absolute;right:0;top:calc(100% + 6px);z-index:20;min-width:220px;display:flex;flex-direction:column;background:var(--card);border:2px solid var(--line);border-radius:16px;padding:6px;box-shadow:0 12px 30px -10px rgba(20,10,40,.45)}
.menu button{border:0;background:none;text-align:left;font-weight:700;font-size:17px;padding:10px 12px;border-radius:10px;min-height:44px}
.menu button:active{background:var(--line)}
.help{position:fixed;inset:0;z-index:30;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(20,16,30,.55)}
.helpbox{background:var(--card);color:var(--ink);border-radius:20px;padding:18px;max-width:560px;max-height:85vh;overflow:auto}
.helpbox p{font-size:16px}
.game .ghead{gap:6px}
.game .who{flex:0 1 auto;min-width:0}
.modebtn{min-height:44px;padding:4px 12px;border-radius:999px;border:2px solid var(--line);background:var(--card);font-weight:800;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.ghead .menuwrap:first-of-type{flex:0 1 auto;min-width:0;margin-left:auto}
.modes{min-width:260px;padding:10px 12px;gap:2px}
.modes .lbl{margin:4px 0 2px;width:auto}
.modes .row{margin-bottom:6px}
@media (max-width:480px){.game .who .sw{display:none}}
@media (min-width:900px) and (min-aspect-ratio:5/4){.game .kb{height:clamp(140px,30vh,300px)}}
/* popovers span the header so their chips never wrap awkwardly */
.game .ghead{position:relative}
.game .ghead .menuwrap{position:static}
.game .modes{left:0;right:0;min-width:0}
/* the staff is width-bound on phones: give the spare height to the keys */
.game .kb{height:clamp(140px,34vh,360px)}
@media (min-aspect-ratio:5/4){.game .kb{height:clamp(140px,32vh,320px)}}
.replay{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);min-height:44px;padding:6px 18px;border-radius:999px;border:0;background:#5b4bd6;color:#fff;font-weight:800;font-size:16px;box-shadow:0 6px 16px -8px rgba(40,20,120,.6)}
