/* Glimmerglen — web UI styles. Cozy parchment panels over a pixel-art canvas. */
:root {
  --vh: 1vh;
  --cream: #fff6e3;
  --parch: #f3e2c0;
  --parch-d: #e8d1a4;
  --brown: #7a4a2c;
  --brown-d: #5a3420;
  --pink: #ff8fab;
  --pink-d: #e0668a;
  --gold: #ffd166;
  --gold-d: #e0a93a;
  --mint: #7fdcb7;
  --mint-d: #4fb894;
  --sky: #8ecdf7;
  --sky-d: #5aa8db;
  --plum: #3b2a3a;
  --plum-l: #6b5468;
  --night: #1d2a3a;
  --text-scale: 1;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --pad: clamp(6px, 1.6vmin, 14px);
  --radius: 14px;
  --shadow: 0 4px 0 rgba(59, 42, 58, 0.28), 0 10px 26px rgba(20, 10, 30, 0.28);
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tap: 44px;
  color-scheme: light;
}
@supports (height: 1dvh) { :root { --vh: 1dvh; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--night); color: var(--plum);
  font-family: var(--font); font-weight: 800;
  font-size: calc(clamp(12px, calc(5px + 1.65vmin), 18px) * var(--text-scale));
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
#app { position: fixed; inset: 0; overflow: hidden; }
#world { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; display: block; background: var(--night); }
#ui { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: none; }
#ui .pe, #ui button, #ui input, #ui select, #ui .panel, #ui .screen, #ui .dlg, #ui .modal-backdrop { pointer-events: auto; }
#fade { position: absolute; inset: 0; background: #0d0a14; opacity: 0; pointer-events: none; z-index: 50; transition: opacity 0.25s ease; }
#fade.on { opacity: 1; pointer-events: auto; }
button { font-family: var(--font); font-weight: 900; color: var(--plum); cursor: pointer; }
input { font-family: var(--font); font-weight: 800; -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.hidden { display: none !important; }

/* ---------- boot ---------- */
#boot { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, #2f6b3a 0%, #1d2a3a 70%); transition: opacity 0.5s; }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; color: var(--cream); }
.boot-logo { font-size: 3em; font-weight: 900; letter-spacing: 0.02em; text-shadow: 0 3px 0 var(--brown), 0 0 24px rgba(255, 209, 102, 0.6); }
.boot-bar { width: min(60vw, 320px); height: 14px; margin: 1em auto 0.6em; background: rgba(0, 0, 0, 0.3); border: 3px solid var(--brown); border-radius: 10px; overflow: hidden; }
.boot-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--pink)); transition: width 0.25s; }
.boot-msg { opacity: 0.85; font-size: 0.95em; }
#rotate-hint { display: none; position: absolute; inset: 0; z-index: 70; background: var(--night); color: var(--cream);
  align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 2em; }
