*{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:#f8efe6;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;line-height:1}

/* ----- Gate ----- */
#gate{position:fixed;inset:0;z-index:9999;background:linear-gradient(160deg,#f3e0d0,#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:22px;color:#9a4a32;line-height:1.35}
.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 #e4c4ae;border-radius:12px;margin-bottom:14px;outline:none}
#gatePw:focus,#ansPin:focus{border-color:#9a4a32}
#gateGo,.pin-go{width:100%;font-size:20px;padding:14px;border:0;border-radius:12px;background:#9a4a32;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,#9a4a32,#c46b4a);
  color:#fff;padding:10px 12px 0;
  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}
.tabs{display:flex;gap:6px;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:8px}
.tabs::-webkit-scrollbar{display:none}
.tab{flex:1 1 0;min-width:72px;border:0;border-radius:16px;padding:9px 10px;font-size:16px;background:rgba(255,255,255,.22);color:#fff;min-height:44px;white-space:nowrap;font-weight:700}
.tab.on{background:#fff;color:#9a4a32}

footer.bar{
  position:sticky;bottom:0;z-index:20;
  background:#fff;border-top:2px solid #ead6c6;
  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.bar button{
  flex:1;min-height:52px;border:0;border-radius:14px;font-size:17px;font-weight:700;padding:8px 10px
}
#btnClear{background:#f4e6e6;color:#8a2a2a}
#btnMum{background:#9a4a32;color:#fff}

main{max-width:900px;margin:0 auto;padding:14px 12px 28px}
.panel{display:none}
.panel.on{display:block}
.lead{font-size:16px;line-height:1.55;color:#553b2a;background:#fff;border-radius:14px;padding:12px 14px;margin:0 0 14px;box-shadow:0 2px 8px rgba(0,0,0,.05)}
.soon{text-align:center;background:#fff;border-radius:16px;padding:28px 16px;box-shadow:0 2px 8px rgba(0,0,0,.05)}
.soon p{font-size:18px;line-height:1.6;margin:8px 0}
.old-links{font-size:14px;color:#555;line-height:1.6;margin:18px 4px 8px}
.old-links a{color:#9a4a32}

/* ----- Questions ----- */
.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 #ead6c6}
.ins{display:flex;align-items:flex-start;gap:10px;background:#f8eee4;border-radius:12px;padding:10px 12px;margin-bottom:10px;line-height:1.45;font-size:17px}
.ins b{color:#9a4a32;margin-right:4px;font-size:18px;flex:0 0 auto}
.ins .ins-t{flex:1;min-width:0}
.tip{font-size:14px;color:#666;margin:0 0 8px 4px;line-height:1.45}
.bank{display:inline-block;border:2px solid #e67e22;border-radius:10px;padding:6px 12px;font-size:16px;margin:0 0 10px;letter-spacing:.5px;background:#fffaf3}
.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}
.item-row{background:#fbf6ef;border-radius:12px;padding:8px 8px;margin:8px 0}

/* Play buttons */
.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;
  touch-action:manipulation;
  -webkit-user-select:none;user-select:none;
  position:relative;z-index:2;pointer-events:auto;
}
.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}

.optwrap{
  display:inline-flex;align-items:center;gap:4px;margin:4px 6px 4px 0;vertical-align:middle;max-width:100%;
}
.optwrap .play.sm{width:44px;height:44px;flex:0 0 auto}
.opt{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  border:2px dashed #999;border-radius:16px;padding:8px 14px;margin:0;
  font-size:18px;min-width:52px;min-height:48px;background:#fff;cursor:pointer;
  -webkit-tap-highlight-color:transparent;user-select:none
}
.opt.pic{flex-direction:column;min-width:76px;min-height:76px;border-radius:16px;font-size:16px;padding:8px 8px}
.opt .em{font-size:36px}
.opt.sel{border-style:solid;border-color:#e67e22;background:#ffe8d0;font-weight:700;color:#c0392b}
.opt.ok{border-style:solid;border-color:#27ae60;background:#e8f8ef;color:#1e8449}
.opt.bad{border-style:solid;border-color:#c0392b;background:#fdecea;color:#922}

/* Match */
.match{display:grid;grid-template-columns:1fr 1fr;gap:10px 14px;margin-top:6px}
.mcol{display:flex;flex-direction:column;gap:8px}
.mbtn{
  font-family:inherit;font-size:17px;min-height:56px;border-radius:12px;
  border:2px solid #e0c8b6;background:#fff;padding:8px 10px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;
  text-align:center;line-height:1.35;white-space:normal;
  -webkit-tap-highlight-color:transparent
}
.mbtn .em{font-size:28px}
.mbtn.on{border-color:#e67e22;background:#ffe8d0;font-weight:700}
.mbtn.paired{border-color:#27ae60;background:#e8f8ef}
.mpairs{margin-top:8px;font-size:16px;color:#1e8449}
.mpairs span{display:inline-block;background:#eef8f1;border-radius:8px;padding:2px 8px;margin:2px 4px 2px 0}

/* Reorder */
.rcards{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.rcard{
  font-family:inherit;font-size:18px;min-height:52px;padding:8px 14px;
  border-radius:12px;border:2px solid #e0c8b6;background:#fff;cursor:pointer
}
.rcard.used{opacity:.35;pointer-events:none}
.rbuilt{min-height:48px;border:2px dashed #e4c4ae;border-radius:12px;padding:8px 12px;font-size:20px;letter-spacing:1px;background:#fbf6ef;margin:6px 0}
.rreset, .pad-tools button, .qfoot button{
  font-family:inherit;font-size:16px;min-height:44px;padding:6px 14px;
  border-radius:10px;border:1px solid #e0c8b6;background:#fff;cursor:pointer;font-weight:700
}
.qfoot button{background:#9a4a32;color:#fff;border:0;min-height:48px;font-size:17px;padding:8px 16px}

/* Pads */
.pad-wrap{margin:10px 0 16px}
.pad-head{display:flex;align-items:center;gap:10px;margin-bottom:6px}
.pad-label{font-size:40px;font-weight:800;color:#9a4a32;line-height:1}
.pad-box{position:relative;width:100%;height:180px;border:2px solid #e4c4ae;border-radius:12px;background:#fffef8;overflow:hidden;touch-action:none}
.pad-guide{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-size:140px;font-weight:800;color:rgba(43,95,138,.14);pointer-events:none;
  line-height:1;font-family:"PingFang HK","Noto Sans CJK HK",serif
}
canvas.pad{position:absolute;inset:0;width:100%;height:100%;touch-action:none}
.pad-tools{display:flex;gap:8px;margin-top:6px}

/* TF / food-like toggles */
.tf-row,.choice-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:10px 0;font-size:17px}
.tog{display:flex;gap:6px}
.tog button{
  min-width:52px;min-height:48px;border-radius:12px;border:2px solid #e0c8b6;background:#fff;
  font-size:20px;font-weight:800;cursor:pointer
}
.tog button.sel.good{border-color:#27ae60;background:#e8f8ef;color:#1e8449}
.tog button.sel.bad{border-color:#c0392b;background:#fdecea;color:#922}

.food-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:10px}
.fd .optwrap{margin:4px 2px}
.fd{text-align:center;background:#fbf6ef;border-radius:14px;padding:10px 6px;border:2px solid #ead6c6}
.fd .em{font-size:36px;display:block;margin-bottom:6px}
.fd .lab{font-size:14px;margin-bottom:6px}
.fd .tog{justify-content:center}

.ans-box{display:none;margin-top:10px;padding:10px 12px;background:#e8f8ef;border:2px solid #27ae60;border-radius:12px;font-size:16px;line-height:1.5;color:#1e8449}
.ans-box.on{display:block}
.ans-box .lab{font-weight:800;margin-right:6px}
.qfoot{display:flex;align-items:center;gap:10px;margin-top:10px;flex-wrap:wrap}
.res{font-size:16px;font-weight:700}
.res.ok{color:#1e8449}
.res.bad{color:#c0392b}
.res.free{color:#9a4a32}

/* Parent sheet */
#mumSheet{position:fixed;inset:0;z-index:30;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;padding:20px}
#mumSheet[hidden]{display:none!important}
.mum-box{background:#fff;border-radius:18px;padding:22px 18px;max-width:560px;width:100%;max-height:86vh;overflow:auto;box-shadow:0 10px 40px rgba(0,0,0,.28)}
.mum-box h2{margin:0 0 8px;color:#9a4a32;font-size:22px}
.mum-tip{margin:0 0 12px;color:#555}
#mumAns{font-size:16px;line-height:1.6}
#mumAns h3{margin:14px 0 6px;color:#9a4a32;font-size:18px}
#mumAns p{margin:4px 0}
.mum-close{width:100%;margin-top:16px;min-height:48px;border:0;border-radius:12px;background:#9a4a32;color:#fff;font-size:18px;font-weight:700}

/* 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 (max-width:420px){
  .tab{font-size:15px;padding:9px 8px}
  .pad-box{height:160px}
  .pad-guide{font-size:120px}
}

/* ----- Home theme extras ----- */
.ico{display:block;overflow:visible}
.g5-block{margin:12px 0 18px;padding:10px;background:#fbf6ef;border-radius:14px;border:2px solid #ead6c6}
.g5-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:8px}
.g5-title{font-size:18px;font-weight:800;color:#9a4a32}
.g5-count{font-size:15px;color:#666}
.g5-grid{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin:8px 0}
.g5item{
  width:60px;height:60px;border:3px dashed #d0b49a;border-radius:16px;background:#fff;
  display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;
  -webkit-tap-highlight-color:transparent;position:relative;user-select:none
}
.g5item.pending{border-style:solid;border-color:#e67e22;background:#fff3e4;box-shadow:0 0 0 3px rgba(230,126,34,.2)}
.g5item.g0{border-style:solid;border-color:#e67e22;background:#ffe8d0}
.g5item.g1{border-style:solid;border-color:#2980b9;background:#d6eaf8}
.g5item.g2{border-style:solid;border-color:#27ae60;background:#d5f5e3}
.g5item.g3{border-style:solid;border-color:#8e44ad;background:#f5e6fa}
.g5item.g4{border-style:solid;border-color:#c0392b;background:#fadbd8}
.g5item.g5{border-style:solid;border-color:#16a085;background:#d5f4ef}
.g5item .g5-badge{
  position:absolute;top:-8px;right:-8px;min-width:22px;height:22px;border-radius:11px;
  background:#9a4a32;color:#fff;font-size:12px;font-weight:800;display:flex;align-items:center;justify-content:center;
  padding:0 5px
}
.g5-tools{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0}
.g5-tools button{
  font-family:inherit;font-size:15px;min-height:44px;padding:6px 12px;border-radius:10px;
  border:1px solid #e0c8b6;background:#fff;cursor:pointer;font-weight:700
}
.g5-fills{margin-top:10px}
.g5-fill-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:10px 0;font-size:18px;font-weight:700}
.g5-blank{
  display:inline-flex;align-items:center;justify-content:center;min-width:48px;min-height:44px;
  border:2px solid #9a4a32;border-radius:10px;background:#fff;padding:0 8px;color:#9a4a32
}
.g5-blank.empty{color:#ccc}
.nums{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.nums .opt{min-width:48px}

/* Home scene */
.home-scene{
  position:relative;height:360px;border-radius:18px;overflow:hidden;
  border:3px solid #c4a484;margin:8px 0 12px;background:#f3efe4;
  touch-action:manipulation
}
.hs-wall{position:absolute;inset:0 0 32% 0;background:linear-gradient(#f7f1e6,#efe4d2)}
.hs-floor{position:absolute;left:0;right:0;bottom:0;height:32%;background:linear-gradient(#e2c8a4,#d2b48c)}
.hs-base{position:absolute;background:#c9a882;border-radius:6px}
.hs-window{
  position:absolute;right:8%;top:7%;width:72px;height:72px;border-radius:10px;
  background:linear-gradient(#b9e0f0,#eaf7fc);border:4px solid #8b5a3c;box-sizing:border-box
}
.hs-window:after{content:"";position:absolute;inset:0;border:0;background:
  linear-gradient(#8b5a3c,#8b5a3c) 50% 0/4px 100% no-repeat,
  linear-gradient(#8b5a3c,#8b5a3c) 0 50%/100% 4px no-repeat}
.hs-rug{
  position:absolute;left:18%;bottom:4%;width:48%;height:18%;border-radius:50%;
  background:#c97b6a;opacity:.85;border:3px solid transparent
}
.scene-hit{
  position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;
  min-width:56px;min-height:56px;padding:4px;border:3px solid transparent;border-radius:14px;
  cursor:pointer;-webkit-tap-highlight-color:transparent;background:transparent
}
.scene-hit .lab{font-size:12px;font-weight:700;color:#5a2e20;line-height:1.1;margin-top:1px;text-align:center}
.scene-hit.found{border-color:#27ae60;background:rgba(39,174,96,.18);box-shadow:0 0 0 3px rgba(39,174,96,.2)}
.scene-hit.miss{animation:shake .35s ease;border-color:#c0392b}
@keyframes shake{25%{transform:translateX(-4px)}75%{transform:translateX(4px)}}
.scene-chips{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.scene-chip{
  display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;
  border:2px solid #e0c8b6;background:#fff;font-size:15px;font-weight:700;color:#555
}
.scene-chip.found{border-color:#27ae60;background:#e8f8ef;color:#1e8449}
.scene-status{font-size:16px;font-weight:700;color:#9a4a32;margin:4px 0 8px}

/* Story */
.story{background:#fffaf3;border:2px solid #ead6c6;border-radius:16px;padding:10px 10px 6px;margin:0 0 12px}
.story h3{margin:0 0 8px;color:#9a4a32;font-size:20px;display:flex;align-items:center;gap:8px}
.story-card{
  display:grid;grid-template-columns:88px 1fr;gap:10px;align-items:center;
  background:#fff;border-radius:14px;padding:8px;margin:0 0 8px;border:1px solid #ead6c6
}
.story-card .art{display:flex;align-items:center;justify-content:center}
.story-card .line{display:flex;align-items:flex-start;gap:8px;font-size:18px;line-height:1.45;margin:0}
.story-all{margin:4px 0 8px}

/* Sentence pads */
.pad-box.sent{height:132px}
.pad-guide.sent{
  font-size:42px;letter-spacing:.12em;font-weight:800;
  background:repeating-linear-gradient(90deg,transparent 0 8px,transparent 8px),
    linear-gradient(#e4c4ae,#e4c4ae) 0 33%/100% 1px no-repeat,
    linear-gradient(#e4c4ae,#e4c4ae) 0 66%/100% 1px no-repeat
}
.sent-boxes{display:flex;flex-wrap:wrap;gap:4px;margin:0 0 6px}
.sent-box{
  min-width:36px;height:44px;border:2px solid #e4c4ae;border-radius:8px;
  display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:800;color:#9a4a32;background:#fffef8
}
.read-list{display:flex;flex-direction:column;gap:8px}
.read-row{
  display:flex;align-items:center;gap:10px;background:#fbf6ef;border-radius:14px;
  padding:10px 12px;font-size:20px;font-weight:700;min-height:56px
}

.pic-prompt{display:flex;align-items:center;gap:10px;margin:4px 0}
.pic-prompt .ico{flex:0 0 auto}

@media (max-width:420px){
  .home-scene{height:320px}
  .g5item{width:54px;height:54px}
  .story-card{grid-template-columns:72px 1fr}
}
