/* Grain: a Victorian glassworks specimen cabinet.
   Walnut, brass plates, linen labels, ink, typewriter numbers, wax seals. */

:root {
  --walnut: #3b2a20;
  --walnut-dk: #241912;
  --brass: #b8893b;
  --brass-lt: #e0b860;
  --brass-dk: #6f4f1d;
  --linen: #efe6d2;
  --linen-sh: #d9ccb0;
  --ink: #2a211b;
  --ink-soft: rgba(42, 33, 27, 0.62);
  --oxblood: #7a2e2a;
  --verdigris: #4f7d6e;
  --umber: #15100c;
  --fell: "IM Fell English SC", "IM Fell English", Georgia, "Times New Roman", serif;
  --body: "Spectral", Georgia, "Times New Roman", serif;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
  --linen-tex:
    repeating-linear-gradient(0deg, rgba(120, 98, 66, 0.05) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 98, 66, 0.045) 0 1px, transparent 1px 4px);
  --walnut-tex:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 2px, transparent 2px 148px),
    repeating-linear-gradient(90deg, rgba(255, 214, 160, 0.022) 0 1px, transparent 1px 7px, rgba(0, 0, 0, 0.04) 7px 9px, transparent 9px 17px),
    repeating-linear-gradient(89deg, transparent 0 37px, rgba(0, 0, 0, 0.05) 37px 39px, transparent 39px 71px);
  --plank-tex:
    repeating-linear-gradient(0deg, rgba(255, 214, 160, 0.03) 0 1px, transparent 1px 5px, rgba(0, 0, 0, 0.06) 5px 6px, transparent 6px 11px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--walnut-dk);
  background-image: var(--walnut-tex);
  color: var(--linen);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass-lt); outline-offset: 2px; }
.fell { font-family: var(--fell); font-weight: 400; letter-spacing: 0.01em; }
.typed { font-family: var(--mono); }
.hand { font-family: var(--body); font-style: italic; }
.muted { opacity: 0.7; }
.noscript { padding: 40px; font-family: var(--body); }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; perspective: 2200px; perspective-origin: 0 50%; }
.screen {
  position: absolute; inset: 0; overflow: hidden;
  background-color: var(--walnut-dk);
  background-image: var(--walnut-tex);
  transform-origin: left center;
  backface-visibility: hidden;
}
.screen.page-out {
  z-index: 5;
  animation: pageTurn 0.4s cubic-bezier(0.55, 0.05, 0.7, 0.4) forwards;
  box-shadow: 18px 0 40px rgba(0, 0, 0, 0.6);
}
.screen.page-out::after {
  content: ""; position: absolute; inset: 0; background: #000; opacity: 0;
  animation: pageShade 0.4s ease-in forwards; pointer-events: none;
}
@keyframes pageTurn {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-96deg); }
}
@keyframes pageShade { to { opacity: 0.45; } }
.reduced-motion .screen.page-out { animation: none; display: none; }

/* ---------------------------------------------------------------- brass */
.plate, .btn.primary, .sq-btn, .tool-btn, .mini-btn {
  background-color: var(--brass);
  color: #3a2810;
  border: 1px solid var(--brass-dk);
  box-shadow:
    inset 0 1px 0 rgba(240, 206, 128, 0.9),
    inset 0 -2px 0 rgba(70, 46, 12, 0.35),
    0 2px 0 rgba(20, 12, 6, 0.55),
    0 5px 10px rgba(0, 0, 0, 0.32);
  text-shadow: 0 1px 0 rgba(240, 206, 128, 0.55);
}
.plate { position: relative; border-radius: 3px; font-family: var(--fell); }
.screw {
  position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: #8e6a2c;
  box-shadow: inset 0 1px 0 rgba(240, 206, 128, 0.8), inset 0 -1px 1px rgba(0, 0, 0, 0.45);
}
.screw::after {
  content: ""; position: absolute; left: 1px; right: 1px; top: 3.5px; height: 1px;
  background: rgba(50, 32, 8, 0.75); transform: rotate(38deg);
}
.screw.l { left: 7px; }
.screw.r { right: 7px; }
.screw.r::after { transform: rotate(-22deg); }

.sq-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0; border-radius: 3px;
}
.sq-btn .ico { width: 22px; height: 22px; }
.sq-btn:hover:not(:disabled), .tool-btn:hover:not(:disabled), .mini-btn:hover:not(:disabled), .plate.menu-plate:hover { background-color: #c4974a; }
.sq-btn:active:not(:disabled), .tool-btn:active:not(:disabled), .mini-btn:active:not(:disabled), .menu-plate:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(60, 38, 8, 0.5), 0 1px 0 rgba(20, 12, 6, 0.5);
}
.sq-btn.lit { background-color: var(--brass-lt); }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--oxblood); color: var(--linen);
  font: 700 11px/18px var(--mono); text-shadow: none; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.ico { display: block; }