#rotate-hint div { font-size: 4em; animation: spin 2.4s ease-in-out infinite; }
@media (orientation: portrait) and (max-width: 700px) { body.in-game #rotate-hint { display: flex; } }
@keyframes spin { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }

/* ---------- icons ---------- */
.ico { display: inline-block; image-rendering: pixelated; image-rendering: crisp-edges; background-repeat: no-repeat; flex: none; vertical-align: middle; }
.ico-missing { background: radial-gradient(circle at 35% 30%, #fffaf0 0%, var(--parch-d) 75%); border: 2px solid rgba(122, 74, 44, 0.45); border-radius: 30%; position: relative; }
.ico-missing::after { content: attr(data-l); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--brown); font-size: 0.75em; }
.ico-glyph { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-size: 1.05em; width: 1.3em; height: 1.3em; }
canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- panels & buttons ---------- */
.panel { background: var(--cream); border: 3px solid var(--brown); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.pop { animation: pop 0.22s cubic-bezier(.2, 1.4, .5, 1) both; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fadein { animation: fadein 0.3s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4em; min-height: 2.6em; padding: 0.35em 1em;
  border: 3px solid var(--brown); border-radius: 999px; background: var(--gold); box-shadow: 0 3px 0 var(--brown);
  font-size: 1em; line-height: 1.1; transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; white-space: nowrap; outline: none; }
.btn:hover { filter: brightness(1.06); }
.btn:active, .btn.pressed { transform: translateY(2px) scale(0.96); box-shadow: 0 1px 0 var(--brown); }
.btn:disabled, .btn.disabled { filter: grayscale(0.7) opacity(0.6); cursor: default; transform: none; }
.btn-pink { background: var(--pink); }
.btn-mint { background: var(--mint); }
.btn-sky { background: var(--sky); }
.btn-cream { background: var(--cream); }
.btn-parch { background: var(--parch); }
.btn-big { font-size: 1.2em; min-height: 2.8em; padding: 0.4em 1.4em; }
.btn-small { font-size: 0.85em; min-height: 2.2em; padding: 0.2em 0.8em; }
.btn-round { width: 2.6em; height: 2.6em; padding: 0; border-radius: 50%; }
.focus, .btn:focus-visible, .slot:focus-visible, .chip:focus-visible { outline: 3px solid var(--sky-d) !important; outline-offset: 2px; }
.x-btn { position: absolute; top: -0.9em; right: -0.9em; width: 2.6em; height: 2.6em; border-radius: 50%; border: 3px solid var(--brown);
  background: var(--pink); box-shadow: 0 3px 0 var(--brown); font-size: 1em; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 0; }
.x-btn:active { transform: translateY(2px) scale(0.94); box-shadow: 0 1px 0 var(--brown); }
.chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.25em 0.7em; border-radius: 999px; background: var(--parch);
  border: 2px solid var(--brown); font-size: 0.9em; min-height: 2.2em; cursor: pointer; }
.chip.on { background: var(--gold); }
.muted { color: var(--plum-l); font-weight: 700; }
.small { font-size: 0.85em; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 0.5em; }
.col { display: flex; flex-direction: column; gap: 0.5em; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--parch-d); border-radius: 8px; border: 2px solid var(--cream); }
h2, h3 { margin: 0; font-weight: 900; }
.title-text { font-size: 1.3em; font-weight: 900; }
.coin-t::before { content: '✦ '; color: var(--gold-d); }
.star-t::before { content: '★ '; color: var(--gold-d); }

/* ---------- modal layers ---------- */
.modal-backdrop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(29, 20, 40, 0.45); padding: calc(var(--pad) + var(--safe-t)) calc(var(--pad) + var(--safe-r)) calc(var(--pad) + var(--safe-b)) calc(var(--pad) + var(--safe-l)); }
.modal-backdrop.clear { background: transparent; }
.confirm { padding: 1.2em 1.4em; max-width: min(92vw, 30em); text-align: center; }
.confirm p { margin: 0 0 1em; font-size: 1.1em; }
.confirm .row { justify-content: center; flex-wrap: wrap; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l)); }
.hud-tl { position: absolute; left: calc(8px + var(--safe-l)); top: calc(6px + var(--safe-t)); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; max-width: 46vw; }
.hud-tr { position: absolute; right: calc(8px + var(--safe-r)); top: calc(6px + var(--safe-t)); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.hearts { display: flex; flex-wrap: wrap; gap: 1px; max-width: 13em; filter: drop-shadow(0 2px 0 rgba(59, 42, 58, 0.35)); }
.heart { width: 1.55em; height: 1.55em; display: inline-flex; align-items: center; justify-content: center; }
.heart .ico { width: 100%; height: 100%; }
.heart.bounce { animation: hb 0.45s ease; }
@keyframes hb { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 60% { transform: scale(0.9); } 100% { transform: scale(1); } }
.heart-css { width: 1.3em; height: 1.2em; position: relative; }
.heart-css::before { content: '♥'; position: absolute; inset: -0.25em 0 0 0; font-size: 1.5em; line-height: 1; color: #ff5d73; -webkit-text-stroke: 2px var(--brown); }
.heart-css.half::before { background: linear-gradient(90deg, #ff5d73 50%, #f3e2c0 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.heart-css.empty::before { color: #f3e2c0; }
.hud-pill { display: inline-flex; align-items: center; gap: 0.35em; background: rgba(255, 246, 227, 0.94); border: 2px solid var(--brown); border-radius: 999px;
  padding: 0.12em 0.65em 0.12em 0.35em; box-shadow: 0 2px 0 rgba(59, 42, 58, 0.35); font-size: 0.95em; min-height: 1.9em; white-space: nowrap; }
.hud-pill .ico { width: 1.3em; height: 1.3em; }
.hud-pill.bump { animation: bump 0.35s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }
.buffs { display: flex; gap: 4px; flex-wrap: wrap; }
.buff { display: inline-flex; align-items: center; gap: 0.2em; background: rgba(255, 246, 227, 0.92); border: 2px solid var(--brown); border-radius: 10px; padding: 0.05em 0.4em 0.05em 0.2em; font-size: 0.8em; }
.buff .ico { width: 1.4em; height: 1.4em; }
.buff.low { animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.tracker { pointer-events: auto; display: flex; align-items: flex-start; gap: 0.4em; background: rgba(255, 246, 227, 0.92); border: 2px solid var(--brown);
  border-radius: 12px; padding: 0.35em 0.55em; box-shadow: 0 2px 0 rgba(59, 42, 58, 0.35); max-width: min(46vw, 22em); cursor: pointer; }
.tracker .tq { font-size: 0.78em; color: var(--brown); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 900; }
.tracker .ts { font-size: 0.88em; line-height: 1.2; font-weight: 800; }
.tracker.flash { animation: tflash 0.9s ease; }
@keyframes tflash { 0%, 100% { background: rgba(255, 246, 227, 0.92); } 30% { background: var(--gold); transform: scale(1.04); } }
.flicker-btn { width: 2.2em; height: 2.2em; flex: none; border-radius: 50%; border: 2px solid var(--brown); background: #ffe2a8; display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 2px 0 var(--brown); }
.flicker-btn .ico, .flicker-btn canvas { width: 1.6em; height: 1.6em; }
.hud-row { display: flex; gap: 4px; align-items: center; }
.hud-btn { width: 2.6em; height: 2.6em; border-radius: 12px; border: 2px solid var(--brown); background: rgba(255, 246, 227, 0.95); box-shadow: 0 2px 0 var(--brown);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; pointer-events: auto; font-size: 1em; }
.hud-btn .ico { width: 1.7em; height: 1.7em; }
.hud-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--brown); }
.clock { gap: 0.3em; }
.rank-badge .ico { width: 1.4em; height: 1.4em; }
.saved-dot { position: absolute; right: calc(10px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); font-size: 0.75em; color: var(--cream); opacity: 0; transition: opacity 0.4s; text-shadow: 0 1px 2px #000; }
.saved-dot.on { opacity: 0.85; }
.prompt { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); background: rgba(255, 246, 227, 0.92); border: 2px solid var(--brown);
  border-radius: 999px; padding: 0.2em 0.8em; font-size: 0.9em; box-shadow: 0 2px 0 rgba(59, 42, 58, 0.35); white-space: nowrap; transition: opacity 0.2s; }
.prompt kbd { font-family: var(--font); font-weight: 900; background: var(--gold); border: 2px solid var(--brown); border-radius: 6px; padding: 0 0.35em; margin-right: 0.35em; font-size: 0.85em; }
.prompt.off { opacity: 0; }

/* ---------- touch controls ---------- */
.touch { position: absolute; inset: 0; pointer-events: none; }
.touch .joy-zone { position: absolute; left: 0; top: 18%; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
.joy-base { position: absolute; width: 8.4em; height: 8.4em; margin: -4.2em 0 0 -4.2em; border-radius: 50%; background: rgba(255, 246, 227, 0.18);
  border: 3px solid rgba(255, 246, 227, 0.45); opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.joy-base.on { opacity: 1; }
.joy-base.idle { opacity: 0.35; left: calc(5.4em + var(--safe-l)); top: calc(100% - 5.2em - var(--safe-b)); }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 3.6em; height: 3.6em; margin: -1.8em 0 0 -1.8em; border-radius: 50%; background: rgba(255, 246, 227, 0.85); border: 3px solid var(--brown); }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 3px solid var(--brown); box-shadow: 0 4px 0 var(--brown);
  display: flex; align-items: center; justify-content: center; flex-direction: column; font-weight: 900; color: var(--plum); transition: transform 0.08s, opacity 0.2s; }
.tbtn.down { transform: translateY(3px) scale(0.94); box-shadow: 0 1px 0 var(--brown); }
.tbtn-action { right: calc(1.4em + var(--safe-r)); bottom: calc(1.6em + var(--safe-b)); width: 5.6em; height: 5.6em; background: var(--gold); font-size: 1em; }
.tbtn-action .lbl { font-size: 1.05em; line-height: 1; }
.tbtn-action.empty { opacity: 0.55; }
.tbtn-horse { right: calc(7.8em + var(--safe-r)); bottom: calc(1.2em + var(--safe-b)); width: 3.8em; height: 3.8em; background: var(--sky); font-size: 0.85em; }
.tbtn-horse .ico { width: 2.2em; height: 2.2em; }
.tbtn-horse .lbl { font-size: 0.75em; }
.tbtn-horse.off { opacity: 0.0; pointer-events: none; }

/* ---------- toasts & banners ---------- */
.toasts { position: absolute; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(60vw, 26em); }
.toast { display: inline-flex; align-items: center; gap: 0.45em; background: var(--cream); border: 2px solid var(--brown); border-radius: 999px; padding: 0.2em 0.9em 0.2em 0.4em;
  box-shadow: 0 2px 0 rgba(59, 42, 58, 0.35); font-size: 0.92em; animation: toastin 0.25s cubic-bezier(.2, 1.4, .5, 1) both; max-width: 100%; }
.toast .ico { width: 1.5em; height: 1.5em; }
.toast.out { animation: toastout 0.3s ease both; }
@keyframes toastin { from { transform: translateY(-10px) scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastout { to { transform: translateY(-8px); opacity: 0; } }
.banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: 2em; font-weight: 900; color: var(--cream);
  text-shadow: 0 3px 0 var(--brown), 0 0 18px rgba(0, 0, 0, 0.45); animation: banner 3s ease both; letter-spacing: 0.03em; }
@keyframes banner { 0% { opacity: 0; transform: translateY(8px); } 15%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
.bubble { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); max-width: min(80vw, 30em); display: flex; gap: 0.5em; align-items: center;
  background: var(--cream); border: 3px solid var(--brown); border-radius: 16px; padding: 0.4em 0.9em 0.4em 0.5em; box-shadow: var(--shadow); animation: toastin 0.25s both; }
.bubble.out { animation: toastout 0.3s both; }
.bubble canvas, .bubble .ico { width: 2.4em; height: 2.4em; flex: none; }
.qbanner { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); min-width: min(80vw, 22em); max-width: 90vw; text-align: center;
  background: var(--cream); border: 3px solid var(--brown); border-radius: 18px; box-shadow: var(--shadow); padding: 0.6em 1.2em 0.8em; animation: qb 3.6s ease both; }
.qbanner .k { color: var(--pink-d); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.08em; }
.qbanner .t { font-size: 1.4em; font-weight: 900; }
.qbanner .r { font-size: 0.9em; color: var(--plum-l); margin-top: 0.2em; }
@keyframes qb { 0% { opacity: 0; transform: translate(-50%, -10px) scale(0.9); } 8%, 85% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- dialogue ---------- */
.dlg { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); width: min(94vw, 46em); display: flex; gap: 0.8em; align-items: stretch;
  padding: 0.75em 1em 0.8em; min-height: 6.4em; cursor: pointer; }
.dlg.pop { animation: dlgpop 0.2s cubic-bezier(.2, 1.4, .5, 1) both; }
@keyframes dlgpop { from { transform: translateX(-50%) translateY(10px) scale(0.97); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.dlg-portrait { flex: none; width: 5.2em; height: 5.2em; border-radius: 50%; border: 3px solid var(--brown); background: radial-gradient(circle at 50% 35%, #fff 0%, var(--sky) 100%);
  overflow: hidden; display: flex; align-items: center; justify-content: center; align-self: center; }
.dlg-portrait canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.dlg-portrait.none { display: none; }
.dlg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dlg-name { align-self: flex-start; margin: -1.55em 0 0.25em -0.2em; background: var(--pink); border: 3px solid var(--brown); border-radius: 999px; padding: 0.05em 0.8em; font-size: 0.95em; font-weight: 900; box-shadow: 0 2px 0 var(--brown); }
.dlg-name.none { visibility: hidden; }
.dlg-text { font-size: 1.12em; line-height: 1.38; font-weight: 800; min-height: 2.8em; white-space: pre-wrap; overflow-wrap: anywhere; }
.dlg.sign .dlg-text { font-style: normal; color: var(--brown-d); }
.dlg-next { position: absolute; right: 0.9em; bottom: 0.35em; color: var(--brown); font-size: 0.9em; animation: nudge 0.8s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }
.dlg-choices { display: flex; flex-wrap: wrap; gap: 0.45em; margin-top: 0.5em; }
.dlg-choices .btn { font-size: 0.95em; }

/* ---------- item get / rank up ---------- */
.itemget { padding: 1.1em 1.6em 1.2em; text-align: center; min-width: min(80vw, 20em); max-width: min(92vw, 28em); }
.itemget .big { width: 4.5em; height: 4.5em; margin: -2.6em auto 0.3em; border-radius: 50%; background: radial-gradient(circle, #fff9d6 0%, var(--gold) 70%);
  border: 3px solid var(--brown); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 6px rgba(255, 209, 102, 0.35), 0 0 30px rgba(255, 209, 102, 0.8); animation: glowpulse 1.6s ease-in-out infinite; }
.itemget .big .ico, .itemget .big canvas { width: 3em; height: 3em; }
@keyframes glowpulse { 50% { box-shadow: 0 0 0 10px rgba(255, 209, 102, 0.2), 0 0 40px rgba(255, 209, 102, 0.95); } }
.itemget h3 { font-size: 1.3em; margin-bottom: 0.25em; }
.itemget p { margin: 0 0 0.9em; color: var(--plum-l); font-weight: 700; }
.rankup .big { background: radial-gradient(circle, #fff 0%, var(--pink) 75%); }
.rays { position: absolute; left: 50%; top: 0; width: 22em; height: 22em; margin: -11em 0 0 -11em; pointer-events: none; opacity: 0.55;
  background: repeating-conic-gradient(rgba(255, 209, 102, 0.55) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: rays 8s linear infinite; mask-image: radial-gradient(circle, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 70%); }
@keyframes rays { to { transform: rotate(360deg); } }
.name-input { width: 100%; font-size: 1.2em; padding: 0.4em 0.7em; border: 3px solid var(--brown); border-radius: 12px; background: #fff; color: var(--plum); text-align: center; outline: none; }
.name-input:focus { border-color: var(--pink-d); }

/* ---------- big panels (menu, cook, shop...) ---------- */
.sheet { width: min(96vw, 60em); height: min(calc(92 * var(--vh)), 38em); max-height: calc(100 * var(--vh) - 2 * var(--pad) - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column; overflow: visible; }
.sheet-head { display: flex; align-items: center; gap: 0.6em; padding: 0.5em 0.9em; border-bottom: 3px solid var(--brown); background: var(--parch); border-radius: 11px 11px 0 0; min-height: 3em; }
.sheet-head .title-text { flex: 1; }
.sheet-body { flex: 1; min-height: 0; display: flex; }
.tabs { display: flex; flex-direction: column; gap: 4px; padding: 0.5em; border-right: 3px solid var(--brown); background: var(--parch); border-radius: 0 0 0 11px; overflow-y: auto; flex: none; }
.tab { display: flex; align-items: center; gap: 0.45em; padding: 0.35em 0.7em; border-radius: 10px; border: 2px solid transparent; background: transparent; font-size: 0.95em; min-height: 2.6em; text-align: left; white-space: nowrap; }
.tab .ico { width: 1.5em; height: 1.5em; }
.tab .em { width: 1.5em; text-align: center; font-size: 1.1em; }
.tab.on { background: var(--cream); border-color: var(--brown); box-shadow: 0 2px 0 var(--brown); }
.tab-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0.7em 0.9em; }
@media (max-height: 460px) { .tab .tl { display: none; } .tab { padding: 0.3em 0.45em; } .tabs { padding: 0.35em; } }
.split { display: flex; gap: 0.8em; flex: 1; min-height: 0; }
.split > .left { flex: 1.4; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.split > .right { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.card { background: var(--parch); border: 2px solid var(--brown); border-radius: 12px; padding: 0.6em 0.8em; }
.card-cream { background: #fffaf0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.6em, 1fr)); gap: 0.4em; align-content: start; }
.slot { position: relative; aspect-ratio: 1; min-height: 3.2em; background: var(--parch); border: 2px solid var(--brown); border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0; transition: transform 0.08s; }
.slot .ico { width: 72%; height: 72%; }
.slot.sel { background: var(--gold); box-shadow: 0 0 0 2px var(--gold-d) inset; }
.slot.worn::after { content: '✓'; position: absolute; top: 1px; left: 4px; font-size: 0.8em; color: var(--mint-d); }
.slot:active { transform: scale(0.94); }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-size: 0.78em; font-weight: 900; color: var(--plum); text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.slot.locked { filter: grayscale(1) brightness(0.8); opacity: 0.55; }
.slot.empty-slot { border-style: dashed; background: transparent; }
.cats { display: flex; gap: 0.35em; flex-wrap: wrap; margin-bottom: 0.6em; }
.detail { display: flex; flex-direction: column; gap: 0.4em; }
.detail .ico.hero { width: 3.4em; height: 3.4em; }
.detail h3 { font-size: 1.15em; }
.detail p { margin: 0; font-weight: 700; color: var(--plum-l); line-height: 1.3; }
.tagline { display: flex; gap: 0.35em; flex-wrap: wrap; }
.tag { font-size: 0.78em; padding: 0.05em 0.55em; border-radius: 999px; border: 2px solid var(--brown); background: var(--cream); }
.tag.buff-glow { background: #fff3a8; } .tag.buff-warm { background: #ffc49a; } .tag.buff-cool { background: #bfe8ff; } .tag.buff-zoom { background: #d6f5b0; } .tag.buff-lucky { background: #b9f0c9; }
.list { display: flex; flex-direction: column; gap: 0.4em; }
.li { display: flex; align-items: center; gap: 0.6em; padding: 0.45em 0.7em; background: var(--parch); border: 2px solid var(--brown); border-radius: 12px; min-height: 3em; text-align: left; width: 100%; font-size: 0.95em; }
.li.sel { background: var(--gold); }
.li .ico { width: 2em; height: 2em; }
.li .price { margin-left: auto; white-space: nowrap; }
.li.done { opacity: 0.7; }
.empty-msg { text-align: center; color: var(--plum-l); padding: 2em 1em; font-weight: 700; }
.section-title { font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.07em; color: var(--brown); margin: 0.4em 0 0.3em; font-weight: 900; }

/* ---------- character preview ---------- */
.preview { position: relative; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 80%, #bfe8a8 0%, #8fd0a0 45%, #6fae8a 100%);
  border: 3px solid var(--brown); border-radius: 14px; overflow: hidden; min-height: 9em; }
.preview canvas { image-rendering: pixelated; width: auto; height: 90%; max-height: 14em; }
.preview .turn { position: absolute; bottom: 0.4em; display: flex; gap: 0.4em; }

/* ---------- cooking ---------- */
.cook-top { display: flex; gap: 0.8em; align-items: center; }
.cook-stage { align-items: center; justify-content: center; gap: 0.6em; background: radial-gradient(circle at 50% 38%, #fff1cc 0%, var(--parch) 72%);
  border: 2px solid var(--brown); border-radius: 14px; padding: 0.8em; }
.cook-stage .status { min-height: 1.4em; text-align: center; font-size: 0.95em; color: var(--plum-l); }
.cook-stage .status b { color: var(--pink-d); }
.pot-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.pot-wrap .fire { width: 4.2em; height: 4.2em; margin-top: -1.6em; image-rendering: pixelated; }
.pot { position: relative; width: 9em; height: 6em; flex: none; display: flex; align-items: flex-end; justify-content: center; z-index: 1; }
.pot-body { width: 8em; height: 5em; border-radius: 0 0 4em 4em; background: linear-gradient(#5a4a5a, #3b2a3a); border: 3px solid var(--plum); position: relative; }
.pot-body::before { content: ''; position: absolute; left: -0.4em; right: -0.4em; top: -0.5em; height: 1em; border-radius: 50%; background: #7fdc9f; border: 3px solid var(--plum); }
.pot.bubbling .pot-body::before { animation: bubble 0.3s ease-in-out infinite alternate; background: #ffd166; }
@keyframes bubble { to { transform: scaleY(1.25) translateY(-2px); } }
.pot .steam { position: absolute; bottom: 5.4em; width: 0.7em; height: 0.7em; border-radius: 50%; background: rgba(255, 255, 255, 0.85); animation: steam 1.4s ease-out infinite; opacity: 0; }
@keyframes steam { 0% { transform: translateY(0) scale(0.6); opacity: 0.9; } 100% { transform: translateY(-3em) scale(1.6); opacity: 0; } }
.pot-slots { display: flex; gap: 0.4em; }
.pot-slot { width: 3.8em; height: 3.8em; border: 3px dashed var(--brown); border-radius: 12px; background: rgba(255, 255, 255, 0.5); display: flex; align-items: center; justify-content: center; padding: 0; }
.pot-slot.filled { border-style: solid; background: var(--cream); animation: pop 0.2s both; }
.pot-slot .ico { width: 75%; height: 75%; }
.result-card { text-align: center; padding: 1em; }
.result-card .ico { width: 4em; height: 4em; }
.flyer { position: fixed; z-index: 40; pointer-events: none; transition: transform 0.35s cubic-bezier(.4, 0, .2, 1), opacity 0.35s; }

/* ---------- shop ---------- */
.shop-keeper { display: flex; align-items: center; gap: 0.6em; }
.shop-keeper canvas { width: 3em; height: 3em; border-radius: 50%; border: 2px solid var(--brown); background: var(--sky); }
.owned { color: var(--mint-d); }

/* ---------- map ---------- */
.mapview { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #2b3a4a; border: 3px solid var(--brown); border-radius: 12px; }
.mapview .mapwrap { position: relative; }
.mapview img, .mapview canvas.mapimg { image-rendering: pixelated; display: block; width: 100%; height: 100%; }
.marker { position: absolute; transform: translate(-50%, -100%); font-size: 0.8em; pointer-events: none; white-space: nowrap; }
.marker.me { width: 0.9em; height: 0.9em; transform: translate(-50%, -50%); border-radius: 50%; background: var(--pink); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brown); animation: blink 0.7s steps(2) infinite; }
.marker.quest { color: var(--gold); font-size: 1.4em; text-shadow: 0 0 0 var(--brown), 0 2px 0 var(--brown), 1px 0 0 var(--brown), -1px 0 0 var(--brown); animation: nudge 0.8s infinite; }
.marker.npc { width: 0.55em; height: 0.55em; transform: translate(-50%, -50%); border-radius: 50%; background: var(--sky); border: 1px solid var(--brown); }
.marker.label { transform: translate(-50%, -50%); background: rgba(255, 246, 227, 0.88); border: 1px solid var(--brown); border-radius: 6px; padding: 0 0.3em; font-size: 0.72em; }
.world-tiles { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 0.6em; flex: 1; min-height: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(127, 220, 183, 0.35), transparent 70%); border-radius: 12px; padding: 0.3em; }
.realm-tile { position: relative; border: 3px solid var(--brown); border-radius: 14px; overflow: hidden; min-height: 3.2em; display: flex; align-items: flex-end; justify-content: center; background-size: cover; background-position: center; image-rendering: pixelated; padding: 0; }
.realm-tile .nm { background: rgba(255, 246, 227, 0.92); border-top: 2px solid var(--brown); width: 100%; padding: 0.25em; font-size: 0.9em; }
.realm-tile.here { box-shadow: 0 0 0 4px var(--gold); }
.realm-tile.locked::after { content: '🔒'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2em; background: rgba(40, 30, 50, 0.55); }
.realm-tile .em { position: absolute; top: 0.2em; left: 0.4em; font-size: 1.4em; }

/* ---------- journal ---------- */
.progress { height: 1.2em; border-radius: 999px; background: var(--parch); border: 2px solid var(--brown); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--pink)); border-radius: 999px; transition: width 0.6s; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); gap: 0.4em; }
.stat { background: var(--parch); border: 2px solid var(--brown); border-radius: 10px; padding: 0.35em 0.6em; font-size: 0.9em; }
.stat b { display: block; font-size: 1.3em; }

/* ---------- settings ---------- */
.setting { display: flex; align-items: center; gap: 0.8em; padding: 0.4em 0; border-bottom: 2px dashed var(--parch-d); min-height: 3em; }
.setting label { flex: 1; }
.setting input[type=range] { width: min(40vw, 14em); accent-color: var(--pink-d); height: 2em; touch-action: pan-x; }
.seg { display: inline-flex; border: 2px solid var(--brown); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: var(--parch); padding: 0.3em 0.8em; min-height: 2.4em; font-size: 0.9em; }
.seg button.on { background: var(--gold); }
.seg button + button { border-left: 2px solid var(--brown); }

/* ---------- title / creator / screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.title-screen { background: transparent; }
.logo { font-size: clamp(2.6em, 11vmin, 6em); font-weight: 900; color: var(--cream); letter-spacing: 0.02em; line-height: 1;
  text-shadow: 0 0.06em 0 var(--brown), 0 0.12em 0 rgba(59, 42, 58, 0.5), 0 0 0.6em rgba(255, 209, 102, 0.7); animation: float 4s ease-in-out infinite; }
.logo-sub { color: var(--cream); font-size: 1.05em; margin-top: 0.4em; text-shadow: 0 2px 0 var(--brown); opacity: 0.95; }
@keyframes float { 50% { transform: translateY(-6px); } }
.title-menu { display: flex; flex-direction: column; gap: 0.5em; margin-top: 1.4em; min-width: 14em; }
.title-menu .btn { width: 100%; }
.title-foot { position: absolute; bottom: calc(8px + var(--safe-b)); left: 0; right: 0; text-align: center; color: var(--cream); opacity: 0.7; font-size: 0.8em; text-shadow: 0 1px 2px #000; }
.slots { display: flex; gap: 0.7em; flex-wrap: wrap; justify-content: center; }
.slotcard { width: 13em; min-height: 9em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25em; padding: 0.6em; background: var(--parch); border: 3px solid var(--brown); border-radius: 14px; box-shadow: 0 3px 0 var(--brown); }
.slotcard canvas { width: 3.6em; height: 3.6em; border-radius: 50%; border: 2px solid var(--brown); background: var(--sky); image-rendering: pixelated; }
.slotcard.empty { background: rgba(255, 246, 227, 0.6); border-style: dashed; }
.slotcard .nm { font-size: 1.1em; }
.slotcard .meta { font-size: 0.8em; color: var(--plum-l); }
.creator { width: min(97vw, 64em); height: min(calc(94 * var(--vh)), 40em); max-height: calc(100 * var(--vh) - 12px - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column; }
.creator-body { flex: 1; min-height: 0; display: flex; gap: 0.8em; padding: 0.7em; }
.creator-left { flex: 1.25; min-width: 0; display: flex; flex-direction: column; gap: 0.5em; }
.creator-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.5em; }
.presets { display: flex; gap: 0.4em; overflow-x: auto; padding-bottom: 0.3em; touch-action: pan-x; flex: none; }
.preset { flex: none; width: 4.6em; display: flex; flex-direction: column; align-items: center; padding: 0.3em 0.2em; border-radius: 12px; border: 2px solid var(--brown); background: var(--parch); font-size: 0.85em; }
.preset canvas { width: 3em; height: 3em; image-rendering: pixelated; }
.preset.on { background: var(--gold); box-shadow: 0 2px 0 var(--brown); }
.blurb { font-weight: 700; color: var(--plum-l); min-height: 2.5em; font-size: 0.95em; }
.pickrow { display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.pickrow .lbl { width: 5.2em; font-size: 0.9em; flex: none; }
.swatch { width: 2.2em; height: 2.2em; border-radius: 50%; border: 3px solid var(--brown); padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--gold), 0 0 0 5px var(--brown); }
.stepper { display: inline-flex; align-items: center; gap: 0.3em; }
.stepper .val { min-width: 7.5em; text-align: center; font-size: 0.95em; }

/* ---------- cutscene ---------- */
.cutscene { background: #0d0a14; cursor: pointer; }
.cut-art { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cut-art canvas { image-rendering: pixelated; max-width: 100%; max-height: 100%; transition: opacity 0.8s; }
.cut-text { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); width: min(92vw, 44em); padding: 0.9em 1.2em; font-size: 1.15em; line-height: 1.4; text-align: center; }
.cut-skip { position: absolute; right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t)); }
.credits { background: linear-gradient(#141026, #2b2150); overflow: hidden; }
.credits-roll { position: absolute; left: 0; right: 0; top: 100%; text-align: center; color: var(--cream); font-size: 1.15em; line-height: 1.7; }
.credits-roll .h { color: var(--gold); font-size: 1.3em; margin-top: 1.2em; }

/* ---------- fishing / race ---------- */
.fishbar { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(70vw, 24em); padding: 0.6em 0.8em; text-align: center; }
.fishbar .track { position: relative; height: 1.6em; border-radius: 999px; border: 3px solid var(--brown); background: var(--parch); overflow: hidden; margin-top: 0.3em; }
.fishbar .zone { position: absolute; top: 0; bottom: 0; background: var(--mint); }
.fishbar .needle { position: absolute; top: -2px; bottom: -2px; width: 6px; margin-left: -3px; background: var(--plum); border-radius: 3px; }
.fishbar.win .track { box-shadow: 0 0 0 4px var(--mint); }
.fishbar.lose .track { box-shadow: 0 0 0 4px var(--pink); }
.racehud { position: absolute; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); padding: 0.35em 1em; display: flex; gap: 1em; align-items: center; font-size: 1.1em; }
.racehud .tm { font-size: 1.3em; min-width: 3.2em; text-align: center; }
.racehud .tm.low { color: #e0465a; animation: blink 0.5s steps(2) infinite; }
.count { position: absolute; left: 0; right: 0; top: 35%; text-align: center; font-size: 4em; font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 var(--brown); animation: countpop 0.8s ease both; }
@keyframes countpop { 0% { transform: scale(2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { opacity: 0; } }

/* ---------- responsive tweaks ---------- */
@media (pointer: coarse) {
  .btn { min-height: max(var(--tap), 2.6em); }
  .chip, .tab, .li, .seg button { min-height: max(var(--tap), 2.4em); }
  .x-btn { width: max(var(--tap), 2.6em); height: max(var(--tap), 2.6em); }
  .hud-btn { width: max(var(--tap), 2.6em); height: max(var(--tap), 2.6em); }
  .slot { min-height: var(--tap); }
}
@media (max-height: 430px) {
  .sheet { height: calc(100 * var(--vh) - 12px - var(--safe-t) - var(--safe-b)); }
  .sheet > .x-btn { top: 0.3em; right: 0.35em; }
  .sheet > .sheet-head { padding-right: 3.6em; min-height: 2.6em; padding-top: 0.3em; padding-bottom: 0.3em; }
  .dlg { min-height: 5.4em; padding: 0.6em 0.9em; }
  .dlg-portrait { width: 4.2em; height: 4.2em; }
  .creator-body { padding: 0.5em; gap: 0.5em; }
}
@media (max-width: 560px) {
  .split { flex-direction: column; }
  .creator-body { flex-direction: column; overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .banner, .qbanner { animation: none !important; }
}
