/* Cozy pixel style — palette + font from the Figma mood board */
@font-face {
  font-family: "VCR OSD Mono";
  src: url("fonts/VCR_OSD_MONO.ttf") format("truetype");
  font-display: swap;
}
:root {
  --cream: #fbf1dc;
  --paper: #fff7e6;
  --wood: #caa070;
  --wood-dark: #8d6440;
  --ink: #3e2f22;        /* darker for readability */
  --ink-soft: #6e5a46;
  --sage: #a5ca8c;
  --sage-dark: #5f8a54;
  --teal: #6cc3c8;
  --teal-dark: #3f8794;
  --water: #5aaebd;
  --peach: #f1c38f;
  --pink: #f2a0a8;
  --sun: #f2c26b;
  --sun-dark: #b9893a;
  --px: 4px;
  --shadow: 6px 6px 0 rgba(62,47,34,.3);
  --font: "VCR OSD Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); font-size: 18px; line-height: 1.4;
  background: var(--water); overflow: hidden;
}
button { font-family: var(--font); }
kbd { font: inherit; background: var(--paper); border: 2px solid var(--wood-dark); padding: 0 6px; }

/* ===== Full-screen island ===== */
.stage {
  /* the game view fills the whole window; the camera follows the player around the island */
  position: fixed; inset: 0; width: 100vw; height: 100vh;
}
.stage { z-index: 1; }
#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; background: var(--water); }

.hud { position: fixed; z-index: 5; display: flex; gap: 10px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-left { top: 10px; left: 10px; flex-direction: column; align-items: flex-start; }
.hud-right { top: 10px; right: 10px; }
/* bottom-left: bag with the controls hint above it (bottom-right water is the town island) */
.hud-bottom { left: 10px; bottom: 10px; max-width: calc(100vw - 180px); flex-direction: column-reverse; align-items: flex-start; }

.chip {
  background: var(--paper); color: var(--ink); padding: 6px 12px; font-size: 1.05rem;
  border: var(--px) solid var(--wood-dark); box-shadow: 4px 4px 0 rgba(62,47,34,.3);
}
.chip.small { font-size: .95rem; padding: 2px 10px; box-shadow: none; margin-left: auto; margin-right: 12px; }

/* square menu buttons (Figma: top-right "daily" / "goals") */
.menu-btn {
  width: 76px; height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--paper); color: var(--ink); font-size: .95rem; cursor: pointer;
  border: var(--px) solid var(--wood-dark); box-shadow: inset 0 -6px 0 rgba(0,0,0,.08), 4px 4px 0 rgba(62,47,34,.3);
}
.menu-btn .ico { font-size: 1.7rem; line-height: 1; }
.menu-btn:hover { background: #fff; transform: translateY(-2px); }
.menu-btn.active { background: var(--sun); }
.menu-btn:focus-visible, .close:focus-visible, button:focus-visible { outline: 3px dashed var(--teal-dark); outline-offset: 3px; }

.bag {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; max-width: 100%;
  background: var(--paper); border: var(--px) solid var(--wood-dark); box-shadow: 4px 4px 0 rgba(62,47,34,.3);
}
.bag-label { font-size: 1rem; white-space: nowrap; }
.bag-items { display: flex; gap: 6px; overflow-x: auto; }
.bag-items .empty { font-size: .95rem; color: var(--ink-soft); }
.bag-items .item {
  position: relative; width: 56px; height: 56px; display: grid; place-items: center; cursor: pointer;
  background: var(--cream); border: 3px solid var(--wood);
}
.bag-items .item img { width: 40px; height: 40px; image-rendering: pixelated; }
.bag-items .item .count {
  position: absolute; right: -2px; bottom: -4px; font-size: .8rem; background: var(--wood-dark); color: var(--paper); padding: 0 4px;
}
.bag-items .item:hover { border-color: var(--sun); }
.bag-items .item.selected { border-color: var(--sage-dark); background: #e2f0d6; outline: 3px solid var(--sage-dark); }
/* "?" controls: small, quiet circle in the top-right corner */
.hud-right { align-items: flex-start; }
.help-dot {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer; align-self: flex-start;
  font-size: 1rem; line-height: 1; color: var(--ink); background: var(--paper);
  border: 3px solid var(--wood-dark); opacity: .5; transition: opacity .15s;
}
.help-dot:hover, .help-dot:focus-visible, .help-dot.active { opacity: 1; }
/* "?" with the little round music button stacked right under it */
.dot-stack { display: flex; flex-direction: column; align-items: center; gap: 8px; align-self: flex-start; }
.music-dot, .pixel-dot { display: grid; place-items: center; }
.music-dot .pi, .pixel-dot .pi { width: 17px; height: 17px; vertical-align: middle; color: var(--ink); }  /* "?" and music note: same pixel ink style */
.music-dot.unavailable { opacity: .3; cursor: not-allowed; }
.help-pop {
  position: fixed; top: 50px; right: 10px; z-index: 15; width: 340px; max-width: calc(100vw - 20px);
  background: var(--paper); border: var(--px) solid var(--wood-dark); box-shadow: var(--shadow); padding: 12px 16px;
}
.help-pop h3 { margin: 0 0 8px; }
.help-pop { width: 400px; }
.help-pop dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); font-size: .95rem; line-height: 1.35; }
.help-pop dt, .help-pop dd { margin: 0; padding: 8px 0; border-top: 2px dashed rgba(110,90,70,.3); }
.help-pop dt:first-of-type, .help-pop dd:first-of-type { border-top: none; }
.help-pop dt { padding-right: 12px; }
.help-pop dd { color: var(--ink-soft); }
.help-pop kbd { white-space: nowrap; }
.music-credit { margin: 10px 0 0; color: var(--ink-soft); font-size: .75rem; }
.music-credit a { color: var(--teal-dark); }

/* town island pinned to the bottom-right corner of the screen */
.town-isle {
  position: fixed; right: 6px; bottom: 6px; z-index: 5; padding: 0; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
}
.town-isle canvas { width: 180px; height: 120px; image-rendering: pixelated; display: block; transition: transform .15s; }
.town-isle .town-label {
  order: -1; margin-bottom: -10px; position: relative; z-index: 1; font-size: 1rem; padding: 2px 10px;
  background: var(--paper); border: 3px solid var(--wood-dark); box-shadow: 3px 3px 0 rgba(62,47,34,.3);
}
.town-isle:hover canvas { transform: translateY(-4px); }
.town-isle:hover .town-label, .town-isle.active .town-label { background: var(--sun); }
.town-isle:hover .town-label::after { content: " · visit"; }