/* ---------------------------------------------------------------- linen paper */
.paper {
  position: relative; isolation: isolate; color: var(--ink);
}
.paper::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-color: var(--linen);
  background-image: var(--linen-tex);
  filter: url(#deckle);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 10px 26px rgba(0, 0, 0, 0.42);
}
.paper-tag {
  display: inline-block; color: var(--ink);
  background-color: var(--linen); background-image: var(--linen-tex);
  border: 1px solid var(--linen-sh);
  padding: 3px 10px; border-radius: 1px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.25);
  font-family: var(--mono); font-size: 14px;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 7px 18px; border-radius: 3px;
  font-family: var(--fell); font-size: 18px; line-height: 1.1;
  background-color: var(--linen); background-image: var(--linen-tex);
  color: var(--ink); border: 1px solid rgba(42, 33, 27, 0.75);
  box-shadow: 0 2px 0 rgba(42, 33, 27, 0.55);
}
.btn .ico { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { background-color: #f7f0df; }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(42, 33, 27, 0.55); }
.btn.primary { background-image: none; }
.btn.primary:hover:not(:disabled) { background-color: #c4974a; }
.btn.danger { background: var(--oxblood); color: var(--linen); border-color: #4e1c19; box-shadow: 0 2px 0 #3a1513; text-shadow: none; }
.btn.danger:hover:not(:disabled) { background: #8a3732; }
.btn.quiet { background: none; border-color: transparent; box-shadow: none; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 15px; }
.btn.big { min-height: 50px; padding: 10px 26px; font-size: 21px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.mini-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 3px;
}
.mini-btn .ico { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- the jar */
.jar-hold {
  position: relative; flex: 1; min-width: 0; min-height: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.jar-rim {
  position: relative; margin-top: 18px; padding: 6px;
  background: #1b130e;
  border-radius: 6px 6px 22px 22px;
  box-shadow:
    0 0 0 2px var(--brass-dk),
    0 0 0 5px var(--brass),
    0 0 0 6px #5a4019,
    inset 0 0 0 1px rgba(239, 230, 210, 0.1),
    0 22px 26px -12px rgba(0, 0, 0, 0.75);
}
.jar-lip {
  position: absolute; left: -16px; right: -16px; top: -20px; height: 13px; border-radius: 4px;
  background: var(--brass); border: 1px solid var(--brass-dk);
  box-shadow: inset 0 2px 0 rgba(240, 206, 128, 0.85), inset 0 -3px 0 rgba(70, 46, 12, 0.35), 0 3px 4px rgba(0, 0, 0, 0.45);
}
.jar-lip::after {
  content: ""; position: absolute; left: 14px; right: 14px; top: 5px; height: 1px; background: rgba(70, 46, 12, 0.45);
}
.jar-canvas {
  display: block; border-radius: 2px 2px 17px 17px; touch-action: none; cursor: none;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.shelf {
  width: calc(100% + 24px); max-width: none; height: 18px; margin-top: 7px; flex: none;
  background-color: var(--walnut); background-image: var(--plank-tex);
  border-top: 2px solid #5b4232; border-radius: 1px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.jar-status {
  position: absolute; top: 14px; left: 18px; z-index: 2; pointer-events: none;
  font: 700 13px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--linen); background: rgba(21, 16, 12, 0.75); padding: 3px 9px; border: 1px solid rgba(239, 230, 210, 0.35);
}
.jar-status.paused { color: #e9b4a8; border-color: rgba(214, 120, 110, 0.6); }
.end-stamp {
  position: absolute; left: 50%; top: 42%; z-index: 3; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-7deg) scale(2); opacity: 0;
  font-family: var(--fell); font-size: clamp(26px, 4vw, 48px); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 22px; border: 4px double currentColor;
  background-color: var(--linen); background-image: var(--linen-tex);
  transition: transform 0.2s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.2s;
}
.end-stamp.win { color: var(--verdigris); }
.end-stamp.lose { color: var(--oxblood); }
.end-stamp.in { opacity: 0.95; transform: translate(-50%, -50%) rotate(-7deg) scale(1); }

/* ---------------------------------------------------------------- satchel */
.satchel { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.satchel-head { align-self: flex-start; transform: rotate(-1.5deg); font-family: var(--fell); font-size: 17px; }
.vials { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 10px 2px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--brass-dk) transparent; }
.vial-btn {
  position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 9px;
  padding: 5px 22px 5px 7px; text-align: left; width: 100%; flex: none;
  background-color: var(--linen); background-image: var(--linen-tex); color: var(--ink);
  border: 1px solid var(--linen-sh); border-radius: 1px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 3px 5px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s;
}
.vial-btn:hover { transform: translateX(3px); }
.vial-btn.selected { transform: translateX(8px); border-color: var(--ink); background-color: #f8f2e3; }
.vial-btn.selected::before {
  content: ""; position: absolute; left: -9px; top: 50%; margin-top: -6px;
  border: 6px solid transparent; border-left: 7px solid var(--brass-lt); border-right: 0;
}
.vial-btn.empty { opacity: 0.6; }
.vial-btn.empty .vial-amt { color: var(--oxblood); }
.vial-btn.flash { animation: shakeX 0.3s; }
@keyframes shakeX { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
.vial { position: relative; display: block; width: 26px; height: 34px; }
.vial-cork {
  position: absolute; left: 8px; top: 0; width: 10px; height: 8px; border-radius: 2px 2px 1px 1px;
  background: #9a7650; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 230, 190, 0.3);
}
.vial-bulb {
  position: absolute; left: 0; right: 0; bottom: 0; height: 27px; overflow: hidden;
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  border: 1.5px solid var(--ink); background: var(--umber);
}
.vial-bulb::after {
  content: ""; position: absolute; left: 5px; top: 4px; width: 2px; height: 11px; border-radius: 1px;
  background: rgba(239, 230, 210, 0.45);
}
.vial-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background-size: 100% auto; background-position: center bottom;
  image-rendering: pixelated; transition: height 0.25s;
}
.vial-label { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.vial-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vial-amt { font-size: 13px; color: var(--ink-soft); }
.vial-key { position: absolute; right: 6px; top: 4px; font-size: 11px; color: rgba(42, 33, 27, 0.5); }
.satchel.compact .vials { flex-direction: row; overflow: visible; padding: 0; gap: 8px; }
.satchel.compact .vial-btn { width: auto; grid-template-columns: 22px auto; padding: 4px 22px 4px 6px; }
.satchel.compact .vial-btn.selected { transform: translateY(-4px); }
.satchel.compact .vial-btn.selected::before { left: 50%; top: auto; bottom: -10px; margin: 0 0 0 -6px; border: 6px solid transparent; border-top: 7px solid var(--brass-lt); border-bottom: 0; }
.satchel.compact .vial { transform: scale(0.85); transform-origin: left center; }
.satchel.compact .vial-amt { display: none; }

/* ---------------------------------------------------------------- tools */
.toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 50px; padding: 5px 2px 4px; border-radius: 3px;
}
.tool-btn .ico { width: 22px; height: 22px; }
.tool-name { font-family: var(--fell); font-size: 13px; line-height: 1; }
.tool-btn.active {
  background-color: var(--linen); color: var(--ink); text-shadow: none;
  border-color: var(--ink);
  box-shadow: inset 0 2px 3px rgba(42, 33, 27, 0.35), 0 1px 0 rgba(20, 12, 6, 0.5);
}
.tool-btn[data-tool="erase"].active { color: var(--oxblood); }
.tool-btn:disabled { opacity: 0.45; }
.tool-sep { display: none; }
.brush { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--linen); }
.brush-label { font-family: var(--fell); font-size: 16px; flex: 1; }
.brush-show { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 64px; }
.brush-dot { display: inline-block; border-radius: 50%; border: 1.5px solid var(--linen); }
.brush-val { font-size: 15px; min-width: 18px; text-align: right; }
.tool-chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 8px 2px 0; font-size: 14px; }
.tool-chip .ico { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- jar screen */
.jar-screen {
  display: grid;
  grid-template-columns: minmax(140px, 188px) minmax(0, 1fr) minmax(206px, 246px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "satchel jar side";
  gap: 10px 18px; padding: 12px 18px 14px;
}
.jar-top { grid-area: top; display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-plate {
  display: flex; flex-direction: column; justify-content: center; min-width: 0;
  padding: 4px 26px 5px; border-radius: 3px; line-height: 1.1;
}
.plate-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; text-shadow: none; }
.plate-title { font-size: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jar-sub { flex: 1; min-width: 0; font-style: italic; color: rgba(239, 230, 210, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.top-btns { display: flex; gap: 8px; }
.timer { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; transform: rotate(-1deg); }
.timer-ico .ico { width: 20px; height: 20px; }
.timer-val { font-size: 22px; font-weight: 700; min-width: 54px; }
.timer.urgent { color: var(--oxblood); animation: pulse 1s infinite; }
.reduced-motion .timer.urgent { animation: none; }
@keyframes pulse { 50% { transform: rotate(-1deg) scale(1.06); } }
.jar-screen .satchel { grid-area: satchel; }
.jar-center { grid-area: jar; min-width: 0; min-height: 0; display: flex; }
.side { grid-area: side; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 8px; scrollbar-width: thin; scrollbar-color: var(--brass-dk) transparent; }
.goals-card, .shelf-card { padding: 14px 16px 16px; }
.card-title { margin: 0 0 8px; font-size: 22px; line-height: 1.1; border-bottom: 1px solid rgba(42, 33, 27, 0.35); padding-bottom: 6px; }
.goal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.goal { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 2px 7px; align-items: start; font-size: 15px; line-height: 1.25; }
.goal-check { width: 16px; height: 16px; margin-top: 2px; border: 1.5px solid var(--ink); border-radius: 1px; color: transparent; display: grid; place-items: center; }
.goal-check .ico { width: 13px; height: 13px; stroke-width: 2.4; }
.goal.done .goal-check { color: var(--linen); background: var(--verdigris); border-color: var(--verdigris); }
.goal.done .goal-label { color: var(--verdigris); }
.goal.failed .goal-label { text-decoration: line-through; color: var(--oxblood); }
.goal.failed .goal-check { border-color: var(--oxblood); }
.bar { grid-column: 2; display: block; height: 6px; border: 1px solid rgba(42, 33, 27, 0.7); margin-top: 3px; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.25s; }
.goal.done .bar-fill { background: var(--verdigris); }
.bonus-line { display: flex; align-items: center; gap: 7px; margin-top: 12px; padding-top: 9px; border-top: 1px dashed rgba(42, 33, 27, 0.4); font-size: 14px; font-style: italic; }
.bonus-line.done { color: var(--oxblood); font-style: normal; font-weight: 600; }
.mini-seal { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px dashed rgba(42, 33, 27, 0.55); color: transparent; }
.mini-seal svg { width: 12px; height: 12px; }
.bonus-line.done .mini-seal, .order-bonus .mini-seal { background: var(--oxblood); border: 0; color: #d99d8d; }
.order-bonus .mini-seal .ico { width: 12px; height: 12px; }
.par-line { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--ink-soft); }
.used-val.over { color: var(--oxblood); font-weight: 700; }
.hint-slip {
  margin-top: 12px; padding: 8px 10px; font-size: 15px; line-height: 1.35;
  background: #f6edd2; border-left: 3px solid var(--brass); transform: rotate(-0.6deg);
}
.hint-slip::before { content: "Ilse's margin note: "; font-style: normal; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; display: block; color: var(--ink-soft); }
.run-info { margin-top: 12px; padding-top: 9px; border-top: 1px dashed rgba(42, 33, 27, 0.4); font-size: 13px; }
.run-score { font-weight: 700; margin-bottom: 5px; }
.run-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.tag-reagent, .tag-hex { font-size: 12px; padding: 1px 6px; border: 1px solid var(--ink); border-radius: 1px; }
.tag-reagent.rare { border-color: var(--verdigris); color: var(--verdigris); }
.tag-reagent.legendary { border-color: var(--brass-dk); background: rgba(184, 137, 59, 0.2); }
.tag-hex { border-color: var(--oxblood); color: var(--oxblood); border-style: dashed; }
.tools-card { padding: 2px 0 0; }

/* ---------------------------------------------------------------- free jar shelf */
.shelf-note { margin: 0 0 10px; font-size: 13px; font-style: italic; color: var(--ink-soft); }
.shelf-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; }
.slot { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "thumb thumb" "name btns" "when btns"; gap: 1px 4px; min-width: 0; align-items: center; }
.slot-thumb { grid-area: thumb; margin-bottom: 3px; }
.slot-name { grid-area: name; }
.slot-when { grid-area: when; }
.slot-btns { grid-area: btns; }
.slot-thumb {
  aspect-ratio: 16 / 9; background: var(--umber) center / cover no-repeat; image-rendering: pixelated;
  border: 2px solid var(--brass); border-radius: 2px 2px 6px 6px;
  display: grid; place-items: center; font: 11px var(--mono); color: rgba(239, 230, 210, 0.35);
}
.slot-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-when { font-size: 11px; color: var(--ink-soft); }
.slot-btns { display: flex; gap: 4px; }
.slot-btns .mini-btn { width: 24px; height: 24px; }
.slot-btns .mini-btn .ico { width: 14px; height: 14px; }
.shelf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- title */
.title-screen {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
  gap: 30px; padding: 26px 36px 22px; align-items: stretch;
}
.title-jar { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.title-jar { justify-content: center; }
.title-jar .jar-hold { flex: 1 1 auto; max-height: calc((100vw - 400px) * 0.5625 + 70px); }
.title-under { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 22px; padding-top: 12px; }
.title-caption { margin: 0; font-size: 13px; color: rgba(239, 230, 210, 0.6); }
.title-menu { display: flex; flex-direction: column; justify-content: flex-start; gap: 11px; min-height: 0; overflow-y: auto; padding: 6px 6px 10px; }
.title-menu > :first-child { margin-top: auto; }
.title-menu > :last-child { margin-bottom: auto; }
.shop-label { padding: 16px 18px 14px; margin-bottom: 8px; text-align: center; transform: rotate(-1deg); }
.shop-name { font-size: 25px; line-height: 1.1; }
.shop-town { font-size: 13px; color: var(--ink-soft); margin-top: 4px; letter-spacing: 0.06em; }
.menu-plate {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 9px 24px 10px 26px; text-align: left; transition: background-color 0.12s;
}
.plate-ico .ico { width: 26px; height: 26px; }
.plate-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.12; }
.plate-label { font-size: 23px; }
.plate-note { font-family: var(--body); font-style: italic; font-size: 13.5px; color: #4a3416; text-shadow: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- page screens */
.page-screen { display: flex; flex-direction: column; gap: 12px; padding: 14px 22px 0; }
.page-top { display: flex; align-items: center; gap: 14px; flex: none; }
.page-top .title-plate { min-width: 0; }
.page-top-right { margin-left: auto; transform: rotate(1deg); font-size: 15px; }

/* ledger */
.ledger-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 10px 50px; scrollbar-width: thin; scrollbar-color: var(--brass-dk) transparent; }
.ledger-paper {
  max-width: 900px; margin: 0 auto; padding: 26px 40px 34px 74px;
}
.ledger-paper::before { filter: none; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2), 0 16px 34px rgba(0, 0, 0, 0.5);
  background-image: var(--linen-tex), repeating-linear-gradient(180deg, transparent 0 33px, rgba(79, 125, 110, 0.13) 33px 34px); }
.ledger-rule { position: absolute; left: 52px; top: 0; bottom: 0; width: 4px; border-left: 1px solid rgba(122, 46, 42, 0.55); border-right: 1px solid rgba(122, 46, 42, 0.55); }
.ledger-chapter { margin-bottom: 30px; }
.ledger-chapter.sealed .chapter-head, .ledger-chapter.sealed .chapter-blurb { opacity: 0.55; }
.chapter-head { display: flex; align-items: baseline; gap: 14px; border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.chapter-num { font-size: 15px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.08em; }
.chapter-title { font-size: 30px; line-height: 1.1; flex: 1; }
.chapter-stars { font-size: 14px; color: var(--ink-soft); }
.chapter-blurb { margin: 6px 0 4px; font-style: italic; font-size: 15px; color: var(--ink-soft); }
.orders { list-style: none; margin: 0; padding: 0; }
.order {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  width: 100%; padding: 9px 8px; text-align: left; background: none; border: 0;
  border-bottom: 1px solid rgba(79, 125, 110, 0.35); color: var(--ink);
}
.order:hover:not(:disabled) { background: rgba(184, 137, 59, 0.14); }
.order.locked { color: rgba(42, 33, 27, 0.42); }
.order-no { font-size: 14px; color: var(--oxblood); }
.order-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.order-title { font-size: 18px; font-weight: 600; }
.order-client { font-size: 14px; font-style: italic; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-dots { display: none; }
.order-best { font-size: 13px; color: var(--ink-soft); }
.order .lock .ico { width: 20px; height: 20px; }
.seals { display: inline-flex; gap: 4px; }
.seal-mini { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed rgba(42, 33, 27, 0.4); color: transparent; }
.seal-mini svg { width: 12px; height: 12px; }
.seal-mini.on { border: 0; background: var(--oxblood); color: #d9988a; box-shadow: inset 0 0 0 2px #65241f, 0 1px 1px rgba(0, 0, 0, 0.3); }
.nb-stub {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px; padding: 10px 14px;
  background: #f4ead0; border: 1px solid var(--linen-sh); color: var(--ink); text-align: left;
  transform: rotate(-0.5deg); box-shadow: 0 2px 4px rgba(60, 40, 20, 0.2); font-size: 16px;
}
.nb-stub .hand { flex: 1; }
.nb-stub.missing { background: none; border-style: dashed; box-shadow: none; color: var(--ink-soft); }
.nb-stub:hover:not(:disabled) { background: #f9f1dc; }
.nb-stub.new { border-color: var(--oxblood); }
.nb-stub-ico .ico { width: 22px; height: 22px; }
.nb-stub-tag { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--oxblood); }

/* codex */
.codex-tabs { display: flex; gap: 3px; padding: 0 18px; flex: none; margin-bottom: -12px; position: relative; z-index: 1; overflow-x: auto; scrollbar-width: none; }
.index-tab {
  display: flex; align-items: baseline; gap: 7px; padding: 6px 16px 8px; border: 0;
  background: var(--linen-sh); color: var(--ink);
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 100%, 0 100%);
  transform: translateY(5px); transition: transform 0.12s;
  flex: none;
}
.index-tab.on { background-color: var(--linen); transform: none; }
.index-tab:hover { transform: translateY(2px); }
.index-tab.on:hover { transform: none; }
.tab-label { font-family: var(--fell); font-size: 18px; }
.tab-count { font-size: 12px; color: var(--ink-soft); }
.codex-scroll {
  flex: 1; min-height: 0; overflow-y: auto; margin: 0 6px 16px; padding: 22px 20px 28px;
  background-color: var(--linen); background-image: var(--linen-tex); color: var(--ink);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin; scrollbar-color: var(--brass-dk) transparent;
}
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.spec-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 10px 12px;
  background: #f7f1e3; border: 1px solid var(--linen-sh); color: var(--ink);
  box-shadow: 0 1px 0 rgba(42, 33, 27, 0.2), 0 4px 8px rgba(80, 56, 28, 0.14);
  text-align: center; transition: transform 0.12s;
}
.spec-card:not(.unknown):hover { transform: translateY(-3px) rotate(-0.5deg); }
.spec-card.unknown { background: #ebe2cb; cursor: default; }
.spec-no { align-self: flex-start; font-size: 11px; color: var(--oxblood); }
.spec-jar {
  position: relative; width: 62px; height: 60px; margin: 6px 0 4px; overflow: hidden;
  border: 1.5px solid var(--ink); border-radius: 46% 46% 8px 8px / 34% 34% 8px 8px; background: var(--umber);
}
.spec-jar::after { content: ""; position: absolute; left: 9px; top: 10px; width: 2px; height: 28px; background: rgba(239, 230, 210, 0.4); }
.spec-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 62%; background-size: cover; image-rendering: pixelated; }
.spec-card.unknown .spec-jar { background: var(--ink); border-color: var(--ink); }
.spec-card.unknown .spec-jar::after { display: none; }
.spec-shadow { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--fell); font-size: 28px; color: rgba(217, 204, 176, 0.45); }
.spec-name { font-size: 19px; line-height: 1.05; }
.spec-card.unknown .spec-name { color: var(--ink-soft); }
.spec-latin { font-style: italic; font-size: 13px; color: var(--ink-soft); line-height: 1.2; }
.spec-latin.big { font-size: 16px; }
.spec-hint { font-style: italic; font-size: 13px; line-height: 1.25; color: #5d4a3a; }
.spec-detail { width: min(560px, 92vw); padding: 24px 28px 26px; }
.spec-detail-no { font-size: 12px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.06em; }
.spec-detail-top { display: flex; gap: 18px; align-items: center; margin: 12px 0; }
.spec-detail-top h2 { margin: 0; font-size: 34px; line-height: 1; }
.spec-detail-swatch { width: 88px; height: 64px; flex: none; background-size: cover; image-rendering: pixelated; border: 3px solid var(--brass); border-radius: 3px 3px 12px 12px; }
.spec-text { font-size: 17px; }
.spec-recipe { font-size: 15px; border-top: 1px dashed rgba(42, 33, 27, 0.4); padding-top: 8px; }
.spec-props { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-soft); }
.codex-modal .modal-holder { width: min(1120px, 100%); height: min(100%, 860px); max-width: none; overflow: hidden; }
.codex-screen.as-overlay { position: relative; height: 100%; padding: 14px 16px 0; background-color: var(--walnut-dk); background-image: var(--walnut-tex); border: 2px solid var(--brass-dk); border-radius: 4px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); }

/* trials */
.trials-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 10px 34px; }
.trials-body.start { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: center; }
.trials-intro { width: min(560px, 100%); padding: 24px 30px 26px; }
.trials-intro h2, .tally h2, .summary h2, .hex-card h2, .daily-card h2 { margin: 4px 0 10px; font-size: 32px; line-height: 1.05; }
.tally-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--oxblood); }
.trials-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; border-top: 1px solid rgba(42, 33, 27, 0.3); padding-top: 12px; }
.trials-stats > div { display: flex; flex-direction: column; align-items: center; }
.stat-n { font-size: 24px; font-weight: 700; }
.stat-l { font-size: 13px; font-style: italic; color: var(--ink-soft); }
.reagent-shelf { width: min(440px, 100%); padding: 20px 22px; }
.reagent-shelf h3 { margin: 0 0 8px; font-size: 22px; }
.reagent-list { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow-y: auto; }
.reagent-list li { display: grid; grid-template-columns: 12px auto minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid rgba(79, 125, 110, 0.25); font-size: 14px; }
.rl-name { font-weight: 600; white-space: nowrap; }
.rl-text { color: var(--ink-soft); font-style: italic; font-size: 13px; }
.rar-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); margin-right: 6px; }
.rar-dot.rare { background: var(--verdigris); border-color: var(--verdigris); }
.rar-dot.legendary { background: var(--brass); border-color: var(--brass-dk); }
.round-track { display: flex; gap: 6px; flex: none; }
.track-cell {
  width: 34px; height: 34px; display: grid; place-items: center; font: 700 15px var(--mono);
  color: rgba(239, 230, 210, 0.6); border: 1.5px solid rgba(239, 230, 210, 0.3); border-radius: 2px;
}
.track-cell.hex { border-style: dashed; border-color: rgba(214, 120, 110, 0.6); }
.track-cell.now { color: var(--ink); background: var(--brass); border: 1.5px solid var(--brass-lt); }
.track-cell.won { color: var(--linen); background: var(--verdigris); border-color: var(--verdigris); }
.track-cell.lost { color: var(--linen); background: var(--oxblood); border-color: var(--oxblood); }
.track-cell.forgiven { color: var(--linen); border-color: var(--brass); }
.tally, .summary, .hex-card, .daily-card, .daily-result { width: min(560px, 100%); padding: 22px 28px 24px; }
.tally-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.tally-table td { padding: 4px 0; border-bottom: 1px dotted rgba(42, 33, 27, 0.35); }
.tally-table td:last-child { text-align: right; }
.tally-table tr.sum td { font-weight: 700; border-bottom: 0; border-top: 1.5px solid var(--ink); }
.pick { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.pick .btn.quiet, .on-wood .btn.quiet { color: var(--linen); }
.pick-title { margin: 6px 0 0; font-size: 24px; color: var(--linen); }
.reagents { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.reagent-card {
  width: 196px; min-height: 230px; padding: 16px 14px 14px; border: 0; background: none; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: dealIn 0.4s backwards cubic-bezier(0.2, 0.8, 0.2, 1);
  transition: transform 0.15s;
}
.reduced-motion .reagent-card { animation: none; }
@keyframes dealIn { from { opacity: 0; transform: translateY(24px) rotate(-4deg); } }
.reagent-card:hover { transform: translateY(-6px) rotate(0.6deg); }
.reagent-card::after { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(42, 33, 27, 0.5); pointer-events: none; }
.reagent-card.rare::after { border: 2px solid var(--verdigris); }
.reagent-card.legendary::after { border: 3px double var(--brass-dk); }
.rarity { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft); }
.reagent-card.rare .rarity { color: var(--verdigris); }
.reagent-card.legendary .rarity { color: #8a6424; font-weight: 700; }
.reagent-bottle .ico { width: 44px; height: 44px; color: var(--ink); }
.reagent-name { font-size: 22px; line-height: 1.05; }
.reagent-text { font-size: 14px; line-height: 1.3; flex: 1; }
.reagent-take { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--oxblood); }
.hex-card { text-align: center; }
.hex-card .hex-sigil { margin: 8px auto 2px; width: 72px; height: 72px; color: var(--oxblood); }
.hex-card .hex-sigil svg { width: 100%; height: 100%; }
.hex-card .row-btns { justify-content: center; }
.hex-bonus { font-size: 13px; color: var(--ink-soft); }
.summary { text-align: center; }
.summary .row-btns { justify-content: center; }
.big-score { font-size: 52px; font-weight: 700; line-height: 1; margin: 8px 0; }
.best-line { font-size: 14px; color: var(--ink-soft); }
.best-seal { margin: 6px auto 0; }
.summary-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; text-align: left; margin-top: 16px; border-top: 1px solid rgba(42, 33, 27, 0.3); padding-top: 10px; }
.summary-cols h3 { margin: 0 0 4px; font-size: 18px; }
ul.plain { list-style: none; margin: 0; padding: 0; font-size: 14px; }
ul.plain li { padding: 2px 0; }

/* daily */
.daily-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 8px 10px 34px; }
.daily-flavour { font-style: italic; margin: 0 0 8px; }
.daily-cols { display: grid; grid-template-columns: 1.2fr 1fr 0.6fr; gap: 16px; margin-top: 8px; }
.daily-cols h3 { margin: 0 0 4px; font-size: 18px; }
.daily-clock { display: flex; align-items: center; gap: 6px; font-size: 20px; }
.daily-clock .ico { width: 20px; height: 20px; }
.daily-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; width: min(560px, 100%); }
.daily-note { width: 100%; text-align: center; margin: 0; font-size: 14px; font-style: italic; color: rgba(239, 230, 210, 0.75); }
.daily-result { text-align: center; }
.daily-result.win .big-score { color: var(--verdigris); }
.daily-result.lose .big-score { color: var(--oxblood); }
.daily-parts { font-size: 13px; color: var(--ink-soft); }

