*{box-sizing:border-box}
html,body{margin:0;padding:0;overflow-x:hidden;-webkit-text-size-adjust:100%;overscroll-behavior-x:none}
body{
  font-family:"PingFang HK","Noto Sans CJK HK","Noto Sans HK","Hiragino Sans GB",system-ui,sans-serif;
  background:#f3faf5;color:#222;
  padding-bottom:env(safe-area-inset-bottom);
}
button,input{font-family:inherit}
.em{font-family:"Apple Color Emoji","Noto Color Emoji","Segoe UI Emoji",sans-serif}

/* ----- Gate ----- */
#gate{position:fixed;inset:0;z-index:9999;background:linear-gradient(160deg,#e8f7ee,#fff4e0);display:flex;align-items:center;justify-content:center;padding:24px}
body.unlocked #gate{display:none}
body:not(.unlocked)>*:not(#gate){display:none!important}
.gate-box{background:#fff;border-radius:22px;box-shadow:0 8px 28px rgba(0,0,0,.1);padding:32px 24px;width:100%;max-width:360px;text-align:center}
.gate-box h1{margin:0 0 6px;font-size:24px;color:#1a7a4c}
.gate-box>p{margin:0 0 16px;font-size:17px;color:#555}
#gatePw,#ansPin{width:100%;font-size:28px;letter-spacing:.35em;text-align:center;padding:12px;border:2px solid #b7e0c6;border-radius:12px;margin-bottom:14px;outline:none}
#gatePw:focus,#ansPin:focus{border-color:#1a7a4c}
#gateGo,.pin-go{width:100%;font-size:20px;padding:14px;border:0;border-radius:12px;background:#1a7a4c;color:#fff;min-height:52px;font-weight:700}
.gate-msg{color:#c0392b;margin:12px 0 0;font-size:16px;display:none}
.gate-msg.show{display:block}

/* ----- Header / footer ----- */
header{
  background:linear-gradient(90deg,#1a7a4c,#2a9d5c);
  color:#fff;padding:10px 12px 8px;
  padding-top:max(10px,env(safe-area-inset-top));
  position:sticky;top:0;z-index:20;box-shadow:0 2px 8px rgba(0,0,0,.12)
}
header h1{font-size:18px;margin:0 0 2px;line-height:1.3}
header .sub{font-size:13px;opacity:.92;margin:0 0 8px}
.chips{display:flex;gap:6px;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:4px}
.chips::-webkit-scrollbar{display:none}
.chip{flex:0 0 auto;border:0;border-radius:16px;padding:8px 12px;font-size:14px;background:rgba(255,255,255,.22);color:#fff;min-height:40px;white-space:nowrap}
.chip.on{background:#fff;color:#1a7a4c;font-weight:700}

footer.nav{
  position:sticky;bottom:0;z-index:20;
  background:#fff;border-top:2px solid #d8efe2;
  display:flex;gap:8px;padding:10px 12px;
  padding-bottom:max(10px,env(safe-area-inset-bottom));
  box-shadow:0 -2px 10px rgba(0,0,0,.06)
}
footer.nav button{
  flex:1;min-height:52px;border:0;border-radius:14px;font-size:18px;font-weight:700;padding:8px 10px
}
#btnPrev,#btnNext{background:#1a7a4c;color:#fff}
#btnPrev:disabled,#btnNext:disabled{background:#c5d9cc;color:#fff}
#btnClear{background:#f4e6e6;color:#8a2a2a;flex:0 0 auto;padding:8px 16px;font-size:16px}

main{max-width:900px;margin:0 auto;padding:14px 12px 24px}

/* ----- Cover ----- */
.cover{text-align:center;padding:18px 10px 30px}
.cover-brand{font-size:16px;color:#1a7a4c;font-weight:700}
.cover-title{font-size:34px;font-weight:800;color:#1a7a4c;margin:8px 0 10px}
.cover-tag{display:inline-block;border:2px solid #e67e22;color:#e67e22;border-radius:999px;padding:4px 14px;font-size:15px;font-weight:700}
.cover-em{font-size:42px;margin:16px 0}
.cover-subs{font-size:18px;margin-bottom:16px}
.cover-note{font-size:15px;color:#555;line-height:1.7;background:#fff;border-radius:16px;padding:14px 16px;text-align:left;margin:16px auto;max-width:520px;box-shadow:0 2px 8px rgba(0,0,0,.05)}
.cover-foot{font-size:18px;color:#1a7a4c;font-weight:700;margin:16px 0}
.name-row{margin:12px auto;max-width:420px;display:flex;align-items:center;gap:8px;justify-content:center;font-size:17px}
.name-row input{flex:1;min-width:0;font-size:18px;padding:10px 12px;border:2px solid #b7e0c6;border-radius:10px}
#btnStart{min-height:64px;width:100%;max-width:360px;font-size:22px;font-weight:800;border:0;border-radius:18px;background:#e67e22;color:#fff;box-shadow:0 4px 0 #c46812}

/* ----- Questions ----- */
.page-hd{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px;gap:8px}
.subj{font-size:22px;font-weight:800;color:#1a7a4c;margin:0}
.pg-lab{color:#666;font-size:14px}
.qcard{background:#fff;border-radius:16px;padding:14px 12px;margin-bottom:16px;box-shadow:0 2px 8px rgba(0,0,0,.06);border:2px solid #d8efe2}
.ins{display:flex;align-items:flex-start;gap:10px;background:#eef8f1;border-radius:12px;padding:10px 12px;margin-bottom:10px;line-height:1.45;font-size:17px}
.ins b{color:#1a7a4c;margin-right:4px;font-size:18px}
.tip{font-size:14px;color:#666;margin:0 0 8px 4px;line-height:1.45}
.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:10px 0;min-height:48px}
.prompt{font-size:18px;line-height:1.45}
.arrow{color:#888}

/* Play buttons — large tap targets */
.play{
  flex:0 0 auto;width:56px;height:56px;border-radius:50%;
  background:#e67e22;color:#fff;border:0;font-size:22px;line-height:1;
  display:inline-flex;align-items:center;justify-content:center;
  box-shadow:0 3px 0 #c46812;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.play.sm{width:46px;height:46px;font-size:18px;box-shadow:0 2px 0 #c46812}
.play.playing{background:#27ae60;box-shadow:0 3px 0 #1e8449;animation:pulse 1s ease-in-out infinite}
@keyframes pulse{50%{transform:scale(1.06)}}
.play:active{transform:translateY(2px);box-shadow:none}

.opt{
  display:inline-flex;align-items:center;justify-content:center;
  border:2px dashed #999;border-radius:999px;padding:8px 16px;margin:3px;
  font-size:18px;min-width:52px;min-height:48px;background:#fff;cursor:pointer;
  -webkit-tap-highlight-color:transparent;user-select:none
}
.opt.sel{border-style:solid;border-color:#e67e22;background:#ffe8d0;font-weight:700;color:#c0392b}

/* Match */
.match{display:grid;grid-template-columns:1fr 1fr;gap:10px 16px;margin-top:6px}
.mcol{display:flex;flex-direction:column;gap:8px}
.mbtn{
  font-size:18px;min-height:64px;border-radius:14px;border:2px solid #ddd;background:#fff;
  padding:8px 10px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;text-align:center
}
.mbtn .small{display:block;font-size:14px;color:#555}
.mbtn.pick{border-color:#3498db;background:#eaf4fb;box-shadow:0 0 0 3px rgba(52,152,219,.28)}
.mbtn.done{border-color:#27ae60;background:#e8f8ef}
.mpairs{font-size:15px;color:#555;margin-top:8px;min-height:24px}
.mpairs span{display:inline-block;background:#eef8f1;border-radius:8px;padding:3px 8px;margin:2px 4px 2px 0}

/* Sequence */
.seq{display:flex;justify-content:space-around;align-items:flex-start;gap:8px;flex-wrap:wrap;margin:8px 0 14px}
.seq-item{text-align:center;flex:1 1 70px;max-width:140px}
.seq-lab{font-size:15px;margin:4px 0 6px;line-height:1.3}
.sc{
  width:48px;height:48px;border:2.5px solid #333;border-radius:50%;
  display:inline-flex;align-items:center;justify-content:center;
  font-size:22px;font-weight:800;background:#fff;cursor:pointer;vertical-align:middle
}
.sc.has{background:#eef8f1;border-color:#1a7a4c;color:#1a7a4c}

/* Trace / draw */
.trow{display:flex;gap:8px;margin:8px 0;flex-wrap:wrap;align-items:center}
.tg{
  width:64px;height:64px;border:2px solid #c33;font-size:42px;line-height:60px;text-align:center;color:#d0d0d0;
  background:linear-gradient(#c99 0 0) center/100% 1px no-repeat,linear-gradient(#c99 0 0) center/1px 100% no-repeat;
  border-radius:4px;position:relative
}
.tg.dark{color:#222}
.pad-wrap{margin:8px 0}
.pad-tools{display:flex;gap:8px;margin-top:6px;flex-wrap:wrap}
.pad-tools button{font-size:15px;border:1px solid #ddd;background:#fff;border-radius:10px;min-height:40px;padding:4px 14px}
canvas.pad{display:block;width:100%;background:#fffef8;border:2px solid #e8c4a0;border-radius:10px;touch-action:none}
.draw-box{border:2px dashed #aaa;border-radius:14px;padding:8px;margin:8px 0;background:#fff}
.draw-box .lab{text-align:center;color:#888;font-size:14px;margin-bottom:4px}
.draw-box canvas.pad{height:240px}
.draw-box.smile canvas.pad{height:180px}
.draw-box.idea canvas.pad{height:280px}

/* Letters / numbers */
.lt{gap:6px}
.lb{
  width:48px;height:48px;border:2px solid #333;border-radius:8px;font-size:20px;font-weight:700;
  text-align:center;line-height:44px;background:#fff
}
.lb.slot,.slot,.bx{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:52px;min-height:48px;border:2.5px solid #333;border-radius:10px;
  font-size:22px;font-weight:700;background:#fffef8;cursor:pointer;padding:0 8px
}
.lb.slot.on,.slot.on,.bx.on{border-color:#e67e22;box-shadow:0 0 0 3px rgba(230,126,34,.28);background:#fff4e8}
.tilebank,.numpad{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 4px}
.tile{
  min-width:44px;min-height:44px;border:2px solid #ccc;border-radius:10px;background:#fff;
  font-size:18px;font-weight:700;padding:4px 8px;cursor:pointer
}
.tile:active{background:#eef8f1}
.legend{font-size:15px;color:#555;margin:0 0 8px}
.attr-box{margin:8px 0;padding:10px;border:1.5px dashed #ddd;border-radius:12px}
.attr-items{display:flex;flex-wrap:wrap;gap:10px 14px;font-size:26px;justify-content:center}
.stat-row{display:flex;align-items:center;gap:10px;margin:8px 0;font-size:18px;flex-wrap:wrap}
.stat-name{min-width:130px}
.eqn,.wp{font-size:18px;margin:10px 0;line-height:1.5}
.ba,.eq{display:flex;align-items:center;gap:8px;font-size:20px;flex-wrap:wrap;margin:8px 0}
.nb{font-size:24px;font-weight:800;min-width:36px;text-align:center}
.bonds{margin:8px 0}
.bond-block{display:flex;gap:12px;align-items:flex-start;margin-bottom:12px;border:1.5px solid #ddd;border-radius:14px;padding:12px;flex-wrap:wrap}
.bond-total{width:52px;height:52px;border-radius:50%;border:3px solid #2a7;display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:800;color:#185;flex-shrink:0}
.bond-pairs{display:flex;flex-wrap:wrap;gap:10px 16px;align-items:center}
.bond-pair{display:flex;align-items:center;gap:6px;font-size:18px}
.bp{font-weight:800;min-width:20px;text-align:center}
.pat{margin:12px 0;padding:8px;background:#fafafa;border-radius:12px}
.pat .objs{font-size:26px;letter-spacing:2px;display:block;margin-bottom:6px}
.pat-opts{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:16px}
.like-row{display:flex;align-items:center;gap:12px;margin:12px 0;flex-wrap:wrap}
.like-pic{text-align:center;min-width:80px}
.like-word{display:inline-block;border:1.5px solid #333;border-radius:8px;padding:2px 10px;font-size:18px;font-weight:700;margin-top:4px}
.like-line{flex:1;font-size:18px;min-width:200px}
.tf{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:10px 0;flex-wrap:wrap;font-size:17px}
.tf .tfl{display:flex;align-items:center;gap:8px;flex:1}
.tfbtn{width:52px;height:52px;border:2.5px solid #333;border-radius:10px;background:#fff;font-size:24px;font-weight:800;cursor:pointer}
.tfbtn.ok{background:#e8f8ef;border-color:#27ae60;color:#1e8449}
.tfbtn.bad{background:#fdecea;border-color:#c0392b;color:#c0392b}
.gs-item{margin:12px 0}
.gs-item .qtxt{font-size:17px;margin-bottom:6px}
.oral{margin:8px 0;padding:10px 12px;background:#f7faf8;border-radius:12px;border:1.5px solid #cfe8d8}
.end-cheer{margin:16px 0 8px;padding:14px;background:#eef8f1;border-radius:14px;text-align:center;font-size:18px;color:#185;font-weight:700}
.icon-towel{display:inline-block;width:22px;height:28px;position:relative;vertical-align:middle;margin:0 4px -2px}
.icon-towel::before{content:"";position:absolute;top:1px;left:0;right:0;height:3px;background:#8a8a8a;border-radius:2px}
.icon-towel::after{content:"";position:absolute;top:4px;left:3px;right:3px;height:22px;background:repeating-linear-gradient(90deg,#7ec8e8 0 5px,#f3fbff 5px 9px);border:1.5px solid #4a90a8;border-radius:0 0 3px 3px}
.icon-boxlid{display:inline-block;width:32px;height:28px;position:relative;vertical-align:middle}
.icon-boxlid .body{position:absolute;bottom:0;left:6px;width:20px;height:15px;background:#e0a45a;border:1.6px solid #8a5a20;border-radius:1px 1px 3px 3px}
.icon-boxlid .lid{position:absolute;top:3px;left:1px;width:22px;height:6px;background:#c4843a;border:1.6px solid #8a5a20;border-radius:2px 3px 1px 1px;transform:rotate(-32deg);transform-origin:left center}
.icon-rect{display:inline-block;width:40px;height:22px;background:#5dade2;border:1.8px solid #1a5276;border-radius:2px;vertical-align:middle}
.icon-hex{display:inline-block;width:30px;height:28px;background:#58d68d;clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%);vertical-align:middle}

/* Answers */
.ans-lock{text-align:center;padding:30px 12px}
.ans-lock h2{color:#1a7a4c}
.ans-banner{background:#185;color:#fff;text-align:center;padding:8px;border-radius:10px;font-weight:700;margin-bottom:12px}
.ans h3{margin:16px 0 6px;color:#1a7a4c;font-size:18px}
.ans p{margin:6px 0;font-size:16px;line-height:1.55}
.pinbox{max-width:320px;margin:16px auto;text-align:center}

/* Confirm */
#askConfirmOverlay{position:fixed;inset:0;z-index:2147483646;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box}
#askConfirmOverlay[hidden]{display:none !important}
#askConfirmBox{background:#fff;border-radius:16px;padding:28px 24px 20px;max-width:440px;width:100%;box-shadow:0 10px 40px rgba(0,0,0,.28);box-sizing:border-box;font-family:inherit}
#askConfirmMsg{font-size:20px;line-height:1.55;color:#222;margin:0 0 22px;text-align:center;font-weight:600}
#askConfirmBtns{display:flex;gap:16px}
#askConfirmNo,#askConfirmYes{flex:1 1 0;min-height:52px;font-size:22px;border:none;border-radius:12px;cursor:pointer;font-weight:700;font-family:inherit;padding:10px 16px}
#askConfirmNo{background:#e5e7eb;color:#111}
#askConfirmYes{background:#c0392b;color:#fff}

@media (min-width:700px){
  .cover-title{font-size:42px}
  .ins{font-size:18px}
}
@media (orientation:landscape) and (max-height:700px){
  header h1{font-size:16px}
  .play{width:48px;height:48px}
  .draw-box canvas.pad{height:180px}
}
.small{font-size:14px;color:#555;display:block}
.big,.mid{font-weight:800}
.mbtn{flex-direction:column}
#btnStart{cursor:pointer}
.slot.wide{min-width:72px}
