/* Planters Playhouse - Little Zen Worlds look: the DS palette (source/game.h), rounded Fredoka, soft paper cards. */
@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka-latin.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
:root {
  --ink: #544042; --paper: #fcf6ec; --cream: #f6ecdc; --sage: #96c4a0; --saged: #5c9670; --sageink: #284632;
  --pink: #f4aaba; --pinkd: #d25a82; --peach: #facea9; --wood: #d6aa78; --woodd: #aa7c56; --muted: #a0908c; --sky: #badef4;
  --line: #e6d6c2; --shadow: #e4d0bb; --r: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "Fredoka", "Nunito", system-ui, sans-serif; color: var(--ink); background: var(--cream); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: var(--saged); }
.icon { display: inline-block; background-image: url(/img/icons.png); background-repeat: no-repeat; background-size: 1200% auto; }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px max(14px, env(safe-area-inset-left)); background: rgba(252, 246, 236, .92); backdrop-filter: blur(8px); border-bottom: 2px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 19px; color: var(--saged); text-decoration: none; }
.brand-icon { width: 30px; height: 30px; }
.topbar nav { display: flex; gap: 6px; }
.navlink { text-decoration: none; color: var(--ink); font-size: 15px; padding: 6px 10px; border-radius: 10px; }
.navlink:hover { background: var(--cream); }
.navlink.lzw { color: var(--pinkd); }