/* ===== Pop-up windows ===== */
.modal {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(40,55,45,.45);
}
.modal.bottom { align-items: flex-end; }
.hidden { display: none !important; }
.window {
  width: 640px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--cream); border: 6px solid var(--wood-dark); box-shadow: 10px 10px 0 rgba(62,47,34,.35);
  animation: pop .18s ease-out;
}
.window.wide { width: 880px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.window-head {
  display: flex; align-items: center; padding: 10px 16px; background: var(--peach); border-bottom: var(--px) solid var(--wood-dark);
}
.window-head h2 { margin: 0; font-size: 1.5rem; flex: 1; }
.window-head .chip.small { flex: none; }
.close {
  width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; color: var(--ink);
  background: var(--paper); border: 3px solid var(--wood-dark);
}
.close:hover { background: var(--pink); }
.window-body { padding: 16px 20px 20px; overflow-y: auto; }
.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.card { background: var(--paper); border: 3px solid var(--wood); padding: 12px 14px; }

h2 { font-size: 1.5rem; } h3 { margin: 14px 0 8px; font-size: 1.2rem; }
.card h3 { margin-top: 0; }
.lead { font-size: 1.1rem; margin: 0 0 8px; }
.muted { color: var(--ink-soft); font-size: .95rem; }
label { display: block; margin: 12px 0; font-size: 1rem; }
input, select {
  width: 100%; padding: 10px; font: inherit; color: var(--ink); margin-top: 6px;
  background: #fff; border: 3px solid var(--wood); border-radius: 0; outline: none;
}
input:focus, select:focus { border-color: var(--teal-dark); }

button.primary, button.secondary {
  width: 100%; padding: 12px 16px; font-size: 1.1rem; cursor: pointer; margin-top: 8px;
  border: var(--px) solid; box-shadow: inset 0 -6px 0 rgba(0,0,0,.12);
}
button.primary { background: var(--sage); color: #fff; text-shadow: 2px 2px 0 var(--sage-dark); border-color: var(--sage-dark); }
button.primary:hover { background: #b2d49a; }
button.secondary { background: var(--paper); color: var(--ink); border-color: var(--wood); font-size: 1rem; }
button.secondary:hover { background: #fff; }
button.primary:active, button.secondary:active { transform: translateY(2px); box-shadow: none; }

.checklist, .list, .history { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 10px 4px; border-bottom: 3px dotted var(--wood); display: flex; gap: 10px; align-items: center; }
.checklist li b { margin-left: auto; white-space: nowrap; }
.list li { padding: 8px 4px; border-bottom: 3px dotted var(--wood); }

/* shop */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.shop-grid .item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; cursor: pointer; text-align: center;
  background: var(--paper); border: var(--px) solid var(--wood); box-shadow: inset 0 -5px 0 rgba(0,0,0,.06);
}
.shop-grid .item img { width: 56px; height: 56px; image-rendering: pixelated; }
.shop-grid .item .name { font-size: 1rem; }
.shop-grid .item .price { font-size: 1.05rem; background: var(--sun); padding: 2px 10px; border: 2px solid var(--sun-dark); }
.shop-grid .item .need { font-size: .85rem; color: var(--ink-soft); }
.shop-grid .item:hover { border-color: var(--sun-dark); transform: translateY(-2px); }
.shop-grid .item.locked { background: #efe6d3; }
.shop-grid .item.locked img { opacity: .45; filter: grayscale(.7); }
.shop-grid .item.locked .price { background: #e4d8c0; border-color: var(--wood); }

.goal { background: var(--paper); border: 3px solid var(--wood); padding: 12px; margin-top: 12px; }
.goal-top { display: flex; justify-content: space-between; gap: 8px; font-size: 1.1rem; }
.bar { height: 22px; background: #ecdcbc; border: 3px solid var(--wood-dark); margin: 8px 0; }
.bar div {
  height: 100%; background: var(--teal);
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(255,255,255,.25) 8px 12px);
}
.goal-row { display: flex; gap: 8px; margin-top: 8px; } .goal-row input { margin: 0; min-width: 0; }
.town-bar { height: 18px; background: var(--paper); border: var(--px) solid var(--wood); }
#projectFill { height: 100%; width: 0; background: var(--sage); transition: width .6s; }
.feed { max-height: 220px; overflow-y: auto; }
.feed li { font-size: .85rem; }
.town-code { letter-spacing: 3px; font-size: 1.2rem; color: var(--teal-dark); }

.game-dialog {
  width: min(620px, 100%); max-height: 90vh; overflow-y: auto; padding: 18px;
  color: var(--ink); background: var(--paper); border: 6px solid var(--wood-dark);
  box-shadow: 8px 8px 0 rgba(90,70,54,.35);
}
.layered-modal { z-index: 110; align-items: center; overflow-y: auto; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-close { padding: 4px 10px; color: var(--ink); background: var(--peach); border: var(--px) solid var(--wood-dark); cursor: pointer; }
.dialog-actions { display: flex; gap: 8px; margin-top: 12px; }
.dialog-actions > * { flex: 1; }
.secondary-btn {
  padding: 8px 12px; color: var(--ink); font: 600 .9rem var(--font); cursor: pointer;
  background: var(--peach); border: var(--px) solid var(--wood-dark);
}
.secondary-btn:hover { background: #f5d2ab; }
.secondary-btn:disabled { cursor: default; opacity: .45; }
.star-work { margin-top: 14px; }
.star-work > .primary { margin-top: 12px; }
.star-feedback { min-height: 1.3em; font-weight: 600; color: var(--sage-dark); }
.mid-track {
  position: relative; display: block; width: 100%; height: 72px; margin: 12px 0;
  background: #d7ece6; border: 3px solid var(--wood-dark); cursor: crosshair;
}
.mid-track:disabled { opacity: 1; }
.mid-dot, .mid-guess {
  position: absolute; top: 50%; width: 18px; height: 18px; border: 3px solid var(--paper);
  border-radius: 50%; transform: translate(-50%, -50%);
}
.mid-dot { background: var(--teal-dark); }
.mid-guess { background: var(--pink); }
.fill-shape { width: min(280px, 100%); height: 120px; margin: 14px auto; border: 5px solid var(--wood-dark); background: var(--cream); }
.fill-level { height: 100%; background: var(--teal); border-right: 3px solid var(--teal-dark); }
.color-swatch { width: 140px; height: 82px; margin: 10px auto; border: 4px solid var(--wood-dark); }
.color-swatch.color-hidden { background: #d8d0c0 !important; }
.color-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; }
.color-controls .color-swatch, .color-controls .primary { grid-column: 1 / -1; }
.color-controls label { margin: 4px 0; }
.draw-canvas { width: 100%; max-width: 320px; height: auto; margin: 10px 0; border: 3px solid var(--wood-dark); outline: none; box-shadow: none; touch-action: none; }
.line-actions { display: flex; gap: 8px; }
.line-actions > * { flex: 1; }
.recall-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: min(300px, 100%); margin: 12px auto; }
.recall-cell { aspect-ratio: 1; background: #d9e8d2; border: 3px solid var(--wood); cursor: pointer; }
.recall-grid.flash .recall-cell.target { background: var(--sun); box-shadow: inset 0 0 0 8px var(--paper); }
.recall-cell.selected { background: var(--teal); border-color: var(--teal-dark); }
.upright-stage { height: 140px; display: grid; place-items: center; background: #e2eee2; border: 3px solid var(--wood); }
.tilted-shape { width: 100px; height: 64px; background: var(--sun); border: 5px solid var(--wood-dark); box-shadow: 6px 6px 0 rgba(90,70,54,.25); }
.speed-track { position: relative; width: min(100%, 320px); height: 58px; margin: 14px 0; overflow: hidden; background: #e2eee2; border: 3px solid var(--wood); }
.speed-track::after { content: ""; position: absolute; inset: 50% 0 auto; border-top: 2px dashed var(--wood-dark); }
.speed-track span { position: absolute; z-index: 1; left: 0; top: 3px; font-size: 2rem; }
.speed-track span.racing { animation: car-race var(--race-time) linear forwards; }
@keyframes car-race { to { transform: translateX(250px); } }
.shade-order { list-style: none; padding: 0; }
.shade-order li { display: flex; align-items: center; gap: 8px; padding: 5px; border-bottom: 1px dotted var(--wood); }
.shade-order li > span:nth-child(2) { flex: 1; }
.shade-swatch { width: 38px; height: 32px; border: 2px solid var(--wood-dark); }
.shade-order button { min-width: 42px; }
.star-result { padding: 18px; text-align: center; background: #e8f3dc; border: 3px solid var(--sage-dark); }
.result-score { font-size: 3.2rem; color: var(--sage-dark); }
.result-score small { font-size: 1.2rem; }
.star-result p { margin: 8px 0; }
#copyCode, #leaveTown { padding: 4px 12px; margin-top: 8px; }
.goal-row button, .mission button, #chatForm button, #copyCode, #leaveTown {
  font: 600 .95rem var(--font); color: #fff; cursor: pointer; padding: 0 12px;
  background: var(--sun); border: var(--px) solid #c79a45; text-shadow: 1px 1px 0 #c79a45;
}
.mission { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mission button { padding: 4px 10px; background: var(--sage); border-color: var(--sage-dark); text-shadow: 1px 1px 0 var(--sage-dark); }
.mission.done { text-decoration: line-through; opacity: .6; }


.goal-row button, .mission button, #chatForm button, #copyCode, #leaveTown {
  font-size: 1rem; color: #fff; cursor: pointer; padding: 6px 14px;
  background: var(--sun); border: 3px solid var(--sun-dark); text-shadow: 1px 1px 0 var(--sun-dark);
}
.mission button { background: var(--sage); border-color: var(--sage-dark); text-shadow: 1px 1px 0 var(--sage-dark); }
.mission .tag { font-size: .85rem; color: var(--ink-soft); }
.mission.done span:first-child { text-decoration: line-through; opacity: .6; }

/* history */
.history li {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 4px; border-bottom: 3px dotted var(--wood);
}
.history .date { color: var(--ink-soft); font-size: .95rem; }
.history .amt { font-size: 1.15rem; }
.history .coins { background: var(--sun); border: 2px solid var(--sun-dark); padding: 0 8px; font-size: .95rem; }
.history .empty { display: block; color: var(--ink-soft); }

/* bank: "How you earn" folded behind a ? toggle */
.earn { margin-top: 16px; }
.earn summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 1rem;
  color: var(--ink-soft); padding: 4px 2px; user-select: none;
}
.earn summary::-webkit-details-marker { display: none; }
.earn summary:hover { color: var(--ink); }
.earn .q {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .85rem;
  border: 2px solid var(--wood-dark); background: var(--paper);
}
.earn .arrow { display: inline-block; transition: transform .15s; }
.earn[open] .arrow { transform: rotate(90deg); }
.earn .card { margin-top: 8px; }

/* hard (unblurred) pixel shadows everywhere, to match the art */
.window, .chat-box { box-shadow: 10px 10px 0 rgba(28,52,44,.38); }
.chip, .bag, .menu-btn { box-shadow: 4px 4px 0 rgba(28,52,44,.38); }

/* ===== Receipt-style windows: translucent paper, dotted leaders, torn bottom edge ===== */
:root { --receipt: rgba(255, 251, 242, .88); }
.modal { background: rgba(30, 55, 50, .25); }
.window, .chat-box {
  background: var(--receipt); border: none; position: relative;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  box-shadow: 8px 8px 0 rgba(28,52,44,.3);
}
/* zig-zag torn edge along the bottom of each receipt */
.window::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(-45deg, transparent 7px, var(--receipt) 0) 0 0 / 14px 10px repeat-x,
              linear-gradient(45deg, transparent 7px, var(--receipt) 0) 0 0 / 14px 10px repeat-x;
}
.window-head, .chat-head {
  background: none; border-bottom: 2px dashed var(--ink-soft); padding: 14px 18px 10px;
  text-align: center; text-transform: uppercase; letter-spacing: 2px;
}
.window-head h2 { font-size: 1.25rem; text-align: center; }
.close, .chat-head button { width: 32px; height: 32px; border: 2px solid var(--ink-soft); background: transparent; font-size: 1rem; }
.window-body { padding: 12px 20px 22px; }
.card, .goal { background: transparent; border: none; border-top: 2px dashed rgba(110,90,70,.45); padding: 10px 0 0; }
input, select { background: rgba(255,255,255,.7); border-width: 2px; }

/* "label ........ value" rows */
.checklist li { border-bottom: none; padding: 6px 0; }
.checklist li > span:first-child { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.checklist li > span:first-child::after { content: ""; flex: 1; border-bottom: 2px dotted rgba(110,90,70,.55); transform: translateY(-4px); }
.history li { border-bottom: 1px dashed rgba(110,90,70,.45); }
.goal-top span:first-child { flex: 1; display: flex; gap: 8px; }
.goal-top span:first-child::after { content: ""; flex: 1; border-bottom: 2px dotted rgba(110,90,70,.55); transform: translateY(-6px); }

/* bank quick-add buttons */
.quick-add { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.quick-add button {
  padding: 12px 0; font-size: 1.15rem; cursor: pointer; color: var(--ink);
  background: rgba(255,255,255,.6); border: 2px solid var(--wood-dark); box-shadow: 3px 3px 0 rgba(28,52,44,.25);
}
.quick-add button:hover { background: var(--sun); }
.quick-add button:active { transform: translate(2px, 2px); box-shadow: none; }
#depAmount { margin-top: 0; }
label[for="depAmount"] { margin-bottom: 0; }

/* daily: receipts pinned to the right side, island stays playable */
.modal.side { background: none; pointer-events: none; justify-content: flex-end; align-items: flex-start; padding: 100px 10px 150px; z-index: 12; }
.modal.side .window { pointer-events: auto; width: 360px; max-height: calc(100vh - 260px); animation: slideIn .18s ease-out; }
/* Short screens (sideways phones): the 100px/150px gaps above left almost no room, so the panel runs from just
   under the menu buttons to the bottom edge (it covers the bottom HUD while open; you can't walk then anyway),
   and the text is a size smaller so several tasks fit at once. */
@media (max-height: 520px) {
  .modal.side { padding: calc(var(--edge, 8px) + 52px) var(--edge, 8px) var(--edge, 8px); }
  .modal.side .window { width: min(380px, 62vw); max-height: 100%; }
  .modal.side .window-head { padding: 4px 10px 4px; }
  .modal.side .window-head h2 { font-size: 1rem; letter-spacing: 1px; }
  .modal.side .window-body { padding: 6px 14px 10px; }
  .modal.side .lead { font-size: .8rem; margin: 0 0 4px; }
  .modal.side .muted { font-size: .72rem; margin: 6px 0 0; }
  .modal.side .checklist li { padding: 2px 0; min-height: 32px; font-size: .85rem; }
  .modal.side .mission .box { width: 18px; height: 18px; }
  .modal.side .mission.done .box::after, .modal.side .mission.striking .box::after { font-size: 1.25rem; top: -7px; }
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Edit mode ===== */
.edit-bar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; max-width: calc(100vw - 420px);
  background: var(--sun); color: var(--ink); border: 3px solid var(--sun-dark); box-shadow: 4px 4px 0 rgba(28,52,44,.38);
  font-size: .95rem;
}
.edit-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
.edit-top { display: flex; align-items: center; gap: 10px; }
.edit-hint { flex: 1; font-size: .85rem; }
.edit-bar button { cursor: pointer; font-size: 1rem; padding: 4px 14px; background: var(--paper); border: 2px solid var(--ink); color: var(--ink); }
.edit-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.edit-tools .tool { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; padding: 4px 10px; background: rgba(255,247,230,.7); }
.edit-tools .tool img { width: 20px; height: 20px; image-rendering: pixelated; border: 1px solid var(--ink); }
.edit-tools .tool.active { background: var(--ink); color: var(--paper); }
body.paving #game { cursor: crosshair; }
/* shop category tabs */
.shop-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.shop-tab { cursor: pointer; font-size: .95rem; padding: 6px 12px; color: var(--ink); background: rgba(255,255,255,.55); border: 2px solid var(--wood); }
.shop-tab:hover { background: #fff; }
.shop-tab.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.shop-section { grid-column: 1 / -1; margin: 10px 0 0; font-size: 1.05rem; border-bottom: 1px dashed rgba(110,90,70,.45); padding-bottom: 4px; }
.shop-section:first-child { margin-top: 0; }
.shop-section small { font-size: .78rem; color: var(--ink-soft); text-transform: none; letter-spacing: 0; margin-left: 6px; }
.shop-grid .path-kit img { border: 2px solid var(--wood-dark); }
.shop-grid .path-kit.owned .price { background: var(--sage); border-color: var(--sage-dark); color: #fff; }
body.editing #game { cursor: grab; }
body.holding, body.holding #game { cursor: grabbing; }
body.holding .bag { outline: 3px dashed var(--sun-dark); outline-offset: 3px; }
/* Phones: edit mode becomes a slim full-width strip at the top, standing in for the coins + menu (hidden while editing),
   so the D-pad, A button and the bag (drop items on it) stay free. Path styles scroll sideways in one row. */
@media (max-width: 760px) {
  body.editing .hud-left, body.editing .hud-right { display: none; }
  .edit-bar { top: 10px; bottom: auto; left: 10px; right: 10px; transform: none; max-width: none; gap: 6px; padding: 8px 10px; font-size: .85rem; }
  .edit-top { flex-wrap: wrap; gap: 4px 10px; }
  .edit-top b { flex: 1; }
  .edit-hint { order: 3; flex-basis: 100%; font-size: .75rem; line-height: 1.35; }
  .edit-bar button { min-height: 36px; padding: 4px 12px; }
  .edit-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .edit-tools::-webkit-scrollbar { display: none; }
  .edit-tools .tool { flex: none; font-size: .85rem; }
}

/* ===== Bank (Figma Desktop-3): amount + LOG are big; account + goal are small ===== */
.bank-window { width: 680px; }
.bank-body { display: flex; flex-direction: column; gap: 12px; }
.bank-q { margin: 4px 0 2px; text-align: center; font-size: 1.35rem; font-weight: 400; }
.bank-q label { margin: 0; font-size: inherit; }
.bank-q .real { color: #d9534f; }
.amt-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
/* warm peach "price tag" tiles (picked one turns green) */
.amt-tile {
  height: 110px; font-size: 2rem; cursor: pointer; color: var(--ink);
  background: #f6d8b0; border: 3px solid #d9a86c; box-shadow: inset 0 -6px 0 rgba(160,100,40,.15), 4px 4px 0 rgba(28,52,44,.25);
}
.amt-tile:hover { background: #fae3c4; transform: translateY(-2px); }
.amt-tile.on { background: #a6d7b0; border-color: var(--sage-dark); }
.amt-tile:active { transform: translate(2px, 2px); box-shadow: none; }
.amt-input { font-size: 1.3rem; padding: 14px 16px; margin: 0; background: rgba(217, 217, 217, .8); border: 3px solid transparent; }
.amt-input:focus { border-color: var(--teal-dark); background: #fff; }
.bank-small { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.small-label { display: block; margin: 0; font-size: .9rem; color: var(--ink); }
.small-label select { margin-top: 4px; padding: 6px 10px; font-size: .95rem; background: rgba(217, 217, 217, .8); border: 2px solid transparent; }
/* bank: "goal?" picker (your unfinished Goals, with mini progress bars) */
.goal-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.goal-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 110px; max-width: 170px; padding: 6px 10px;
  cursor: pointer; color: var(--ink); text-align: left; background: rgba(217, 217, 217, .55); border: 3px solid transparent;
}
.goal-opt.none, .goal-opt.add { min-width: 0; justify-content: center; align-self: stretch; font-size: .85rem; }
.goal-opt.add { border-style: dashed; border-color: rgba(110,90,70,.45); background: transparent; }
.goal-opt-name { font-size: .8rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-opt-bar { width: 100%; height: 6px; background: rgba(255,255,255,.7); }
.goal-opt-bar i { display: block; height: 100%; background: var(--sage-dark); }
.goal-opt-amt { font-size: .7rem; color: var(--ink-soft); }
.goal-opt:hover { background: rgba(255, 255, 255, .8); transform: translateY(-2px); }
.goal-opt.on { background: #e2f0d6; border-color: var(--sage-dark); box-shadow: 3px 3px 0 rgba(28,52,44,.25); }
.log-btn {
  margin-top: 10px; height: 96px; font-size: 2.4rem; letter-spacing: 2px; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 0 12px;
  background: #a6d7b0; border: 4px solid var(--sage-dark); box-shadow: inset 0 -8px 0 rgba(0,0,0,.08), 6px 6px 0 rgba(28,52,44,.3);
}
.log-btn:hover { background: #b6e0bf; }
.log-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.link-btn { align-self: center; background: none; border: none; color: var(--ink-soft); font-size: .9rem; cursor: pointer; text-decoration: underline; }
.bank-body .earn { margin-top: 0; }
@media (max-width: 760px) { .amt-tile { height: 70px; font-size: 1.5rem; } .log-btn { height: 72px; font-size: 1.5rem; } }

/* ===== History & Future ===== */
.future-body { display: flex; flex-direction: column; gap: 14px; }
.future-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fstat { padding: 10px 12px; background: rgba(255,255,255,.55); border-top: 3px solid var(--wood-dark); }
.fstat b { display: block; font-size: 1.6rem; font-weight: 400; }
.fstat small { color: var(--ink-soft); font-size: .8rem; }
.what-if { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1rem; }
.what-if label { margin: 0; }
.rate-box { display: inline-flex; align-items: center; gap: 4px; font-size: 1.1rem; }
.rate-box input { width: 90px; margin: 0; padding: 4px 8px; font-size: 1.1rem; }
.horizon-pick { display: flex; gap: 6px; }
.hz { padding: 4px 12px; cursor: pointer; font-size: .9rem; color: var(--ink); background: #f6d8b0; border: 2px solid #d9a86c; }
.hz.on { background: #a6d7b0; border-color: var(--sage-dark); }
/* milestone markers on the graph (click to show that year's island) */
#futureChart .ms { cursor: pointer; outline: none; }
#futureChart .msline { stroke: rgba(62,47,34,.22); stroke-width: 1; stroke-dasharray: 3 3; }
#futureChart .mslabel { fill: var(--ink-soft); font: 11px var(--font); }
#futureChart .ms.on .msline { stroke: var(--ink); stroke-dasharray: none; opacity: .5; }
#futureChart .ms.on .mslabel, #futureChart .ms:hover .mslabel, #futureChart .ms:focus .mslabel { fill: var(--ink); font-weight: 700; }
.chart-wrap { position: relative; margin: 0; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; margin-bottom: 4px; }
.chart-legend i { display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; }
.chart-legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 6px, transparent 6px 10px); }
#futureChart { width: 100%; height: auto; display: block; overflow: visible; }
#futureChart .grid { stroke: rgba(62,47,34,.12); stroke-width: 1; }
#futureChart .today { stroke: rgba(62,47,34,.35); stroke-width: 1; stroke-dasharray: 2 3; }
#futureChart .tick { fill: var(--ink-soft); font: 11px var(--font); }
#futureChart .dl { fill: var(--ink); font: 12px var(--font); }
#futureChart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#futureChart .end { stroke: #fffbf2; stroke-width: 2; }
#futureChart .xhair { stroke: var(--ink); stroke-width: 1; opacity: .5; }
/* readout above the graph: shows the amounts under your finger/mouse, and "$X saved in N yrs!" while the graph draws in.
   It sits above the lines instead of floating on them, so nothing on the graph gets covered. */
.chart-read { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-height: 2.4em; margin: 2px 0 4px; padding: 5px 10px;
  font-size: .85rem; background: rgba(255,255,255,.55); border: 2px dashed rgba(110,90,70,.35); }
.chart-read b { font-size: .95rem; }
.chart-read i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: middle; }
.chart-read.flash { background: var(--sun); border: 2px solid var(--ink); animation: msPop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes msPop { from { opacity: 0; scale: .9; } to { opacity: 1; scale: 1; } }
@media (max-width: 520px) { .chart-read { min-height: 5.4em; align-content: center; } } /* fixed height so the graph doesn't jump under your finger */
#futureChart { touch-action: pan-y; } /* sideways drags read the graph; up/down still scrolls the window */
.chart-table summary { cursor: pointer; font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }
.chart-table table { border-collapse: collapse; font-size: .85rem; margin-top: 6px; }
.chart-table th, .chart-table td { padding: 4px 12px; text-align: right; border-bottom: 1px dashed rgba(110,90,70,.4); }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-wrap figcaption { font-size: .75rem; margin-top: 6px; }
.preview h3 { margin: 0 0 8px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.preview-head h3 { margin: 0; }
/* the preview as a slightly tilted postcard with a white border and a stamp */
.postcard { position: relative; width: fit-content; max-width: 100%; margin: 6px auto 4px; padding: 12px 12px 34px;
  background: #fffdf7; transform: rotate(-1.2deg); box-shadow: 8px 8px 0 rgba(28,52,44,.28); }
#previewIsland { width: 100%; max-width: 560px; height: auto; display: block; image-rendering: pixelated; background: var(--water); }
.postcard-stamp { position: absolute; right: 14px; bottom: 8px; font-size: .85rem; color: #b5443f; border: 2px solid #b5443f; padding: 0 8px; transform: rotate(-4deg); }
.pv-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: .95rem; }
.pv-list li { padding: 6px 10px; background: rgba(255,255,255,.5); border-left: 3px solid var(--sun-dark); }
.hist-log { border-top: 2px dashed rgba(110,90,70,.45); padding-top: 8px; }
.hist-log summary { cursor: pointer; font-size: 1rem; }
.hist-log[open] summary { margin-bottom: 8px; }
@media (max-width: 760px) { .future-stats { grid-template-columns: 1fr; } }

/* ===== Stats card (top-left): dark, rounded — deliberately unlike the paper UI ===== */
.stats {
  flex-direction: column; gap: 0; padding: 4px 0; min-width: 176px;
  background: rgba(46, 36, 27, .84); color: #fff7e6; border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(28,52,44,.38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.stat { display: flex; align-items: center; gap: 10px; padding: 7px 14px; }
.stat + .stat { border-top: 1px solid rgba(255,247,230,.16); }
.stat-ico { font-size: 1.35rem; width: 28px; text-align: center; }
.stat b { display: block; font-size: 1.3rem; line-height: 1.1; color: var(--sun); font-weight: 400; }
.stat:first-child b { font-size: 1.6rem; }
.stat small { display: block; font-size: .7rem; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,247,230,.72); }

/* ===== Bank greeting ===== */
.bank-hello { font-size: 2.1rem; line-height: 1.1; margin: 4px 0 6px; color: var(--teal-dark); text-shadow: 2px 2px 0 rgba(63,135,148,.18); }
.bank-ask { display: block; font-size: 1rem; margin: 0 0 4px; color: var(--ink-soft); }
.bank-ask .real { color: var(--sage-dark); text-decoration: underline wavy rgba(95,138,84,.5); text-underline-offset: 4px; }

/* ===== Configure accounts ===== */
.acct-editor { margin: -4px 0 12px; padding: 10px 12px; border: 2px dashed rgba(110,90,70,.5); background: rgba(255,255,255,.45); }
.acct-head { display: flex; justify-content: space-between; align-items: center; font-size: .95rem; margin-bottom: 6px; }
.acct-head button, .acct-add button, .acct-list button {
  cursor: pointer; font-size: .9rem; color: var(--ink); background: transparent; border: 2px solid var(--ink-soft); padding: 2px 10px;
}
.acct-head button:hover, .acct-add button:hover { background: var(--sun); }
.acct-list { list-style: none; margin: 0; padding: 0; }
.acct-list li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px dashed rgba(110,90,70,.4); }
.acct-list button { padding: 0 8px; }
.acct-list button:hover:not(:disabled) { background: var(--pink); }
.acct-list button:disabled { opacity: .35; cursor: not-allowed; }
.acct-add { display: flex; gap: 6px; margin-top: 8px; } .acct-add input { margin: 0; padding: 6px 8px; }

/* ===== Daily checklist ===== */
.mission { cursor: pointer; gap: 10px; user-select: none; }
.mission .box {
  flex: none; width: 22px; height: 22px; position: relative;
  border: 2px solid var(--ink); background: rgba(255,255,255,.6);
}
.mission:not(.done):hover .box, .mission:focus-visible .box { background: var(--sun); }
.mission:focus-visible { outline: 2px dashed var(--teal-dark); outline-offset: 2px; }
.mission.done .box::after, .mission.striking .box::after {
  content: "✓"; position: absolute; left: 2px; top: -8px; font-size: 1.5rem; color: var(--sage-dark);
}
.mission .text { flex: 1; position: relative; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mission .text::after { content: ""; flex: 1; border-bottom: 2px dotted rgba(110,90,70,.55); transform: translateY(-4px); }
/* strike-through drawn on the words themselves, so every wrapped line gets its own line
   (.label is the flex item; .ink is plain inline text inside it, and box-decoration-break: clone
   gives each wrapped line its own copy of the background line) */
.mission .ink {
  background: linear-gradient(var(--ink), var(--ink)) no-repeat 0 55% / 0 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.mission.striking .ink { animation: strike .45s ease-out forwards; }
.mission.done .ink { background-size: 100% 2px; }
.mission.done { cursor: default; opacity: .5; }
.mission.striking { animation: fadeDone .6s ease-in forwards; }
@keyframes strike { to { background-size: 100% 2px; } }
@keyframes fadeDone { 70% { opacity: 1; } to { opacity: .5; } }

/* ===== History sorting ===== */
.hist-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hist-tools label { margin: 0; white-space: nowrap; }
.hist-tools select { margin: 0; width: auto; flex: 1; }
.history li.group {
  display: flex; justify-content: space-between; margin-top: 14px; padding: 6px 0 4px;
  border-bottom: 2px solid var(--ink); text-transform: uppercase; letter-spacing: 1px; font-size: 1rem;
}

/* ===== Towns ===== */
/* corkboard newsboard */
.newsboard {
  position: relative; padding: 14px 14px 18px; margin: 22px 0 14px;
  background-color: #c79a68;
  background-image:
    radial-gradient(rgba(110,70,35,.35) 1.5px, transparent 1.6px),
    radial-gradient(rgba(255,235,200,.25) 1px, transparent 1.2px);
  background-size: 9px 9px, 13px 13px; background-position: 0 0, 4px 6px;
  border: 10px solid #8d6440; box-shadow: inset 0 0 0 2px #6e4a31, 6px 6px 0 rgba(28,52,44,.3);
}
.board-title {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap;
  padding: 4px 16px; font-size: 1rem; letter-spacing: 2px; text-transform: uppercase;
  background: var(--paper); border: 2px solid var(--outline, #3e2f22); box-shadow: 3px 3px 0 rgba(28,52,44,.3);
}
.board { display: flex; gap: 16px; overflow-x: auto; padding: 18px 6px 6px; min-height: 150px; align-items: flex-start; }
.poster {
  position: relative; flex: none; width: 168px; padding: 20px 12px 10px;
  background: var(--paper); color: var(--ink); transform: rotate(var(--tilt, 0deg));
  box-shadow: 3px 5px 0 rgba(40,25,12,.35); transition: transform .15s;
}
.poster:hover { transform: rotate(0deg) scale(1.05); z-index: 1; }
.poster .pin {
  position: absolute; top: 6px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff9a8a, #d9534f 55%, #9e2f2b);
  box-shadow: 2px 2px 0 rgba(0,0,0,.3);
}
.poster .headline { margin: 0 0 4px; font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; overflow-wrap: anywhere; }
.poster .body { margin: 0; font-size: .85rem; line-height: 1.3; overflow-wrap: anywhere; }
.poster .stamp {
  display: inline-block; margin-top: 8px; padding: 1px 6px; font-size: .8rem; color: #b5443f;
  border: 2px solid #b5443f; transform: rotate(-6deg); opacity: .85;
}
.poster .meta { margin: 8px 0 0; font-size: .7rem; color: var(--ink-soft); border-top: 1px dashed rgba(110,90,70,.5); padding-top: 4px; }

/* gallery of towns */
.town-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 8px 0 12px; }
.town-card {
  display: flex; flex-direction: column; gap: 4px; padding: 10px; text-align: left; cursor: pointer; color: var(--ink);
  background: rgba(255,255,255,.55); border: 3px solid var(--wood-dark); box-shadow: 4px 4px 0 rgba(28,52,44,.3);
}
.town-card:hover { transform: translateY(-3px); background: rgba(255,255,255,.8); }
.town-card img { width: 100%; height: 110px; object-fit: contain; image-rendering: pixelated; background: var(--water); }
.town-card h4 { margin: 4px 0 0; font-size: 1.15rem; }
.town-meta { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.town-card.add {
  align-items: center; justify-content: center; min-height: 200px; font-size: 1.05rem; text-align: center;
  background: transparent; border-style: dashed; box-shadow: none;
}
.town-bar { height: 18px; background: rgba(255,255,255,.6); border: 2px solid var(--wood-dark); }
.town-bar .fill { height: 100%; width: 0; background: var(--sage); transition: width .6s;
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(255,255,255,.25) 8px 12px); }
.town-form { border-top: 2px dashed rgba(110,90,70,.45); padding-top: 8px; margin-bottom: 8px; }
.town-form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.town-name-field { max-width: 320px; }

/* one town in its own pop-up (on top of the Towns window) */
.sub-modal {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(30, 55, 50, .3);
}
.sub-modal .window { width: 620px; animation: pop .18s ease-out; }
.newsboard.small { border-width: 8px; }
.newsboard.small .board { min-height: 120px; }
.newsboard.small .poster { width: 150px; }
.town-bar.big { height: 24px; }
.invite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; padding: 8px 0; border-top: 1px dashed rgba(110,90,70,.45); border-bottom: 1px dashed rgba(110,90,70,.45); }
.members li::after { content: none; }
.town-project { margin: 4px 0 0; font-size: .95rem; }
.proj-new { border-top: 1px dashed rgba(110,90,70,.45); margin-top: 8px; }
.proj-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 10px; align-items: end; }
.proj-form label { margin: 0; }
.proj-form .primary { width: auto; margin: 0; padding: 10px 14px; }
@media (max-width: 760px) { .proj-form { grid-template-columns: 1fr; } }
.back { cursor: pointer; font-size: 1rem; color: var(--ink); background: transparent; border: 2px solid var(--ink-soft); padding: 4px 12px; }
.back:hover { background: var(--sun); }
.town-detail-title { font-size: 1.5rem; margin: 12px 0 4px; }
.town-code { letter-spacing: 3px; font-size: 1.2rem; color: var(--teal-dark); }
#leaveTown { margin-top: 12px; }
@media (max-width: 760px) { .town-form-cols { grid-template-columns: 1fr; } }

/* villager chat */
.chat-scene { width: 680px; max-width: 100%; display: flex; flex-direction: column; }
.chat-stage { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 40px; margin-bottom: -6px; }
.chat-portrait {
  width: 144px; height: 168px; image-rendering: pixelated; image-rendering: crisp-edges;
  transition: filter .2s, transform .2s; transform-origin: bottom center;
  filter: brightness(.6) saturate(.6); transform: scale(.9);
}
.chat-portrait.talking { filter: none; transform: none; animation: talkBob .5s steps(2) infinite; }
#chatMe.talking { animation: slideL .25s ease-out, talkBob .5s steps(2) .25s infinite; }
#chatFox.talking { animation: slideR .25s ease-out, talkBob .5s steps(2) .25s infinite; }
@keyframes talkBob { 50% { transform: translateY(-6px); } }
@keyframes slideL { from { transform: translateX(-12px); opacity: 0; } }
@keyframes slideR { from { transform: translateX(12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chat-portrait.talking, #chatMe.talking, #chatFox.talking { animation: none; } }
.chat-box {
  position: relative; width: 100%; background: var(--paper); border-radius: 28px;
  border: 6px solid var(--wood-dark); box-shadow: 10px 10px 0 rgba(62,47,34,.35); animation: pop .18s ease-out;
}
.chat-name {
  position: absolute; top: -22px; right: 48px; padding: 4px 18px; font-size: 1.1rem; color: var(--ink);
  background: var(--peach); border: 4px solid var(--wood-dark); border-radius: 14px; transform: rotate(-3deg);
}
.chat-name.me { right: auto; left: 48px; background: #dff1ef; border-color: var(--teal-dark); transform: rotate(3deg); }
.chat-close { position: absolute; top: 10px; right: 14px; width: 36px; height: 36px; background: transparent; border: 2px solid var(--ink-soft); color: var(--ink); cursor: pointer; border-radius: 50%; }
#chatForm .chat-hist-btn { flex: none; background: transparent; border: 2px solid var(--ink-soft); color: var(--ink); box-shadow: none; }
#chatForm .chat-hist-btn:hover, .chat-close:hover { background: var(--sun); }
.chat-history { padding: 50px 20px 12px; border-bottom: 3px dotted var(--wood); }
.chat-history:not(.hidden) ~ #chatLog, .chat-history:not(.hidden) ~ .chat-next { display: none; }
#chatHistoryList { max-height: 300px; overflow-y: auto; padding-right: 6px; }
.hist-day { text-align: center; font-size: .8rem; color: var(--ink-soft); margin: 10px 0 4px; }
.hist-msg { margin: 6px 0; padding: 8px 12px; max-width: 85%; border: 3px solid var(--wood); background: var(--cream); border-radius: 14px; }
.hist-msg b { display: block; font-size: .8rem; color: var(--wood-dark); }
.hist-msg.me { margin-left: auto; background: #dff1ef; border-color: var(--teal-dark); }
.chat-memory { font-size: .9rem; margin-top: 10px; } .chat-memory ul { margin: 4px 0 0 18px; padding: 0; }
.chat-forget { margin-top: 10px; background: transparent; border: 2px solid var(--ink-soft); color: var(--ink-soft); padding: 4px 10px; min-height: 36px; cursor: pointer; font: inherit; font-size: .8rem; }
.chat-next { position: absolute; right: 28px; bottom: 72px; color: var(--wood-dark); opacity: 0; animation: nextBlink .8s steps(2) infinite; }
.chat-box.done .chat-next { opacity: 1; }
@keyframes nextBlink { 50% { transform: translateY(4px); } }
@media (max-width: 560px) { .chat-portrait { width: 96px; height: 112px; } .chat-stage { padding: 0 16px; } }
.chat-head {
  background: var(--peach); color: var(--ink); font-size: 1.2rem; padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center; border-bottom: var(--px) solid var(--wood-dark);
}
.chat-head button { width: 40px; height: 40px; background: var(--paper); border: 3px solid var(--wood-dark); color: var(--ink); font-size: 1.1rem; cursor: pointer; }
#chatLog { min-height: 110px; max-height: 200px; overflow-y: auto; padding: 30px 56px 16px 28px; font-size: 1.2rem; line-height: 1.5; cursor: pointer; }
#chatForm { display: flex; gap: 8px; padding: 12px; border-top: 3px dotted var(--wood); } #chatForm input { margin: 0; }

#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 40; padding: 12px 20px; max-width: 90vw;
  background: var(--paper); color: var(--ink); border: var(--px) solid var(--wood-dark); box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 1.05rem;
}
#toast.show { opacity: 1; }

/* small screens: stack, shrink buttons */
@media (max-width: 760px) {
  body { font-size: 16px; overflow: auto; }
  .stage { top: 0; transform: none; }
  .menu-btn { width: 58px; height: 58px; font-size: .75rem; }
  .menu-btn .ico { font-size: 1.3rem; }
  .hud-right { gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
  .chip { font-size: .85rem; padding: 4px 8px; }
  .town-isle canvas { width: 120px; height: 80px; }
  .hud-bottom { max-width: calc(100vw - 140px); }
  .help-pop { top: 50px; }
  .two-col { grid-template-columns: 1fr; }
}

/* ===== Entrance screen ===== */
body.intro-open { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--teal); overflow: hidden; padding: 16px;
}
.intro[hidden] { display: none; }
#introScene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.intro-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; max-width: 100%; margin-top: -18vh; }

/* wooden sign, same planks as the game header */
.intro-sign {
  position: relative; padding: 18px 28px; max-width: 100%; text-align: center;
  background: var(--wood); border: 6px solid var(--wood-dark); box-shadow: 8px 8px 0 rgba(90,70,54,.3);
  background-image: repeating-linear-gradient(0deg, transparent 0 12px, rgba(141,100,64,.35) 12px 16px);
  transform-origin: 50% -40px;
  animation: signDrop .7s cubic-bezier(.3,1.5,.5,1) both, signSway 4s ease-in-out 1.4s infinite;
}
/* little ropes the sign hangs from */
.intro-sign::before, .intro-sign::after {
  content: ""; position: absolute; top: -46px; width: 6px; height: 40px; background: var(--wood-dark);
}
.intro-sign::before { left: 24px; } .intro-sign::after { right: 24px; }
.intro-title {
  margin: 0; font-size: clamp(1.8rem, 7vw, 3.6rem); line-height: 1.15; color: var(--paper);
  text-shadow: 4px 4px 0 var(--wood-dark); letter-spacing: 2px; text-transform: uppercase;
}
.intro-title .word { display: inline-block; white-space: nowrap; }
.intro-title .ch {
  display: inline-block; opacity: 0;
  animation: letterDrop .5s cubic-bezier(.3,1.8,.5,1) forwards;
  animation-delay: calc(var(--i) * 70ms + 500ms);
}

.intro-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.intro-btn {
  font: 600 1.15rem var(--font); color: #fff; cursor: pointer; padding: 12px 22px;
  border: var(--px) solid; box-shadow: inset 0 -6px 0 rgba(0,0,0,.12), 6px 6px 0 rgba(90,70,54,.3);
  opacity: 0; animation: btnPop .45s cubic-bezier(.3,1.6,.5,1) forwards;
  animation-delay: calc(var(--letters, 14) * 70ms + 900ms);
}
.intro-btn.star { animation-delay: calc(var(--letters, 14) * 70ms + 1050ms); }
.intro-btn.go { background: var(--sage); border-color: var(--sage-dark); text-shadow: 2px 2px 0 var(--sage-dark); }
.intro-btn.go:hover { background: #b2d49a; }
.intro-btn.star { background: var(--sun); border-color: #c79a45; text-shadow: 2px 2px 0 #c79a45; }
.intro-btn.star:hover { background: #f5cf85; }
.intro-btn:hover { transform: translateY(-3px); }
.intro-btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.intro-btn:focus-visible { outline: var(--px) dashed var(--paper); outline-offset: 4px; }
.intro-btn.wiggle { animation: wiggle .5s ease; opacity: 1; }

.intro-note {
  margin: 0; min-height: 1.4em; padding: 0 12px; text-align: center; color: var(--ink); font-weight: 600;
  background: var(--paper); border: var(--px) solid var(--wood-dark); opacity: 0;
}
.intro-note:empty { visibility: hidden; }
.intro-note.show { animation: btnPop .35s cubic-bezier(.3,1.6,.5,1) forwards; padding: 8px 14px; }

/* leaving: sign hops, buttons sink, then the screen closes like a camera iris onto the island */
.intro.leaving { animation: irisOut .9s cubic-bezier(.6,0,.8,.4) .45s forwards; }
.intro.leaving .intro-sign { animation: hop .45s ease-out forwards; }
.intro.leaving .intro-btn { animation: sink .35s ease-in forwards; }
.intro.leaving .intro-btn.picked { animation: picked .45s ease-out forwards; }
.intro.leaving .intro-note { opacity: 0; }

@keyframes signDrop { from { transform: translateY(-120vh); } to { transform: none; } }
@keyframes signSway { 0%, 100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.2deg); } }
@keyframes letterDrop { 0% { opacity: 0; transform: translateY(-40px) scale(.6); } 100% { opacity: 1; transform: none; } }
@keyframes btnPop { 0% { opacity: 0; translate: 0 20px; scale: .7; } 100% { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -4deg; } 75% { rotate: 4deg; } }
@keyframes hop { 0% { transform: none; } 40% { transform: translateY(-24px) scale(1.05); } 100% { transform: translateY(-6px) scale(.95); } }
@keyframes picked { 0% { opacity: 1; transform: none; } 40% { transform: scale(1.15); } 100% { opacity: 1; transform: scale(1.05); } }
@keyframes sink { to { opacity: 0; transform: translateY(16px); } }
@keyframes irisOut {
  from { clip-path: circle(150% at 50% 55%); }
  to { clip-path: circle(0% at 50% 55%); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-sign, .intro-title .ch, .intro-btn, .intro-note.show { animation: none !important; opacity: 1; transform: none; }
  .intro.leaving { animation: none; opacity: 0; transition: opacity .3s; }
  .intro.leaving .intro-sign, .intro.leaving .intro-btn { animation: none; }
}
@media (max-width: 480px) {
  .intro-sign { padding: 14px 16px; }
  .intro-btn { width: 100%; font-size: 1.05rem; }
  .game-dialog { padding: 12px; }
  .color-controls { grid-template-columns: 1fr; }
  .color-controls .color-swatch, .color-controls .primary { grid-column: 1; }
}

/* personal goals tracker (Goals pop-up) */
#personalGoals .goal { position: relative; padding-bottom: 44px; }
.goal-completed { opacity: .7; }
.goal-name { display: block; padding-right: 40px; }
.goal-star {
  position: absolute; top: 5px; right: 6px; padding: 2px 6px; color: var(--ink-soft); cursor: pointer;
  background: transparent; border: 0; font: 1.55rem/1 var(--font);
}
.goal-star.starred { color: var(--sun); text-shadow: 1px 1px 0 var(--wood-dark); }
.goal-star:focus-visible { outline: 2px solid var(--teal-dark); outline-offset: 2px; }
.goal-complete { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: .85rem; }
.goal-complete input { width: auto; margin: 0; accent-color: var(--sage-dark); }
.goal-menu { position: absolute; right: 6px; bottom: 4px; z-index: 2; }
.goal-menu summary { list-style: none; cursor: pointer; padding: 0 8px; font-size: 1.4rem; line-height: 1.2; }
.goal-menu summary::-webkit-details-marker { display: none; }
.goal-menu summary:focus-visible { outline: 2px solid var(--teal-dark); outline-offset: 2px; }
.goal-menu button {
  position: absolute; right: 0; bottom: calc(100% + 4px); white-space: nowrap; padding: 6px 10px;
  font: .85rem var(--font); color: var(--ink); cursor: pointer; background: var(--paper); border: var(--px) solid var(--wood-dark);
  box-shadow: 3px 3px 0 rgba(90,70,54,.25);
}

/* ===== Header title = home button ===== */
.intro[hidden] { display: none; }
.home-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 0; margin: 0; cursor: pointer;
  background: none; border: none; font: inherit; color: inherit; text-shadow: inherit; letter-spacing: inherit;
}
.pixel-palm {
  width: 44px; height: 44px; flex: none; image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 var(--wood-dark));
}
.pixel-palm .palm-top { transform-origin: 8px 10px; }
.home-btn:hover .pixel-palm .palm-top { animation: palmSway 1.6s ease-in-out infinite; }
@keyframes palmSway { 0%, 50%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.home-btn:hover .pixel-palm { animation: palmHop .4s cubic-bezier(.3,1.8,.5,1); }
@keyframes palmHop { 40% { translate: 0 -5px; } }
.home-btn:hover span { color: #fff; }
.home-btn:focus-visible { outline: var(--px) dashed var(--paper); outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) {
  .pixel-palm .palm-top, .home-btn:hover .pixel-palm { animation: none; }
}

/* Home title sign above the stats card (top-left HUD) */
.hud-left .stats { display: flex; }
.home-title { margin: 0; font-size: 1.25rem; font-weight: 400; }
.home-title .home-btn {
  gap: 8px; padding: 6px 12px 6px 8px; color: var(--paper); text-shadow: 2px 2px 0 var(--wood-dark); letter-spacing: 1px;
  background: var(--wood); border: var(--px) solid var(--wood-dark); box-shadow: 4px 4px 0 rgba(28,52,44,.38);
  background-image: repeating-linear-gradient(0deg, transparent 0 10px, rgba(141,100,64,.35) 10px 13px);
}
.home-title .pixel-palm { width: 32px; height: 32px; filter: drop-shadow(2px 2px 0 var(--wood-dark)); }
.home-title .home-btn:hover { transform: translateY(-2px); }
@media (max-width: 600px) { .home-title span { display: none; } }

/* ===== Pixel icons (icons.js): still until you hover, like a rollover ===== */
.pi {
  display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -.22em; flex: none;
  overflow: visible; image-rendering: pixelated; transform-origin: 50% 90%;
  animation: none; animation-iteration-count: infinite; animation-timing-function: ease-in-out;
}
.pa-spin, .pa-twinkle { transform-origin: 50% 50%; }
.pa-flicker { transform-origin: 50% 100%; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-spin, :hover > .pa-spin, .pa-spin:hover { animation: pi-spin 1.6s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-hop, :hover > .pa-hop, .pa-hop:hover { animation: pi-hop 1.1s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-flicker, :hover > .pa-flicker, .pa-flicker:hover { animation: pi-flicker .6s steps(1) infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-bob, :hover > .pa-bob, .pa-bob:hover { animation: pi-bob 1.2s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-twinkle, :hover > .pa-twinkle, .pa-twinkle:hover { animation: pi-twinkle 1.2s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-sway, :hover > .pa-sway, .pa-sway:hover { animation: pi-sway 1.6s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-swing, :hover > .pa-swing, .pa-swing:hover { animation: pi-swing 1.1s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-tap, :hover > .pa-tap, .pa-tap:hover { animation: pi-tap 1s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-tilt, :hover > .pa-tilt, .pa-tilt:hover { animation: pi-tilt 1.4s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-wiggle, :hover > .pa-wiggle, .pa-wiggle:hover { animation: pi-wiggle 1.2s ease-in-out infinite; }
:is(button, a, summary, label, li, .stat, .sky-clock, .item):hover .pa-pop, :hover > .pa-pop, .pa-pop:hover { animation: pi-pop .4s cubic-bezier(.3,1.8,.5,1); }
/* every move starts right away (no waiting through a pause first) */
@keyframes pi-spin    { 0%, 60%, 100% { transform: scaleX(1); } 15% { transform: scaleX(.35); } 30% { transform: scaleX(-1); } 45% { transform: scaleX(.35); } }
@keyframes pi-hop     { 0%, 50%, 100% { transform: none; } 20% { transform: translateY(-18%); } 35% { transform: translateY(0) scale(1.06, .94); } }
@keyframes pi-flicker { 0% { transform: scale(.94, 1.06) skewX(-4deg); } 50% { transform: scale(1.04, .96) skewX(3deg); } }
@keyframes pi-bob     { 0%, 100% { transform: none; } 50% { transform: translateY(-9%); } }
@keyframes pi-twinkle { 0%, 100% { transform: none; filter: none; } 50% { transform: scale(1.14) rotate(8deg); filter: brightness(1.12); } }
@keyframes pi-sway    { 0%, 50%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes pi-swing   { 0%, 50%, 100% { transform: rotate(0); } 15% { transform: rotate(-16deg); } 30% { transform: rotate(8deg); } }
@keyframes pi-tap     { 0%, 45%, 100% { transform: none; } 15% { transform: translateY(-14%); } 30% { transform: translateY(4%); } }
@keyframes pi-tilt    { 0%, 50%, 100% { transform: rotate(0); } 15% { transform: rotate(-10deg); } 30% { transform: rotate(6deg); } }
@keyframes pi-wiggle  { 0%, 45%, 100% { transform: rotate(0); } 10% { transform: rotate(-12deg); } 20% { transform: rotate(10deg); } 30% { transform: rotate(-4deg); } }
@keyframes pi-pop     { from { transform: scale(.6); } 60% { transform: scale(1.25); } to { transform: none; } }
/* shop + bag items bob only while you hover them */
.shop-grid .item img, .bag-items .item img { image-rendering: pixelated; }
.shop-grid .item:hover img, .bag-items .item:hover img { animation: pi-bob 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .pi, .shop-grid .item img, .bag-items .item img { animation: none !important; }
}

/* town build info pop-up */
.contrib-list { list-style: none; padding: 0; margin: 0 0 22px; }
.contrib-list .contrib { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 6px 0; }
.contrib-list .contrib .town-bar { grid-column: 1 / -1; }
.contrib-list .contrib .fill { filter: saturate(2.2) brightness(.9); }

/* encouragement notes */
.note-form { display: flex; gap: 8px; margin-top: 12px; }
.note-form input { flex: 1; min-width: 0; margin: 0; }
.note-form select { width: auto; margin: 0; }
.note-form .primary { width: auto; margin: 0; padding: 8px 14px; }

/* poster hearts / edit / delete */
.poster-actions { display: flex; gap: 6px; margin-top: 6px; }
.poster-actions button { background: none; border: none; padding: 2px 4px; margin: 0; width: auto; font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink-soft); }
.poster-actions button:disabled { cursor: default; }
.poster-actions .heart.on { color: #d9534f; }
.poster-actions button:not(:disabled):hover { transform: scale(1.15); }
.poster .note-edit { width: 100%; margin: 0; font-size: .85rem; padding: 4px; }

/* ===== Sky clock (sky.js): time, mood of the hour, next sunrise / sunset ===== */
.sky-clock {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; min-width: 176px;
  background: rgba(46, 36, 27, .84); color: #fff7e6; border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(28,52,44,.38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sky-clock canvas {
  width: 84px; height: 42px; flex: none; image-rendering: pixelated; border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(255,247,230,.25);
}
.sky-text { display: flex; flex-direction: column; line-height: 1.15; }
.sky-text b { font-size: 1.15rem; font-weight: 400; color: var(--sun); }
.sky-text small { font-size: .7rem; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(255,247,230,.75); }
.sky-text .sky-next { text-transform: none; letter-spacing: .5px; margin-top: 2px; white-space: nowrap; }
.sky-text .sky-next .pi { width: 1.4em; height: 1.4em; vertical-align: -.35em; }
@media (max-width: 600px) { .sky-clock canvas { width: 56px; height: 28px; } .sky-text .sky-next { display: none; } }

/* ===== Daily Star (opens over the intro's island scene) ===== */
.intro-stage.star-mode { margin-top: 0; }
.intro-stage.star-mode .intro-sign,
.intro-stage.star-mode .intro-buttons,
.intro-stage.star-mode .intro-note { display: none; }

.star-card {
  width: 640px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; background: var(--paper);
  border: 6px solid var(--wood-dark); box-shadow: 8px 8px 0 rgba(90,70,54,.35);
}
.star-card[hidden] { display: none; }
.star-card.pop { animation: btnPop .45s cubic-bezier(.3,1.6,.5,1) both; }
.star-head {
  flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 14px; font-weight: 700; font-size: 1.1rem; color: var(--ink);
  background: var(--sun); border-bottom: var(--px) solid var(--wood-dark);
  background-image: repeating-linear-gradient(90deg, transparent 0 12px, rgba(255,255,255,.18) 12px 16px);
}
.star-x { background: none; border: none; color: var(--ink); font: 700 1.1rem var(--font); cursor: pointer; padding: 2px 6px; }
.star-x:hover { color: var(--paper); }
.star-body { overflow-y: auto; padding: 12px 18px 16px; }
.star-body h3 { margin: 14px 0 6px; font-size: 1rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1px; }
.star-status { margin: 0; font-size: .85rem; color: var(--ink-soft); text-align: right; }
.star-setup {
  margin: 0; padding: 10px 12px; line-height: 1.5; background: var(--cream);
  border: var(--px) solid var(--wood); cursor: default;
}
.star-setup.typing { cursor: pointer; }
.star-setup.typing::after { content: "▌"; animation: blink .6s steps(1) infinite; color: var(--wood-dark); }
@keyframes blink { 50% { opacity: 0; } }
#starForm label { margin: 14px 0 0; }
#starForm textarea {
  width: 100%; margin-top: 6px; padding: 8px; font: inherit; color: var(--ink); resize: vertical;
  background: #fff; border: var(--px) solid var(--wood); border-radius: 0; outline: none;
}
#starForm textarea:focus { border-color: var(--teal-dark); }
#starForm textarea.shake { animation: shake .35s; }
@keyframes shake { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.star-go { margin-top: 10px; background: var(--sun); border-color: #c79a45; text-shadow: 2px 2px 0 #c79a45; }
.star-go:hover { background: #f5cf85; }

.star-score { text-align: center; padding: 6px 0 2px; }
.star-meter { display: flex; justify-content: center; gap: 8px; }
.pstar { width: 44px; height: 44px; fill: #e5d6b8; opacity: 0; animation: btnPop .4s cubic-bezier(.3,1.8,.5,1) forwards; animation-delay: calc(var(--k) * 160ms + 150ms); }
.pstar svg { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.pstar.lit { fill: var(--sun); filter: drop-shadow(3px 3px 0 #c79a45); }
.pstar.lit svg { animation: twinkle 1.6s ease-in-out infinite; animation-delay: calc(var(--k) * 200ms + 1s); }
@keyframes twinkle { 50% { scale: 1.12; rotate: 6deg; } }
.star-verdict { margin: 8px 0 0; font-size: 1.3rem; font-weight: 700; }
.star-coins {
  display: inline-block; margin: 8px 0 0; padding: 4px 12px; font-weight: 700;
  background: var(--paper); border: var(--px) solid var(--wood-dark); box-shadow: var(--px) var(--px) 0 rgba(90,70,54,.3);
  opacity: 0; animation: btnPop .4s cubic-bezier(.3,1.6,.5,1) 1s forwards;
}
.star-yours { margin: 0; padding: 8px 12px; background: #dff1ef; border: var(--px) solid var(--teal-dark); font-style: italic; overflow-wrap: anywhere; }
.star-beats { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.star-beats li { padding: 4px 8px; font-size: .85rem; background: #ecdcbc; color: var(--ink-soft); border: var(--px) solid #d9c49c; }
.star-beats li.hit { background: var(--sage); color: #fff; border-color: var(--sage-dark); text-shadow: 1px 1px 0 var(--sage-dark); }
.star-actions { display: flex; gap: 8px; margin-top: 16px; }
.star-actions .primary { flex: 1; margin: 0; }
.star-back {
  font: 600 1rem var(--font); color: var(--ink); cursor: pointer; padding: 0 16px;
  background: var(--peach); border: var(--px) solid var(--wood-dark); box-shadow: inset 0 -4px 0 rgba(0,0,0,.1);
}
.star-src { margin: 16px 0 0; padding-top: 10px; border-top: var(--px) dotted var(--wood); font-size: .85rem; color: var(--ink-soft); }
.star-src a { color: var(--teal-dark); font-weight: 700; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .star-card.pop, .pstar, .pstar.lit svg, .star-coins, #starForm textarea.shake { animation: none !important; opacity: 1; }
}

/* Daily Star: already-played screen */
.star-done-msg {
  margin: 14px 0 0; padding: 10px 12px; text-align: center; line-height: 1.5; font-weight: 600;
  background: var(--cream); border: var(--px) solid var(--wood);
}
.star-done-timer { margin: 8px 0 0; text-align: center; font-size: .9rem; color: var(--ink-soft); }
.star-done-timer::before { content: "⏳ "; }

/* ===== "more" menu: three grey dots that open edit / goals / history ===== */
.more-wrap { position: relative; display: flex; }
.more-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; min-width: 190px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--paper); border: var(--px) solid var(--wood-dark); box-shadow: 6px 6px 0 rgba(28,52,44,.38);
  transform-origin: top right; animation: moreOpen .18s cubic-bezier(.3,1.5,.5,1);
}
.more-menu.hidden { display: none; }
.more-menu::before {   /* little pixel notch pointing at the button */
  content: ""; position: absolute; top: -12px; right: 26px; width: 12px; height: 12px;
  background: var(--paper); border-left: var(--px) solid var(--wood-dark); border-top: var(--px) solid var(--wood-dark);
  transform: rotate(45deg); transform-origin: center;
}
@keyframes moreOpen { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.more-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; cursor: pointer; text-align: left;
  font: 1rem var(--font); color: var(--ink); background: transparent; border: 2px solid transparent;
}
.more-item .pi { width: 1.6em; height: 1.6em; }
.more-item:hover, .more-item:focus-visible { background: var(--cream); border-color: var(--wood); }
.more-item.active, .more-item[aria-pressed="true"] { background: var(--sun); border-color: var(--sun-dark, #c79a45); }
.more-btn[aria-expanded="true"] { background: var(--cream); }
.pa-dots { animation: none; }   /* the dots sit still... */
.more-btn:hover .pa-dots, .more-btn[aria-expanded="true"] .pa-dots { animation: pi-dothop .35s cubic-bezier(.3,1.8,.5,1); } /* ...and hop once together */
@keyframes pi-dothop { 50% { transform: translateY(-14%) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .more-btn .pa-dots, .more-menu { animation: none; } }
.character-customizer { display: grid; grid-template-columns: minmax(0, 1fr) 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.character-categories { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.character-categories h3, .character-avatar h3, .character-options > h3, .character-gender h3 { margin: 0 0 12px; }
.character-category, .character-option {
  padding: 8px 10px; cursor: pointer; color: var(--ink); background: rgba(255,255,255,.55);
  border: 2px solid var(--wood); font: 600 .95rem var(--font); text-align: center;
}
.character-category { width: 100%; max-width: 160px; text-align: left; }
.character-category:hover, .character-option:hover { background: var(--cream); }
.character-category[aria-pressed="true"], .character-option[aria-pressed="true"] { background: var(--sun); border-color: var(--wood-dark); }
.character-avatar { min-width: 0; padding: 14px 8px; text-align: center; background: var(--cream); border: 2px dashed var(--wood); }
.character-avatar canvas { display: block; width: 160px; height: 122px; max-width: 100%; margin: 0 auto; image-rendering: pixelated; }
.character-privacy { margin: 8px 0 0; color: var(--ink-soft); font-size: .8rem; }
.character-options { min-width: 0; }
.character-choice-section { margin: 0 0 18px; }
.character-choice-section h4 { margin: 0 0 8px; font-size: 1rem; }
.character-colours, .character-options-list, .character-gender-options { display: flex; flex-wrap: wrap; gap: 8px; }
.character-swatch {
  width: 34px; height: 34px; padding: 3px; cursor: pointer; background: transparent;
  border: 2px solid var(--wood); border-radius: 2px;
}
.character-swatch span { display: block; width: 100%; height: 100%; background: var(--swatch); }
.character-swatch:hover { transform: translateY(-2px); }
.character-swatch[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.character-help { margin: 4px 0; color: var(--ink-soft); }
.character-gender { margin: 14px auto 0; padding-top: 10px; text-align: center; border-top: 2px dashed var(--wood); }
.character-gender-options { justify-content: center; }
@media (max-width: 760px) {
  .character-customizer { grid-template-columns: minmax(130px, .8fr) minmax(0, 1.2fr); grid-template-areas: "avatar avatar" "categories options"; }
  .character-categories { grid-area: categories; }
  .character-avatar { grid-area: avatar; }
  .character-options { grid-area: options; }
}
@media (max-width: 480px) {
  .character-customizer { grid-template-columns: 1fr; grid-template-areas: "avatar" "categories" "options"; gap: 14px; }
  .character-categories { flex-direction: row; flex-wrap: wrap; }
  .character-categories h3 { flex-basis: 100%; }
  .character-category { flex: 1 1 40%; text-align: center; }
  .character-gender-options { gap: 6px; }
  .character-option { padding: 7px; }
}

/* ===== Bank: warm "welcome!" the first time it pops up ===== */
.bank-welcome { text-align: center; margin: 0 0 14px; padding: 10px 8px 12px; background: var(--cream); border: var(--px) dashed var(--sun); }
.bank-welcome[hidden] { display: none; }
.welcome-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.welcome-row .pi { width: 1.8rem; height: 1.8rem; }
.welcome-word { margin: 0; font-size: 2.6rem; line-height: 1; font-weight: 400; color: var(--sun); text-shadow: 3px 3px 0 var(--wood-dark); letter-spacing: 2px; }
.welcome-word span {
  display: inline-block; opacity: 0;
  animation: welcomeIn .5s cubic-bezier(.3,1.8,.5,1) forwards;   /* drops in once, then stays still */
  animation-delay: calc(var(--i) * 70ms + 150ms);
}
@keyframes welcomeIn { from { opacity: 0; transform: translateY(-24px) scale(.5); } to { opacity: 1; transform: none; } }
.welcome-sub { margin: 8px 0 0; color: var(--ink-soft); font-size: .95rem; opacity: 0; animation: welcomeIn .5s ease-out 1s forwards; }
@media (prefers-reduced-motion: reduce) {
  .welcome-word span, .welcome-sub { animation: none; opacity: 1; }
}

/* goals icon: on hover the arrow flies in and thunks into the bullseye */
.pa-target .ta { transform-box: view-box; }
:is(button, a, summary, label, li):hover .pa-target .ta, :hover > .pa-target .ta, .pa-target:hover .ta {
  animation: pi-arrow 1.4s cubic-bezier(.5,0,.75,0) infinite;
}
:is(button, a, summary, label, li):hover .pa-target .tb, :hover > .pa-target .tb, .pa-target:hover .tb {
  animation: pi-thunk 1.4s ease-out infinite; transform-origin: 50% 55%; transform-box: view-box;
}
@keyframes pi-arrow {
  0% { transform: translate(60%, -60%); opacity: 0; }
  8% { opacity: 1; }
  30% { transform: none; animation-timing-function: ease-out; }
  34% { transform: translate(-3%, 3%); }
  40%, 100% { transform: none; }
}
@keyframes pi-thunk { 0%, 30%, 60%, 100% { transform: none; } 36% { transform: scale(1.08) rotate(-4deg); } 46% { transform: scale(.97) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .pa-target .ta, .pa-target .tb { animation: none !important; } }

/* tasks icon: the second task's tick pops in while you hover, then stays until you move away */
.pa-list .lt { opacity: 0; transform-box: view-box; transform-origin: 33% 61%; }
:is(button, a, summary, label, li):hover .pa-list .lt, :hover > .pa-list .lt, .pa-list:hover .lt {
  animation: pi-tick .45s cubic-bezier(.3,1.8,.5,1) .05s both;
}
@keyframes pi-tick {
  0% { opacity: 0; transform: scale(.2) rotate(-25deg); }
  60% { opacity: 1; transform: scale(1.3) rotate(6deg); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  :is(button, a, summary, label, li):hover .pa-list .lt, .pa-list:hover .lt { animation: none; opacity: 1; }
}

/* empty bag: "Empty. Visit the shop!" walks you to the shop */
.walk-shop {
  display: inline-flex; align-items: center; min-height: 32px; /* big enough to tap on phones */
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 4px;
}
.walk-shop:hover { color: var(--teal-dark); text-decoration-style: solid; }

/* ===== Real money saved: the star of the HUD, on a hanging wooden sign, top middle ===== */
.hud-top { top: 18px; left: 50%; transform: translateX(-50%); }
.saved-banner {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 22px 8px 14px;
  background: var(--wood); border: var(--px) solid var(--wood-dark); box-shadow: 5px 5px 0 rgba(28,52,44,.38);
  background-image: repeating-linear-gradient(0deg, transparent 0 12px, rgba(141,100,64,.35) 12px 15px);
  transform-origin: 50% -18px; animation: savedDrop .8s cubic-bezier(.3,1.5,.5,1) both;
}
.saved-banner::before, .saved-banner::after {   /* ropes */
  content: ""; position: absolute; top: -22px; width: var(--px); height: 18px; background: var(--wood-dark);
}
.saved-banner::before { left: 22px; } .saved-banner::after { right: 22px; }
.saved-ico .pi { width: 2.6rem; height: 2.6rem; vertical-align: middle; }
.saved-text { display: flex; flex-direction: column; line-height: 1; }
.saved-text b { font-size: 2.2rem; font-weight: 400; color: var(--paper); text-shadow: 3px 3px 0 var(--wood-dark); letter-spacing: 1px; }
.saved-text small { margin-top: 4px; font-size: .75rem; letter-spacing: 2px; text-transform: uppercase; color: #fff3c4; text-shadow: 1px 1px 0 var(--wood-dark); }
.saved-banner.bump { animation: savedBump .6s cubic-bezier(.3,1.8,.5,1); }
.saved-banner.bump .saved-text b { color: #fff3c4; }
@keyframes savedDrop { from { transform: translateY(-140%); } to { transform: none; } }
/* slim version once you start walking: "$11 REAL MONEY SAVED" on one line, no piggy. Hover → full sign again */
.saved-banner, .saved-ico, .saved-ico .pi, .saved-text b, .saved-text small {
  transition: padding .3s ease, gap .3s ease, width .3s ease, height .3s ease, opacity .25s ease, font-size .3s ease, margin .3s ease;
}
.saved-banner.compact:not(:hover) { padding: 4px 14px; gap: 0; cursor: pointer; }
.saved-banner.compact:not(:hover) .saved-ico { width: 0; opacity: 0; overflow: hidden; }
.saved-banner.compact:not(:hover) .saved-ico .pi { width: 0; height: 1.4rem; }
.saved-banner.compact:not(:hover) .saved-text { flex-direction: row; align-items: baseline; gap: 8px; }
.saved-banner.compact:not(:hover) .saved-text b { font-size: 1.3rem; text-shadow: 2px 2px 0 var(--wood-dark); }
.saved-banner.compact:not(:hover) .saved-text small { margin-top: 0; font-size: .65rem; }
.saved-banner.compact:not(:hover)::before, .saved-banner.compact:not(:hover)::after { height: 12px; top: -16px; }

/* left HUD (coins, streak, clock): once you walk, it slims to icons + numbers and tucks against the left edge.
   Hover anywhere over that corner to open it back up. */
.hud-left .stats, .hud-left .sky-clock {
  transition: transform .35s ease, min-width .35s ease, padding .3s ease, gap .3s ease, opacity .3s ease, border-radius .3s ease;
}
.hud-left .stat { transition: padding .3s ease; }
.hud-left .stat small, .sky-text small { display: block; max-height: 2.4em; overflow: hidden; transition: max-height .3s ease, opacity .25s ease, margin .3s ease; }
.sky-clock canvas { transition: width .3s ease, opacity .25s ease; }
.hud-left.tucked:not(:hover) .stats, .hud-left.tucked:not(:hover) .sky-clock {
  min-width: 0; transform: translateX(-16px); border-radius: 0 12px 12px 0; opacity: .88;
}
.hud-left.tucked:not(:hover) .stat { padding: 4px 12px 4px 20px; }
.hud-left.tucked:not(:hover) .stat small { max-height: 0; opacity: 0; }
.hud-left.tucked:not(:hover) .sky-clock { padding: 6px 12px 6px 22px; gap: 0; }
.hud-left.tucked:not(:hover) .sky-clock canvas { width: 0; opacity: 0; }
.hud-left.tucked:not(:hover) .sky-text small { max-height: 0; opacity: 0; margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .hud-left .stats, .hud-left .sky-clock, .hud-left .stat, .hud-left .stat small, .sky-text small, .sky-clock canvas { transition: none; }
}
@keyframes savedBump { 0% { transform: none; } 30% { transform: scale(1.12) rotate(-2deg); } 60% { transform: scale(.97) rotate(1deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .saved-banner, .saved-banner.bump { animation: none; } }
@media (max-width: 760px) {
  .hud-top { top: auto; bottom: 86px; }            /* small screens: sits above the bag instead */
  .saved-banner::before, .saved-banner::after { display: none; }
  .saved-text b { font-size: 1.6rem; }
  .saved-ico .pi { width: 2rem; height: 2rem; }
}

/* ===== On-screen controls: touch screens only ===== */
.touch-controls { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: block; }
  .dpad {
    position: fixed; z-index: 6; left: 12px; bottom: 160px;   /* above the bag and the 'money saved' sign (which sits at the bottom on phones) */
    display: grid; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); gap: 2px;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .pad {
    font: 1.1rem var(--font); color: var(--ink); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; background: rgba(255, 247, 230, .82);
    border: 3px solid var(--wood-dark); box-shadow: 3px 3px 0 rgba(28,52,44,.3);
  }
  .pad.up { grid-area: 1 / 2; } .pad.left { grid-area: 2 / 1; } .pad.right { grid-area: 2 / 3; } .pad.down { grid-area: 3 / 2; }
  .pad.on, .pad:active { background: var(--sun); transform: translate(2px, 2px); box-shadow: none; }
}

/* ===== Phones & touch screens: comfortable tap targets, no iOS zoom on focus (checked by scripts/mobile-check.mjs) ===== */
@media (max-width: 760px), (pointer: coarse) {
  input:not(.amt-input), select, textarea, .small-label select { font-size: 16px; }   /* under 16px, iPhones zoom in when you tap a field */
  .goal-opt, .hz, .link-btn { min-height: 36px; }
  .link-btn { padding: 8px 14px; }
  .close, .chat-head button { min-width: 36px; min-height: 36px; }
  .note-form { flex-wrap: wrap; }
  .note-form input { flex: 1 1 100%; }                           /* the note gets its own line instead of being squeezed */
  /* touch screens can't hover, so the slim HUD stays fully on screen instead of tucking past the edge */
  .hud-left.tucked:not(:hover) .stats, .hud-left.tucked:not(:hover) .sky-clock { transform: none; }
  .saved-banner.compact:not(:hover) .saved-text small { font-size: .7rem; }   /* 11.2px: still readable when slim */
  .saved-text small { white-space: nowrap; }   /* one line, so the sign stays short and clear of the D-pad */
  .hud-top { left: 0; right: 0; transform: none; display: flex; justify-content: center; }   /* centre the sign on the full width (left:50% capped it at half the screen) */
}

/* very narrow phones (e.g. iPhone SE): keep the bag to 2 lines so it stays below the money-saved sign */
@media (max-width: 400px) {
  .bag-word { display: none; }                          /* icon only, no "Bag" word */
  .bag-items .empty { font-size: .85rem; }
  .saved-banner { padding: 6px 12px; gap: 8px; }        /* a more compact sign, so it ends before the town island */
  .saved-text b { font-size: 1.4rem; }
  .saved-text small { letter-spacing: 1px; font-size: .7rem; }
  .saved-ico .pi { width: 1.6rem; height: 1.6rem; }
  .hud-top { justify-content: flex-start; padding-left: 10px; }   /* line the sign up with the bag, away from the town island */
}

/* ===== Touch screens: compact HUD so nothing overlaps (portrait AND landscape) =====
   Top-left: palm button + one slim row of stats + small clock. Top-right: small menu buttons.
   Bottom: D-pad on the left, bag in the middle/left, A button + town on the right.
   Checked by scripts/mobile-check.mjs (incl. "HUD pieces overlap"). */
@media (pointer: coarse) {
  .hud-left { top: 8px; left: 8px; gap: 6px; }
  .home-title span { display: none; }
  .home-title .home-btn { padding: 4px 6px; }
  .home-title .pixel-palm { width: 28px; height: 28px; }
  .stats { flex-direction: row; min-width: 0; padding: 0; border-radius: 10px; }
  .stat { gap: 4px; padding: 5px 9px; }
  .stat + .stat { border-top: 0; border-left: 1px solid rgba(255,247,230,.16); }
  .stat small { display: none; }
  .stat b, .stat:first-child b { font-size: 1rem; }
  .stat-ico { width: auto; font-size: 1rem; }
  .sky-clock { min-width: 0; padding: 4px 8px 4px 4px; gap: 6px; border-radius: 10px; }
  .sky-clock canvas { width: 40px; height: 20px; }
  .sky-text small { display: none; }
  .sky-text b { font-size: .9rem; }

  .hud-right { top: 8px; right: 8px; gap: 6px; flex-wrap: nowrap; max-width: none; }
  .menu-btn { width: 46px; height: 46px; font-size: .7rem; gap: 0; }
  .menu-btn .ico { font-size: 1.1rem; }

  /* Bottom of the screen: every size and position comes from these few values, which scale with the screen
     (vmin = the screen's shorter side), so small and big phones, portrait and landscape all get the same layout.
     Pieces are stacked by adding up the heights below them, so they can't overlap. */
  :root {
  --edge: clamp(6px, 2.5vmin, 14px);          /* gap to the screen edge */
  --gap: clamp(4px, 1.5vmin, 10px);           /* gap between stacked pieces */
  --pad: clamp(36px, 11.5vmin, 54px);         /* one D-pad button */
  --bag-h: clamp(46px, 13vmin, 60px);         /* the bag strip */
  --sign-h: clamp(40px, 12vmin, 58px);        /* the 'real money saved' sign */
  --town-w: clamp(84px, 26vmin, 120px);       /* the town island (3:2 picture + its label) */
  --town-h: calc(var(--town-w) * 2 / 3 + 1.4rem);
  }

  .town-isle { right: var(--edge); bottom: var(--edge); }
  .town-isle canvas { width: var(--town-w); height: calc(var(--town-w) * 2 / 3); }
  .town-isle .town-label { font-size: .75rem; padding: 0 6px; }

  .hud-bottom { left: var(--edge); bottom: var(--edge); max-width: calc(100vw - 2 * var(--edge) - var(--town-w) - var(--gap)); }
  .bag { gap: 6px; padding: 4px 6px; height: var(--bag-h); box-sizing: border-box; }
  .bag-label { font-size: .8rem; }
  .bag-items { align-self: stretch; align-items: center; }
  .bag-items .empty { font-size: .8rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .bag-items .item { width: calc(var(--bag-h) - 14px); height: calc(var(--bag-h) - 14px); flex: none; }
  .bag-items .item img { width: 70%; height: 70%; }

  /* money-saved sign: fixed height (slim or full), sits right on top of the bag */
  .hud-top { top: auto; bottom: calc(var(--edge) + var(--bag-h) + var(--gap)); }
  .saved-banner { height: var(--sign-h); box-sizing: border-box; max-width: calc(100vw - 2 * var(--edge) - var(--town-w) - var(--gap)); overflow: hidden; }
  .saved-text b { font-size: clamp(1.2rem, 6vmin, 1.7rem); }
  .saved-ico .pi { width: clamp(1.4rem, 7vmin, 2rem); height: clamp(1.4rem, 7vmin, 2rem); }

  .dpad { left: var(--edge); gap: 2px; grid-template-columns: repeat(3, var(--pad)); grid-template-rows: repeat(3, var(--pad)); }
  .pad { font-size: calc(var(--pad) * .4); }
}
/* portrait phones: left side from the bottom up is bag → money sign → D-pad; right side is the town */
@media (pointer: coarse) and (orientation: portrait) {
  .hud-top { justify-content: flex-start; padding-left: var(--edge); }
  .dpad { bottom: calc(var(--edge) + var(--bag-h) + var(--sign-h) + 2 * var(--gap)); }
}
/* landscape phones: one bottom row (D-pad | bag with the sign above it | town), so the tall left column stays clear */
@media (pointer: coarse) and (orientation: landscape) {
  .dpad { bottom: var(--edge); }
  .hud-bottom { left: calc(var(--edge) + 3 * var(--pad) + 4px + var(--gap)); right: calc(var(--edge) + var(--town-w) + var(--gap)); max-width: none; }
  .hud-bottom .bag { width: 100%; }
  .hud-top { left: calc(var(--edge) + 3 * var(--pad) + 4px + var(--gap)); right: calc(var(--edge) + var(--town-w) + var(--gap)); justify-content: center; }
  .saved-banner { max-width: 100%; }
}

/* ===== Maple chat on short landscape screens (sideways phones): the whole scene, both
   portraits included, always fits on screen. Checked by scripts/mobile-check.mjs ("chat"). */
@media (orientation: landscape) and (max-height: 520px) {
  #chat.modal { padding: 8px 12px; }
  .chat-scene { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .chat-stage { padding: 0 28px; }
  .chat-portrait { width: 72px; height: 84px; }
  .chat-name { top: -18px; font-size: .9rem; padding: 2px 12px; }
  #chatLog { min-height: 0; max-height: 26vh; max-height: 26dvh; padding: 16px 44px 6px 20px; font-size: 1rem; }
  .chat-next { bottom: 54px; }
  #chatForm { padding: 6px 10px; }
  .chat-history { max-height: 42vh; max-height: 42dvh; overflow-y: auto; padding: 26px 14px 8px; }
  #chatHistoryList { max-height: none; }
}

/* ===== Maple chat never grows taller than the screen (any device, History open or not):
   the portraits keep their size; the history list / dialogue shrink and scroll instead. ===== */
.chat-scene { max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); }
.chat-stage { flex: none; }
.chat-box { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-box > #chatLog { flex: 0 1 auto; min-height: 3em; }
.chat-box > .chat-history { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
.chat-box > .chat-history #chatHistoryList { max-height: none; }
.chat-box > #chatForm { flex: none; }
@media (orientation: landscape) and (max-height: 520px) {
  .chat-scene { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
}

/* ===== Sync devices window ===== */
.sync-window { width: 460px; }
.sync-create { width: 100%; min-height: 44px; }
.sync-join { margin-top: 18px; padding-top: 14px; border-top: 3px dotted var(--wood); }
.sync-join label { display: block; margin-bottom: 6px; }
.sync-row { display: flex; gap: 8px; align-items: stretch; }
.sync-row input { flex: 1; width: auto; min-width: 0; margin: 0; letter-spacing: 2px; text-transform: uppercase; }
.sync-row button.primary { flex: none; width: auto; margin: 0; padding: 8px 20px; min-height: 40px; }
.sync-note { font-size: .85rem; margin: 8px 0 0; }
.sync-qr { display: block; width: 200px; height: 200px; margin: 10px auto; image-rendering: pixelated; background: #fff; border: var(--px) solid var(--wood-dark); }
.sync-code { text-align: center; font-size: 1.6rem; letter-spacing: 3px; color: var(--ink); margin: 8px 0; user-select: all; }
.sync-actions { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; }
.sync-actions button { min-height: 40px; }
.sync-status { min-height: 1.2em; margin: 10px 0 0; }
.sync-qr[hidden], #syncOn[hidden], #syncOff[hidden] { display: none; }