/* results */
.results-screen { justify-content: center; }
.results-wrap { flex: 1; min-height: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 20px 10px 30px; }
.results-card { width: min(640px, 100%); padding: 26px 34px 28px; text-align: center; }
.results-card h1 { margin: 4px 0 2px; font-size: 40px; line-height: 1.05; }
.results-kicker { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--oxblood); }
.results-client { font-style: italic; color: var(--ink-soft); }
.results-lost { font-size: 17px; }
.results-card .row-btns { justify-content: center; }
.seal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0 12px; }
.seal-slot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.seal-ring { width: 84px; height: 84px; border-radius: 50%; border: 1.5px dashed rgba(42, 33, 27, 0.4); }
.seal-label { font-size: 14px; line-height: 1.2; max-width: 170px; }
.wax-seal.star-seal { position: absolute; top: 0; left: 50%; margin-left: -42px; width: 84px; height: 84px; opacity: 0; transform: scale(2.4) rotate(14deg); transition: transform 0.2s cubic-bezier(0.55, 0, 0.8, 0.2), opacity 0.12s; }
.star-seal svg { width: 40px; height: 40px; }
.star-seal.stamped { opacity: 1; transform: scale(1) rotate(-9deg); }
.reduced-motion .star-seal { transition: none; }
.results-used { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 8px auto 0; max-width: 420px; font-size: 14px; }
.used-bar { position: relative; height: 8px; border: 1px solid var(--ink); }
.used-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.used-par { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--oxblood); }

