/* Draw, Ellie, Draw! UI. Paper-sticker panels: opaque, high contrast, 2px violet outline. */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
:root {
  --ink: #2B2A4C;          /* text on panels (13:1 on --panel) */
  --violet: #4B4370;       /* gel-pen plum outlines (style B) */
  --panel: #FFFBF4;
  --paper: #F3EBDC;
  --wood: #B98B5E;
  --teal: #0F766E;         /* primary buttons, white text 5.5:1 */
  --teal-dark: #0B5B55;
  --sun: #FFC93C;          /* focus ring, star fills */
  --surface: #FFFBF4;      /* cards (same as --panel) */
  --muted: #4A4870;
  --line: #4B4370;         /* outlines (paper-sticker violet) */
  --coral-hi: #E8503F;
  --radius: 24px;
  --coral: #C8392B;        /* primary action (AA with white text) */
  --pen-marker: #7B6BC4;
  --pen-crayon: #E8503F;
  --pen-pencil: #9C8420;
  --pen: var(--pen-marker);
  --ui-pl: 0px; --ui-pt: 0px; --ui-pw: 100vw; --ui-ph: 100vh;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: "Nunito", ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Fredoka", "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --shadow: 3px 3px 0 #F6C9D8;   /* pastel, printed slightly off-register */
  --pink: #F6C9D8; --lilac: #D9CCF5; --mint: #BFE6D8; --butter: #FFE9A8;
  --font-hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Marker Felt", cursive;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--wood);
  overscroll-behavior: none; touch-action: none; font-family: var(--font); color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body { font-size: 16px; line-height: 1.3; position: fixed; inset: 0; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.noscript { position: fixed; inset: 0; margin: 0; padding: 24px; background: var(--paper); color: var(--ink); font-size: 20px; text-align: center; z-index: 99; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3, button, .plabel, .tot, .badge, .toast, .chip, .ink .lbl, .tip { font-family: var(--font-head); }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; min-width: 52px; padding: 8px 22px; border-radius: 999px;
  border: 2px solid var(--violet); background: var(--panel); color: var(--ink);
  font-size: 18px; font-weight: 700; line-height: 1.1; text-align: center;
  box-shadow: var(--shadow); pointer-events: auto;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn svg { width: 24px; height: 24px; flex: none; }
.btn:active, .btn.pressed { transform: translate(2px, 2px) scale(.96); box-shadow: 1px 1px 0 var(--pink); }
.btn.primary { background-color: var(--coral); color: #fff; border-color: var(--violet);
  background-image: radial-gradient(circle at 16% 28%, rgba(255,255,255,.75) 0 1.5px, transparent 2.2px), radial-gradient(circle at 84% 66%, rgba(255,255,255,.6) 0 1.5px, transparent 2.2px), radial-gradient(circle at 60% 18%, rgba(255,255,255,.5) 0 1px, transparent 1.8px); }
.btn.big { min-height: 68px; padding: 10px 34px; font-size: 24px; border-radius: 999px; }
.btn.big svg { width: 32px; height: 32px; }
.btn.round { border-radius: 50%; padding: 0; width: 52px; height: 52px; }
.btn.small { min-height: 48px; font-size: 16px; padding: 6px 16px; }
.btn.danger { background: #FDE9E4; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; box-shadow: none; cursor: default; }
.btn[disabled]:active { transform: none; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--sun); outline-offset: 3px; box-shadow: 0 0 0 3px var(--ink);
}
a { color: inherit; }

/* ---------- Screens ---------- */
#screens, #overlays { position: absolute; inset: 0; pointer-events: none; }
#hud { z-index: 1; isolation: isolate; }
#screens { z-index: 2; isolation: isolate; }
#overlays { z-index: 3; isolation: isolate; }
.screen {
  position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; pointer-events: auto; touch-action: pan-y;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  display: flex; flex-direction: column; align-items: center;
  animation: fadein .18s ease both;
}
.screen > .inner { margin: auto; width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.screen.paper {
  background: radial-gradient(circle, rgba(75,67,112,.2) 1px, transparent 1.5px) 0 0 / 16px 16px, var(--paper);
}
.screen.dim { background: rgba(43, 42, 76, .55); }
.card {
  background: var(--panel); border: 2px solid var(--violet); border-radius: 24px; box-shadow: 4px 5px 0 var(--pink); position: relative;
  padding: 20px 22px; width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  pointer-events: auto; text-align: center;
}
h1 { font-size: clamp(34px, 9vw, 56px); font-weight: 700; line-height: 1.05; color: var(--violet); }
h2 { font-size: clamp(24px, 6vw, 32px); font-weight: 700; line-height: 1.1; }
h3 { font-size: 20px; font-weight: 700; }
.tagline { font-size: 20px; font-weight: 600; }
.muted { color: #4A4870; }
.text { font-size: 18px; line-height: 1.4; max-width: 34em; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.fine { font-size: 16px; }
.ellie-canvas { display: block; }

/* title */
.title-top { position: absolute; top: calc(10px + var(--sat)); right: calc(10px + var(--sar)); display: flex; gap: 8px; }
.title-foot { font-size: 16px; max-width: 30em; }
.title-foot a { font-weight: 700; }

/* loading */
.pbar { width: min(320px, 80vw); height: 22px; border-radius: 12px; border: 2px solid var(--violet); background: var(--panel); overflow: hidden; }
.pbar > i { display: block; height: 100%; width: 0; background: var(--pen-marker); border-radius: 10px; transition: width .15s linear; }

/* map */
.map { max-width: 760px; }
.map-head { width: 100%; display: flex; align-items: center; gap: 10px; }
.map-head h1 { font-size: clamp(22px, 5.5vw, 32px); flex: 1; text-align: center; }
.map-top { width: 100%; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.slots { display: flex; gap: 8px; }
.slot {
  width: 56px; height: 56px; border-radius: 14px; border: 2px solid var(--violet); background: #fff; display: grid; place-items: center;
}
.slot svg { width: 40px; height: 40px; }
.slot.missing { border-style: dashed; background: transparent; color: #4A4870; }
.chapter { width: 100%; background: var(--panel); border: 2px solid var(--violet); border-radius: 22px; padding: 14px; box-shadow: var(--shadow); text-align: left; }
.chapter.locked { background: #EDE6D6; }
.chapter-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chapter-head .ct { flex: 1; min-width: 0; }
.chapter-head .ct small { display: block; font-size: 14px; font-weight: 600; color: #4A4870; }
.chapter-head .ct h2 { font-size: 22px; }
.pages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pagebtn { min-height: 64px; padding: 6px 2px; flex-direction: column; gap: 2px; border-radius: 16px; font-size: 22px; }
.pagebtn .stars { display: flex; gap: 1px; }
.pagebtn .stars svg { width: 15px; height: 15px; }
.pagebtn.locked { background: #EDE6D6; border-style: dashed; box-shadow: none; }
.pagebtn svg.lock { width: 24px; height: 24px; }
.tot { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 700; }
.tot svg { width: 22px; height: 22px; }

/* stars */
.star-on { fill: var(--sun); stroke: var(--violet); stroke-width: 1.6; stroke-linejoin: round; }
.star-off { fill: #fff; stroke: var(--violet); stroke-width: 1.6; stroke-linejoin: round; stroke-dasharray: 2.6 2; opacity: .85; }
.bigstars { display: flex; gap: 8px; justify-content: center; }
.bigstars svg { width: clamp(56px, 18vw, 84px); height: clamp(56px, 18vw, 84px); overflow: visible; }
.bigstars .s .star-on { display: none; }
.bigstars .s.on .star-on { display: inline; }
.bigstars .s.on .star-off { display: none; }
.bigstars .s.on { animation: pop .42s cubic-bezier(.3, 1.6, .5, 1) both; transform-origin: 50% 55%; }
.bigstars .s { transform-box: fill-box; transform-origin: center; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; border-radius: 999px; background: var(--sun); border: 2px solid var(--violet); font-weight: 700; font-size: 16px; }
.badge svg { width: 18px; height: 18px; }
.found { display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border: 2px solid var(--violet); border-radius: 18px; padding: 8px 14px; width: 100%; }
.found .slot { flex: none; }
.found b { display: block; font-size: 18px; }
.found span { font-size: 16px; }
.achs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.achs li { display: flex; align-items: center; gap: 8px; background: #FFF1C2; border: 2px solid var(--violet); border-radius: 14px; padding: 6px 12px; font-weight: 700; font-size: 16px; text-align: left; }
.achs li svg { width: 22px; height: 22px; flex: none; }
.stats { display: flex; gap: 8px 18px; flex-wrap: wrap; justify-content: center; font-size: 17px; font-weight: 600; }
.msg { font-size: 18px; min-height: 2.6em; display: flex; align-items: center; justify-content: center; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; width: 100%; }
.pencard { display: flex; align-items: center; gap: 14px; background: #fff; border: 2px solid var(--violet); border-radius: 18px; padding: 10px 14px; text-align: left; width: 100%; }
.pencard .pi { flex: none; }
.pencard b { display: block; font-size: 20px; }
.chdone { animation: none; }

/* ---------- Settings / pause ---------- */
.overlay { position: absolute; inset: 0; pointer-events: auto; background: rgba(43, 42, 76, .6); display: flex; padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)); overflow-y: auto; animation: fadein .15s ease both; touch-action: pan-y; }
.overlay .card { margin: auto; max-width: 440px; }
.overlay .card .btn { width: 100%; max-width: 360px; }
.overlay .card .btn.round { width: 52px; }
.setrow { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; text-align: left; }
.setrow > label, .setrow > .lbl { flex: 1; font-size: 18px; font-weight: 700; min-width: 0; }
.setrow input[type=range] { flex: 1.4; min-width: 0; height: 48px; accent-color: var(--teal); background: transparent; cursor: pointer; touch-action: pan-y; }
input[type=range] { -webkit-appearance: none; appearance: none; }
input[type=range]::-webkit-slider-runnable-track { height: 14px; border-radius: 8px; background: #fff; border: 2px solid var(--violet); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 8px; background: #fff; border: 2px solid var(--violet); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%; background: var(--teal); border: 3px solid var(--violet); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--teal); border: 3px solid var(--violet); }
.overlay .card .switch, .switch { width: 104px; max-width: 104px; min-height: 48px; padding: 4px 8px 4px 6px; justify-content: space-between; gap: 6px; font-size: 16px; }
.switch .knob { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid var(--violet); display: grid; place-items: center; flex: none; }
.switch .knob svg { width: 16px; height: 16px; }
.switch[aria-checked="true"] { background: var(--teal); color: #fff; padding: 4px 6px 4px 12px; }
.seg { display: flex; gap: 8px; flex: 1.4; }
.overlay .card .seg .btn { min-width: 0; flex: 1; padding: 6px 4px; font-size: 15px; gap: 4px; }
.seg .btn[aria-pressed="true"] { background: var(--teal); color: #fff; }
.seg .btn[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--sun); }
hr { width: 100%; border: 0; border-top: 2px dashed rgba(59, 52, 112, .35); margin: 2px 0; }
.holdbtn { position: relative; overflow: hidden; }
.holdbtn .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #F3A395; z-index: 0; }
.holdbtn > * { position: relative; z-index: 1; }

/* ---------- Toasts ---------- */
#toasts { position: absolute; top: calc(8px + var(--sat)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
.toast {
  max-width: min(92vw, 520px); padding: 10px 18px; border-radius: 18px; background: var(--panel); border: 2px solid var(--violet);
  box-shadow: var(--shadow); font-size: 17px; font-weight: 700; text-align: center; color: var(--ink);
  animation: toastin .18s ease both;
}
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity .18s ease, transform .18s ease; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 1; isolation: isolate; }
#hud .bar { position: absolute; display: flex; pointer-events: none; }
#hud .bar > *, #hud .bar .grp > * { pointer-events: auto; }
#hud .grp { display: flex; gap: 6px; pointer-events: none; }
.hbtn { min-width: 48px; min-height: 48px; width: 48px; height: 48px; padding: 0; border-radius: 16px; font-size: 14px; }
.hbtn svg { width: 26px; height: 26px; }
.hbtn.on, .hbtn[aria-pressed="true"] { background: #fff; border-width: 4px; border-color: var(--violet); box-shadow: 0 0 0 3px var(--sun), var(--shadow); }
.hbtn.ff { width: auto; min-width: 48px; padding: 0 8px; gap: 2px; font-weight: 700; }
.hbtn.ff svg { width: 22px; height: 22px; }
.hbtn.pulse { animation: pulse 1.1s ease-in-out infinite; }
.pen { width: 52px; height: 52px; min-width: 52px; min-height: 52px; padding: 0; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; }
.pen canvas, .pen > svg.pi { width: 30px; height: 30px; display: block; }
.pen .line { width: 34px; height: 8px; display: block; }
.pen .chk { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--teal); border: 2px solid var(--violet); display: none; place-items: center; }
.pen .chk svg { width: 12px; height: 12px; }
.pen[aria-pressed="true"] { background: #fff; border-width: 4px; box-shadow: 0 0 0 3px var(--sun), var(--shadow); }
.pen[aria-pressed="true"] .chk { display: grid; }
.tray { display: flex; gap: 6px; padding: 5px; border-radius: 20px; background: rgba(255, 248, 238, .92); border: 2px solid var(--violet); }
.tray .btn { box-shadow: none; }
.tray.dis .pen, .tray.dis .hbtn { opacity: .55; }

.go {
  width: 76px; height: 76px; min-width: 76px; min-height: 76px; padding: 0; border-radius: 50%; flex-direction: column; gap: 0;
  background: var(--teal); color: #fff; font-size: 15px; font-weight: 700; border-width: 3px;
}
.go { position: relative; }
.go svg { width: 30px; height: 30px; }
.go[data-mode="run"] { background: #FFF8EE; color: var(--ink); }
.go[data-mode="run"] svg { color: var(--coral); }
.go.pulse::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid var(--sun); animation: ring 1s ease-out infinite; pointer-events: none; }
.go.pulse { animation: pulse 1s ease-in-out infinite; }
html.rm .go.pulse, html.rm .hbtn.pulse { outline: 4px solid var(--sun); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .go.pulse, .hbtn.pulse { outline: 4px solid var(--sun); outline-offset: 3px; } }

.hud-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; pointer-events: none; }
.hud-info > * { pointer-events: none; }
.plabel { align-self: flex-start; max-width: 100%; padding: 2px 12px; border-radius: 14px; background: var(--panel); border: 2px solid var(--violet);
  font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plabel .pn { opacity: .85; margin-right: 6px; }
.ink { position: relative; height: 32px; border-radius: 16px; border: 2px solid var(--violet); background: var(--panel); overflow: visible; min-width: 90px; }
.ink .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 14px 0 0 14px; background: var(--pen); transition: width .08s linear;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.28) 0 3px, transparent 3px 9px); }
.ink[data-pen="pencil"] .fill { background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 6px, transparent 6px 10px); }
.ink .clip { position: absolute; inset: 0; border-radius: 14px; overflow: hidden; }
.ink .lbl { position: absolute; left: 10px; top: 0; bottom: 0; display: flex; align-items: center; font-size: 14px; font-weight: 700; color: var(--ink);
  background: var(--panel); padding: 0 6px; margin: 3px 0; border-radius: 10px; line-height: 1; z-index: 2; }
.ink.empty .lbl { background: #FDE9E4; }
.ink .tick { position: absolute; top: -8px; bottom: -8px; width: 0; border-left: 2px dashed var(--violet); z-index: 3; }
.ink .tick svg { position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; transform: translate(-50%, -50%); }
.ink .tick .star-on { stroke-width: 1.8; }
.ink .tick.lost { border-left-style: dotted; opacity: .8; }

/* landscape bars */
html[data-lay="landscape"] #hud .bar-left, html[data-lay="landscape"] #hud .bar-right {
  top: 0; bottom: 0; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px;
}
html[data-lay="landscape"] #hud .bar-left { left: 0; width: max(var(--ui-pl), 76px); padding-left: max(6px, var(--sal)); }
html[data-lay="landscape"] #hud .bar-right { right: 0; width: max(calc(100% - var(--ui-pl) - var(--ui-pw)), 76px); padding-right: max(6px, var(--sar)); }
html[data-lay="landscape"] #hud .grp { flex-direction: column; align-items: center; }
html[data-lay="landscape"] #hud .tray { flex-direction: column; }
html[data-lay="landscape"] #hud .bar-top {
  left: var(--ui-pl); width: var(--ui-pw); top: max(calc(var(--ui-pt) + 4px), var(--sat)); padding: 0 10px; align-items: center; justify-content: center;
}
html[data-lay="landscape"] #hud .hud-info { flex-direction: row; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; }
html[data-lay="landscape"] #hud .plabel { flex: none; max-width: 40%; }
html[data-lay="landscape"] #hud .ink { flex: 1; }
html[data-lay="landscape"] #hud .bar-bottom, html[data-lay="portrait"] #hud .bar-left, html[data-lay="portrait"] #hud .bar-right { display: none; }

/* portrait bars */
html[data-lay="portrait"] #hud .bar-top {
  left: 0; right: 0; top: 0; height: max(var(--ui-pt), calc(92px + var(--sat))); padding: var(--sat) calc(10px + var(--sar)) 6px calc(10px + var(--sal));
  flex-direction: row; align-items: flex-end; gap: 10px;
}
html[data-lay="portrait"] #hud .bar-bottom {
  left: 0; right: 0; bottom: 0; height: max(calc(100% - var(--ui-pt) - var(--ui-ph)), calc(160px + var(--sab)));
  padding: 6px calc(10px + var(--sar)) calc(6px + var(--sab)) calc(10px + var(--sal)); flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
}
html[data-lay="portrait"] #hud .bar-bottom .acts { width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: space-between; gap: 6px; pointer-events: none; }
html[data-lay="portrait"] #hud .bar-bottom .acts > * { pointer-events: auto; }
html[data-lay="portrait"] #hud .bar-bottom .acts .grp { flex: 1; justify-content: center; flex-wrap: wrap; }
html[data-lay="portrait"] #hud .bar-bottom .acts .grp > * { pointer-events: auto; }
html.lh[data-lay="portrait"] #hud .bar-bottom .acts, html.lh[data-lay="portrait"] #hud .bar-top { flex-direction: row-reverse; }
@media (max-height: 420px) and (orientation: landscape) {
  .go { width: 64px; height: 64px; min-width: 64px; min-height: 64px; font-size: 14px; }
  .go svg { width: 24px; height: 24px; }
  html[data-lay="landscape"] #hud .bar-left, html[data-lay="landscape"] #hud .bar-right { gap: 4px; padding-top: 4px; padding-bottom: 4px; }
  .tray { padding: 3px; gap: 3px; }
  .plabel { font-size: 14px; }
}
@media (max-width: 380px) {
  .pen { width: 50px; }
  html[data-lay="portrait"] #hud .bar-bottom .acts .grp { gap: 4px; }
}

/* ---------- Motion ---------- */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.2) rotate(-18deg); } 70% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html.rm *, html.rm *::before, html.rm *::after { animation: none !important; transition: none !important; }
.ink .tick .star-off { fill: #DDD8EC; stroke-dasharray: none; opacity: 1; }
.pencard .pi { width: 44px; height: 44px; display: grid; place-items: center; }
.pencard .pi svg, .pencard .pi canvas { width: 40px; height: 40px; }

@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.tip { position: relative; width: min(92vw, 420px); display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px; border-radius: 18px; background: var(--panel); border: 2px solid var(--violet); box-shadow: var(--shadow); font-size: 16px; font-weight: 700; pointer-events: none; }
.tip svg { width: 24px; height: 24px; flex: none; }
.tip span { flex: 1; }
.tip .btn { pointer-events: auto; flex: none; }
@media (min-width: 1100px) and (min-height: 700px) {
  html[data-lay="landscape"] .hbtn { width: 56px; height: 56px; min-width: 56px; min-height: 56px; }
  html[data-lay="landscape"] .hbtn.ff { width: auto; }
  html[data-lay="landscape"] .hbtn svg { width: 30px; height: 30px; }
  html[data-lay="landscape"] .pen { width: 62px; height: 62px; min-width: 62px; min-height: 62px; }
  html[data-lay="landscape"] .pen canvas, html[data-lay="landscape"] .pen > svg.pi { width: 36px; height: 36px; }
  html[data-lay="landscape"] .go { width: 92px; height: 92px; min-width: 92px; min-height: 92px; font-size: 18px; }
  html[data-lay="landscape"] .go svg { width: 36px; height: 36px; }
  html[data-lay="landscape"] .ink { height: 34px; }
  html[data-lay="landscape"] .ink .lbl { font-size: 16px; }
  html[data-lay="landscape"] .plabel { font-size: 18px; padding: 4px 14px; }
}
html.playing[data-lay="landscape"] #toasts { top: calc(var(--ui-pt) + 44px); }
@media (max-height: 480px) {
  .screen { padding-top: calc(8px + var(--sat)); padding-bottom: calc(8px + var(--sab)); }
  .card { padding: 10px 16px; gap: 6px; }
  .screen h1, .card h1 { font-size: 28px; }
  .card h2 { font-size: 22px; }
  .bigstars svg { width: 46px; height: 46px; }
  .msg { min-height: 0; font-size: 16px; }
  .stats { font-size: 15px; }
  .btn.big { min-height: 56px; padding: 6px 26px; font-size: 21px; }
  .screen > .inner { gap: 8px; }
  .ellie-canvas { max-height: 28vh; width: auto !important; }
  .found { padding: 4px 10px; }
  .overlay .card { gap: 6px; }
  .setrow { min-height: 48px; }
}
.ink-hint { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 6px; border-radius: 12px; background: var(--sun); border: 2px solid var(--violet); font-size: 14px; font-weight: 700; pointer-events: none; }
.ink-hint svg { width: 18px; height: 18px; }
html[data-lay="landscape"] #hud .ink-hint { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; white-space: nowrap; }
html[data-lay="landscape"] #hud .hud-info { position: relative; }
.hbtn.ff[disabled] { border-style: dashed; }
.hbtn.ff.on, .hbtn.ff.pressed { background: var(--sun); }

/* ---------- Studio chrome (GAME_STYLE.md): chip, back link, poster, share ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 15px; font-weight: 600; color: var(--ink); box-shadow: var(--shadow); text-decoration: none; pointer-events: auto; }
.back-link { color: var(--muted) !important; font-size: 15px !important; min-height: 48px; padding: 5px 14px !important; width: fit-content; }
.back-link:active { transform: translateY(2px); }
.title-left { position: absolute; top: calc(10px + var(--sat)); left: calc(10px + var(--sal)); z-index: 2; }
.poster { width: min(100%, 440px, 62vh); aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; border: 2px solid var(--line); box-shadow: var(--shadow); background: var(--paper); flex: none; }
.poster svg, .poster img { display: block; width: 100%; height: 100%; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 2px; }
.btn.btn-ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.card .back-link { margin-top: 4px; }
.map-top .back-link { align-self: center; }
html.on-title #toasts { top: calc(66px + var(--sat)); }

.setrow.langrow { flex-direction: column; align-items: stretch; gap: 6px; min-height: 0; }
.setrow.langrow .seg { flex: none; }
.overlay .card .seg .btn { font-size: 16px; min-height: 52px; }
.startip { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 16px; font-weight: 700; color: var(--ink); background: #FFF1C2; border: 2px solid var(--line); border-radius: 14px; padding: 6px 12px; }
.startip svg { width: 22px; height: 22px; flex: none; }
@media (max-height: 420px) {
  .title-screen > .inner { max-width: 760px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; row-gap: 6px; align-items: center; justify-items: center; }
  .title-screen > .inner > :first-child { grid-row: 1 / span 4; width: min(100%, 52vh); }
  .title-screen .poster { width: 100%; }
  .title-screen h1 { font-size: 30px; }
  .title-screen .tagline { font-size: 16px; }
  .title-screen .btn.big { min-height: 56px; padding: 6px 22px; font-size: 20px; }
  .title-screen .title-foot { font-size: 13px; }
  .startip { padding: 4px 10px; font-size: 15px; }
}

/* =====================================================================
   v2: Gel-pen Diary chrome, chapter papers, album, story cards, key pips
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hand { font-family: var(--font-hand); font-weight: 700; }

/* washi tape on cards */
.tape::before, .bookpage::before, .hero::before {
  content: ""; position: absolute; top: -11px; left: 50%; width: 84px; height: 22px; margin-left: -42px; transform: rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(246,201,216,.92) 0 7px, rgba(255,233,168,.92) 7px 14px);
  border-left: 2px dotted rgba(75,67,112,.35); border-right: 2px dotted rgba(75,67,112,.35); pointer-events: none; z-index: 1;
}
.overlay .card.tape::before { display: none; }

/* title / ending hero */
.hero { position: relative; padding: 14px 22px 6px; background: var(--panel); border: 2px solid var(--violet); border-radius: 22px; box-shadow: 4px 5px 0 var(--pink); transform: rotate(-1.2deg); flex: none; }
.hero .ellie-canvas { margin: 0 auto; }
.hero .sparkles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* map */
.map .inner { max-width: 760px; }
.chapters { width: 100%; display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 1000px) { .map .inner { max-width: 1040px; } .chapters { grid-template-columns: 1fr 1fr; } }
.map-head { gap: 8px; }
.chapter {
  position: relative; background-color: var(--cp, var(--panel)); color: var(--ct, var(--ink)); border: 2px solid var(--cl, var(--violet));
  background-image: radial-gradient(circle, var(--cdot, rgba(75,67,112,.2)) 1px, transparent 1.5px); background-size: 14px 14px;
  box-shadow: 4px 4px 0 var(--ctint, var(--pink));
}
.chapter.locked { filter: saturate(.55); opacity: .82; }
.chapter.current { outline: 3px dashed var(--ctint); outline-offset: 3px; }
.chapter .ct small { color: inherit; opacity: .85; }
.chapter .ct h2 { font-family: var(--font-hand); }
.chip-in { padding: 2px 10px 2px 6px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 2px solid var(--cl, var(--violet)); font-size: 15px; gap: 4px; }
.chip-in svg { width: 20px; height: 20px; }
.chapter-head { flex-wrap: wrap; row-gap: 6px; }
.pagebtn { position: relative; background: #FFFBF4; }
.pagebtn .pnum { font-size: 22px; }
.pagebtn .smark { position: absolute; top: -6px; right: -4px; width: 22px; height: 22px; }
.pagebtn.locked { background: rgba(255,251,244,.6); }
.smark { width: 20px; height: 20px; flex: none; }
.tot .smark { width: 22px; height: 22px; }

/* found row (new sticker / charm) */
.found { flex-wrap: wrap; box-shadow: 2px 2px 0 var(--butter); }
.found .ftxt { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
.found .btn { flex: 1 1 100%; width: 100%; }
.stkpop { display: grid; place-items: center; }
.stkpop canvas { display: block; }
.newstk .stkpop { animation: stkin .7s cubic-bezier(.3, 1.5, .5, 1) .5s both; }

/* story + ending cards: a coloring-book page in the next chapter paper */
.screen.story { background-color: var(--cp); background-image: radial-gradient(circle, var(--cdot) 1px, transparent 1.5px); background-size: 16px 16px; }
.storycard { max-width: 460px; gap: 12px; padding: 26px 22px 20px; background-color: var(--cp); color: var(--ct); border-color: var(--cl);
  background-image: radial-gradient(circle, var(--cdot) 1px, transparent 1.5px); background-size: 14px 14px; box-shadow: 4px 5px 0 var(--ctint); }
.story-art { display: flex; align-items: flex-end; justify-content: center; gap: 14px; }
.motif { flex: none; overflow: visible; transform: rotate(4deg); }
.eyebrow { font-family: var(--font-head); font-weight: 600; font-size: 15px; letter-spacing: .02em; opacity: .85; }
.story-line { font-family: var(--font-hand); font-weight: 700; font-size: clamp(22px, 5.6vw, 28px); line-height: 1.3; }
.story-sub { font-size: 17px; line-height: 1.4; }
.storycard .muted { color: inherit; opacity: .8; }
.storycard .btn.btn-ghost { color: var(--ct); border-color: var(--cl); }
.screen.story .btn { color: #2B2A4C; }
.screen.story .btn.primary { color: #fff; }

/* album */
.album-inner { max-width: 760px; gap: 12px; }
.countchip { padding: 4px 12px; border-radius: 999px; background: var(--panel); border: 2px solid var(--violet); box-shadow: var(--shadow); }
.bookwrap { width: 100%; touch-action: pan-y; }
.bookpage {
  position: relative; width: 100%; padding: 26px 14px 14px; border-radius: 22px; background-color: var(--cp); color: var(--ct); border: 2px solid var(--cl);
  background-image: radial-gradient(circle, var(--cdot) 1px, transparent 1.5px); background-size: 14px 14px; box-shadow: 5px 5px 0 var(--ctint);
  display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center;
}
.bookpage.in-r { animation: slidein-r .28s ease both; }
.bookpage.in-l { animation: slidein-l .28s ease both; }
.bp-head { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 12px; }
.bp-head small { flex: 1 1 100%; font-family: var(--font-head); font-weight: 600; opacity: .85; }
.bp-head h2 { font-size: clamp(24px, 6.5vw, 34px); }
.bp-count { padding: 2px 10px 2px 6px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 2px solid var(--cl); font-size: 16px; gap: 4px; }
.slots5 { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.btn.stk { padding: 4px; min-width: 60px; min-height: 60px; border-radius: 18px; transform: rotate(var(--rot, 0deg)); background: rgba(255,255,255,.62); border: 2px dashed var(--cl); box-shadow: none; color: var(--ink); }
.btn.stk.got { border-style: solid; background: rgba(255,255,255,.8); box-shadow: 2px 3px 0 var(--ctint); }
.btn.stk.sel { outline: 3px solid var(--sun); outline-offset: 2px; }
.btn.stk:active { transform: rotate(var(--rot, 0deg)) scale(.95); }
.stk-wrap { position: relative; display: block; flex: none; }
.stk-wrap canvas { position: absolute; inset: 0; display: block; }
.stk-wrap canvas:only-child { position: static; }
.stk-wrap .ring { position: absolute; left: 50%; top: 50%; width: 60%; height: 60%; margin: -30% 0 0 -30%; border: 3px solid #fff; border-radius: 50%; opacity: 0; animation: peelring .7s ease-out .3s both; }
.stk-canvas.peel { animation: peel .7s cubic-bezier(.2, .9, .3, 1.2) .3s both; }
.stk-canvas.fadeout { animation: fadeout .45s ease .1s both; }
.stk-detail { width: 100%; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 12px; border-radius: 16px; background: rgba(255,251,244,.92); color: var(--ink); border: 2px solid var(--cl); }
.stk-detail b { font-family: var(--font-head); font-size: 19px; }
.stk-detail .btn { margin-top: 2px; }
.ribbon { padding: 2px 14px; border-radius: 999px; background: var(--butter); color: #2B2A4C; border: 2px solid var(--violet); font-family: var(--font-head); font-weight: 700; }
.album-nav { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.navmid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--violet); background: #fff; }
.dots i.full { background: var(--sun); }
.dots i.cur { width: 16px; height: 16px; margin: -2px; border-width: 3px; }
.charmbox { max-width: 100%; gap: 10px; padding: 22px 14px 14px; }
.charmhead { display: flex; align-items: center; gap: 12px; text-align: left; }
.charms { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.btn.charmbtn { position: relative; width: 52px; height: 52px; min-width: 52px; padding: 0; border-radius: 16px; }
.btn.charmbtn canvas { width: 34px; height: 34px; }
.btn.charmbtn.none svg { width: 22px; height: 22px; }
.btn.charmbtn[aria-pressed="true"] { background: #fff; border-width: 4px; box-shadow: 0 0 0 3px var(--sun), var(--shadow); }
.btn.charmbtn.locked { border-style: dashed; box-shadow: none; background: rgba(255,251,244,.6); }
.btn.charmbtn.locked canvas { opacity: .35; filter: grayscale(1); }
.charmbtn .lk { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); border: 2px solid var(--violet); display: grid; place-items: center; }
.charmbtn .lk svg { width: 11px; height: 11px; }
.charmbtn .chk { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; background: var(--teal); color: #fff; border: 2px solid var(--violet); display: grid; place-items: center; }
.charmbtn .chk svg { width: 12px; height: 12px; }

/* HUD: page label row + key pips (solid key + tick = taken, dashed = still to find) */
.hud-row { display: flex; align-items: center; gap: 6px; min-width: 0; align-self: flex-start; max-width: 100%; }
.hud-row .plabel { flex: 0 1 auto; min-width: 0; }
html[data-lay="landscape"] #hud .hud-row { flex: none; max-width: 46%; }
.keys { display: inline-flex; gap: 3px; padding: 2px 6px; border-radius: 14px; background: var(--panel); border: 2px solid var(--violet); flex: none; }
.kpip { position: relative; width: 28px; height: 24px; color: #8A7A2E; }
.kpip svg { width: 28px; height: 24px; }
.kpip.on { color: #B8860B; }
.kpip.new { animation: pop .42s cubic-bezier(.3, 1.6, .5, 1) both; }
.ktick { position: absolute; right: -3px; bottom: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--teal); color: #fff; border: 1.5px solid var(--violet); display: grid; place-items: center; }
.ktick svg { width: 9px; height: 9px; }
.plabel, .ink, .tray { box-shadow: 2px 2px 0 var(--pink); }

@keyframes slidein-r { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes slidein-l { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes peel { 0% { opacity: 0; transform: scale(1.5) rotate(-28deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes peelring { 0% { opacity: .9; transform: scale(.6); } 100% { opacity: 0; transform: scale(2); } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes stkin { 0% { opacity: 0; transform: scale(1.6) rotate(-25deg); } 100% { opacity: 1; transform: none; } }

@media (max-height: 480px) {
  .hero { padding: 8px 14px 2px; }
  .storycard { padding: 20px 18px 12px; gap: 6px; }
  .story-art canvas { max-height: 64px; width: auto !important; }
  .story-line { font-size: 21px; }
  .bookpage { padding: 22px 12px 10px; gap: 6px; }
  .stk-detail { min-height: 48px; }
}
@media (max-height: 420px) { .title-screen .hero { width: min(100%, 52vh); } }
html[data-lay="landscape"] #hud .hud-row.haskeys { max-width: 62%; }
html[data-lay="landscape"] #hud .hud-row.haskeys .pname { display: none; }
@media (max-height: 420px) { .title-screen { padding-top: 62px; } .title-screen > .inner { margin-top: 0; } }

/* HUD page chip: number never truncated, name takes what is left */
.plabel { display: flex; align-items: center; }
.plabel .pn { flex: none; margin-right: 0; }
.plabel .pname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plabel .pname:not(:empty)::before { content: "\00b7\00a0"; margin-left: 6px; }
html[data-lay="landscape"] #hud .hud-row { flex: 0 1 auto; max-width: 56%; min-width: 0; }
html[data-lay="landscape"] #hud .hud-row .plabel { max-width: none; flex: 0 1 auto; min-width: 0; }
html[data-lay="landscape"] #hud .hud-row.haskeys { max-width: 64%; }
html[data-lay="landscape"] #hud .ink { min-width: 120px; }
@media (max-height: 420px) { html[data-lay="landscape"] #hud .hud-row .plabel { font-size: 14px; } }
html.playing[data-lay="landscape"]:has(.ink-hint:not([hidden])) #toasts { top: calc(var(--ui-pt) + 80px); }

/* ===== v2 QA fixes: compact landscape HUD, ink-empty chip, sticky result buttons, pause grid, banners ===== */
.hud-info { position: relative; }
.ink-empty { position: absolute; top: calc(100% + 4px); right: 0; padding: 2px 10px; border-radius: 12px; background: #FDE9E4; border: 2px solid var(--violet);
  font: 700 14px var(--font-head); color: var(--ink); pointer-events: none; z-index: 4; white-space: nowrap; }
html[data-lay="landscape"] #hud .hud-row.haskeys .pname { display: block; }
html[data-lay="landscape"] #hud .hud-row.haskeys { max-width: 66%; }

.actions.sticky { position: sticky; bottom: 0; z-index: 3; background: var(--panel); padding: 8px 0 2px; margin-top: 2px; border-top: 2px dashed rgba(75,67,112,.22); }
#toasts { top: calc(12px + var(--sat)); }
@keyframes toastin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
html.on-title .tip { position: fixed; left: 50%; right: auto; top: auto; bottom: calc(10px + var(--sab)); transform: translateX(-50%); }

@media (max-height: 420px) {
  html[data-lay="landscape"] #hud .bar-top { top: 0; padding: 2px 8px 0; }
  html[data-lay="landscape"] #hud .hud-info { gap: 6px; }
  html[data-lay="landscape"] #hud .hud-row { max-width: 66%; }
  html[data-lay="landscape"] #hud .plabel { font-size: 13px; padding: 0 8px; height: 26px; background: rgba(255,251,244,.9); box-shadow: none; }
  html[data-lay="landscape"] #hud .ink { height: 26px; min-width: 100px; background: rgba(255,251,244,.9); box-shadow: none; }
  html[data-lay="landscape"] #hud .ink .lbl { font-size: 12px; margin: 2px 0; left: 6px; }
  html[data-lay="landscape"] #hud .ink .tick { top: -3px; bottom: -3px; }
  html[data-lay="landscape"] #hud .ink .tick svg { width: 22px; height: 22px; }
  html[data-lay="landscape"] #hud .keys { padding: 1px 4px; gap: 1px; background: rgba(255,251,244,.9); box-shadow: none; }
  html[data-lay="landscape"] #hud .kpip, html[data-lay="landscape"] #hud .kpip svg { width: 20px; height: 18px; }
  html[data-lay="landscape"] #hud .ktick { width: 11px; height: 11px; right: -2px; bottom: -3px; }
  html[data-lay="landscape"] #hud .ktick svg { width: 7px; height: 7px; }
  .ink-empty { font-size: 12px; padding: 0 8px; }
  html.playing[data-lay="landscape"] #toasts { top: calc(var(--ui-pt) + 34px); }
  html.playing[data-lay="landscape"]:has(.ink-hint:not([hidden])) #toasts { top: calc(var(--ui-pt) + 66px); }
}
@media (max-height: 480px) {
  .screen.dim .card .startip, .screen.dim .card .msg { display: none; }
  .screen.dim .card { gap: 6px; padding: 12px 16px 6px; }
  .screen.dim .card .found { padding: 4px 10px; gap: 8px; }
  .screen.dim .card .found .btn { flex: 0 0 auto; width: auto; }
  .screen.dim .card .found canvas { width: 48px !important; height: 48px !important; }
  .actions.sticky { flex-wrap: nowrap; gap: 6px; }
  .actions.sticky .btn { padding: 4px 14px; min-height: 48px; font-size: 16px; }
  .actions.sticky .btn.big { min-height: 52px; font-size: 19px; padding: 4px 18px; }
  .overlay .card.pause { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; max-width: 560px; padding: 10px 14px; }
  .overlay .card.pause > h2 { grid-column: 1 / -1; font-size: 20px; }
  .overlay .card.pause > .btn, .overlay .card.pause > .chip { width: 100%; max-width: none; }
  .overlay .card.pause > .btn.primary, .overlay .card.pause > .chip { grid-column: 1 / -1; }
  .overlay .card.pause > .chip { justify-self: center; width: fit-content; }
}
