:root {
  --bg: #fff1f4;
  --bg2: #ffe6ef;
  --panel: #ffffff;
  --ink: #5a3e4d;
  --ink-soft: #9a7c8a;
  --line: #f1d9e2;
  --accent: #ff5d8f;
  --accent-d: #e8447a;
  --shadow: 0 10px 30px rgba(150, 80, 110, 0.16);
  --surface: #fff;                     /* buttons, sheets */
  --surface-a: rgba(255, 255, 255, 0.95);
  --field: #fffafc;                    /* inputs, tiles */
  --tint: #fff0f5;                     /* selected / highlighted fills */
  --card: #fff8fb;                     /* grouping cards in the menu */
  --bar: rgba(255, 255, 255, 0.7);
  --ring: rgba(255, 93, 143, 0.2);
  --toast: #5a3e4d;
  --frost-bg: #fff3f7; --frost-line: #f8cfdc;
  --msg-bg: #f1f4ff; --msg-line: #d3dafa; --msg-ink: #4a5bc8;
  --ok-bg: #eafaf0; --gold-bg: #fff7d6; --off: #f0e6ec;
}

/* ---------- Themes (Settings ⚙️) ---------- */
:root[data-theme="mint"] {
  --bg: #effaf4; --bg2: #dcf3e6; --ink: #3b5247; --ink-soft: #7a9487; --line: #cde6d8;
  --accent: #2fb380; --accent-d: #1f9a6a; --shadow: 0 10px 30px rgba(60, 120, 90, 0.16);
  --field: #f8fdfa; --tint: #e3f6ec; --card: #f4fbf7; --ring: rgba(47, 179, 128, 0.22); --toast: #3b5247; --off: #e3efe8;
}
:root[data-theme="sky"] {
  --bg: #eef3ff; --bg2: #dfe8ff; --ink: #3c4466; --ink-soft: #7d86aa; --line: #d3dcf7;
  --accent: #5b7cfa; --accent-d: #4263e0; --shadow: 0 10px 30px rgba(70, 90, 160, 0.16);
  --field: #f8faff; --tint: #e7edff; --card: #f4f7ff; --ring: rgba(91, 124, 250, 0.22); --toast: #3c4466; --off: #e4e8f5;
}
:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #1b1623; --bg2: #251b31; --panel: #241d2d; --ink: #f4e8ef; --ink-soft: #b7a2b3; --line: #45374f;
  --accent: #ff6f9c; --accent-d: #ff8fb3; --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --surface: #322a3d; --surface-a: rgba(44, 36, 54, 0.96); --field: #2d2537; --tint: #4a2c44; --card: #2a2234;
  --bar: rgba(36, 29, 45, 0.8); --ring: rgba(255, 111, 156, 0.3); --toast: #0f0c14;
  --frost-bg: #3a2233; --frost-line: #6a3a55; --msg-bg: #232a4a; --msg-line: #3d4a86; --msg-ink: #9fb0ff;
  --ok-bg: #1f3a2c; --gold-bg: #3d3417; --off: #3a3044;
}
:root[data-theme="night"] .btn.primary { color: #2a1420; border-color: var(--accent); }
:root[data-theme="night"] .btn.primary:hover { background: var(--accent-d); }
:root[data-theme="night"] .msg-card .btn.primary { color: #fff; }
:root[data-theme="night"] .toggle.on { color: #2a1420; }
:root[data-theme="night"] .backdrop { background: rgba(0, 0, 0, 0.6); }
:root[data-theme="night"] .cake-card .thumb { background: #3a3044; }
:root[data-theme="night"] .topping-btn { background: #382f45; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* class display rules must never un-hide a hidden element */
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Birthday banner ---------- */
.bday-banner {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 44px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.2px;
  color: #6a3550;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  background: linear-gradient(90deg, #ffb3c9, #ffe08a, #b9e8d0, #c3b6f2, #ffb3c9);
  background-size: 300% 100%;
  animation: bdayShimmer 9s linear infinite;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
@keyframes bdayShimmer { to { background-position: 300% 50%; } }
.bday-x {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  color: #6a3550; font-weight: 800; font-size: 12px; line-height: 1;
  cursor: pointer;
}
.bday-x:hover { background: rgba(255, 255, 255, 0.75); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.2px; }
.brand .logo { font-size: 22px; }
.actions { display: flex; align-items: center; gap: 8px; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }
/* toolbar buttons sit in little trays: history · cake tools · keep & share · settings */
.tgroup { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 15px; background: var(--tint); }

/* settings */
.settings-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.settings-body h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.theme-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border: 2px solid var(--line);
  border-radius: 14px; background: var(--field); font: inherit; font-weight: 800; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.theme-btn:hover { box-shadow: var(--shadow); }
.theme-btn.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.theme-dot { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  border: 3px solid var(--swatch-b); background: linear-gradient(160deg, var(--swatch-a), var(--swatch-b)); }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 13px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
.btn.icon { padding: 8px 11px; font-size: 18px; line-height: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent-d); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { background: transparent; }

/* ---------- Layout ---------- */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 40px;   /* bottom room for the hint pill */
  min-width: 0;
}
#cake {
  touch-action: none;
  border-radius: 18px;
  cursor: crosshair;
}
.stage-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bar);
  padding: 5px 12px;
  border-radius: 20px;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ---------- Panel ---------- */
.panel {
  flex: 0 0 300px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.panel-col, .pcard { display: contents; }
/* one column (narrow screens): keep the natural order, frosting right after flavor */
.frost-card { order: 1; } .g-plate { order: 2; } .msg-card { order: 3; } .g-toppings { order: 4; }
.group h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.group .hint { font-size: 10px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.group.grow { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* collapsible sections */
.group.collapsible .ghead { cursor: pointer; user-select: none; align-items: center; }
.group.collapsible .ghead .chev { margin-left: auto; font-size: 11px; transition: transform 0.15s; }
.group.collapsible:not(.open) .ghead .chev { transform: rotate(-90deg); }
.group.collapsible:not(.open) .gbody { display: none; }

/* message section */
.text-in { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-weight: 600; color: var(--ink); background: var(--field); }
.msg-row { display: flex; gap: 8px; margin-top: 8px; }
.msg-row select { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-weight: 600; background: var(--field); color: var(--ink); }
.msg-colors { display: flex; gap: 6px; margin: 11px 0; flex-wrap: wrap; }
.mini-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.mini-swatch.sel { box-shadow: 0 0 0 2px var(--accent); }
.btn.full { width: 100%; }
.sub-label { margin: 11px 0 -5px; font-size: 11px; font-weight: 800; color: var(--ink-soft); }

/* Frosting and Message are separate cards with their own colour, and their
   swatches differ in kind: dollops of frosting vs. letters you write with. */
.group.card { padding: 12px; border-width: 1px; border-style: solid; border-radius: 14px; }
.frost-card { background: var(--frost-bg); border-color: var(--frost-line); }
.frost-card .ghead { color: var(--accent-d); }
.msg-card { background: var(--msg-bg); border-color: var(--msg-line); }
.msg-card .ghead { color: var(--msg-ink); }
.msg-card .btn.primary { background: #5b6ee1; border-color: #4a5bc8; }
.msg-card .btn.primary:hover { background: #4a5bc8; }
.msg-card .text-in, .msg-card select { background: var(--surface); border-color: var(--msg-line); }
.group.card:not(.open) .ghead { margin-bottom: 0; }
.group.card .msg-colors { margin-bottom: 4px; }
.msg-card .msg-colors { margin-bottom: 11px; }

.frost-swatch { --dollop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5c1.2 3.2 5 4.3 5 7.8 2.8.9 4.5 3 4.5 5.6 0 3.9-4.2 7.1-9.500 7.1s-9.500-3.200-9.500-7.100c0-2.600 1.700-4.700 4.500-5.600 0-3.500 3.800-4.600 5-7.800z'/%3E%3C/svg%3E");
  width: 29px; height: 29px; padding: 0; border: none; background: none; border-radius: 9px; cursor: pointer;
  filter: drop-shadow(0 0 0.7px rgba(90, 62, 77, 0.95)) drop-shadow(0 1px 1px rgba(90, 62, 77, 0.3)); }
.frost-swatch::before { content: ""; display: block; width: 100%; height: 100%; background: currentColor;
  -webkit-mask: var(--dollop) center / contain no-repeat; mask: var(--dollop) center / contain no-repeat; }
.frost-swatch.sel { outline: 2px solid var(--accent); outline-offset: 2px; }

.text-swatch { width: 30px; height: 30px; padding: 0; border: 1px solid #d3dafa; border-radius: 8px; background: #fff;
  font: 800 19px/1 Georgia, "Times New Roman", serif; cursor: pointer; }
.text-swatch.light { background: #5a3e4d; border-color: #5a3e4d; }
.text-swatch.sel { box-shadow: 0 0 0 2px var(--msg-bg), 0 0 0 4px #5b6ee1; }
.tiny { margin: 8px 0 0; font-size: 11px; color: var(--ink-soft); }

/* segmented control (tiers) */
.seg { display: flex; gap: 6px; }
.seg-btn { flex: 1; padding: 9px 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); font: inherit; font-weight: 700; font-size: 13px; color: var(--ink); cursor: pointer; }
.seg-btn:hover { box-shadow: var(--shadow); }
.seg-btn.sel { border-color: var(--accent); background: var(--tint); box-shadow: 0 0 0 2px var(--ring); }

/* drip toggle */
.drip-row { display: flex; align-items: center; justify-content: space-between; }
.drip-label { font-weight: 700; font-size: 13px; }
.toggle { min-width: 56px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--off); font: inherit; font-weight: 800; font-size: 12px; color: var(--ink-soft); cursor: pointer; }
.toggle.on { background: var(--accent); border-color: var(--accent-d); color: #fff; }

/* pattern stepper (< name >) */
.stepper { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.step-btn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--field); font-size: 18px; line-height: 1; font-weight: 800; color: var(--ink); cursor: pointer; padding: 0; }
.step-btn:hover { box-shadow: var(--shadow); }
.step-name { flex: 1; text-align: center; font-weight: 800; font-size: 13px; color: var(--ink);
  background: var(--tint); border: 1px solid var(--line); border-radius: 9px; padding: 6px 4px; }

/* palette categories */
.palette { display: flex; flex-direction: column; gap: 0; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
.palette-cat { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--ink-soft); margin: 12px 2px 6px; }
.palette-cat:first-child { margin-top: 0; }
.topping-btn.armed { border-color: var(--accent); background: var(--tint);
  box-shadow: 0 0 0 3px var(--ring); }

.shapes { display: flex; gap: 8px; flex-wrap: wrap; }
.shape-btn {
  width: 52px; height: 52px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  display: grid; place-items: center;
  transition: border-color 0.12s, transform 0.06s;
}
.shape-btn:hover { transform: translateY(-1px); }
.shape-btn.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

input[type=range] {
  width: 100%;
  accent-color: var(--accent);
  height: 26px;
}

.flavors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.flavor-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: none; background: none; cursor: pointer; padding: 2px;
}
.swatch {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 3px 6px rgba(0,0,0,0.08);
  transition: transform 0.08s;
}
.flavor-btn:hover .swatch { transform: scale(1.08); }
.flavor-btn.sel .swatch { box-shadow: 0 0 0 2px var(--accent), 0 3px 8px rgba(0,0,0,0.12); }
.flavor-btn small { font-size: 10px; color: var(--ink-soft); font-weight: 600; }

.palette {
  display: flex;
  flex-direction: column;
  padding: 2px;
}
.topping-btn {
  touch-action: pan-y;   /* fingers can still scroll the panel; tap to pick a topping */
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  cursor: grab;
  padding: 6px 2px 5px;
  transition: transform 0.06s, box-shadow 0.15s;
  user-select: none;
}
.topping-btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.topping-btn:active { cursor: grabbing; }
.topping-btn small { font-size: 9.5px; color: var(--ink-soft); font-weight: 700; }
.topping-btn canvas { pointer-events: none; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; }
.modal[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(70, 40, 55, 0.4); backdrop-filter: blur(2px); }
.sheet {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(80,40,60,0.35);
  width: min(460px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sheet.wide { width: min(820px, 94vw); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 18px; }
.x { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.sheet-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line);
}

.export-body { display: flex; gap: 18px; padding: 18px 20px; flex-wrap: wrap; }
.export-preview {
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 20px 20px;
  border-radius: 14px; overflow: hidden;
  width: 240px; height: 240px; flex: 0 0 auto;
}
.export-grid { display: flex; flex-direction: column; gap: 12px; flex: 1 1 180px; }
.export-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.export-grid select, .export-grid input {
  font: inherit; font-weight: 600; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--field);
}

.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; padding: 18px 20px; overflow-y: auto;
}
.cake-card {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--field); display: flex; flex-direction: column;
}
.cake-card .thumb { background: #fff7ea; display: grid; place-items: center; }
.cake-card .meta { padding: 8px 10px; }
.cake-card .name { font-weight: 800; font-size: 14px; }
.cake-card .date { font-size: 11px; color: var(--ink-soft); }
.cake-card .row { display: flex; gap: 6px; padding: 0 10px 10px; }
.cake-card .row .btn { flex: 1; padding: 6px; font-size: 12px; }
.gallery-empty { padding: 40px; text-align: center; color: var(--ink-soft); grid-column: 1/-1; }

/* Report a problem */
.report-body { padding: 18px 20px 22px; }
.report-intro { margin: 0 0 16px; font-size: 14px; color: var(--ink-soft); }
.report-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 10px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--field); cursor: pointer; font: inherit; font-weight: 800; font-size: 14px; color: var(--ink);
  transition: transform 0.06s, box-shadow 0.15s, border-color 0.12s;
}
.report-opt:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--accent); }
.report-opt:active { transform: translateY(0); }
.ro-emoji { font-size: 28px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--toast); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-weight: 700; font-size: 14px; z-index: 100; opacity: 0;
  transition: opacity 0.2s, transform 0.2s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .panel { flex: 0 0 auto; max-height: 46vh; border-left: none; border-top: 1px solid var(--line); gap: 14px; padding: 12px 14px; 54px; }   /* bottom room: the arcade strip floats over the bottom left corner */
  .brand { font-size: 17px; }
  /* toolbar: icon-only buttons that wrap instead of running off-screen */
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand-name, .actions .lbl, .actions .sep { display: none; }
  .tgroup { display: contents; }
  .actions { flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
  .actions .btn { padding: 7px 9px; font-size: 17px; line-height: 1; }
  .stage { padding: 6px 6px 28px; }
  .stage-hint { bottom: 4px; font-size: 11.5px; padding: 3px 10px; max-width: 96%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Modes ---------- */
.brand { display: flex; align-items: center; gap: 8px; }
.mode-pill { font: inherit; font-size: 13px; font-weight: 800; color: var(--accent-d); background: var(--tint);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.mode-pill:hover { box-shadow: var(--shadow); }
.home-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
.mode-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 22px 12px; border: 2px solid var(--line); border-radius: 18px; background: var(--field);
  font: inherit; color: var(--ink); cursor: pointer; transition: transform 0.06s, box-shadow 0.15s, border-color 0.12s; }
.mode-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--accent); }
.mode-card b { font-size: 17px; }
.mode-card small { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.mode-emoji { font-size: 40px; line-height: 1.1; }

/* ---------- Story: order card on the stage ---------- */
.order { position: absolute; top: 12px; left: 12px; z-index: 5; width: 330px; max-width: calc(100% - 24px);
  max-height: calc(100% - 24px); display: flex; flex-direction: column;
  background: var(--surface-a); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.order-head { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border: none; background: none;
  font: inherit; color: var(--ink); cursor: pointer; text-align: left; flex: 0 0 auto; }
.order-face { font-size: 34px; line-height: 1; }
.order-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.order-who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-who small { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.order-head { touch-action: none; cursor: grab; user-select: none; }
.order.moving { box-shadow: 0 16px 40px rgba(150, 80, 110, 0.32); }
.order.moving .order-head { cursor: grabbing; }
.order-grip { font-size: 16px; line-height: 1; color: var(--ink-soft); opacity: 0.6; }
.order-min { flex: 0 0 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 17px; font-weight: 800; line-height: 1; color: var(--ink-soft); }
.order-min::before { content: "–"; }
.order.collapsed .order-min::before { content: "+"; }
.order.dock { animation: orderDock 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); transform-origin: top left; }
@keyframes orderDock { from { transform: translate(28vw, 18vh) scale(1.35); opacity: 0; } }

/* the new-order announcement */
.intro-sheet { width: min(640px, 94vw); padding: 30px 34px 26px; align-items: center; text-align: center; overflow-y: auto;
  animation: introIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes introIn { from { transform: scale(0.7) translateY(30px); opacity: 0; } }
.intro-tag { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent-d);
  background: var(--tint); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; }
.intro-face { font-size: 96px; line-height: 1.1; margin-top: 8px; }
.intro-who { margin: 2px 0 14px; font-size: 30px; }
.intro-brief { margin: 0 0 18px; padding: 16px 20px; font-size: 21px; line-height: 1.45; background: var(--tint);
  border-radius: 6px 20px 20px 20px; text-align: left; align-self: stretch; }
.order-goals.intro-goals { align-self: stretch; text-align: left; gap: 8px; }
.intro-goals .goal { font-size: 17.5px; }
.intro-goals .goal .tick { flex-basis: 20px; height: 20px; }
.intro-goals .goal-sep { font-size: 12px; margin-top: 8px; }
.intro-actions { display: flex; gap: 12px; margin-top: 22px; align-self: stretch; }
.intro-actions .btn { flex: 1; padding: 13px 10px; font-size: 16px; }
.intro-actions .btn.primary { flex: 2; font-size: 18px; }
.order.collapsed .order-body { display: none; }
.order.collapsed { width: auto; }
.order.ready .order-head { background: var(--ok-bg); }
.order-body { padding: 0 12px 12px; overflow-y: auto; }
.order-brief { margin: 2px 0 12px; padding: 11px 13px; font-size: 15px; line-height: 1.4; background: var(--tint); border-radius: 4px 14px 14px 14px; }
.order-goals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.goal { display: flex; align-items: flex-start; gap: 7px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.goal .tick { flex: 0 0 17px; height: 17px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 11px; line-height: 1; color: #fff; margin-top: 1px; }
.goal.bonus .tick { border-radius: 5px; border-color: #f3d98a; }
.goal.done .tick { background: #37b36b; border-color: #2c9a5a; }
.goal.bonus.done .tick { background: #f4b400; border-color: #dba100; }
.goal.done .tick::before { content: "✓"; }
.goal.bonus.done .tick::before { content: "★"; }
.goal.done { color: var(--ink-soft); }
.goal.pop .tick { animation: goalPop 0.45s ease; }
@keyframes goalPop { 40% { transform: scale(1.6); } }
.goal-sep { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); margin-top: 5px; }
.order-actions { display: flex; gap: 8px; margin-top: 12px; }
.order-actions .btn { flex: 1; padding: 10px 6px; font-size: 14px; }
.order.ready #orderServe { animation: servePulse 1.4s ease-in-out infinite; }
@keyframes servePulse { 50% { box-shadow: 0 0 0 6px var(--ring); } }
.order.shake { animation: orderShake 0.35s; }
@keyframes orderShake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Story: order list ---------- */
.story-total { font-size: 14px; font-weight: 800; color: #c28a00; margin-left: 8px; white-space: nowrap; }
.story-body { padding: 6px 20px 18px; overflow-y: auto; }
.chapter h3 { margin: 16px 0 2px; font-size: 15px; }
.chapter p { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.mission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.mission { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--field); font: inherit; color: var(--ink); cursor: pointer; text-align: left; transition: transform 0.06s, box-shadow 0.15s, border-color 0.12s; }
.mission:hover:not(:disabled) { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--accent); }
.mission:disabled { opacity: 0.5; cursor: default; }
.mission.current { border-color: var(--accent); background: var(--tint); }
.mission-face { font-size: 30px; line-height: 1; }
.mission-info { display: flex; flex-direction: column; min-width: 0; }
.mission-info b { font-size: 13.5px; }
.mission-info small { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.mission-stars { font-size: 12px; letter-spacing: 1px; color: #f4b400; }
.story-ending { margin: 18px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--gold-bg); font-weight: 700; font-size: 14px; text-align: center; }

/* ---------- Story: result ---------- */
.result-body { padding: 16px 20px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; }
.result-thumb canvas { border-radius: 16px; display: block; }
.result-stars { font-size: 38px; letter-spacing: 6px; color: #f4b400; line-height: 1; }
.result-stars .off { color: var(--off); }
.result-stars span { display: inline-block; animation: starIn 0.5s backwards; }
.result-stars span:nth-child(2) { animation-delay: 0.18s; }
.result-stars span:nth-child(3) { animation-delay: 0.36s; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.result-thanks { margin: 4px 0; font-size: 14px; text-align: center; line-height: 1.4; }
#resultGoals { align-self: stretch; margin-bottom: 8px; }
#resultModal .sheet-foot { flex-wrap: wrap; }

@media (max-width: 760px) {
  .brand .logo { display: none; }
  .mode-pill { padding: 6px 9px; font-size: 15px; }
  .mode-pill .lbl { display: none; }
  .order { top: 6px; left: 6px; width: 270px; max-height: calc(100% - 12px); }
  .order-head { padding: 6px 9px; }
  .order-face { font-size: 24px; }
  .order-brief { font-size: 13.5px; padding: 9px 11px; }
  .goal { font-size: 13px; }
  .intro-sheet { padding: 18px 16px 16px; }
  .intro-face { font-size: 60px; }
  .intro-who { font-size: 21px; }
  .intro-brief { font-size: 15.5px; }
  .intro-goals .goal { font-size: 14.5px; }
  .home-body { padding: 14px; gap: 10px; }
}

/* mid-width screens: icon-only toolbar so it never runs off the edge */
.actions { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1080px) { .actions .lbl { display: none; } }

/* wide screens: the panel is double width, two columns, so nothing scrolls */
@media (min-width: 1200px) {
  .panel { flex-basis: 620px; flex-direction: row; align-items: flex-start; gap: 20px; padding: 14px 16px; }
  .panel-col { display: flex; flex-direction: column; gap: 14px; flex: 1 1 0; min-width: 0; }
  .panel .group { order: 0; }
  /* related controls share a card: cake base · look · message | frosting · toppings */
  .pcard { display: flex; flex-direction: column; gap: 12px; padding: 11px 12px; border: 1px solid var(--line);
    border-radius: 16px; background: var(--card); }
  .pcard .group h3 { margin-bottom: 8px; }
  .shapes { gap: 6px; flex-wrap: nowrap; }
  .shape-btn { width: 48px; height: 48px; }
  .plates { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
  .plates .swatch { width: 34px; height: 34px; }
  .msg-card .tiny { display: none; }
  .msg-card .msg-colors { margin-bottom: 9px; }
  .palette-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .palette-cat { margin: 6px 2px 4px; }
  .topping-btn { padding: 3px 1px 3px; min-width: 0; }
  .topping-btn canvas { width: 40px !important; height: 40px !important; }
  .topping-btn small { font-size: 9px; letter-spacing: -0.2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
