:root { --ink: #22203a; --card: #fffdf8; --accent: #e85d75; --ok: #2e9b5f; --no: #d2453a; --radius: 18px; font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif; color: var(--ink); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe8ff; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 14px; padding: .6em 1em; background: #eef0ff; color: var(--ink); touch-action: manipulation; }
button.big { background: var(--accent); color: #fff; font-weight: 700; font-size: 1.1rem; padding: .7em 1.3em; box-shadow: 0 4px 0 #b8445a; }
button.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #b8445a; }
button.ghost { background: transparent; text-decoration: underline; }
#stage { position: fixed; inset: 0; }
#scene { width: 100%; height: 100%; display: block; touch-action: none; }
#tags { position: fixed; inset: 0; pointer-events: none; }
.tag, .float { position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 800; padding: .15em .55em; border-radius: 999px; background: #fffd; box-shadow: 0 2px 6px #0002; font-size: .85rem; transition: opacity .6s; }
.tag.hero { background: var(--accent); color: #fff; font-size: 1rem; }
.tag.pet { background: #fff8d8; }
.tag.fade { opacity: 0; }
.float { background: #fff; font-size: 1.05rem; animation: rise 1.1s ease-out forwards; }
@keyframes rise { from { margin-top: 0; opacity: 1; } to { margin-top: -40px; opacity: 0; } }
#fader { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .45s; }
#fader.on { opacity: 1; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: .6rem; align-items: center; padding: max(.5rem, env(safe-area-inset-top)) .8rem .5rem; pointer-events: none; }
#hud > * { pointer-events: auto; }
#title { font-weight: 800; background: #fffc; padding: .3em .8em; border-radius: 999px; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#preview-badge { background: #ffe07a; padding: .2em .6em; border-radius: 8px; font-weight: 700; font-size: .8rem; }
#stars { margin-left: auto; background: #fffc; padding: .3em .8em; border-radius: 999px; font-weight: 800; color: #c88a00; }
#btn-settings { background: #fffc; font-size: 1.2rem; padding: .3em .6em; }

#narration, #game { position: fixed; left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 1.5rem)); background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 30px #0003; padding: 1rem 1.2rem; }
#narration { bottom: max(1rem, env(safe-area-inset-bottom)); }
#line { font-size: clamp(1.1rem, 2.6vw, 1.45rem); line-height: 1.45; margin: 0 0 .6rem; }
.row { display: flex; gap: .6rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
#line-count { margin-right: auto; opacity: .55; font-weight: 700; }

#game { bottom: max(.8rem, env(safe-area-inset-bottom)); max-height: 62vh; overflow: auto; }
#game.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(calc(-50% - 8px)); } 75% { transform: translateX(calc(-50% + 8px)); } }
.g-head { display: flex; align-items: center; gap: .5rem; }
.badge { background: #eef0ff; padding: .2em .7em; border-radius: 999px; font-weight: 800; font-size: .85rem; }
#g-emoji { font-size: 1.8rem; }
#g-prompt { font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 700; margin: .5rem 0; }
#g-big { font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 900; text-align: center; letter-spacing: .08em; margin: .2rem 0 .6rem; }
#g-feedback { min-height: 1.6em; font-weight: 800; text-align: center; margin-top: .4rem; }
#g-feedback.ok { color: var(--ok); } #g-feedback.nope { color: var(--no); }
.choices { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.choice { min-width: 4.5rem; min-height: 3.4rem; font-size: 1.15rem; font-weight: 800; background: #fff; border: 3px solid #dfe2f5; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.choice .em { font-size: 1.6rem; }
.choice.right { border-color: var(--ok); background: #e2f7ea; }
.choice.wrong { border-color: var(--no); opacity: .45; }
.choice.hint { animation: pulse 1s infinite; border-color: #f2c230; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.stones .choice { border-radius: 50% 46% 52% 44%; background: #d8d8e0; border-color: #a8a8b8; min-width: 5rem; min-height: 4.4rem; font-size: 1.5rem; }
.tiles .choice { min-width: 3.4rem; font-size: 1.6rem; background: #fff6d8; border-color: #f2d27a; }
.faces .choice { flex-direction: column; min-width: 6rem; }
.cards .choice { max-width: 100%; text-align: left; }
.spell .slots { display: flex; gap: .4rem; justify-content: center; width: 100%; margin-bottom: .6rem; }
.slot { width: 2.6rem; height: 3rem; border-bottom: 4px solid #c8c8d8; font-size: 1.8rem; font-weight: 900; text-align: center; }
.slot.filled { border-color: var(--ok); }
.tilerow, .card-row, .answer-row { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; width: 100%; }
.answer-row { min-height: 3.6rem; border: 2px dashed #dfe2f5; border-radius: 14px; padding: .3rem; margin-bottom: .5rem; }
.choice.used { opacity: .3; }
.wiggle { animation: shake .3s; }
.flash { min-height: 6rem; }
.flashcard { display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: 1.2rem; animation: pop .3s; }
.flashcard .em { font-size: 4rem; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }

.sheet { position: fixed; inset: 0; background: #1d1b3a88; display: grid; place-items: center; padding: 1rem; overflow: auto; }
.card { background: var(--card); border-radius: 22px; padding: 1.3rem 1.4rem; width: min(560px, 100%); box-shadow: 0 20px 50px #0004; max-height: calc(100vh - 2rem); overflow: auto; }
.card.center { text-align: center; }
.card h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: .4rem 0 .8rem; }
.card h2 { margin: 0 0 .6rem; }
.card label { display: block; font-weight: 700; margin: .7rem 0; }
.card input:not([type]), .card input[maxlength], .card select { display: block; width: 100%; font: inherit; font-size: 1.1rem; padding: .55em .7em; border-radius: 12px; border: 2px solid #dfe2f5; margin-top: .3rem; }
fieldset { border: 2px solid #eef0ff; border-radius: 14px; margin: .8rem 0; }
legend { font-weight: 800; padding: 0 .4em; }
.privacy { background: #e9f7ef; border-radius: 12px; padding: .6rem .8rem; font-size: .92rem; }
.hint { font-size: .88rem; opacity: .75; margin: .3rem 0; }
.error { color: var(--no); font-weight: 700; min-height: 1.2em; }
.check { display: flex !important; gap: .5rem; align-items: center; font-weight: 600 !important; }
.check input { width: 1.3rem; height: 1.3rem; }
.swatches, .pets { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #dfe2f5; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.pet { display: flex; flex-direction: column; align-items: center; padding: .35em .5em; min-width: 4.2rem; background: #fff; border: 2px solid #eef0ff; }
.pet .em { font-size: 1.6rem; } .pet .lb { font-size: .75rem; }
.pet.on { border-color: var(--accent); background: #fff0f3; }
.photo-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.filebtn { display: inline-block !important; background: #eef0ff; padding: .55em 1em; border-radius: 14px; cursor: pointer; margin: 0 !important; }
.filebtn input { display: none; }
#p-crop { width: 240px; height: 240px; display: block; margin: .6rem auto; border-radius: 14px; background: #ddd; touch-action: none; cursor: grab; }
.zoom { text-align: center; } .zoom input { width: 70%; }
.greeting { font-weight: 800; color: var(--accent); letter-spacing: .05em; text-transform: uppercase; }
.starring { font-weight: 800; font-size: 1.2rem; color: #5a4ab0; margin-top: -.3rem; }
.giver { font-style: italic; font-size: 1.1rem; }
.stars { font-size: 2rem; color: #f2b400; letter-spacing: .1em; }
[hidden] { display: none !important; }
@media (max-width: 520px) { .choice { min-width: 3.8rem; font-size: 1rem; } .stones .choice { min-width: 4.2rem; } #game { max-height: 70vh; } }

.grownups { border: 2px solid #eef0ff; border-radius: 14px; padding: .5rem .8rem; margin: .8rem 0; }
.grownups summary { font-weight: 800; cursor: pointer; }
.grownups textarea { display: block; width: 100%; font: inherit; border: 2px solid #dfe2f5; border-radius: 12px; padding: .5em; margin-top: .3rem; }
.tables { display: flex; flex-wrap: wrap; gap: .3rem; }
.tt { display: inline-flex !important; gap: .25rem; align-items: center; background: #f6f4ff; border-radius: 10px; padding: .2em .5em; margin: 0 !important; font-weight: 700; }
.card.wide { width: min(980px, 100%); }
.hub .card { max-height: calc(100vh - 2rem); }
#hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .4rem 1rem; overflow-y: auto; }
#hub-grid .country { margin: .4rem 0; }
#hub-grid h3 { margin: .2rem 0 .4rem; }
.story-card { display: inline-flex; flex-direction: column; align-items: flex-start; gap: .15rem; width: 100%; min-height: 4.5rem; margin: 0 0 .5rem 0; background: #fff; border: 2px solid #eef0ff; text-align: left; vertical-align: top; }
.story-card:hover { border-color: var(--accent); }
.story-card .fest { font-size: .8rem; color: #8a6ad2; font-weight: 700; }
.story-card .done { color: #f2b400; }
.center-row { justify-content: center; }

#btn-recentre { background: #fffc; font-size: 1.1rem; padding: .3em .55em; }
#nav-hint { position: fixed; top: 4.2rem; left: 50%; transform: translateX(-50%); background: #000a; color: #fff; padding: .45em 1em; border-radius: 999px; font-weight: 700; font-size: .95rem; pointer-events: none; white-space: nowrap; animation: hintpulse 2.4s ease-in-out infinite; z-index: 5; }
@keyframes hintpulse { 50% { opacity: .65; } }
#explore { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(1rem, env(safe-area-inset-bottom)); width: min(620px, calc(100% - 1.5rem)); background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 30px #0003; padding: .8rem 1.1rem; }
#explore p { margin: 0 0 .4rem; font-size: 1.15rem; font-weight: 700; }
a.btn { display: inline-block; text-decoration: none; text-align: center; }
#f-buy { background: #e85d75; color: #fff; padding: .7em 1.3em; border-radius: 999px; font-weight: 800; }
@media (max-width: 520px) { #nav-hint { font-size: .8rem; top: 3.8rem; } }

/* quest tracker, guide arrow, voice */
#found { background: #fffc; border-radius: 999px; padding: .2em .65em; font-weight: 800; font-size: .95rem; }
#found.pop { animation: questpop .6s ease-out; }
#btn-level { background: #fffc; font-weight: 800; font-size: .9rem; padding: .3em .7em; border-radius: 999px; white-space: nowrap; }
#btn-level.l3 { background: #ffe07a; } #btn-level.l4 { background: #e85d75; color: #fff; }
.pkgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; }
.pkg { display: flex; gap: .35rem; align-items: flex-start; border: 2px solid #e2ddf0; border-radius: 12px; padding: .35rem .5rem; font-size: .85rem; cursor: pointer; }
.pkg:has(input:checked) { border-color: var(--accent); background: #fff0f3; }
.pkg small { display: block; color: #6b6480; font-size: .72rem; }
#p-pack-box[disabled] { opacity: .55; }
/* puzzles */
.choices.puz { flex-direction: column; align-items: center; gap: .45rem; }
.puz-status { font-weight: 700; font-size: .95rem; text-align: center; min-height: 1.3em; }
.puz-board { display: grid; gap: 4px; }
.puz-extra { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.wordle .puz-board { display: flex; flex-direction: column; gap: 4px; }
.wg-row { display: flex; gap: 4px; justify-content: center; }
.wg-cell { width: 2.4rem; height: 2.4rem; border: 2px solid #d5d0e5; border-radius: 8px; display: grid; place-items: center; font-weight: 900; font-size: 1.25rem; background: #fff; }
.wg-cell.yes, .wg-key.yes { background: #4caf6a; color: #fff; border-color: #4caf6a; }
.wg-cell.near, .wg-key.near { background: #f2c230; color: #222; border-color: #f2c230; }
.wg-cell.no, .wg-key.no { background: #9a96a8; color: #fff; border-color: #9a96a8; }
.wordle .puz-extra { width: 100%; max-width: 480px; }
.wg-kb { display: flex; flex-direction: column; gap: 4px; flex: 1 1 100%; width: 100%; }
.wg-krow { display: flex; gap: 3px; justify-content: center; }
.wg-key { flex: 1; min-width: 0; padding: .55em 0; border-radius: 7px; border: 0; background: #e9e6f2; font-weight: 800; font-size: .9rem; }
.wg-key.wide { flex: 1.6; font-size: .8rem; }
.gem, .tile15, .sq { width: min(11vw, 2.7rem); height: min(11vw, 2.7rem); border: 0; border-radius: 9px; background: #f1eef8; font-size: min(6.5vw, 1.45rem); display: grid; place-items: center; padding: 0; }
.gems .gem.sel { outline: 3px solid var(--accent); background: #ffe3ea; }
.gems .gem.pop { transform: scale(1.25); opacity: .35; transition: .2s; }
.gem.hint, .tile15.hint { outline: 3px dashed #f2c230; }
.tile15 { background: #6a5acd; color: #fff; font-weight: 900; font-size: 1.3rem; }
.tile15.home { background: #4caf6a; } .tile15.gap { background: transparent; }
.sq.given { background: #e9e6f2; } .sq.open { background: #fff; border: 2px dashed #c9c3dc; }
.sq.rb { box-shadow: 4px 0 0 #6a5acd; } .sq.bb { box-shadow: 0 4px 0 #6a5acd; } .sq.rb.bb { box-shadow: 4px 0 0 #6a5acd, 0 4px 0 #6a5acd, 4px 4px 0 #6a5acd; }
.sudoku .puz-board { gap: 6px; } .sq.bad { background: #ffd2d8; }
.pal { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; }
.palb { font-size: 1.35rem; padding: .25em .5em; border-radius: 10px; border: 2px solid #e2ddf0; background: #fff; }
.palb.on { border-color: var(--accent); background: #fff0f3; }
.code-hist { display: flex; flex-direction: column; gap: 3px; max-height: 9rem; overflow-y: auto; }
.code-row { display: flex; gap: .8rem; justify-content: space-between; font-size: 1.1rem; background: #f7f5fc; border-radius: 8px; padding: .1rem .6rem; }
.code-cur { display: flex; gap: 6px; justify-content: center; margin: .3rem 0; }
.code-slot { width: 2.6rem; height: 2.6rem; border: 2px dashed #c9c3dc; border-radius: 10px; display: grid; place-items: center; font-size: 1.4rem; background: #fff; }
.puz-skip { font-size: .85rem; }
@media (max-height: 760px) { .wg-cell { width: 2rem; height: 2rem; font-size: 1.05rem; } .wg-key { padding: .4em 0; } }
#btn-voice { background: #fffc; font-size: 1.1rem; padding: .3em .55em; }
#btn-voice.off { opacity: .55; }
#quest { position: fixed; top: calc(max(.5rem, env(safe-area-inset-top)) + 2.9rem); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 1.2rem); background: #1f1b3de6; color: #fff; border-radius: 16px; padding: .45rem .9rem .5rem; text-align: center; display: flex; flex-direction: column; gap: .1rem; pointer-events: none; z-index: 4; box-shadow: 0 6px 18px #0004; border: 2px solid #ffd76a; }
#quest[hidden] { display: none; }
#q-chapter { font-size: .78rem; opacity: .85; font-weight: 600; }
#q-goal { font-size: 1.08rem; }
#quest.new { animation: questpop .7s ease-out; }
@keyframes questpop { 0% { transform: translateX(-50%) scale(.85); } 50% { transform: translateX(-50%) scale(1.08); } 100% { transform: translateX(-50%) scale(1); } }
#q-steps { font-size: .7rem; letter-spacing: .1em; }
#q-steps i { font-style: normal; opacity: .45; margin: 0 .25em; }
#q-steps i.done { opacity: 1; color: #8df0a8; }
#q-steps i.now { opacity: 1; color: #ffd76a; font-weight: 800; }
#guide { position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none; font-weight: 900; color: #ffd76a; text-shadow: 0 2px 0 #0008, 0 0 10px #000a; }
#guide.on { font-size: 2.4rem; animation: guidebob .7s ease-in-out infinite alternate; }
#guide.edge { font-size: 1.15rem; background: #1f1b3de6; border: 2px solid #ffd76a; border-radius: 999px; padding: .4em .9em; text-shadow: none; top: 45%; animation: hintpulse 1.2s ease-in-out infinite; }
#guide.edge.l { left: .5rem; } #guide.edge.r { left: auto; right: .5rem; }
@keyframes guidebob { to { margin-top: -14px; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%); width: max-content; top: calc(max(.5rem, env(safe-area-inset-top)) + 8.2rem); max-width: min(560px, calc(100% - 1.5rem)); background: #fff; border-radius: 16px; padding: .55rem 1rem; font-weight: 700; box-shadow: 0 8px 22px #0004; z-index: 6; pointer-events: none; text-align: center; }
#nav-hint { top: auto; bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 7.2rem); }
#guide.edge { pointer-events: auto; cursor: pointer; }
#x-who { display: block; color: var(--accent); margin-bottom: .15rem; }
#x-who:empty { display: none; }
#again, #g-again { font-size: .9rem; padding: .35em .7em; }
.g-head #g-again { margin-left: auto; }
.choice.reading { outline: 4px solid #ffd76a; outline-offset: 2px; }
@media (max-width: 520px) { #q-goal { font-size: .95rem; } #q-chapter { font-size: .7rem; } #title { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

#stars, #found, #btn-level { white-space: nowrap; }
.lv-num { display: none; }
@media (max-width: 560px) {
  #hud { gap: .3rem; padding-left: .5rem; padding-right: .5rem; }
  #title { display: none; }
  #stars, #found { font-size: .82rem; padding: .2em .5em; }
  #btn-level, #btn-voice, #btn-recentre, #btn-settings { font-size: .85rem; padding: .3em .45em; }
  .lv-stars, .lv-name { display: none; } .lv-num { display: inline; }
  #hud > :first-child:not(#title) { margin-left: auto; }
  #stars { margin-left: auto; }
}