/* ---------- buttons (DS cv_button: paper face, soft bottom edge; hot = peach with sage rim) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 14px;
  border: 2px solid #dccbb8; background: var(--paper); box-shadow: 0 3px 0 var(--shadow); cursor: pointer; font-size: 16px; text-decoration: none; color: var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s; user-select: none; }
.btn:hover { background: #fff; }
.btn:active, .btn.pressed { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }
.btn.hot { background: var(--peach); border-color: var(--saged); box-shadow: 0 3px 0 #c9a585; font-weight: 500; }
.btn.go { background: var(--sage); border-color: var(--saged); color: var(--sageink); font-weight: 600; box-shadow: 0 3px 0 #5f8f6b; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.on { background: var(--sage); border-color: var(--saged); color: var(--sageink); font-weight: 600; }
.btn.big { min-height: 52px; font-size: 18px; padding: 10px 22px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.round { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #dccbb8; background: rgba(255, 250, 242, .92); box-shadow: 0 2px 0 var(--shadow); cursor: pointer; display: grid; place-items: center; padding: 0; }
.round.on { background: var(--sage); border-color: var(--saged); }

/* ---------- hero */
.hero { background: linear-gradient(#e2f2fb, #fdf1e2 62%, var(--cream)); padding: 26px 16px 34px; }
.hero-inner { max-width: 1160px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1.05fr; align-items: center; gap: 24px; }
.kicker { margin: 0 0 6px; color: var(--pinkd); font-weight: 500; letter-spacing: .02em; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 56px); line-height: 1.04; color: var(--saged); font-weight: 600; }
.hero h1 span { color: var(--ink); font-weight: 500; font-size: .74em; }
.lede { font-size: 18px; line-height: 1.5; max-width: 34em; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.tiny { font-size: 13px; color: var(--muted); }
.hero-art img { width: 100%; height: auto; display: block; border-radius: 26px; box-shadow: 0 6px 0 var(--shadow); border: 3px solid #fff; background: #eaf5fb; }
.steps { list-style: none; max-width: 1160px; margin: 30px auto 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steps li { position: relative; background: var(--paper); border: 2px solid #cfe3d3; border-radius: 20px; padding: 16px 16px 12px 84px; box-shadow: 0 3px 0 var(--shadow); min-height: 112px; }
.steps h3 { margin: 2px 0 4px; font-size: 20px; color: var(--saged); font-weight: 600; }
.steps p { margin: 0; line-height: 1.4; font-size: 15px; }
.step-ic { position: absolute; left: 12px; top: 18px; width: 62px; height: 62px; }
.step-n { position: absolute; left: 8px; top: 8px; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--pink); color: #fff; font-weight: 600; display: grid; place-items: center; font-size: 14px; }

/* ---------- game frame */
.game { padding: 18px 14px 26px; scroll-margin-top: 56px; }
.game-frame { max-width: 1200px; margin: 0 auto; display: flex; gap: 0; height: min(760px, calc(100vh - 90px)); min-height: 560px; border-radius: 26px; overflow: hidden;
  border: 3px solid #fff; box-shadow: 0 6px 0 var(--shadow), 0 10px 30px rgba(120, 90, 70, .12); background: var(--paper); }
.stage { position: relative; flex: 1 1 auto; min-width: 0; background: #f4e3d1; overflow: hidden; touch-action: none; }
#view { display: block; width: 100%; height: 100%; cursor: grab; outline: none; }
#view.dragging { cursor: grabbing; }
.banner, .count { position: absolute; top: 12px; background: rgba(255, 250, 242, .95); border-radius: 12px; padding: 5px 13px; font-size: 16px; font-weight: 500; box-shadow: 0 2px 0 rgba(200, 170, 140, .4); pointer-events: none; }
.banner { left: 12px; max-width: calc(100% - 110px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { right: 12px; color: var(--saged); }
.banner:empty, .count:empty, .hint:empty { display: none; }
.titlecard { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(255, 250, 242, .96); border-radius: 18px; padding: 8px 26px 10px; text-align: center; box-shadow: 0 3px 0 rgba(200, 170, 140, .45); pointer-events: none; white-space: nowrap; }
.titlecard h2 { margin: 0; color: var(--saged); font-weight: 600; font-size: clamp(22px, 3.2vw, 32px); }
.titlecard p { margin: 0; color: var(--pinkd); font-size: 15px; }
.titlecard[hidden] { display: none; }
.hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(255, 250, 242, .95); border-radius: 12px; padding: 5px 14px; font-size: 14px; box-shadow: 0 2px 0 rgba(200, 170, 140, .4); white-space: nowrap; pointer-events: none; max-width: calc(100% - 120px); overflow: hidden; text-overflow: ellipsis; }
.stage-tools { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.i-eye, .i-sound { width: 22px; height: 22px; background: no-repeat center/contain; }
.i-eye { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23544042' stroke-width='2.2' stroke-linecap='round'%3E%3Cellipse cx='12' cy='15' rx='9' ry='4.5'/%3E%3Cpath d='M12 3v8M8.5 7.5 12 11l3.5-3.5'/%3E%3C/svg%3E"); }
.i-sound { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23544042' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E"); }
.muted-snd .i-sound { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0908c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z'/%3E%3Cpath d='M17 9l5 6M22 9l-5 6'/%3E%3C/svg%3E"); }

/* ---------- panel (the DS bottom screen) */
.panel { flex: 0 0 440px; display: flex; flex-direction: column; background: var(--cream); border-left: 3px solid #fff; min-height: 0; }
.tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 6px 6px 0; border-bottom: 3px solid var(--sage); }
.tab { border: 0; border-radius: 12px 12px 0 0; background: #ecdecc; padding: 4px 2px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 13.5px; line-height: 1.1; }
.tab .icon { width: 30px; height: 30px; }
.tab.on { background: var(--sage); color: var(--sageink); font-weight: 600; }
.tab:not(.on):hover { background: #f3e6d6; }
.shelf { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; align-content: start; background: var(--paper); margin: 8px 8px 0; border-radius: 14px; touch-action: pan-y; }
.cell { position: relative; border: 2px solid transparent; border-radius: 14px; background: transparent; padding: 4px 2px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cell .icon { width: 64px; height: 64px; pointer-events: none; transition: transform .12s; }
.cell:hover .icon { transform: translateY(-2px) scale(1.04); }
.cell .nm { font-size: 12.5px; line-height: 1.15; text-align: center; min-height: 2.3em; }
.cell.chosen { background: #d6ecd6; border-color: var(--sage); }
.cell.focus { background: var(--peach); }
.cell.locked .icon { filter: grayscale(1) brightness(.55) opacity(.45); }
.cell.locked .nm { color: var(--muted); }
.cell.locked::after { content: "?"; position: absolute; top: 22px; left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 22px; color: #fff; text-shadow: 0 1px 0 var(--ink); }
.cell .tag { position: absolute; top: 3px; right: 4px; font-size: 11px; background: var(--saged); color: #fff; border-radius: 8px; padding: 0 6px; }
.inpot { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0; min-height: 50px; overflow-x: auto; scrollbar-width: thin; }
.inpot .lbl { font-size: 12px; color: var(--muted); flex: 0 0 auto; width: 44px; line-height: 1.1; }
.chip { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; border: 2px solid transparent; background: var(--paper); padding: 0; cursor: pointer; position: relative; }
.chip .icon { width: 36px; height: 36px; position: absolute; left: 1px; top: 1px; }
.chip.on { border-color: var(--pinkd); background: #fde3ea; }
.chip .sz { position: absolute; right: -2px; bottom: -3px; font-size: 10px; background: #fff; border-radius: 6px; padding: 0 3px; border: 1px solid var(--line); }
.inpot .empty { font-size: 13px; color: var(--muted); }
.status { padding: 4px 12px 0; min-height: 26px; font-size: 15px; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.status b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.status .msg { color: #c8507a; }
.controls { display: grid; grid-template-columns: repeat(3, 44px) 1fr 1fr 1.15fr; gap: 6px; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
.controls .btn { min-height: 46px; padding: 6px 4px; font-size: 16px; }
.controls .btn.sz { padding: 0; }
.pcard { margin: 10px; padding: 16px; background: var(--paper); border: 3px solid var(--sage); border-radius: 20px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.pcard h2 { margin: 0; text-align: center; color: var(--saged); font-size: 30px; font-weight: 600; }
.pcard .center { text-align: center; margin: 0; }
.pcard .muted { color: var(--muted); font-size: 14px; }
.pcard .unlock { color: var(--pinkd); font-weight: 500; }
.menu { display: flex; flex-direction: column; gap: 10px; padding: 14px 26px; overflow-y: auto; }
.menu .btn { width: 100%; }
.menu .note { text-align: center; color: var(--muted); font-size: 14px; margin: 0; }
.deco { display: flex; justify-content: space-between; padding: 8px 14px 0; }
.deco .icon { width: 34px; height: 34px; }
.qrbox { display: flex; gap: 14px; align-items: center; background: #fff; border-radius: 16px; padding: 10px; border: 2px solid var(--line); }
.qrbox .qr { width: 132px; height: 132px; flex: 0 0 auto; }
@media (min-width: 861px) { .qrbox .qr { width: 168px; height: 168px; } }
.qrbox .qr svg { width: 100%; height: 100%; display: block; }
.qrbox .meta { min-width: 0; font-size: 14px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; background: var(--cream); border-radius: 8px; padding: 4px 6px; display: block; margin: 4px 0; user-select: all; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1 1 0; min-width: 120px; }
.sill { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 6px; background: #f4e6d4; }
.shelfrow { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px 4px 12px; min-height: 92px; }
.shelfrow::after { content: ""; position: absolute; left: -6px; right: -6px; bottom: 2px; height: 10px; border-radius: 3px; background: linear-gradient(var(--wood) 0 60%, var(--woodd) 60%); box-shadow: 0 3px 4px rgba(120, 80, 50, .25); }
.sp { position: relative; z-index: 1; border: 2px solid transparent; border-radius: 12px; background: transparent; padding: 0; aspect-ratio: 1; cursor: pointer; display: grid; place-items: end center; }
.sp img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sp.on { background: var(--peach); border-color: #e8b48c; }
.sp .num { position: absolute; left: 3px; top: 1px; font-size: 11px; color: var(--muted); }
.sill-head { margin: 8px 2px 0; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; } .sill-head span { color: var(--saged); }
.sill-empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.howto { padding: 6px 18px; overflow-y: auto; line-height: 1.5; font-size: 15.5px; }
.howto h3 { color: var(--saged); margin: 10px 0 4px; }
.howto kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 5px; font-family: inherit; font-size: 13px; }
.paste { display: flex; gap: 6px; }
.paste .btn { width: auto; flex: 0 0 auto; }
.paste input { flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
.list { margin: 0; padding-left: 18px; font-size: 14px; columns: 2; column-gap: 18px; }
.err { color: #c0506c; }

/* ---------- drag ghost, modal, toast */
.ghost-drag { position: fixed; z-index: 50; width: 76px; height: 76px; pointer-events: none; display: none; transform: translate(-50%, -70%) scale(1.1); filter: drop-shadow(0 6px 4px rgba(90, 60, 50, .3)); }
.ghost-drag.show { display: block; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(84, 64, 66, .38); display: grid; place-items: center; padding: 14px; }
.modal[hidden] { display: none; }
.modal-card { width: min(460px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; background: var(--paper); border-radius: 24px; border: 3px solid var(--sage); padding: 18px; box-shadow: 0 6px 0 var(--shadow); }
.modal-card h2 { margin: 0 0 8px; color: var(--saged); text-align: center; font-weight: 600; }
.order-prev { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; display: block; border-radius: 16px; background: linear-gradient(#e2f2fb, #fdf1e2); }
.order-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 15px; }
.order-facts dt { color: var(--muted); } .order-facts dd { margin: 0; }
.soon { text-align: center; background: #fde3ea; color: var(--pinkd); border-radius: 14px; padding: 10px; font-weight: 600; font-size: 18px; margin: 8px 0; }
.order-sizes { margin: 0 0 8px; }
.order-sizes .btn { flex: 1 1 28%; min-width: 88px; flex-direction: column; gap: 0; min-height: 52px; font-size: 14px; padding: 6px 8px; line-height: 1.15; }
.order-sizes .price { font-weight: 600; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 70; background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 14px; transition: .25s; pointer-events: none; font-size: 15px; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.foot { text-align: center; padding: 10px 16px 30px; font-size: 14px; }

/* ---------- phones and narrow windows: stage on top, shelf below, like the two DS screens */
@media (max-width: 860px) {
  .hero { padding-top: 16px; }
  .hero-inner { grid-template-columns: 1fr; gap: 14px; }
  .hero-art { order: -1; }
  .lede { font-size: 16.5px; }
  .steps { grid-template-columns: 1fr; gap: 10px; margin-top: 20px; }
  .steps li { min-height: 0; }
  .game { padding: 0; }
  .game-frame { flex-direction: column; height: calc(100svh - 50px); min-height: 600px; border-radius: 0; border: 0; box-shadow: none; }
  .stage { flex: 0 0 45%; }
  .panel { flex: 1 1 auto; border-left: 0; border-top: 3px solid #3c3034; }
  .topbar .navlink:not(.lzw) { display: none; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 2px; padding: 4px; margin: 6px 6px 0; }
  .cell { padding: 2px 1px 4px; }
  .cell .icon { width: 52px; height: 52px; }
  .cell .nm { font-size: 12px; min-height: 0; }
  .inpot { min-height: 46px; padding-top: 4px; }
  .chip { width: 38px; height: 38px; } .chip .icon { width: 32px; height: 32px; }
  .status { min-height: 22px; font-size: 14px; }
  .tab { font-size: 12px; }
  .tab .icon { width: 26px; height: 26px; }
  .controls { grid-template-columns: repeat(3, 40px) 1fr 1fr 1.1fr; gap: 5px; }
  .banner, .count { font-size: 14.5px; top: 8px; }
  .banner { left: 8px; } .count { right: 8px; }
  .hint { font-size: 13px; bottom: 8px; }
  .titlecard { top: 10px; padding: 6px 18px 8px; }
  .stage-tools { right: 8px; bottom: 8px; flex-direction: row; }
  .round { width: 38px; height: 38px; }
  .menu { padding: 12px 20px; }
}
@media (max-width: 380px) { .controls .btn { font-size: 14.5px; } .tab { font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
/* build-time hero capture (tools/shots.mjs renders /?shot=hero) */
body.shot > *:not(.game) { display: none !important; }
body.shot .game { padding: 0; }
body.shot .game-frame { width: 760px; height: 620px; min-height: 0; max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
body.shot .panel, body.shot .stage-tools, body.shot .banner, body.shot .count, body.shot .hint, body.shot .titlecard { display: none !important; }
body.shot .game-frame { flex-direction: row; }
body.shot .stage { flex: 1 1 auto; }
