/* The game: the map of nine floating islands, the HUD, and every world's screen. */
body.game { min-height: 100svh; background: var(--mint); overflow-x: hidden; }
body.game.in-level { overflow: hidden; }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px var(--gutter); pointer-events: none; }
.hud > * { pointer-events: auto; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 4px; border: var(--line); border-radius: 999px; background: var(--white); box-shadow: 0 3px 0 var(--ink); cursor: pointer; text-align: left; }
.me #meAvatar { width: 44px; height: 44px; border-radius: 50%; background: var(--sun-2); border: var(--line-2); display: grid; place-items: center; overflow: hidden; }
.me #meAvatar svg { width: 40px; margin-top: 6px; }
.me b { display: block; font: 800 16px/1.1 var(--display); }
.me small { font: 700 12px/1 var(--mono); color: var(--ink-2); }
.hud-right { display: flex; gap: 8px; align-items: center; }
.ask-btn { min-height: 48px; }

/* ---------- the map ---------- */
.map-wrap { min-height: 100svh; display: grid; place-items: center; padding: 76px 10px 120px; }
.map { position: relative; width: min(1100px, 96vw, calc((100svh - 200px) * 1.6)); aspect-ratio: 16 / 10; }
.map.tall { width: min(560px, 96vw); aspect-ratio: 10 / 16.5; }
.map svg.route { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cloud { position: absolute; width: 90px; height: 34px; background: var(--white); border: var(--line-2); border-radius: 999px; opacity: .9; animation: drift 30s linear infinite; }
.cloud::before { content: ''; position: absolute; width: 44px; height: 40px; left: 18px; top: -20px; background: var(--white); border: var(--line-2); border-bottom: 0; border-radius: 50% 50% 0 0; }
@keyframes drift { from { transform: translateX(-30px); } 50% { transform: translateX(30px); } to { transform: translateX(-30px); } }
.isle { position: absolute; transform: translate(-50%, -50%); width: clamp(86px, 14%, 150px); background: none; border: 0; padding: 0; cursor: pointer; display: grid; justify-items: center; gap: 2px; animation: float 4s ease-in-out infinite; }
.map.tall .isle { width: clamp(86px, 25%, 140px); }
.isle:nth-child(odd) { animation-delay: -2s; }
@keyframes float { 0%, 100% { margin-top: 0; } 50% { margin-top: -8px; } }
.isle svg { width: 100%; overflow: visible; }
.isle .lm { position: absolute; top: -2%; left: 50%; transform: translateX(-50%); font-size: clamp(30px, 3.4vw, 46px); line-height: 1; filter: drop-shadow(0 3px 0 rgba(16, 34, 61, .25)); transition: transform .2s var(--spring); }
.isle:hover .lm, .isle:focus-visible .lm { transform: translateX(-50%) translateY(-6px) scale(1.1); }
.isle .num { position: absolute; top: 34%; left: 6%; width: 32px; height: 32px; border-radius: 50%; border: var(--line-2); background: var(--white); font: 800 16px/28px var(--display); text-align: center; }
.isle .nm { background: var(--white); border: var(--line-2); border-radius: 999px; padding: 3px 10px; font: 800 13px/1.2 var(--display); white-space: nowrap; box-shadow: 0 2px 0 var(--ink); }
.isle .st { font-size: 14px; letter-spacing: 1px; color: var(--ink); min-height: 18px; }
.isle .st i { font-style: normal; color: var(--sun); -webkit-text-stroke: 1px var(--ink); }
.isle.locked { filter: saturate(.25); }
.isle.locked .num { background: var(--paper-2); }
.isle.current .nm { background: var(--sun); }
.isle.current::after { content: ''; position: absolute; inset: 10% 0 auto; margin: auto; width: 70%; aspect-ratio: 2 / 1; border: 3px dashed var(--ink); border-radius: 50%; animation: spin 8s linear infinite; pointer-events: none; opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }
.map .walker { position: absolute; width: clamp(46px, 6%, 70px); transform: translate(-50%, -100%); transition: left .9s var(--spring), top .9s var(--spring); pointer-events: none; z-index: 3; }
.map.tall .walker { width: clamp(46px, 12%, 64px); }

.banner { position: fixed; z-index: 15; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; background: var(--white); border: var(--line); border-radius: 22px; box-shadow: 0 5px 0 var(--ink); }
.banner .bp { width: 58px; flex: none; }
.banner p { font-weight: 600; font-size: 16px; line-height: 1.35; }

/* ---------- overlays ---------- */
.overlay { position: fixed; z-index: 50; inset: 0; background: rgba(16, 34, 61, .55); display: grid; place-items: center; padding: 14px; overflow-y: auto; }
.sheet { position: relative; width: min(760px, 100%); max-height: calc(100svh - 28px); overflow-y: auto; background: var(--paper); border: var(--line); border-radius: 28px; box-shadow: 0 8px 0 var(--ink); padding: clamp(20px, 4vw, 34px); }
.sheet.narrow { width: min(520px, 100%); }
.sheet h2 { font-size: clamp(28px, 4vw, 38px); margin: 8px 0 10px; }
.sheet .lead { font-size: 17px; font-weight: 600; color: var(--ink-2); }
.x-btn { position: absolute; top: 14px; right: 14px; }
.title-card { display: grid; justify-items: center; text-align: center; gap: 12px; }
.title-card .pip-svg { width: 170px; }

.setup .colors { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.setup .colors button { width: 52px; height: 52px; border-radius: 50%; border: var(--line); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.setup .colors button[aria-pressed="true"] { outline: 4px solid var(--ink); outline-offset: 3px; }
.setup .preview { width: 150px; margin: 0 auto; }
.setup .namebox { display: flex; gap: 10px; align-items: center; margin: 8px 0 20px; }
.setup .namebox output { flex: 1; min-height: 54px; display: flex; align-items: center; padding: 0 16px; border: var(--line); border-radius: 16px; background: var(--white); font: 800 20px/1 var(--display); }

/* ---------- a world ---------- */
.level { position: fixed; z-index: 30; inset: 0; background: var(--paper); display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.lv-top { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); border-bottom: var(--line); background: var(--white); }
.lv-top h3 { font-size: clamp(18px, 2.4vw, 24px); flex: 1; }
.lv-top .dots { display: flex; gap: 5px; }
.lv-top .dots i { width: 12px; height: 12px; border-radius: 50%; border: var(--line-2); background: var(--white); }
.lv-top .dots i.on { background: var(--leaf); }
.lv-top .dots i.bad { background: var(--pink); }
.lv-top .hearts { font-size: 20px; letter-spacing: 2px; }
.lv-body { overflow-y: auto; padding: clamp(14px, 3vw, 28px) var(--gutter) 40px; }
.lv-in { width: min(900px, 100%); margin: 0 auto; display: grid; gap: 18px; }

.say { display: flex; align-items: flex-end; gap: 12px; }
.say .who { width: clamp(70px, 10vw, 96px); flex: none; }
.say .bubble { position: relative; flex: 1; background: var(--white); border: var(--line); border-radius: 22px; padding: 14px 18px; font-weight: 600; font-size: clamp(16px, 1.8vw, 19px); line-height: 1.4; box-shadow: 0 4px 0 var(--ink); }
.say .bubble::before { content: ''; position: absolute; left: -12px; bottom: 18px; width: 18px; height: 18px; background: var(--white); border-left: var(--line); border-bottom: var(--line); transform: rotate(45deg); }
.say.glitchy .bubble { background: var(--grape-2); }
.say.glitchy .bubble::before { background: var(--grape-2); }

.big-item { display: grid; justify-items: center; gap: 6px; padding: 24px; background: var(--white); border: var(--line); border-radius: 28px; box-shadow: 0 6px 0 var(--ink); }
.big-item .emo { font-size: clamp(76px, 12vw, 120px); line-height: 1; }
.big-item b { font: 800 24px/1 var(--display); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.15; min-height: 64px; }
.bins { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bin { background: var(--white); border: var(--line-2); border-radius: 18px; padding: 10px 12px; min-height: 70px; }
.bin b { font: 800 15px/1 var(--display); display: block; margin-bottom: 6px; }
.bin span { font-size: 28px; margin-right: 2px; }

.thinking { display: flex; align-items: center; gap: 10px; font: 700 14px/1 var(--mono); }
.thinking .bar { flex: 1; height: 18px; border: var(--line-2); border-radius: 999px; background: var(--white); overflow: hidden; }
.thinking .bar i { display: block; height: 100%; width: 0; background: var(--leaf); transition: width 1s ease; }

.sentence { font: 800 clamp(28px, 4.4vw, 44px)/1.1 var(--display); text-align: center; padding: 26px 16px; background: var(--white); border: var(--line); border-radius: 26px; box-shadow: 0 6px 0 var(--ink); }
.sentence u { text-decoration: none; display: inline-block; min-width: 3ch; border-bottom: 5px solid var(--leaf); color: var(--leaf); }
.bars { display: grid; gap: 10px; }
.bars .row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 54px; gap: 10px; align-items: center; font-weight: 700; }
.bars .track { height: 26px; border: var(--line-2); border-radius: 10px; background: var(--white); overflow: hidden; }
.bars .track i { display: block; height: 100%; width: 0; background: var(--sky); transition: width .9s var(--spring); }
.bars .row.top .track i { background: var(--leaf); }
.bars .n { font: 700 13px/1 var(--mono); text-align: right; }

.critters { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.crit { position: relative; background: var(--white); border: var(--line-2); border-radius: 16px; padding: 6px 6px 4px; display: grid; justify-items: center; gap: 2px; font: 700 12px/1.1 var(--mono); }
.crit svg { width: 64px; }
.crit .tag { padding: 3px 7px; border-radius: 999px; border: 2px solid var(--ink); }
.crit .tag.y { background: var(--leaf-2); }
.crit .tag.n { background: var(--paper-2); }
.crit.ok { background: var(--leaf-2); }
.crit.wrong { background: var(--pink-2); }
button.crit { cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform .12s; }
button.crit[aria-pressed="true"] { background: var(--sun); transform: translateY(-3px); }
.score { font: 800 22px/1 var(--display); text-align: center; }

/* stamp cards */
.card-zone { display: grid; justify-items: center; }
.msg { width: min(560px, 100%); background: var(--white); border: var(--line); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; }
.msg .mhead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: var(--line-2); background: var(--paper-2); font-weight: 700; }
.msg .mhead .av { width: 34px; height: 34px; border-radius: 50%; border: var(--line-2); display: grid; place-items: center; background: var(--white); font-size: 18px; }
.msg .mbody { padding: 16px; display: grid; gap: 10px; font-size: 18px; font-weight: 600; line-height: 1.4; }
.msg .q { align-self: end; justify-self: end; background: var(--sky); border: var(--line-2); border-radius: 18px 18px 4px 18px; padding: 8px 14px; max-width: 85%; }
.msg .a { justify-self: start; background: var(--leaf-2); border: var(--line-2); border-radius: 18px 18px 18px 4px; padding: 10px 14px; max-width: 92%; }
.msg .scene { font-size: 70px; text-align: center; background: var(--sun-2); border: var(--line-2); border-radius: 14px; padding: 12px; line-height: 1; letter-spacing: 6px; }
.msg .meta { font-size: 14px; color: var(--muted); font-weight: 700; }
.msg .draft { background: var(--paper); border: var(--line-2); border-radius: 14px; padding: 12px 14px; }
.msg .sendrow { display: flex; justify-content: flex-end; font: 700 12px/1 var(--mono); color: var(--muted); }
.msg.tapping .mbody { cursor: crosshair; }
.msg .tl { border-radius: 6px; transition: background .2s; }
.msg.tapping .tl:hover { background: var(--sun-2); }
.msg .tl.found { background: var(--sun); outline: 2px solid var(--ink); }
.msg .tl.show { background: var(--pink-2); outline: 2px dashed var(--ink); }
.stamp-mark { position: absolute; right: 14px; top: 56px; padding: 8px 14px; border: 4px solid currentColor; border-radius: 10px; font: 800 22px/1 var(--display); transform: rotate(-10deg); background: rgba(255, 255, 255, .85); }
.stamp-mark.good { color: var(--leaf); }
.stamp-mark.bad { color: #d6114f; }
.why { background: var(--sun-2); border: var(--line-2); border-radius: 16px; padding: 12px 16px; font-weight: 700; }
.timer { height: 14px; border: var(--line-2); border-radius: 999px; overflow: hidden; background: var(--white); width: min(560px, 100%); justify-self: center; }
.timer i { display: block; height: 100%; background: var(--grape); width: 100%; }

/* prompt workshop */
.pbox { background: var(--ink); color: #8ff7c4; border: var(--line); border-radius: 18px; padding: 14px 16px; font: 700 17px/1.4 var(--mono); min-height: 56px; }
.pbox::before { content: '> '; color: var(--sun); }
.outbox { background: var(--white); border: var(--line); border-radius: 18px; padding: 16px 18px; font-size: 19px; font-weight: 600; line-height: 1.5; min-height: 90px; white-space: pre-wrap; box-shadow: 0 5px 0 var(--ink); }
.outbox .ai-tag { display: inline-block; font: 700 11px/1 var(--mono); letter-spacing: .1em; padding: 4px 8px; border: var(--line-2); border-radius: 999px; background: var(--grape-2); margin-bottom: 8px; }
.tiles { display: grid; gap: 12px; }
.tiles .row b { display: block; font: 700 12px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.tiles .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { border: var(--line-2); border-radius: 14px; background: var(--white); padding: 10px 14px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform .12s; }
.tile[aria-pressed="true"] { background: var(--sun); transform: translateY(-2px); }

/* finish */
.finish .stars { font-size: 46px; letter-spacing: 6px; }
.finish .stars i { font-style: normal; color: var(--sun); -webkit-text-stroke: 2px var(--ink); display: inline-block; }
.finish .stars i.off { color: var(--paper-2); }
.rule-card { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--white); border: var(--line); border-radius: 18px; padding: 12px 16px; box-shadow: 0 4px 0 var(--ink); }
.rule-card .ic { font-size: 30px; }
.rule-card small { font: 700 11px/1 var(--mono); letter-spacing: .1em; color: var(--leaf); text-transform: uppercase; }
.rule-card p { font-weight: 700; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* paywall */
.locked-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 16px 0; }
.lk { background: var(--white); border: var(--line-2); border-radius: 14px; padding: 8px 10px; font-size: 13px; }
.lk b { display: block; font: 800 15px/1.15 var(--display); }
.lk small { color: var(--muted); font-weight: 600; }
.price-card { background: var(--sun); border: var(--line); border-radius: 22px; padding: 18px; display: grid; gap: 10px; justify-items: start; box-shadow: 0 5px 0 var(--ink); }
.price-card .amt { font: 800 44px/1 var(--display); }
.price-card .amt small { font: 700 16px/1 var(--body); }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-weight: 700; }
.ticks li::before { content: '✓ '; font-weight: 800; }
.gate { display: grid; gap: 12px; justify-items: center; text-align: center; }
.gate .q-text { font: 800 40px/1 var(--display); }
.gate-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(400px, 100%); }
.gate-opts button { min-height: 58px; border: var(--line); border-radius: 16px; background: var(--white); font: 800 22px/1 var(--display); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }

/* Ask Pip */
.chat { display: grid; grid-template-rows: auto 1fr auto; gap: 10px; height: min(640px, calc(100svh - 60px)); }
.chat-log { overflow-y: auto; display: grid; align-content: start; gap: 10px; padding: 4px; }
.chat-log .m { max-width: 86%; padding: 10px 14px; border: var(--line-2); border-radius: 18px; font-weight: 600; line-height: 1.45; white-space: pre-wrap; }
.chat-log .m.kid { justify-self: end; background: var(--sky); border-bottom-right-radius: 4px; }
.chat-log .m.pip { justify-self: start; background: var(--white); border-bottom-left-radius: 4px; }
.chat-log .m.warn { justify-self: center; background: var(--pink-2); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: var(--line-2); border-radius: 999px; background: var(--white); padding: 6px 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.chat form { display: flex; gap: 8px; }
.chat form .field { flex: 1; min-width: 0; }
.chat .note { font: 700 11px/1.3 var(--mono); color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .hud { padding: 8px 10px; }
  .me { padding-right: 10px; }
  .me b { font-size: 14px; }
  .ask-btn span { display: none; }
  .hud-right .icon-btn { width: 42px; height: 42px; }
  .choices.three { grid-template-columns: 1fr; }
  .say .bubble { font-size: 16px; }
  .msg .scene { font-size: 54px; }
  .banner p { font-size: 14px; }
  .banner .bp { width: 46px; }
  .lv-top { gap: 8px; }
  .lv-top h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }
  .lv-top .dots { gap: 3px; flex-wrap: wrap; max-width: 40%; justify-content: flex-end; }
  .lv-top .dots i { width: 9px; height: 9px; border-width: 1.5px; }
}

@media print {
  body * { visibility: hidden; }
  .cert, .cert * { visibility: visible; }
  .overlay { background: none; position: absolute; }
  .cert { position: fixed; inset: 0; padding: 40px; }
  .no-print { display: none !important; }
}
