/* v75/v76: library book #3 — 한글 블럭 놀이 (full screen, laid out like the meteor game: a pill and ✕ on top, a thin track, panels in the middle) */
#hgGame{position:fixed;inset:0;z-index:40;background:radial-gradient(120% 80% at 50% 0%,#fbf1df 0%,#f4e3c8 60%,#efd9b8 100%);color:var(--cocoa);touch-action:manipulation;user-select:none;-webkit-user-select:none;display:flex;flex-direction:column;overflow:hidden;font-family:var(--body)}
#hgGame[hidden]{display:none}
#hgGame button{font-family:var(--disp);-webkit-tap-highlight-color:transparent;color:inherit}
.hgHud{flex:none;padding:calc(10px + env(safe-area-inset-top,0px)) 14px 0;display:grid;gap:6px;width:min(560px,100%);margin:0 auto;box-sizing:border-box}
.hgTop{display:flex;align-items:center;gap:8px}
.hgPill{flex:0 1 auto;display:flex;align-items:center;gap:8px;background:#fffaf0;border:2px solid #5b3d2e;border-radius:16px;padding:4px 12px 4px 5px;box-shadow:0 3px 0 #5b3d2e;min-width:0}
.hgPill .hgSE{width:34px;height:34px;border-radius:11px;display:grid;place-items:center;background:#f3e2c6;font-size:20px;flex:none}.hgPill .hgSE .pxe{width:24px;height:24px}
.hgPill div{display:flex;flex-direction:column;line-height:1.15;min-width:0}.hgPill b{font:16px var(--disp);font-weight:400;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hgPill i{font:italic 12px var(--disp);color:var(--soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hgDots{display:flex;gap:3px;margin-left:auto;align-items:center;flex:none}.hgDots em{width:17px;height:17px;border-radius:6px;display:grid;place-items:center;background:rgba(91,61,46,.1);font:10px/1 var(--disp);font-style:normal;color:rgba(91,61,46,.45);transition:all .3s}
.hgDots em.on{background:#f4a63f;color:#fff}.hgDots em.now{background:#fff;color:#d0702a;box-shadow:0 0 0 2px #f4a63f;transform:scale(1.1)}
#hgGame .scX{background:#fffaf0;border-color:#5b3d2e;color:#5b3d2e;box-shadow:0 3px 0 #5b3d2e;flex:none}
.hgTrack{height:7px;border-radius:999px;background:rgba(91,61,46,.12);overflow:hidden;margin:2px 2px 0}.hgTrack i{display:block;height:100%;width:0;border-radius:999px;background:linear-gradient(90deg,#9b86e6,#f4a63f,#ee8fb8);transition:width .5s cubic-bezier(.3,1.3,.5,1)}
.hgMain{flex:1;min-height:0;width:min(560px,100%);margin:0 auto;box-sizing:border-box;padding:8px 14px calc(12px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:8px}
/* the word card: a big picture and the word in Hangul */
.hgWord{flex:none;display:flex;align-items:center;gap:14px;background:#fffaf0;border:2px solid #ecdcc6;border-radius:22px;padding:6px 14px 6px 6px;box-shadow:0 3px 0 #e2ccae}
.hgPicB{position:relative;flex:none;width:96px;height:96px;border:0;padding:0;border-radius:20px;background:radial-gradient(circle at 50% 60%,#fff6e2,#f0e0c6);cursor:pointer}
.hgPicB img{width:86px;height:86px;margin:5px;object-fit:contain;display:block}.hgPicB i{position:absolute;right:-4px;bottom:-4px;width:28px;height:28px;border-radius:50%;background:#fff;border:2px solid #5b3d2e;font:14px/24px var(--disp);font-style:normal;text-align:center}
.hgPicB.pop img{animation:hgJump .6s cubic-bezier(.3,1.6,.5,1)}@keyframes hgJump{30%{transform:translateY(-12px) scale(1.12) rotate(-6deg)}60%{transform:translateY(0) scale(.95)}}
.hgWT{flex:1;display:flex;justify-content:center;gap:2px;min-width:0;font:clamp(34px,11vw,52px)/1.1 var(--disp);color:#cdb79a;letter-spacing:1px}
.hgWT span{display:inline-block;transition:color .3s,transform .3s}.hgWT span.done{color:#d0702a}.hgWT span.now{color:var(--cocoa);transform:translateY(-3px);text-decoration:underline 4px #f4a63f;text-underline-offset:6px}
.hgWT span.pop{animation:hgMiniPop .55s cubic-bezier(.3,1.7,.5,1)}@keyframes hgMiniPop{40%{transform:scale(1.35) rotate(4deg)}}
/* the big board: a full wall of blocks with letter-shaped holes */
.hgStage{flex:1;min-height:0;position:relative;touch-action:none;display:flex;align-items:center;justify-content:center;background:#fffaf1;border-radius:24px;box-shadow:inset 0 0 0 2px #ecdcc6,0 4px 0 #e2ccae}
.hgStage.order{flex-direction:column;gap:14px}
.hgBd{position:relative;flex:none}
.hgBd .hgC,.hgBd .hgF{position:absolute;box-sizing:border-box}
.hgC i,.hgF i{position:absolute;inset:4%;box-sizing:border-box;border-radius:24%;display:block;background:var(--c);box-shadow:inset 0 -0.16em 0 rgba(0,0,0,.12),inset 0 0.13em 0 rgba(255,255,255,.55);transform-origin:50% 80%}
.hgC i{opacity:0}.hgC.on i{opacity:1}
.hgF i{box-shadow:inset 0 -0.14em 0 rgba(150,110,70,.18),inset 0 0.12em 0 rgba(255,255,255,.8)}
.hgC.g i,.hgC.s i,.hgC.t i{opacity:1;background:#e3cdab;box-shadow:inset 0 .14em .22em rgba(91,61,46,.38),inset 0 -.05em 0 rgba(255,255,255,.55)}
.hgC.s i{background:color-mix(in srgb,var(--c) 30%,#e3cdab);box-shadow:inset 0 .14em .22em rgba(91,61,46,.32),inset 0 0 0 .1em var(--c);animation:hgSock 1.1s ease-in-out infinite}
@keyframes hgSock{50%{background:color-mix(in srgb,var(--c) 55%,#e3cdab)}}
.hgC.t i{background:color-mix(in srgb,var(--c) 22%,#e3cdab);animation:hgTr 1.6s ease-in-out infinite}@keyframes hgTr{50%{background:color-mix(in srgb,var(--c) 40%,#e3cdab)}}
.hgC.hid i{opacity:0}
.k-cho{--c:#9b86e6}.k-jung{--c:#f4a63f}.k-jung.c1{--c:#f2c14a}.k-jung.c2{--c:#f6d270}.k-jong{--c:#ee8fb8}.k-jong.c1{--c:#e977a6}
.hgQB{position:absolute;box-sizing:border-box;border:3px dashed #d2b48e;border-radius:14px;background:#fff6e2;display:grid;place-items:center;font:36px var(--disp);color:#c99a5e;animation:hgQ 1.4s ease-in-out infinite;z-index:2}
.hgQB.wait{animation:none;color:#dccbb2;border-color:#e6d6bf}
@keyframes hgQ{50%{transform:scale(1.04);border-color:#f4a63f;color:#f4a63f}}
.hgQB.go{animation:none;opacity:0;transition:opacity .2s}
.hgHand{position:absolute;width:0;height:0;pointer-events:none;z-index:3;transition:left .25s,top .25s,opacity .25s}
.hgHand::before{content:'';position:absolute;left:-22px;top:-22px;width:44px;height:44px;border-radius:50%;border:3px solid #f4a63f;animation:hgRing 1s ease-out infinite}
.hgHand b{position:absolute;left:2px;top:4px;font-size:30px;line-height:1;animation:hgPoke 1s ease-in-out infinite;filter:drop-shadow(0 2px 0 rgba(0,0,0,.15))}.hgHand b .pxe{width:34px;height:34px}
.hgHand.hide{opacity:0}
@keyframes hgRing{0%{transform:scale(.4);opacity:1}100%{transform:scale(1.4);opacity:0}}@keyframes hgPoke{50%{transform:translate(-4px,-6px)}}
/* combo badge (stage 5) */
.hgCombo{position:absolute;right:12px;top:10px;z-index:4;display:flex;flex-direction:column;align-items:center;gap:3px;font:20px/1 var(--disp);color:#fff;background:linear-gradient(135deg,#f4a63f,#ee8fb8);border-radius:16px;padding:6px 12px 5px;box-shadow:0 3px 0 #c97a4a;opacity:0;transform:scale(.6);transition:opacity .25s,transform .25s;pointer-events:none;white-space:nowrap}
.hgCombo.on{opacity:1;transform:scale(1)}.hgCombo.pop{animation:hgCP .22s}@keyframes hgCP{50%{transform:scale(1.3) rotate(-4deg)}}
.hgCombo small{font:11px var(--disp);opacity:.9}.hgCombo u{display:block;width:100%;height:4px;border-radius:9px;background:rgba(255,255,255,.35);overflow:hidden;text-decoration:none}.hgCombo u i{display:block;height:100%;background:#fff;transform-origin:0 50%}
.hgCombo u i.run{animation:hgCT .9s linear forwards}@keyframes hgCT{from{transform:scaleX(1)}to{transform:scaleX(0)}}
.hgCombo.hot{background:linear-gradient(135deg,#ff7a59,#ff4fa0,#a46bff);box-shadow:0 3px 0 #a0306a,0 0 18px rgba(255,90,160,.6)}
.hgFlash{position:absolute;inset:0;border-radius:24px;pointer-events:none;background:radial-gradient(circle,rgba(255,240,180,.7),rgba(255,240,180,0) 70%);opacity:0;z-index:3}.hgFlash.on{animation:hgFl .5s ease-out}@keyframes hgFl{0%{opacity:1}100%{opacity:0}}
/* syllable slots for the order stage: empty blocks that burst when filled */
.hgSlots{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;padding:0 8px}
.hgSlot{position:relative;width:var(--s);height:var(--s);border-radius:20%;background:#e3cdab;box-shadow:inset 0 6px 12px rgba(91,61,46,.32),inset 0 -2px 0 rgba(255,255,255,.6);display:grid;place-items:center;font:calc(var(--s)*.34) var(--disp);color:rgba(91,61,46,.25);box-sizing:border-box}
.hgSlot.now{box-shadow:inset 0 6px 12px rgba(91,61,46,.28),inset 0 0 0 3px #f4a63f;color:#f4a63f;animation:hgSlotP 1.2s ease-in-out infinite}@keyframes hgSlotP{50%{transform:scale(1.04)}}
.hgSlot.wall{background:none;box-shadow:none;animation:none}
.hgSlot.full{background:#fff;box-shadow:0 4px 0 #e2ccae,inset 0 0 0 2px #ecdcc6;animation:none;font:calc(var(--s)*.62)/1 var(--disp);color:#d0702a}
.hgSlot .hgTxtPop{animation:hgTP .5s cubic-bezier(.3,1.8,.5,1)}@keyframes hgTP{from{transform:scale(.2) rotate(-12deg);opacity:0}}
/* the owl's hint and the tray of pieces */
.hgHint{flex:none;display:flex;align-items:center;gap:8px;min-height:40px}.hgHint img{width:34px;height:41px;image-rendering:pixelated;flex:none}
.hgHint p{margin:0;flex:1;background:#fff;border:2px solid #5b3d2e;border-radius:14px 14px 14px 4px;padding:6px 10px;font:14.5px/1.35 var(--body);color:var(--cocoa);box-shadow:0 2px 0 #5b3d2e}.hgHint p b{font-family:var(--disp);font-weight:400;color:#d0702a}
.hgTray{flex:none;display:flex;gap:10px;justify-content:center;align-items:stretch;min-height:104px}
.hgTray.tiles{min-height:96px}
.hgOpt{position:relative;flex:1;max-width:120px;min-width:0;aspect-ratio:1;border:0;border-radius:22px;background:#fff;box-shadow:0 5px 0 #e2ccae,inset 0 0 0 2px #ecdcc6;cursor:pointer;display:grid;place-items:center;padding:0;transition:transform .12s,opacity .3s}
.hgOpt:active{transform:translateY(3px) scale(.97);box-shadow:0 2px 0 #e2ccae,inset 0 0 0 2px #ecdcc6}
.hgOpt.no{animation:hgNo .45s;opacity:.45}@keyframes hgNo{20%{transform:translateX(-9px) rotate(-4deg)}40%{transform:translateX(8px) rotate(3deg)}60%{transform:translateX(-6px)}80%{transform:translateX(4px)}}
.hgOpt.hint{box-shadow:0 5px 0 #e2ccae,inset 0 0 0 3px #f4a63f,0 0 18px rgba(244,166,63,.6);animation:hgHintB 1s ease-in-out infinite}@keyframes hgHintB{50%{transform:translateY(-4px)}}
.hgOpt.used{visibility:hidden}.hgOpt.in{animation:hgIn .45s cubic-bezier(.3,1.6,.5,1) backwards}@keyframes hgIn{from{transform:translateY(40px) scale(.5);opacity:0}}
.hgOpt.tile{max-width:104px}
.hgPc{position:relative;transition:transform .45s cubic-bezier(.4,1.6,.5,1)}
/* the flying piece and the say-bubble */
.hgFly{position:fixed;left:0;top:0;z-index:5;pointer-events:none;transform-origin:50% 50%}
.hgFx{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:6}
.hgSay{position:absolute;left:50%;top:44%;z-index:7;pointer-events:none;transform:translate(-50%,-50%);font:clamp(64px,22vw,130px)/1 var(--disp);color:#fff;-webkit-text-stroke:3px #5b3d2e;paint-order:stroke;text-shadow:0 6px 0 #5b3d2e;opacity:0;white-space:nowrap}
.hgSay.on{animation:hgSayA 1.35s ease-out}.hgSay.word{font-size:clamp(48px,15vw,92px)}
@keyframes hgSayA{0%{opacity:0;transform:translate(-50%,-30%) scale(.4)}18%{opacity:1;transform:translate(-50%,-50%) scale(1.12)}30%{transform:translate(-50%,-50%) scale(1)}78%{opacity:1}100%{opacity:0;transform:translate(-50%,-70%) scale(1)}}
.hgFloat{position:fixed;z-index:9;pointer-events:none;font:22px var(--disp);color:#fff;background:linear-gradient(135deg,#f4a63f,#ee8fb8);border-radius:999px;padding:4px 14px;box-shadow:0 3px 0 #c97a4a;white-space:nowrap}
.hgFloat.big{font-size:34px;padding:6px 20px;background:linear-gradient(135deg,#ff7a59,#ff4fa0,#a46bff);box-shadow:0 4px 0 #a0306a,0 0 24px rgba(255,90,160,.6)}
/* panels (title, stage card, results) — paper like the pond game */
.hgOver{position:absolute;inset:0;z-index:8;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(91,61,46,.28)}.hgOver[hidden]{display:none}
.hgOver.banner{background:rgba(91,61,46,.12)}
.hgPanel{width:min(380px,100%);max-height:calc(100% - 8px);overflow:auto;box-sizing:border-box;text-align:center;color:var(--cocoa);background:#fffaf0;border:3px solid #5b3d2e;border-radius:24px;padding:18px 16px;box-shadow:0 5px 0 #5b3d2e,0 10px 30px rgba(60,30,10,.25);outline:1.6px dashed rgba(122,82,56,.42);outline-offset:-8px;display:grid;gap:10px;justify-items:center;animation:hgPan .4s cubic-bezier(.3,1.5,.5,1)}
@keyframes hgPan{from{transform:scale(.85);opacity:0}}
.hgLogo{font:30px/1.1 var(--disp);color:#d0702a;text-shadow:0 3px 0 #f6dcb8}
.hgPanel p{margin:0;font:15px/1.55 var(--body)}.hgPanel p b{font-family:var(--disp);font-weight:400;color:#d0702a}
.hgOwl{display:flex;align-items:flex-end;gap:8px;text-align:left}.hgOwl img{width:46px;height:56px;image-rendering:pixelated;flex:none}
.hgOwl p{background:#fff;border:2px solid #5b3d2e;border-radius:16px 16px 16px 5px;padding:8px 10px;font-size:14px;box-shadow:0 2px 0 #5b3d2e}
.hgPath{display:flex;align-items:center;justify-content:center;gap:2px;width:100%;flex-wrap:nowrap}
.hgStg{display:flex;flex-direction:column;align-items:center;gap:2px;padding:7px 2px 6px;border-radius:14px;border:2px solid #ecdcc6;background:#fff;font:12px var(--disp);flex:1;min-width:0;position:relative}
.hgStg .hgSE{font-size:22px;line-height:26px;height:26px}.hgStg .hgSE .pxe{width:24px;height:24px}.hgStg b{font-weight:400;font-size:11px;line-height:1.2;word-break:keep-all}.hgStg small{font:10px var(--disp);color:var(--soft)}
.hgStg.done{border-color:#86cdb9;background:#f0fbf6}.hgStg.done::after{content:'✓';position:absolute;top:-7px;right:-4px;width:16px;height:16px;border-radius:50%;background:#3fae8a;color:#fff;font:11px/16px var(--disp)}
.hgPath>i{font-style:normal;color:#d2b48e;font:14px var(--disp)}
.hgBtns{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.hgGo{border:3px solid #5b3d2e;background:linear-gradient(#ffcf7a,#f4a63f);border-radius:999px;padding:10px 26px;font:20px var(--disp);color:#5b3d2e!important;cursor:pointer;box-shadow:0 4px 0 #5b3d2e}.hgGo:active{transform:translateY(3px);box-shadow:0 1px 0 #5b3d2e}
.hgGo.sub{background:#fff;font-size:16px;padding:8px 18px}
.hgNote{font:12px/1.5 var(--body);color:var(--soft);margin:0}
.hgBig{font-size:56px;line-height:1}.hgBig .pxe{width:64px;height:64px}
.hgStars{display:flex;gap:6px;font-size:34px}.hgStars i{font-style:normal;opacity:.2;filter:grayscale(1);transform:scale(.7);transition:all .4s cubic-bezier(.3,1.7,.5,1)}.hgStars i.on{opacity:1;filter:none;transform:scale(1)}
.hgLearn{display:flex;flex-wrap:wrap;gap:6px;justify-content:center}.hgLearn button{display:flex;flex-direction:column;align-items:center;gap:1px;border:2px solid #ecdcc6;background:#fff;border-radius:14px;padding:4px 8px;cursor:pointer;font:14px var(--disp)}.hgLearn img{width:36px;height:36px}
.hgWdone img{width:120px;height:120px;object-fit:contain}.hgWdone .hgWdT{font:44px/1 var(--disp);color:#d0702a;letter-spacing:2px}
.hgStgCard .hgSE{font-size:48px;line-height:1}.hgStgCard .hgSE .pxe{width:56px;height:56px}.hgStgK{font:13px var(--disp);letter-spacing:4px;color:#d0702a}
.hgDemo{display:flex;gap:10px;align-items:center;justify-content:center}
@media (max-height:680px){.hgPicB{width:72px;height:72px}.hgPicB img{width:64px;height:64px;margin:4px}.hgWT{font-size:34px}.hgTray{min-height:84px}.hgOpt{max-width:96px}.hgHint p{font-size:13px;padding:4px 8px}}
/* v77: the hole to fill — a glowing outline with marching dashes */
.hgOL,.hgGd{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:2}
.hgOL path{fill:none;stroke-linejoin:round;stroke-linecap:round}
.hgOL .gl{stroke:var(--c);stroke-width:.55;opacity:.35;animation:hgOLg 1s ease-in-out infinite}
.hgOL .ln{stroke:#fff;stroke-width:.24}
.hgOL .an{stroke:var(--c);stroke-width:.24;stroke-dasharray:.55 .35;animation:hgAnts .7s linear infinite}
@keyframes hgAnts{to{stroke-dashoffset:-.9}}@keyframes hgOLg{50%{opacity:.7;stroke-width:.75}}
/* v77: stroke guides for tracing — numbered start, a dashed line that flows the way the pen goes, an arrow at the end */
.hgGs{transition:opacity .35s}.hgGs.done{opacity:0}
.hgGd .ln{fill:none;stroke:#5b3d2e;stroke-width:.13;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:.28 .2;animation:hgFlow .6s linear infinite;opacity:.8}
@keyframes hgFlow{to{stroke-dashoffset:-.48}}
.hgGd .end{fill:#5b3d2e;opacity:0}
.hgGd .st{stroke:#fff;stroke-width:.1;filter:drop-shadow(0 .05px .1px rgba(0,0,0,.3))}
.hgGd .hgGm{animation:hgStP 1.2s ease-in-out infinite;transform-box:fill-box;transform-origin:center}
@keyframes hgStP{50%{transform:scale(1.15)}}
.hgGd text{font:.55px var(--disp);fill:#fff;text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#5b3d2e;stroke-width:.06}
/* v77: shell-game shuffle and drag-and-drop for the order stage */
.hgShell{position:relative;flex:none}
.hgSlotB{position:absolute;top:0;border-radius:20%;background:#e3cdab;box-shadow:inset 0 6px 12px rgba(91,61,46,.3),inset 0 -2px 0 rgba(255,255,255,.6);transition:box-shadow .2s}
.hgSlotB.tg{box-shadow:inset 0 6px 12px rgba(91,61,46,.25),0 0 0 4px #f4a63f,0 0 18px rgba(244,166,63,.6)}
.hgTile{position:absolute;top:0;display:grid;place-items:center;cursor:grab;touch-action:none;border-radius:16%;filter:drop-shadow(0 4px 0 rgba(91,61,46,.25))}
.hgTile.lift{z-index:6;cursor:grabbing;filter:drop-shadow(0 14px 14px rgba(91,61,46,.35))}
.hgTile.txt{background:#fff;box-shadow:0 4px 0 #e2ccae,inset 0 0 0 2px #ecdcc6;font:calc(var(--s,100px)*.6)/1 var(--disp);color:#d0702a;filter:none}