/* wax */
.wax-seal {
  position: relative; isolation: isolate; width: 70px; height: 70px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #dc9f90; font-family: var(--fell); font-size: 12px; line-height: 1.05; text-transform: uppercase; letter-spacing: 0.04em;
  text-shadow: 0 -1px 0 rgba(60, 14, 12, 0.6);
}
.wax-seal::before {
  content: ""; position: absolute; inset: -3px; z-index: -1; border-radius: 50%;
  background: var(--oxblood); filter: url(#wax);
  box-shadow: inset 0 0 0 6px #66231f, inset 0 0 0 7px rgba(240, 170, 150, 0.18), 0 2px 3px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------- modals */
#overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.modal-backdrop {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(14, 9, 6, 0.66); opacity: 0; transition: opacity 0.18s; pointer-events: auto;
}
.modal-backdrop.in { opacity: 1; }
.modal-backdrop.out { opacity: 0; pointer-events: none; }
.modal-holder {
  position: relative; max-width: min(760px, 100%); max-height: 100%; overflow-y: auto; overflow-x: hidden;
  padding: 10px; transform: translateY(10px) rotate(0.4deg); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  scrollbar-width: thin; scrollbar-color: var(--brass-dk) transparent;
}
.modal-backdrop.in .modal-holder { transform: none; }
.modal-holder:focus { outline: none; }
.reduced-motion .modal-backdrop, .reduced-motion .modal-holder { transition: none; }
.modal-x {
  position: absolute; top: 18px; right: 18px; z-index: 2; width: 34px; height: 34px; display: grid; place-items: center;
  background: none; border: 0; color: var(--ink); opacity: 0.7;
}
.modal-x:hover { opacity: 1; }
.modal-x .ico { width: 20px; height: 20px; }
.sheet { width: min(440px, 92vw); padding: 24px 28px 26px; }
.sheet h2 { margin: 2px 0 10px; font-size: 32px; line-height: 1.05; }
.sheet-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--oxblood); }
.menu-stack { display: flex; flex-direction: column; gap: 8px; }
.menu-stack .btn { width: 100%; }
.keys { font-size: 12px; color: var(--ink-soft); margin: 14px 0 0; }
.confirm p { font-size: 16px; }

