:root {
  --cream: #fbf4ea;
  --paper: #fffaf3;
  --rose: #e7a0ab;
  --rose-deep: #c96f80;
  --rose-dark: #a2556a;
  --sage: #9fb79a;
  --sage-deep: #6f8f68;
  --butter: #f5d98a;
  --cocoa: #5e463f;
  --cocoa-soft: #8a6f66;
  --line: #ecdccb;
  --tint: #f6d9dd;
  --tint-2: #fbe9eb;
  --shadow: 0 10px 30px rgba(94, 70, 63, 0.12);
  --radius: 22px;
}
body.season-summer { --tint: #d9ecf0; --tint-2: #ebf6f6; }
body.season-autumn { --tint: #f3dcc4; --tint-2: #f9ecdc; }
body.season-winter { --tint: #dfe5f0; --tint-2: #eef1f8; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--cocoa);
  background:
    radial-gradient(circle at 12px 12px, rgba(231, 160, 171, 0.16) 2px, transparent 2.5px) 0 0 / 24px 24px,
    var(--cream);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--rose-deep); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 700; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 24px;
  background: repeating-linear-gradient(90deg, var(--tint) 0 22px, var(--tint-2) 22px 44px);
  border-bottom: 3px dashed rgba(201, 111, 128, 0.35);
  transition: background 1s;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper); font-size: 21px; box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 24px; line-height: 1; white-space: nowrap; }
.brand p { margin: 3px 0 0; font-size: 13px; font-weight: 700; color: var(--cocoa-soft); }
.stats { display: flex; gap: 8px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; background: var(--paper);
  font-weight: 800; font-size: 14px; box-shadow: 0 2px 0 var(--line); white-space: nowrap;
}
.pill.coins { background: #fff2cf; }
.coin {
  display: inline-block; width: 0.95em; height: 0.95em; margin-right: 0.28em; vertical-align: -0.12em;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b8 0 18%, #f2c94c 19% 60%, #d9a22e 61%);
  box-shadow: inset 0 0 0 1.5px #c48d1f;
}
.coin.big { width: 30px; height: 30px; margin: 0; }
.xpbar { width: 64px; height: 8px; border-radius: 99px; background: #f3e4d6; overflow: hidden; }
.xpbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--rose-deep)); border-radius: 99px; transition: width 0.6s ease; }
.bump { animation: bump 0.45s ease; }
.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: var(--paper); box-shadow: 0 2px 0 var(--line); font-size: 18px; line-height: 1;
  transition: transform 0.15s;
}
@media (hover: hover) { .icon-btn:hover { transform: translateY(-2px); } }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--rose-deep); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; animation: bump 0.6s ease 2;
}
.badge[hidden] { display: none; }

/* ---------- layout ---------- */
.shop {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(320px, 1fr) 400px;
  gap: 18px;
  padding: 18px 24px 24px;
  max-width: 1400px; width: 100%;
  margin: 0 auto;
}
.panel {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 2px solid #fff;
}
.panel::after {
  content: ""; position: absolute; inset: 7px; border-radius: 16px;
  border: 2px dashed var(--line); pointer-events: none;
}

/* ---------- counter ---------- */
.customer { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.portrait {
  width: 136px; height: 136px; padding: 6px; border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #fff 0 52%, #f9e3e6 53%);
  box-shadow: 0 0 0 4px #f3cdd3, var(--shadow);
  animation: bob 3.2s ease-in-out infinite;
}
.portrait svg { width: 100%; height: 100%; display: block; }
.portrait.arrive { animation: arrive 0.7s cubic-bezier(.2,1.4,.4,1), bob 3.2s 0.7s ease-in-out infinite; }
.portrait.leave { animation: leave 0.45s ease-in forwards; }
.cust-name { font-weight: 800; font-size: 18px; }
.cust-name small { display: block; font-weight: 600; color: var(--cocoa-soft); font-size: 13px; }
.cust-hearts { color: var(--rose-deep); letter-spacing: 2px; font-size: 15px; min-height: 18px; }
.cust-hearts .off { color: #ecd2d6; }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  background: #fff2cf; color: #9a7420; font-size: 12px; font-weight: 800;
}
.bubble {
  position: relative;
  margin-top: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  min-height: 120px;
  line-height: 1.55;
  font-size: 15.5px;
  cursor: pointer;
}
.bubble::before {
  content: ""; position: absolute; top: -11px; left: 50%;
  width: 18px; height: 18px; background: #fff;
  border-left: 2px solid var(--line); border-top: 2px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.bubble .caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--rose); animation: blink 0.8s steps(2) infinite; }