/* settings */
.settings { width: min(520px, 92vw); }
.set-group { border-top: 1px solid rgba(42, 33, 27, 0.3); padding: 10px 0; }
.set-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 40px; align-items: center; gap: 12px; padding: 6px 0; }
.set-row.check { grid-template-columns: 22px auto minmax(0, 1fr); }
.set-label { font-size: 16px; }
.set-sub { font-size: 13px; font-style: italic; color: var(--ink-soft); }
.keyhint { font-size: 12px; color: var(--ink-soft); }
.slider-val { text-align: right; font-size: 14px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: none; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--ink) var(--p, 50%), var(--linen-sh) var(--p, 50%)); border: 1px solid rgba(42, 33, 27, 0.5); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--linen-sh); border: 1px solid rgba(42, 33, 27, 0.5); }
input[type="range"]::-moz-range-progress { height: 4px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -8px; border-radius: 50%;
  background: var(--brass); border: 1px solid var(--brass-dk); box-shadow: inset 0 1px 0 var(--brass-lt), 0 1px 2px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brass); border: 1px solid var(--brass-dk); }
.ink-check {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--ink); border-radius: 1px; background: transparent; display: grid; place-items: center;
}
.ink-check:checked { background: var(--ink); }
.ink-check:checked::after { content: ""; width: 5px; height: 9px; border: solid var(--linen); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.keys-help h3 { margin: 0 0 6px; font-size: 19px; }
.keys-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: 14px; }
.keys-dl dt { font-size: 13px; white-space: nowrap; }
.keys-dl dd { margin: 0; color: var(--ink-soft); }
.danger-zone { padding-top: 14px; }