.notes { margin-top: 12px; font-size: 13.5px; color: var(--cocoa-soft); }
.notes h3 { font-size: 15px; margin: 0 0 6px; color: var(--cocoa); }
.notes ul { margin: 0; padding-left: 18px; }
.notes li { margin: 3px 0; }
.known { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { padding: 3px 9px; border-radius: 99px; background: #f7ebdf; font-size: 12px; font-weight: 700; }
.chip.love { background: #fde3e7; color: var(--rose-dark); }
.chip.hate { background: #ece7e4; color: var(--cocoa-soft); }

/* ---------- stage ---------- */
.stage { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 560px; }
.stage::after { z-index: 3; }
.room { position: absolute; inset: 0; z-index: 0; }
.room svg { width: 100%; height: 100%; display: block; }
.mannequin {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 8% 20px 0; pointer-events: none;
}
.mannequin svg { height: 100%; max-height: 64vh; width: auto; max-width: 100%; filter: drop-shadow(0 10px 12px rgba(94,70,63,.18)); }
.mannequin.changed svg { animation: wiggle 0.35s ease; }
.stage-actions {
  position: relative; z-index: 2;
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 12px 16px 18px;
}
.sew-btn {
  padding: 14px 36px;
  border: 0; border-radius: 999px;
  background: var(--rose-deep); color: #fff;
  font-weight: 800; font-size: 19px;
  box-shadow: 0 5px 0 var(--rose-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}
@media (hover: hover) { .sew-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--rose-dark); } }
.sew-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--rose-dark); }
.sew-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.ghost-btn {
  padding: 9px 14px; border: 0; border-radius: 999px;
  background: rgba(255, 250, 243, 0.92); font-weight: 800; font-size: 13.5px;
  box-shadow: 0 3px 0 var(--line);
}
.ghost-btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- workbench ---------- */
.workbench { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; position: relative; z-index: 1; }
.tab {
  flex: 1; padding: 9px 4px; border: 0; border-radius: 12px;
  background: #f7ebdf; font-weight: 800; font-size: 13.5px; white-space: nowrap;
}
.tab.active { background: var(--rose); color: #fff; }
.tab.locked { opacity: 0.45; }
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  align-content: start; overflow-y: auto; position: relative; z-index: 1;
  max-height: calc(100vh - 210px); padding: 2px 4px 8px 2px;
}
.tile {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 8px 6px 6px;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}
@media (hover: hover) { .tile:hover { transform: translateY(-2px); border-color: var(--rose); } }
.tile.selected { border-color: var(--rose-deep); background: #fdf0f2; box-shadow: 0 0 0 3px #f6d5db; }
.tile svg { width: 100%; height: 96px; display: block; }
.tile .btn.small { display: inline-block; padding: 4px 12px; font-size: 12.5px; margin-top: 2px; box-shadow: 0 3px 0 var(--rose-dark); white-space: nowrap; }
.tile .label { font-size: 13px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.tile.locked > svg, .tile.locked .swatch { opacity: 0.35; filter: grayscale(0.7); }
.tile.unavailable { cursor: default; }
@media (hover: hover) { .tile.unavailable:hover { transform: none; border-color: var(--line); } }
.tile .price, .tile .lock {
  position: absolute; top: 6px; right: 6px;
  font-size: 11.5px; font-weight: 800;
  background: #fff2cf; border-radius: 999px; padding: 2px 7px;
}
.tile .lock { background: #f1e8e1; color: var(--cocoa-soft); }
.tile .new { position: absolute; top: 6px; left: 6px; font-size: 10.5px; font-weight: 800; color: #fff; background: var(--sage-deep); border-radius: 99px; padding: 1px 6px; }
.swatch {
  width: 66px; height: 66px; margin: 8px auto 10px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line), inset 0 -8px 12px rgba(0,0,0,.08);
}
.swatch.sig { box-shadow: 0 0 0 2px var(--butter), 0 0 0 5px #fff6d8, inset 0 -8px 12px rgba(0,0,0,.08); }
.grid-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--cocoa-soft); text-align: center; margin: 2px 0 0; }

/* ---------- layers (modals) ---------- */
.layer {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(94, 70, 63, 0.38);
  backdrop-filter: blur(3px);
  padding: 18px;
  animation: fade 0.25s ease;
}
.card {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 36px); overflow: auto;
  background: var(--paper);
  border-radius: 26px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(94, 70, 63, 0.3);
  text-align: center;
  animation: pop 0.35s cubic-bezier(.2,1.4,.4,1);
}
.card.wide { width: min(880px, 100%); }
.card.letter {
  text-align: left; width: min(520px, 100%);
  background: #fffdf7 repeating-linear-gradient(transparent 0 29px, #f1e6da 29px 30px);
  border: 2px solid #f1e3d3;
}
.card.letter .body { font-size: 16.5px; line-height: 30px; white-space: pre-line; margin: 6px 0 4px; }
.card h2 { font-size: 30px; margin: 0 0 6px; line-height: 1.1; }
.card h3 { font-size: 19px; margin: 14px 0 8px; }
.card .sub { color: var(--cocoa-soft); margin: 0 0 16px; line-height: 1.5; }
.close-x {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f7ebdf; font-size: 18px; font-weight: 800;
}
.btn {
  padding: 12px 28px; border: 0; border-radius: 999px;
  background: var(--rose-deep); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 0 var(--rose-dark); margin-top: 16px;
  transition: transform 0.1s;
}
@media (hover: hover) { .btn:hover { transform: translateY(-1px); } }
.btn:active { transform: translateY(2px); }
.btn.ghost { background: #f7ebdf; color: var(--cocoa); box-shadow: 0 4px 0 var(--line); }
.btn.sage { background: var(--sage-deep); box-shadow: 0 4px 0 #557150; }
.btn.small { padding: 8px 16px; font-size: 14px; margin-top: 0; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-row .btn { margin-top: 16px; }

/* title */
.title-card { padding: 36px 28px 30px; }
.title-card h2 { font-size: 46px; }
.title-cast { display: flex; justify-content: center; margin: 4px 0 6px; }
.title-cast .face { width: 74px; height: 74px; margin: 0 -8px; filter: drop-shadow(0 4px 4px rgba(94,70,63,.12)); }
.title-cast .face:nth-child(odd) { transform: translateY(8px); }
.version { margin-top: 18px; font-size: 12px; color: var(--cocoa-soft); }

/* sewing */
.track {
  position: relative; height: 58px; margin: 22px 0 12px;
  border-radius: 14px; overflow: hidden;
  background: repeating-linear-gradient(45deg, #f6e4d4 0 8px, #f1dccb 8px 16px);
  border: 2px solid var(--line);
  touch-action: manipulation; cursor: pointer;
}
.zone { position: absolute; top: 0; bottom: 0; background: rgba(159, 183, 154, 0.5); border-left: 2px dashed #7f9c7a; border-right: 2px dashed #7f9c7a; }
.zone .sweet { position: absolute; top: 0; bottom: 0; left: 30%; width: 40%; background: rgba(111, 143, 104, 0.6); }
.needle { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; background: var(--cocoa); border-radius: 2px; will-change: left; }
.needle::after { content: ""; position: absolute; top: 3px; left: -4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--cocoa); background: var(--paper); box-sizing: border-box; }
.stitches { display: flex; gap: 10px; justify-content: center; min-height: 34px; font-weight: 800; }
.stitches span { padding: 4px 14px; border-radius: 999px; background: #f7ebdf; animation: pop 0.3s ease; }
.stitches .perfect { background: #dfeedb; color: #4c6b47; }
.stitches .miss { background: #f8dede; color: var(--rose-dark); }
.seam { display: flex; justify-content: center; gap: 6px; margin: 10px 0 2px; }
.seam i { width: 26px; height: 4px; border-radius: 3px; background: #efe1d4; }
.seam i.done { background: var(--rose-deep); }
.sew-hint { font-size: 13px; color: var(--cocoa-soft); }

/* results */
.result { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: center; text-align: left; }
.result-dress { position: relative; }
.result-dress svg { width: 100%; height: auto; display: block; }
.who { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.who .face { width: 72px; height: 72px; flex: none; border-radius: 50%; background: #fdf0f2; box-shadow: 0 0 0 3px #f3cdd3; }
.who .face svg { width: 100%; height: 100%; }
.reaction { font-size: 18px; font-weight: 700; margin: 12px 0 6px; line-height: 1.4; }
.reaction-extra { margin: 4px 0; font-size: 14.5px; font-weight: 700; color: var(--rose-dark); }
.reaction-extra.meh { color: var(--cocoa-soft); }
.hearts { font-size: 24px; color: var(--rose-deep); letter-spacing: 2px; }
.hearts .empty { color: #ecd2d6; padding: 0; }
.checks { list-style: none; padding: 0; margin: 8px 0; font-size: 14.5px; }
.checks li { padding: 2px 0; }
.checks .ok::before { content: "✓ "; color: #5f8a59; font-weight: 800; }
.checks .no::before { content: "✗ "; color: var(--rose-deep); font-weight: 800; }
.checks .no { color: var(--cocoa-soft); }
.pay { font-size: 22px; font-weight: 800; margin-top: 8px; }
.pay small { font-size: 13px; color: var(--cocoa-soft); font-weight: 700; }
.gains { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* evening */
.summary-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 12px; }
.stat { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 10px 16px; min-width: 110px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12.5px; color: var(--cocoa-soft); font-weight: 700; }
.lookbook { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.look { position: relative; width: 116px; background: #fff; border-radius: 14px; border: 2px solid var(--line); padding: 6px; font-size: 12px; font-weight: 700; }
.look svg { width: 100%; height: 130px; display: block; }
.look .fav { position: absolute; top: 4px; right: 4px; border: 0; background: none; font-size: 16px; color: #e3c8cd; padding: 2px; }
.look .fav.on { color: var(--rose-deep); }
.look .who-sm { display: flex; align-items: center; gap: 4px; justify-content: center; }
.look .who-sm svg { width: 22px; height: 22px; }
.friend-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.friend-up { display: flex; flex-direction: column; align-items: center; font-size: 12.5px; font-weight: 800; }
.friend-up svg { width: 54px; height: 54px; }

/* journal */
.journal-tabs { display: flex; gap: 6px; justify-content: center; margin: 4px 0 16px; flex-wrap: wrap; }
.villager-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; text-align: left; }
.vcard { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px; display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.vcard.unknown { opacity: 0.55; }
.vcard .face svg { width: 64px; height: 64px; }
.vcard h4 { margin: 0; font-size: 15px; }
.vcard p { margin: 2px 0; font-size: 12.5px; color: var(--cocoa-soft); }
.vcard .known { justify-content: flex-start; margin-top: 4px; grid-column: 1 / -1; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.sticker { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; }
.sticker .disc {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; font-weight: 800; color: var(--cocoa);
  border: 4px solid #fff; box-shadow: 0 3px 8px rgba(94,70,63,.18);
  transform: rotate(-6deg);
}
.sticker:nth-child(even) .disc { transform: rotate(5deg); }
.sticker.locked .disc { background: #efe7df !important; color: #d7c9bd; box-shadow: inset 0 0 0 2px #e6dacd; border-style: dashed; border-color: #e6dacd; }
.sticker b { font-size: 13px; }
.sticker span { color: var(--cocoa-soft); text-align: center; line-height: 1.3; }
.progress-line { font-weight: 800; margin: 0 0 12px; color: var(--cocoa-soft); }
.empty { color: var(--cocoa-soft); padding: 24px; }

/* mail */
.mail-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.mail-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; width: 100%; text-align: left; }
.mail-item.unread { border-color: var(--rose); background: #fdf0f2; }
.mail-item svg { width: 40px; height: 40px; flex: none; }
.mail-item b { display: block; }
.mail-item small { color: var(--cocoa-soft); }
.gift-box { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 14px; background: #fff6dc; border-radius: 14px; font-weight: 800; }
.gift-box .swatch { width: 40px; height: 40px; margin: 0; }
.gift-box svg { width: 44px; height: 54px; }
.signoff { display: flex; align-items: center; gap: 10px; }
.signoff svg { width: 54px; height: 54px; }

/* decorate */
.decor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.decor-grid .tile svg { height: 76px; }
.decor-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; text-align: left; }
.decor-layout .journal-tabs { justify-content: flex-start; margin-top: 0; }
.decor-preview { aspect-ratio: 4 / 5; border-radius: 16px; overflow: hidden; border: 2px solid var(--line); background: #f7ebdf; position: sticky; top: 0; }
.decor-preview svg { width: 100%; height: 100%; }

/* settings */
.settings { text-align: left; display: grid; gap: 14px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.setting label { font-weight: 800; }
.setting small { display: block; font-weight: 600; color: var(--cocoa-soft); font-size: 12.5px; }
.setting input[type="range"] { width: 180px; accent-color: var(--rose-deep); }
.toggle { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: #eadbd0; position: relative; cursor: pointer; transition: background 0.2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle:checked { background: var(--sage-deep); }
.toggle:checked::after { transform: translateX(20px); }
select { font: inherit; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--line); background: #fff; color: var(--cocoa); }
.danger { color: var(--rose-dark); }

/* festival */
.judges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.judge { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px 10px; font-size: 13.5px; }
.judge .face { width: 70px; height: 70px; margin: 0 auto; }
.judge .face svg { width: 100%; height: 100%; }
.judge b { display: block; margin-top: 4px; }
.judge q { display: block; margin-top: 6px; color: var(--cocoa-soft); font-style: italic; line-height: 1.35; }
.judge .score { font-size: 28px; font-family: "Fraunces", serif; font-weight: 700; margin-top: 6px; opacity: 0; transform: scale(0.6); transition: all 0.4s cubic-bezier(.2,1.4,.4,1); }
.judge .score.show { opacity: 1; transform: none; }
.judge.met { border-color: var(--sage); }
.rosette { width: 120px; height: 150px; margin: 0 auto; }
.festival-brief { text-align: left; }
.festival-brief .judge q { color: var(--cocoa); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--cocoa); color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toastIn 0.35s cubic-bezier(.2,1.4,.4,1); max-width: 90vw; text-align: center;
}
.toast.sticker { background: #fff; color: var(--cocoa); border: 2px solid var(--butter); }
.toast.out { animation: toastOut 0.3s ease forwards; }

/* coach marks */
.coach {
  position: absolute; z-index: 15; max-width: 260px;
  background: var(--cocoa); color: #fff; border-radius: 16px; padding: 12px 14px 12px;
  font-size: 14px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: pop 0.35s cubic-bezier(.2,1.4,.4,1);
}
.coach b { color: var(--butter); }
.coach button { margin-top: 8px; border: 0; background: var(--rose); color: #fff; font-weight: 800; border-radius: 99px; padding: 5px 14px; font-size: 13px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 13px; border-radius: 2px; animation: fall linear forwards; }

/* critter blink */
.c-eyes { animation: blink-eyes 5s infinite; }
svg[data-mood="delighted"] .c-eyes { animation: none; }
.look .c-eyes, .mail-item .c-eyes, .who-sm .c-eyes { animation-delay: 1.3s; }

@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes arrive { from { transform: translateX(-140px) scale(0.6); opacity: 0; } }
@keyframes leave { to { transform: translateX(160px) scale(0.7); opacity: 0; } }
@keyframes pop { from { transform: scale(0.88); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.18); } }
@keyframes wiggle { 30% { transform: rotate(-1.5deg); } 70% { transform: rotate(1.5deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes blink-eyes { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes toastIn { from { transform: translateY(30px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(20px); opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(201, 111, 128, 0.25); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
.reduce-motion .anim, .reduce-motion .c-eyes { animation: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .shop { grid-template-columns: 260px minmax(0, 1fr); }
  .workbench { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); max-height: none; }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand h1 { font-size: 18px; }
  .brand-mark { display: none; }
  .stage-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    padding: 18px 10px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(251, 244, 234, 0), rgba(251, 244, 234, 0.96) 35%);
  }
  .stats { gap: 5px; }
  .xpbar { display: none; }
  .pill { padding: 5px 10px; font-size: 13px; }
  .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .shop { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .counter { padding: 12px; }
  .customer { flex-direction: row; text-align: left; gap: 12px; }
  .portrait { width: 76px; height: 76px; flex: none; }
  .bubble { margin-top: 12px; min-height: 0; font-size: 15px; }
  .bubble::before { left: 38px; }
  .stage { min-height: 0; height: 52vh; }
  .stage-actions { padding: 8px 10px 14px; }
  .sew-btn { padding: 12px 26px; font-size: 17px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .tile svg { height: 80px; }
  .tabs { overflow-x: auto; }
  .tab { flex: none; padding: 9px 12px; }
  .result { grid-template-columns: 1fr; text-align: center; }
  .result-dress { max-width: 170px; margin: 0 auto; }
  .who { justify-content: center; }
  .gains { justify-content: center; }
  .card { padding: 22px 16px; }
  .card h2 { font-size: 25px; }
  .title-card h2 { font-size: 36px; }
  .judges { grid-template-columns: 1fr; }
  .decor-layout { grid-template-columns: 1fr; }
  .decor-preview { max-width: 220px; margin: 0 auto; position: static; }
  .setting { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .brand h1 { display: none; }
  .brand p { margin: 0; font-size: 13px; color: var(--cocoa); font-weight: 800; white-space: nowrap; }
  .pill.level { padding: 5px 8px; }
  .cal-year { display: none; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
}
@media (max-width: 440px) {
  #decorBtn { display: none; }
  .stats { gap: 4px; }
}

/* ---------- fabric shop ---------- */
.card.emp-card { width: min(1200px, 100%); padding: 0; overflow: auto; text-align: left; }
.emp { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); }
.emp-scene { position: relative; aspect-ratio: 1536 / 1024; background: #c99a63 url(img/emporium.webp) center / cover; align-self: start; }
.emp-bolts { position: absolute; inset: 0; }
.bolt { position: absolute; border: 0; padding: 0 1.5px; background: none; display: flex; align-items: flex-end; justify-content: center; }
.bolt-roll {
  position: relative; display: block; width: var(--roll, 100%); height: 92%;
  border-radius: 7px 7px 3px 3px; overflow: hidden;
  box-shadow: 0 4px 6px rgba(60, 35, 20, 0.35);
  transition: transform 0.2s cubic-bezier(.2,1.4,.4,1), box-shadow 0.2s;
}
.bolt-roll svg { display: block; width: 100%; height: 100%; }
.bolt-roll::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(255,255,255,.28) 32%, rgba(255,255,255,.06) 55%, rgba(0,0,0,.28));
}
.bolt-roll::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 9%; z-index: 1;
  background: radial-gradient(ellipse at 50% 60%, rgba(0,0,0,.25) 0 30%, rgba(255,255,255,.35) 32%, transparent 70%);
}
@media (hover: hover) { .bolt:hover .bolt-roll { transform: translateY(-4%); } }
.bolt.sel .bolt-roll { transform: translateY(-9%); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--rose-deep), 0 10px 14px rgba(60, 35, 20, 0.35); }
.bolt-stock {
  position: absolute; bottom: -6%; left: 50%; transform: translateX(-50%); z-index: 2; pointer-events: none;
  background: #fffaf3; border-radius: 99px; padding: 0 5px; font-size: 10px; font-weight: 800; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.bolt-sig { position: absolute; top: 4%; left: 50%; transform: translateX(-50%); z-index: 2; color: #f2c94c; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.emp-panel { padding: 22px 22px 18px; }
.emp-brief { background: #fff6dc; border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.45; margin-bottom: 14px; }
.emp-brief:empty { display: none; }
.emp-head { display: flex; gap: 14px; align-items: center; }
.emp-swatch { width: 84px; height: 84px; flex: none; border-radius: 16px; overflow: hidden; box-shadow: 0 0 0 2px var(--line), 0 4px 10px rgba(94,70,63,.15); }
.emp-swatch svg { display: block; width: 100%; height: 100%; }
.emp-head h3 { margin: 0 0 6px; font-size: 21px; }
.emp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.emp-prints { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
.emp-print { width: 46px; height: 46px; padding: 0; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); background: none; transition: transform 0.15s; }
@media (hover: hover) { .emp-print:hover { transform: translateY(-2px); } }
.emp-print.sel { border-color: var(--rose-deep); box-shadow: 0 0 0 3px #f6d5db; }
.emp-print svg { display: block; width: 100%; height: 100%; }
.emp-cupboard { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; margin-bottom: 12px; }
.emp-stock { border: 0; cursor: pointer; }
.emp-metres { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.emp-metres small { color: var(--cocoa-soft); }
.emp-buyrow { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.emp-amount { font-weight: 800; min-width: 110px; text-align: center; }
.emp-cost { margin-left: auto; font-weight: 800; font-size: 19px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ---------- craft stepper ---------- */
.stepper {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 26;
  display: flex; gap: 4px; padding: 6px 8px; border-radius: 99px;
  background: rgba(255, 250, 243, 0.95); box-shadow: 0 6px 20px rgba(94,70,63,.2);
  font-size: 12.5px; font-weight: 800; pointer-events: none;
}
.stepper[hidden] { display: none; }
.stepper span { padding: 4px 10px; border-radius: 99px; color: var(--cocoa-soft); white-space: nowrap; }
.stepper span.done { color: var(--sage-deep); }
.stepper span.done::before { content: "✓ "; }
.stepper span.now { background: var(--rose-deep); color: #fff; }
/* While a dress is in progress the stepper owns the top strip; every layer starts below it. */
body.crafting .layer { top: 48px; }
body.crafting .card { max-height: calc(100vh - 84px) !important; }
body.crafting .card.wide.mg-cut { max-height: calc(100dvh - 60px) !important; }
@media (max-width: 760px) { body.crafting .card.wide.mg-cut { height: calc(100dvh - 60px) !important; } }
/* The sewing board keeps its painted aspect ratio, so cap its width by the screen height. */
body.crafting .card.mg-sew { width: min(980px, 100%, calc((100vh - 250px) * 1.5 + 40px)); }

@media (max-width: 860px) {
  .emp { grid-template-columns: 1fr; }
  .stepper { font-size: 11px; top: 6px; }
  .stepper span { padding: 3px 7px; }
}

/* title screen over the painted key art */
.layer.title-layer { background: #f3e3d3 url(img/keyart.webp) center / cover; backdrop-filter: none; align-items: start; padding-top: 5vh; }
.title-layer .card { background: rgba(255, 250, 243, 0.92); backdrop-filter: blur(6px); width: min(560px, 100%); }
@media (max-width: 760px) { .layer.title-layer { align-items: end; padding-bottom: 4vh; background-position: 30% center; } }

/* Too narrow for a label: a little dot says "you have some of this". */
@media (max-width: 860px) {
  .bolt-stock { font-size: 0; width: 9px; height: 9px; padding: 0; background: var(--rose-deep); border: 2px solid #fffaf3; }
}

/* ---------- notepad ---------- */
.notepad {
  position: fixed; left: 14px; bottom: 14px; z-index: 28;
  width: 236px; max-height: min(420px, 60vh);
  display: flex; flex-direction: column;
  background: #fff7cf repeating-linear-gradient(transparent 0 25px, rgba(170, 140, 90, 0.18) 25px 26px);
  background-position: 0 6px;
  border-radius: 4px 4px 10px 4px;
  box-shadow: 0 10px 24px rgba(94, 70, 63, 0.25), inset 0 -18px 18px -18px rgba(150, 110, 40, 0.25);
  transform: rotate(-1.2deg);
  font-family: "Caveat", "Nunito", cursive;
  color: #4b3a35;
  transition: transform 0.2s;
}
.notepad[hidden] { display: none; }
@media (hover: hover) { .notepad:hover { transform: rotate(0deg); } }
.np-head {
  display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px 14px;
  cursor: grab; touch-action: none; user-select: none; font-size: 21px;
}
.np-head:active { cursor: grabbing; }
.np-pin {
  position: absolute; top: -9px; left: 50%; width: 64px; height: 18px; transform: translateX(-50%) rotate(2deg);
  background: rgba(231, 160, 171, 0.65); box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.np-head b { font-weight: 700; }
.np-count { margin-left: auto; font-size: 16px; color: #a07a4f; }
.np-fold { border: 0; background: rgba(255,255,255,.6); border-radius: 50%; width: 24px; height: 24px; font-size: 13px; line-height: 1; flex: none; }
.np-body { overflow: auto; padding: 0 12px 10px 14px; }
.notepad.folded .np-body { display: none; }
.notepad.folded { max-height: none; }
.np-list { list-style: none; margin: 0; padding: 0; }
.np-list li { display: flex; align-items: flex-start; gap: 6px; font-size: 19.5px; line-height: 26px; }
.np-list li.done .np-text { text-decoration: line-through; text-decoration-color: var(--rose-deep); text-decoration-thickness: 2px; opacity: 0.55; }
.np-tick {
  flex: none; width: 17px; height: 17px; margin-top: 5px; padding: 0;
  border: 2px solid #8a6f66; border-radius: 4px; background: rgba(255,255,255,.5);
  font-size: 13px; font-weight: 800; line-height: 13px; color: var(--sage-deep);
}
.np-text { flex: 1; overflow-wrap: anywhere; }
.np-del { flex: none; border: 0; background: none; color: #b39b8c; font-size: 18px; line-height: 26px; padding: 0 2px; opacity: 0; }
.np-del:focus-visible { opacity: 1; }
@media (hover: hover) { .np-list li:hover .np-del { opacity: 1; } }
@media (pointer: coarse) { .np-del { opacity: 0.7; } }
.np-empty { margin: 2px 0 6px; font-size: 18px; line-height: 26px; color: #8a6f66; }
.np-all { display: block; margin: 4px 0 6px; border: 0; background: rgba(201, 111, 128, 0.14); color: var(--rose-dark); border-radius: 99px; padding: 3px 12px; font: 700 17px "Caveat", cursive; }
.np-form { display: flex; gap: 4px; margin-top: 4px; }
.np-input { flex: 1; min-width: 0; border: 0; border-bottom: 2px dashed rgba(138, 111, 102, 0.5); background: transparent; font: 600 19px "Caveat", cursive; color: inherit; padding: 2px 0; }
.np-input:focus { outline: none; border-bottom-color: var(--rose-deep); }
.np-add { border: 0; background: var(--rose-deep); color: #fff; border-radius: 50%; width: 26px; height: 26px; font-weight: 800; flex: none; }
.np-scrap { position: fixed; z-index: 40; width: 26px; height: 18px; background: #fff7cf; box-shadow: 0 2px 6px rgba(0,0,0,.2); pointer-events: none; transition: transform 0.6s cubic-bezier(.5,0,.3,1), opacity 0.6s; }

/* jottable lines in the speech bubble */
.jot { cursor: pointer; border-bottom: 2px dotted rgba(201, 111, 128, 0.55); transition: background 0.15s; border-radius: 3px; }
.jot:focus-visible { background: #fff3c4; outline: none; }
@media (hover: hover) { .jot:hover { background: #fff3c4; } }
.jot.jotted { border-bottom-style: solid; border-bottom-color: var(--sage); }
.jot-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--cocoa-soft); font-weight: 700; }
.notes h3 .jot-hint { display: inline; margin-left: 6px; font-weight: 600; }

/* Phones: the notepad sits on the right edge above the sew bar. */
@media (max-width: 760px) {
  .notepad { left: auto; right: 8px; bottom: calc(84px + env(safe-area-inset-bottom)); width: min(250px, 72vw); }
  .notepad.folded { width: auto; }
  .notepad.folded .np-head b { display: none; }
}

/* ---------- painted portraits ---------- */
.critter-img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.portrait { overflow: hidden; padding: 0; }
.portrait .critter-img { transform: translateY(4%) scale(1.04); transform-origin: 50% 100%; }
.portrait.talking .critter-img { animation: talk 0.32s ease-in-out infinite; }
.who .face, .judge .face, .vcard .face, .friend-up, .title-cast .face { overflow: hidden; border-radius: 50%; }
.who .face .critter-img, .judge .face .critter-img { width: 100%; height: 100%; }
.vcard .face .critter-img { width: 64px; height: 64px; border-radius: 50%; background: #fdf0f2; }
.mail-item .critter-img { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #fdf0f2; }
.signoff .critter-img { width: 54px; height: 54px; border-radius: 50%; background: #fdf0f2; }
.look .who-sm .critter-img { width: 22px; height: 22px; border-radius: 50%; }
.friend-up .critter-img { width: 54px; height: 54px; border-radius: 50%; background: #fdf0f2; }
.judge .face { background: #fdf0f2; }
.title-cast .face { background: radial-gradient(circle at 50% 45%, #fff 0 55%, #f9e3e6 56%); box-shadow: 0 0 0 3px #fff; }
@keyframes talk { 50% { transform: translateY(3%) scale(1.05, 1.025); } }

/* ---------- touch screens (phones and tablets) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* The game isn't text to select: no selection highlight and no iOS long-press callout.
   Typing fields keep both. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg { -webkit-user-drag: none; }
/* Taps register at once: no double-tap-to-zoom wait on anything you can press. */
button, [role="button"], a, label, select, input, .tile, .tab, .jot { touch-action: manipulation; }
/* Cards scroll inside themselves with momentum and never drag the page behind them. */
.card { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; max-height: calc(100dvh - 36px); }
.layer { overscroll-behavior: contain; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
body.crafting .card { max-height: calc(100dvh - 84px - env(safe-area-inset-top)) !important; }
body.crafting .layer { top: calc(48px + env(safe-area-inset-top)); }
.stepper { top: calc(8px + env(safe-area-inset-top)); }
@media (max-width: 860px) { .stepper { top: calc(6px + env(safe-area-inset-top)); } }

/* Notches and rounded corners: keep the bars clear of them. */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.shop { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
@media (max-width: 760px) {
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .shop { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .stage-actions { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  /* Toasts float above the sew bar, not under the thumb. */
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.crafting .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .notepad { max-height: min(340px, 42vh); }
}

/* Fingers are bigger than cursors: everything you can press is at least 44px. */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; font-size: 19px; }
  .ghost-btn { min-height: 44px; padding: 10px 16px; }
  .tab { min-height: 44px; }
  .close-x { width: 44px; height: 44px; top: 10px; right: 10px; }
  .btn { min-height: 48px; }
  .btn.small { min-height: 44px; padding: 10px 18px; }
  select { min-height: 44px; }
  input[type="range"] { height: 44px; }
  /* A transparent border grows the switch's hit area without changing how it looks. */
  .toggle { width: 64px; height: 44px; border: 8px solid transparent; background-clip: padding-box; }
  .coach button { min-height: 44px; padding: 10px 20px; font-size: 15px; }
  .look .fav { min-width: 44px; min-height: 44px; top: 0; right: 0; font-size: 18px; }
  .mail-item { min-height: 60px; }
  .emp-print { width: 50px; height: 50px; }
  .emp-buyrow .btn.small { min-width: 48px; min-height: 48px; padding: 0; font-size: 22px; }
  .chip.emp-stock { min-height: 44px; padding: 6px 12px; }
  .bubble { cursor: default; }

  /* the notepad */
  .np-head { padding: 6px 4px 2px 14px; }
  .np-fold { width: 44px; height: 44px; font-size: 16px; }
  .np-list li { min-height: 44px; align-items: center; }
  .np-tick { position: relative; width: 44px; height: 44px; margin: 0 -6px 0 -12px; border: 0; background: none; font-size: 15px; line-height: 1; }
  .np-tick::before {
    content: ""; position: absolute; left: 11px; top: 11px; width: 22px; height: 22px; box-sizing: border-box;
    border: 2px solid #8a6f66; border-radius: 5px; background: rgba(255,255,255,.5); z-index: -1;
  }
  .np-tick { z-index: 0; }
  .np-del { width: 44px; height: 44px; margin-right: -8px; font-size: 22px; line-height: 1; opacity: 0.75; }
  .np-input { min-height: 44px; }
  .np-add { width: 44px; height: 44px; font-size: 20px; }
  .np-all { min-height: 44px; padding: 6px 14px; }
}
@media (hover: none) { .np-del { opacity: 0.75; } }

/* Phones while a dress is being made: the note tucks into the top corner beside the
   step bar so it never covers the minigame. Tap it to open, tap again to tuck it away. */
.notepad.np-tucked { left: auto !important; right: max(4px, env(safe-area-inset-right)); top: calc(50px + env(safe-area-inset-top)) !important; bottom: auto !important; width: min(270px, 82vw); max-height: 46vh; transform: none; }
.notepad.np-tucked.folded { top: calc(2px + env(safe-area-inset-top)) !important; width: auto; max-height: none; border-radius: 10px; }
.notepad.np-tucked.folded .np-head { padding: 0; cursor: default; }
.notepad.np-tucked.folded .np-head > :not(.np-fold) { display: none; }
.notepad.np-tucked.folded .np-fold { width: 44px; height: 44px; margin: 0; background: none; font-size: 22px; font-family: "Nunito", system-ui, sans-serif; }
.notepad.np-tucked .np-head { cursor: default; }

/* Fabric bolts: a taller invisible hit area so the short bottom shelf is easy to tap. */
@media (pointer: coarse) { .bolt::after { content: ""; position: absolute; inset: -2px 0 -8px; } }

/* The sew bar keeps each button on one line, even on the narrowest phones. */
.stage-actions .sew-btn, .stage-actions .ghost-btn { white-space: nowrap; }
@media (max-width: 400px) {
  .stage-actions { gap: 8px; }
  .stage-actions .sew-btn { padding: 12px 20px; font-size: 16px; }
  .stage-actions .ghost-btn { padding: 10px 12px; }
}

/* Fabric shop on the narrowest phones: the buy row fits without sideways scrolling. */
.emp-cost { white-space: nowrap; }
@media (max-width: 420px) {
  .emp-panel { padding: 16px 14px 14px; }
  .emp-buyrow { gap: 8px; }
  .emp-amount { min-width: 0; flex: 1; }
}

/* Phones: a switch stays beside its label instead of dropping onto a line of its own. */
@media (max-width: 760px) {
  .setting > label { flex: 1 1 150px; min-width: 0; }
  .setting input[type="range"] { flex: 1 1 140px; width: auto; max-width: 220px; }
}
/* Phones and tablets: outside the minigames the note waits behind open cards (letters,
   journal, settings) instead of sitting on top of their buttons. */
@media (max-width: 760px), (max-height: 500px), (pointer: coarse) {
  body:not(.crafting):has(#layers > .layer) .notepad { z-index: 19; }
}

/* Short landscape phones: the fabric shop puts the cabinet beside the counter. */
@media (max-height: 500px) and (min-width: 600px) {
  .emp { grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); }
  .emp-scene { position: sticky; top: 0; }
  .emp-panel { padding: 14px 16px 12px; }
}

/* Coach marks sit above the floating note so their button is never covered. */
.coach { z-index: 29; }
.notepad.np-hop { animation: np-hop 0.5s cubic-bezier(.2,1.6,.4,1); }
@keyframes np-hop { 40% { transform: translateY(-8px) rotate(-3deg) scale(1.08); } }

/* Writing a note on a phone: the note jumps to the top so the keyboard can't hide it. */
.notepad.np-typing {
  left: max(8px, env(safe-area-inset-left)) !important; right: max(8px, env(safe-area-inset-right)) !important;
  top: calc(var(--vv-top, 0px) + 8px + env(safe-area-inset-top)) !important; bottom: auto !important;
  width: auto !important; max-height: calc(var(--vv-h, 60vh) - 16px); transform: none; z-index: 45;
}
@media (min-width: 761px) { .notepad.np-typing { right: auto !important; width: min(420px, calc(100vw - 16px)) !important; } }

/* ---------- purchase receipt ---------- */
.card.buy-card { width: min(400px, 100%); background: transparent; box-shadow: none; padding: 10px; overflow: visible; }
.card.buy-card .close-x { top: 0; right: 0; }
.receipt {
  position: relative; text-align: left; padding: 22px 22px 26px; margin: 8px 6px 16px;
  background: #fffdf8; color: #4b3a35; font-size: 15px;
  box-shadow: 0 14px 30px rgba(94, 70, 63, 0.28);
  transform: rotate(-0.8deg);
}
/* Torn, zig-zag paper edges top and bottom. */
.receipt::before, .receipt::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background-size: 14px 100%; background-repeat: repeat-x; }
.receipt::before { top: -8px; background-image: conic-gradient(from 135deg at top, #fffdf8 90deg, transparent 0); }
.receipt::after { bottom: -8px; background-image: conic-gradient(from -45deg at bottom, #fffdf8 90deg, transparent 0); }
.rc-head { text-align: center; border-bottom: 2px dashed #e6d8c6; padding-bottom: 12px; margin-bottom: 10px; }
.rc-head b { display: block; font-family: "Fraunces", serif; font-size: 19px; letter-spacing: 0.02em; }
.rc-head small { color: var(--cocoa-soft); font-weight: 700; }
.rc-art { width: 92px; height: 92px; margin: 0 auto 6px; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 0 0 2px var(--line); }
.rc-art svg { width: 100%; height: 100%; display: block; }
.rc-line { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; font-weight: 700; }
.rc-line i { flex: 1; border-bottom: 2px dotted #d9c8b4; transform: translateY(-4px); }
.rc-line span:last-child { white-space: nowrap; }
.rc-note { margin: 6px 0 0; font-size: 13.5px; color: var(--cocoa-soft); font-style: italic; }
.rc-perks { margin: 10px 0 0; padding: 8px 10px; background: #f3f8f1; border-radius: 10px; font-size: 13.5px; }
.rc-perks small { display: block; font-weight: 800; color: var(--sage-deep); text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; margin-bottom: 2px; }
.rc-perk { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; padding: 2px 0; }
.rc-perk span { white-space: nowrap; color: var(--cocoa-soft); }
.rc-perk b { color: var(--sage-deep); }
.rc-perk.down b { color: var(--rose-dark); }
.rc-sum { border-top: 2px dashed #e6d8c6; margin-top: 12px; padding-top: 8px; }
.rc-left { font-size: 17px; border-top: 2px solid #4b3a35; margin-top: 4px; padding-top: 6px; }
.rc-left.tight span:last-child { color: var(--rose-dark); }
.rc-warn {
  margin-top: 12px; padding: 9px 11px; border: 2px dashed #e1a2ae; border-radius: 10px; background: #fff4f4;
  font-size: 14px; line-height: 1.45; transform: rotate(0.6deg);
}
.buy-card .btn-row .btn { margin-top: 4px; }
.btn.ghost-warn { background: #f7ebdf; color: var(--rose-dark); box-shadow: 0 4px 0 var(--line); }

/* Fabric shop: colour families on top, shades below. */
.bolt.fam .bolt-roll { border-radius: 50% / 9%; }
.bolt-count { position: absolute; bottom: -4%; right: 2%; z-index: 2; pointer-events: none; min-width: 16px; height: 16px; border-radius: 99px; background: #fffaf3; color: var(--cocoa); font-size: 10px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.emp-shelf-label {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; pointer-events: none;
  padding: 1px 10px; border-radius: 99px; background: rgba(255, 250, 243, 0.92); color: var(--cocoa);
  font-size: 11px; font-weight: 800; letter-spacing: 0.03em; box-shadow: 0 1px 4px rgba(60,35,20,.25); white-space: nowrap;
}
.emp-shelf-label.top { top: 23.5%; }
.emp-shelf-label.bottom { top: 64.8%; }

/* ---------- mod menu ---------- */
.card.mod-card { text-align: left; width: min(760px, 100%); background: #fffaf3 repeating-linear-gradient(135deg, transparent 0 18px, rgba(201,111,128,.04) 18px 36px); }
.mod-card h2 { text-align: center; }
.mod-card .sub { text-align: center; }
.mod-grid { display: grid; gap: 12px; }
.mod-row { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.mod-row > b { display: block; margin-bottom: 8px; }
.mod-row small { color: var(--cocoa-soft); font-weight: 700; }
.mod-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.mod-btns .btn.small { margin: 0; }
.np-text { cursor: pointer; }

/* ---------- shop bonuses ---------- */
.decor-side h3 { margin: 12px 0 6px; font-size: 16px; }
.perk-panel { display: grid; gap: 4px; }
.perk-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 10px; background: #f7f1ea; font-size: 13px; color: #a8958a; }
.perk-row.on { background: #fff; color: var(--cocoa); box-shadow: 0 0 0 2px var(--line); }
.perk-row b { margin-left: auto; font-size: 14px; }
.perk-row.on b { color: var(--sage-deep); }
.perk-icon { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; background: #d8cabd; }
.perk-row.on .perk-icon.p-pay { background: #d9a93a; }
.perk-row.on .perk-icon.p-tip { background: var(--rose-deep); }
.perk-row.on .perk-icon.p-friend { background: #e48aa0; }
.perk-row.on .perk-icon.p-rep { background: #9b7fc6; }
.perk-row.on .perk-icon.p-fabric { background: #6c9bc4; }
.perk-row.on .perk-icon.p-craft { background: var(--sage-deep); }
.perk-row.on .perk-icon.p-festival { background: #e0915a; }
.perk-name { line-height: 1.25; }
.perk-chips { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 4px; }
.perk-chip { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: #f3f8f1; color: var(--sage-deep); white-space: nowrap; }
.perk-chip.none { background: #f4eee8; color: #a8958a; }
.tile .lock.on-wall { background: var(--sage-deep); color: #fff; }
.decor-tile .label { font-size: 12.5px; }