/* letters */
.letter { width: min(660px, 92vw); padding: 30px 40px 28px; }
.letter-head { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.04em; padding-right: 90px; line-height: 1.6; }
.letter-kicker { font-size: 12px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 12px; }
.letter-title { margin: 2px 0 10px; font-size: 34px; line-height: 1.05; }
.letter-body { font-size: 17.5px; line-height: 1.55; color: #33261b; }
.letter-body p { margin: 0 0 10px; }
.letter-sign { text-align: right; font-size: 17px; margin-top: -2px; }
.letter-sign::before { content: "— "; }
.letter-order { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(42, 33, 27, 0.35); }
.letter-order h3, .daily-cols h3 { margin: 0 0 6px; font-size: 19px; }
.order-goals { margin: 0; padding-left: 18px; font-size: 15px; }
.order-goals li { margin-bottom: 3px; }
.order-bonus { display: flex; gap: 7px; align-items: center; font-size: 14px; font-style: italic; margin-top: 8px; }
.order-par { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.order-satchel { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.order-satchel li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 2px 0; }
.mini-vial { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--ink); background-size: cover; image-rendering: pixelated; }
.ms-amt { font-size: 13px; color: var(--ink-soft); }
.order-tools { margin-top: 8px; }
.postmark {
  position: absolute; top: 20px; right: 26px; width: 78px; height: 78px; border-radius: 50%;
  border: 2px solid rgba(122, 46, 42, 0.55); box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5px rgba(122, 46, 42, 0.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(-14deg);
  font: 700 11px var(--mono); color: rgba(122, 46, 42, 0.7); text-transform: uppercase; letter-spacing: 0.1em;
}
.pm-date { font-size: 9px; letter-spacing: 0.04em; margin-top: 2px; }

/* notebook */
.notebook-page {
  position: relative; isolation: isolate; width: min(620px, 92vw); padding: 38px 40px 32px 76px; color: #33261b;
  transform: rotate(-0.7deg);
}
.notebook-page::before {
  content: ""; position: absolute; inset: 0; z-index: -1; filter: url(#deckle);
  background-color: #f1e7cb;
  background-image: var(--linen-tex);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
.nb-margin { position: absolute; left: 56px; top: 0; bottom: 0; width: 1px; background: rgba(122, 46, 42, 0.5); }
.nb-new { font-size: 12px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.nb-num { font-size: 12px; color: var(--ink-soft); }
.nb-title { margin: 4px 0 6px; font-size: 27px; font-weight: 600; line-height: 1.1; }
.nb-text {
  font-size: 18px; line-height: 30px; margin-top: 6px;
  background-image: repeating-linear-gradient(180deg, transparent 0 29px, rgba(79, 125, 110, 0.32) 29px 30px);
}
.nb-text p { margin: 0 0 30px; }
.nb-text p.nb-sign { text-align: right; font-size: 21px; margin: 0; padding-right: 8px; }
.nb-sketch { float: right; width: 112px; height: 104px; margin: 4px -6px 4px 16px; color: rgba(42, 33, 27, 0.72); filter: url(#inkwobble); }

/* intro */
.intro { display: flex; flex-direction: column; align-items: center; width: min(620px, 92vw); }
.intro-note {
  position: relative; z-index: 2; width: min(400px, 86%); padding: 26px 26px 20px; margin-bottom: -14px;
  background: #f6eed6; color: #2f241b; transform: rotate(-2.2deg);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  clip-path: polygon(0 3%, 6% 0, 18% 2%, 33% 0, 51% 2%, 70% 0, 86% 2%, 100% 0, 99% 30%, 100% 62%, 98% 100%, 80% 98%, 61% 100%, 40% 97%, 22% 100%, 3% 98%, 1% 64%);
}
.intro-note-text { margin: 0; font-size: 21px; line-height: 1.4; white-space: pre-line; }
.pin { position: absolute; top: 9px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--brass); box-shadow: inset 0 1px 0 var(--brass-lt), 0 2px 2px rgba(0, 0, 0, 0.45); }
.intro-body { width: 100%; padding: 34px 34px 26px; font-size: 16.5px; }
.intro-body p { margin: 0 0 12px; }
.intro-kicker { font-size: 12px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.08em; margin: 6px 0 10px; }

/* ending */
.ending-screen { display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.ending-page { width: min(660px, 100%); padding: 34px 44px 30px; text-align: center; }
.ending-page h1 { font-size: 40px; margin: 6px 0 14px; line-height: 1.05; }
.ending-kicker { font-size: 12px; color: var(--oxblood); text-transform: uppercase; letter-spacing: 0.1em; }
.ending-text { text-align: left; font-size: 17.5px; line-height: 1.6; }
.ending-seal { margin: 16px auto 0; }
.ending-page .row-btns { justify-content: center; }

/* ---------------------------------------------------------------- discovery + toasts */
#toasts { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.disc-card {
  position: absolute; right: 24px; top: 84px; width: 330px; padding: 16px 18px 46px; pointer-events: auto; cursor: pointer;
  transform: translateX(130%) rotate(3deg); transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.disc-card.in { transform: translateX(0) rotate(-1.2deg); }
.disc-card.out { transform: translateX(130%) rotate(5deg); transition-timing-function: cubic-bezier(0.6, 0, 0.9, 0.4); }
.reduced-motion .disc-card { transition: opacity 0.2s; transform: none; opacity: 0; }
.reduced-motion .disc-card.in { opacity: 1; }
.disc-kicker { font-size: 12px; color: var(--oxblood); letter-spacing: 0.06em; text-transform: uppercase; }
.disc-body { display: flex; gap: 14px; margin-top: 8px; }
.disc-swatch { width: 66px; height: 66px; flex: none; background-size: cover; image-rendering: pixelated; border: 3px solid var(--brass); border-radius: 50% 50% 10px 10px / 40% 40% 10px 10px; }
.disc-name { font-size: 28px; line-height: 1; }
.disc-latin { font-style: italic; font-size: 14px; color: var(--ink-soft); margin-top: 2px; }
.disc-flavour { margin: 6px 0 0; font-size: 14px; line-height: 1.3; }
.disc-seal { position: absolute; right: -10px; bottom: -26px; width: 78px; height: 78px; font-size: 12.5px; opacity: 0; transform: scale(2.4) rotate(20deg); transition: transform 0.18s cubic-bezier(0.55, 0, 0.8, 0.2), opacity 0.1s; }
.disc-card.stamped .disc-seal { opacity: 1; transform: scale(1) rotate(-12deg); }
.codex-counter {
  position: absolute; right: 24px; top: 24px; padding: 5px 14px; font-family: var(--fell); font-size: 18px; border-radius: 3px;
  opacity: 0; transform: translateY(-8px); transition: opacity 0.25s, transform 0.25s;
}
.codex-counter.in { opacity: 1; transform: none; }
.codex-counter.pop { animation: pop 0.35s; }
.reduced-motion .codex-counter.pop { animation: none; }
@keyframes pop { 40% { transform: scale(1.18); } }
.toast { position: absolute; left: 50%; top: 18px; transform: translate(-50%, -12px) rotate(-1deg); opacity: 0; transition: opacity 0.2s, transform 0.2s; font-size: 15px; padding: 5px 14px; }
.toast.in { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .jar-screen { grid-template-columns: minmax(130px, 160px) minmax(0, 1fr) minmax(190px, 214px); gap: 8px 12px; padding: 10px 12px; }
  .jar-sub { display: none; }
}

/* phones in landscape, small laptops: the satchel becomes a bottom strip */
@media (max-height: 600px), (max-width: 900px) {
  .jar-screen {
    grid-template-columns: minmax(0, 1fr) minmax(170px, 210px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "jar side" "satchel satchel";
    gap: 6px 10px; padding: 6px 10px 6px;
  }
  .jar-screen .satchel-head { display: none; }
  .jar-screen .vials { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 6px; gap: 6px; }
  .jar-screen .vial-btn { width: auto; grid-template-columns: 22px auto; padding: 3px 18px 3px 5px; gap: 6px; }
  .jar-screen .vial-btn:hover { transform: none; }
  .jar-screen .vial-btn.selected { transform: translateY(-3px); }
  .jar-screen .vial-btn.selected::before { display: none; }
  .jar-screen .vial { transform: scale(0.8); transform-origin: left center; }
  .jar-screen .vial-name { font-size: 13px; }
  .jar-screen .vial-amt { font-size: 11px; }
  .title-plate { padding: 2px 20px 3px; }
  .plate-title { font-size: 18px; }
  .plate-kicker { font-size: 10px; }
  .sq-btn { width: 34px; height: 34px; }
  .sq-btn .ico { width: 19px; height: 19px; }
  .top-btns { gap: 5px; }
  .timer-val { font-size: 18px; }
  .goals-card, .shelf-card { padding: 9px 11px 11px; }
  .card-title { font-size: 17px; margin-bottom: 5px; padding-bottom: 3px; }
  .goal { font-size: 13px; }
  .goal-list { gap: 6px; }
  .side { gap: 8px; }
  .toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .tool-btn { min-height: 36px; padding: 3px 1px; }
  .tool-btn .ico { width: 19px; height: 19px; }
  .tool-name { display: none; }
  .brush { margin-top: 6px; }
  .jar-rim { margin-top: 14px; padding: 4px; }
  .jar-lip { top: -16px; height: 10px; left: -10px; right: -10px; }
  .shelf { height: 12px; margin-top: 5px; }
  .hint-slip { font-size: 13px; }
  .side .tools-card { order: -1; }
  .title-screen { grid-template-columns: minmax(0, 1fr) minmax(200px, 250px); gap: 16px; padding: 12px 16px 10px; }
  .menu-plate { padding: 6px 18px 7px 20px; grid-template-columns: 24px minmax(0, 1fr); gap: 9px; }
  .plate-ico .ico { width: 21px; height: 21px; }
  .plate-label { font-size: 18px; }
  .plate-note { font-size: 12px; }
  .title-menu { gap: 7px; }
  .shop-label { padding: 9px 12px 8px; margin-bottom: 2px; }
  .shop-name { font-size: 18px; }
  .title-caption { display: none; }
  .title-under { padding-top: 6px; }
  .title-jar .jar-hold { max-height: calc((100vw - 290px) * 0.5625 + 60px); }
  .page-screen { padding: 8px 12px 0; gap: 8px; }
  .disc-card { top: 56px; right: 12px; width: 270px; }
  .disc-name { font-size: 22px; }
}

/* portrait phones: everything stacks */
@media (max-width: 640px) and (orientation: portrait) {
  .jar-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
    grid-template-areas: "top" "jar" "satchel" "side";
  }
  .jar-center { height: 62vw; }
  .jar-top { flex-wrap: wrap; }
  .top-btns { margin-left: auto; }
  .title-screen { grid-template-columns: 1fr; grid-template-rows: auto auto; padding: 12px; overflow-y: auto; align-content: start; }
  .title-jar .jar-hold { flex: none; max-height: none; height: calc(56vw + 48px); }
  .satchel.compact .vials { flex-wrap: wrap; justify-content: center; }
  .title-menu { overflow: visible; }
  .ledger-paper { padding: 18px 14px 22px 40px; }
  .ledger-rule { left: 24px; }
  .order { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .order-best { display: none; }
  .letter { padding: 22px 20px; }
  .letter-order { grid-template-columns: 1fr; }
  .postmark { display: none; }
  .daily-cols, .summary-cols { grid-template-columns: 1fr; }
  .trials-stats { grid-template-columns: repeat(2, 1fr); }
  .notebook-page { padding: 28px 20px 24px 44px; }
  .nb-margin { left: 30px; }
}
@media (hover: none) {
  .jar-canvas { cursor: default; }
}
