/* The Slow Boat. The page is a hand-painted Irish shopfront: fascia, window, stall-riser.
   Petrol paint and gold leaf on the outside, mahogany and stout-cream within. */
:root {
  --stout: #1f120b;
  --mahogany: #351a0e;
  --mahogany-2: #482513;
  --mahogany-3: #5f3219;
  --petrol: #0e3b43;
  --petrol-deep: #0a2c33;
  --petrol-light: #15505a;
  --gilt: #e8b84a;
  --gilt-hot: #f8dc8c;
  --gilt-dim: #a97a22;
  --head: #f4e8cb;
  --head-dim: #d6c7a4;
  --oxblood: #8c2230;
  --alert: #f5a493;
  --warm: #f3c969;
  --kelp: #a9e0b7;
  --sea: #8fd0d2;
  --display: "Superclarendon", "Rockwell", "Clarendon", "Bookman Old Style", "Roboto Slab", Georgia, serif;
  --body: "Gill Sans", "Gill Sans MT", "Trebuchet MS", "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--stout);
  color: var(--head);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
h2, h3 { font-family: var(--display); font-weight: 700; }
h3 { font-size: 16px; color: var(--head); margin-bottom: 4px; }
h4 { font-family: var(--body); font-size: 15.5px; font-weight: 700; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gilt-hot); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1.5px solid transparent;
  background: transparent;
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-gilt {
  background: linear-gradient(180deg, var(--gilt-hot), var(--gilt) 55%, #cf9c33);
  color: #2a1505;
  box-shadow: 0 1.5px 0 #7a5716, inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-gilt:hover { filter: brightness(1.07); }
.btn-gilt:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.2); }
.btn-plain { border-color: rgba(244, 232, 203, 0.55); color: var(--head); background: rgba(10, 6, 2, 0.18); }
.btn-plain:hover { background: rgba(244, 232, 203, 0.12); }
.btn-plain:active { transform: translateY(1px); }
.btn-danger { background: #a22a39; color: #fff3ea; border-color: #d97a7a; }
.btn-full { width: 100%; }
.btn-large { min-height: 52px; font-size: 17px; padding: 10px 24px; }
.btn.is-off { background: rgba(10, 6, 2, 0.32); color: rgba(244, 232, 203, 0.62); border-color: rgba(244, 232, 203, 0.2); box-shadow: none; cursor: not-allowed; }

/* ---------- Start ---------- */
.start { position: fixed; inset: 0; overflow: auto; background: #101d1a; display: flex; flex-direction: column; }
.start-art { flex: 1 1 auto; min-height: 200px; width: 100%; display: block; }
.art-sign { font-family: var(--display); font-weight: 700; font-size: 44px; letter-spacing: 1.5px; }
.start-card {
  flex: none;
  padding: 14px max(24px, calc(50% - 400px)) 18px;
  background: var(--petrol-deep);
  border-top: 4px solid var(--gilt);
}
.start-lede { font-size: 17px; max-width: 62ch; }
.start-goal { font-size: 15.5px; color: var(--head-dim); margin-top: 6px; max-width: 62ch; }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 10px; align-items: center; }
.start-small { font-size: 13px; color: var(--head-dim); }

/* ---------- Layout: the shopfront ---------- */
.pub { height: 100dvh; display: flex; flex-direction: column; min-height: 560px; }
.fascia {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  min-height: 62px;
  background: linear-gradient(180deg, #0f4049, var(--petrol-deep));
  border-bottom: 4px solid #07242a;
  box-shadow: inset 0 3px 0 var(--petrol-light), inset 0 -2px 0 rgba(255, 255, 255, 0.06);
}
.corbel { width: 10px; align-self: stretch; margin: -8px 0; background: linear-gradient(180deg, var(--gilt) 0 12px, var(--petrol-light) 12px); flex: none; }
.corbel-r { margin-left: auto; }
.sign { flex: none; }
.sign-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(22px, 2.5vw, 34px);
  letter-spacing: 0.5px;
  white-space: nowrap;
  color: #c0b598;
  text-shadow: 1px 1px 0 #06222a;
  transition: color 0.5s;
}
.sign[data-gilded="yes"] .sign-name {
  background: linear-gradient(180deg, var(--gilt-hot), var(--gilt) 55%, #b9872c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(1.5px 1.5px 0 #3a1f0a);
}
.clock { display: flex; align-items: center; gap: 8px; color: var(--head); min-width: 0; }
.dial { width: 34px; height: 34px; flex: none; color: var(--gilt); }
.clock-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.clock-text strong { font-size: 15px; white-space: nowrap; }
.clock-text span { font-size: 12.5px; color: var(--head-dim); white-space: nowrap; }
.controls { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
.btn-pause { min-width: 84px; }
.speed { display: flex; border: 1.5px solid rgba(244, 232, 203, 0.5); border-radius: 4px; overflow: hidden; flex: none; }
.speed-btn { border: 0; background: transparent; min-width: 42px; min-height: 40px; font-weight: 700; cursor: pointer; }
.speed-btn + .speed-btn { border-left: 1.5px solid rgba(244, 232, 203, 0.28); }
.speed-btn[aria-checked="true"] { background: var(--head); color: #2a1505; }
.speed-btn:focus-visible { outline-offset: -3px; }

.front {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: minmax(240px, 52%) minmax(0, 1fr);
  grid-template-areas: "window door" "riser door";
  gap: 0;
  background: var(--petrol-deep);
}
.window {
  grid-area: window;
  position: relative;
  min-height: 0;
  background: #17100a;
  border: 8px solid var(--petrol);
  border-bottom-width: 6px;
  outline: 2px solid #07242a;
  outline-offset: -2px;
  overflow: hidden;
}
#scene { display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: pointer; }
.sim-badge { position: absolute; left: 8px; bottom: 6px; font-size: 12px; background: rgba(20, 10, 4, 0.72); padding: 1px 7px; border-radius: 3px; color: var(--head-dim); pointer-events: none; }
.toasts { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: min(92%, 560px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 3; }
.toast { padding: 7px 12px; border-radius: 4px; font-weight: 600; font-size: 14px; line-height: 1.25; background: #f4e8cb; color: #2a1505; box-shadow: 0 3px 12px rgba(10, 4, 0, 0.45); border-left: 5px solid #8d7a55; }
.toast-good { border-left-color: #3f8a56; }
.toast-bad { background: #fbd9cf; border-left-color: var(--oxblood); }
.toast-warn { background: #f8e6ad; border-left-color: #b37a12; }
.toast-note { background: #103e47; color: var(--head); border-left-color: var(--gilt); }
.toast-milestone { background: linear-gradient(180deg, var(--gilt-hot), var(--gilt)); color: #2a1505; border-left-color: #6b4412; font-size: 14.5px; }
.caption { position: absolute; left: 8px; bottom: 30px; max-width: min(92%, 380px); display: flex; gap: 8px; align-items: center; background: rgba(244, 232, 203, 0.97); color: #2a1505; padding: 6px 10px; border-radius: 4px; font-size: 13.5px; line-height: 1.25; }
.caption strong { display: block; }
.portrait-small { width: 40px !important; height: 40px !important; }
.veil { position: absolute; inset: 0; background: rgba(12, 6, 2, 0.45); display: flex; align-items: center; justify-content: center; z-index: 2; }
.veil-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 22px; text-align: center; background: var(--petrol-deep); border: 2px solid var(--gilt); border-radius: 4px; max-width: min(92%, 400px); }
.veil-card strong { font-family: var(--display); font-size: 21px; color: var(--gilt-hot); }

/* ---------- Door column: goal, trends, feed ---------- */
.door { grid-area: door; display: flex; flex-direction: column; min-height: 0; background: var(--petrol); border-left: 4px solid #07242a; overflow-y: auto; }
.goal { padding: 10px 14px 12px; background: linear-gradient(180deg, #123f47, var(--petrol)); border-bottom: 2px solid #07242a; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.goal-head h2 { font-size: 18px; color: var(--gilt-hot); }
.goal-days { font-weight: 700; font-size: 13.5px; }
.goal-days[data-tone="bad"] { color: var(--alert); }
.goal-bars { display: grid; gap: 4px; margin-bottom: 8px; }
.goal-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.goal-val { font-weight: 700; white-space: nowrap; }
.meter { height: 8px; background: rgba(5, 15, 18, 0.65); border-radius: 2px; overflow: hidden; position: relative; }
.meter i { display: block; height: 100%; background: var(--gilt); }
#btn-freehold.is-off { background: rgba(5, 15, 18, 0.35); }
#btn-freehold.is-ready { animation: ready 1.8s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 4px rgba(248, 220, 140, 0.45), 0 1.5px 0 #7a5716; } }
.arrears { margin-top: 8px; background: #fbd9cf; color: #4b0c14; padding: 6px 9px; border-radius: 3px; font-weight: 600; font-size: 13.5px; }
.trends { padding: 4px 14px 8px; }
.trend { padding: 7px 0 8px; border-bottom: 1px solid rgba(244, 232, 203, 0.2); }
.trend:last-child { border-bottom: 0; }
.trend-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.trend-head h3 { font-family: var(--body); font-size: 13.5px; font-weight: 600; color: var(--head-dim); margin: 0; }
.trend-arrow { font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--head); }
.trend-arrow[data-dir="up"]::first-letter { color: var(--kelp); }
.trend-arrow[data-dir="down"]::first-letter { color: var(--alert); }
.trend-value { display: block; font-family: var(--display); font-size: 21px; line-height: 1.15; }
.spark-box { position: relative; height: 42px; margin: 3px 0 2px; touch-action: pan-y; }
.spark { width: 100%; height: 100%; display: block; overflow: visible; }
.spark-grid { stroke: rgba(244, 232, 203, 0.28); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-target { stroke: var(--head); stroke-opacity: 0.65; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; fill: none; }
.spark-line { fill: none; stroke: var(--gilt); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-area { fill: var(--gilt); opacity: 0.14; }
.spark-cross { stroke: var(--head); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--gilt-hot); stroke: var(--petrol); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-tip { position: absolute; top: -6px; background: var(--head); color: #2a1505; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px; white-space: nowrap; pointer-events: none; }
.trend-note { display: block; font-size: 12.5px; color: var(--head-dim); line-height: 1.25; }
.feed { padding: 8px 14px 14px; flex: 1; min-height: 90px; border-top: 2px solid #07242a; background: #0b2f36; }
.feed h2 { font-size: 15px; margin-bottom: 4px; color: var(--head); }
.feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.feed-item { display: grid; grid-template-columns: 46px 1fr; gap: 6px; font-size: 13px; line-height: 1.28; }
.feed-day { color: var(--head-dim); white-space: nowrap; font-size: 12px; padding-top: 1px; }
.tone-good .feed-text { color: #e2f4dd; }
.tone-bad .feed-text { color: #ffd2c6; }
.tone-warn .feed-text { color: #f9e5ae; }
.tone-note .feed-text { color: var(--sea); }
.tone-milestone .feed-text { color: var(--gilt-hot); font-weight: 600; }

/* ---------- Stall-riser: tabs and panels ---------- */
.riser { grid-area: riser; min-height: 0; display: flex; flex-direction: column; background: var(--mahogany); border: 8px solid var(--petrol); border-top: 0; }
.tabs { flex: none; display: flex; background: var(--stout); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 1 auto; min-height: 42px; padding: 7px 12px; background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--head-dim); font-weight: 700; font-size: 14.5px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; white-space: nowrap; }
.tab:hover { color: var(--head); background: rgba(244, 232, 203, 0.06); }
.tab[aria-selected="true"] { color: var(--gilt-hot); border-bottom-color: var(--gilt); background: var(--mahogany); }
.tab:focus-visible { outline-offset: -3px; }
.tab-flag { width: 15px; height: 15px; background: var(--alert); color: #4b0c14; border-radius: 50%; display: inline-block; flex: none; }
.tab-flag::after { content: "!"; display: block; text-align: center; font-size: 12px; line-height: 15px; font-weight: 800; }
.panels { flex: 1; min-height: 0; position: relative; }
.panel { container: panel / inline-size; position: absolute; inset: 0; overflow-y: auto; padding: 10px 14px 18px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.panel:focus-visible { outline-offset: -4px; }
.small-note { font-size: 13px; color: var(--head-dim); line-height: 1.3; }
.empty { font-size: 14px; color: var(--head-dim); font-style: italic; }
.lever-summary { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px 20px; align-items: start; padding: 10px 12px; background: rgba(10, 6, 2, 0.26); border-left: 3px solid var(--gilt); }
.lever-summary .row-buttons { grid-column: 1 / -1; }
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.big-word { font-family: var(--display); font-size: 22px; color: var(--gilt-hot); display: block; }
.effects { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; }
.effects li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted rgba(244, 232, 203, 0.22); padding-bottom: 2px; }
.effects span { color: var(--head-dim); }
.effects strong { white-space: nowrap; }
.meter-reach { margin-top: 7px; height: 9px; overflow: visible; }
.meter-reach b { position: absolute; top: -3px; width: 2px; height: 15px; background: var(--head); }

/* Cellar */
.cellar-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.cellar-summary { font-weight: 600; font-size: 14.5px; flex: 1 1 240px; padding-left: 9px; border-left: 3px solid var(--kelp); }
.cellar-summary[data-tone="warn"] { border-left-color: var(--warm); }
.cellar-summary[data-tone="bad"] { border-left-color: var(--alert); }
.seachart { background: #0d3640; padding: 6px 12px 5px; border-radius: 3px; }
.seachart-head { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: baseline; margin-bottom: 1px; }
.seachart-head h3 { margin: 0; font-size: 14.5px; }
.seachart-note { font-size: 12.5px; color: var(--head-dim); }
.sea { position: relative; height: 40px; margin-right: 44px; border-bottom: 2px solid #2b7a84; background: repeating-linear-gradient(90deg, rgba(244, 232, 203, 0.28) 0 1px, transparent 1px calc(100% / 21)) left bottom / 100% 5px no-repeat, repeating-linear-gradient(90deg, rgba(244, 232, 203, 0.75) 0 1.5px, transparent 1.5px calc(100% / 3)) left bottom / 100% 9px no-repeat; }
.sea-isle { position: absolute; left: 100%; bottom: -2px; width: 42px; height: 40px; }
.boat { position: absolute; width: 34px; height: 26px; margin-left: -17px; display: block; }
.boat svg { display: block; width: 100%; height: 100%; }
.boat b { position: absolute; top: -3px; right: -7px; min-width: 16px; font-size: 11px; line-height: 15px; text-align: center; background: var(--head); color: #2a1505; border-radius: 8px; padding: 0 3px; }
.sea-scale { display: flex; justify-content: space-between; margin: 1px 44px 0 0; font-size: 12px; color: var(--head-dim); }
.stock-head { display: none; }
.stock-list { display: grid; gap: 0; }
.stock-group { margin: 9px 0 2px; font-size: 14.5px; color: var(--gilt-hot); }
.stock-group:first-of-type { margin-top: 0; }
.stock-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(150px, 1.1fr) minmax(170px, 1.3fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(244, 232, 203, 0.14);
}
.stock-row[data-status="out"], .stock-row[data-status="late"] { background: linear-gradient(90deg, rgba(140, 34, 48, 0.26), transparent 70%); }
.stock-id { display: flex; gap: 8px; align-items: center; min-width: 0; }
.stock-icon { flex: none; width: 34px; height: 34px; }
.stock-icon svg { width: 100%; height: 100%; display: block; }
.stock-name { display: grid; min-width: 0; line-height: 1.22; }
.stock-name strong { font-size: 14.5px; }
.stock-pack { font-size: 12.5px; color: var(--head-dim); }
.stock-levels { min-width: 0; }
.stock-counts { display: grid; line-height: 1.2; }
.stock-shelf { font-size: 14.5px; }
.stock-water { font-size: 12.5px; color: var(--sea); }
.stock-bar { display: flex; height: 7px; margin-top: 3px; background: rgba(5, 3, 1, 0.5); border-radius: 2px; overflow: hidden; }
.bar-shelf { background: #c48410; display: block; }
.bar-water { display: block; background: repeating-linear-gradient(135deg, #0a9fb3 0 3px, #075f6b 3px 6px); }
.stock-forecast { display: grid; justify-items: start; gap: 1px; line-height: 1.22; min-width: 0; }
.stock-runway { font-size: 13px; }
.stock-rate { font-size: 12.5px; color: var(--head-dim); }
.stock-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn-order { min-height: 40px; padding: 6px 10px; font-size: 13.5px; white-space: nowrap; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 0 7px; border-radius: 10px; line-height: 1.5; white-space: nowrap; background: rgba(244, 232, 203, 0.15); }
.pill-ok { background: rgba(169, 224, 183, 0.18); color: var(--kelp); }
.pill-good { background: rgba(169, 224, 183, 0.18); color: var(--kelp); }
.pill-soon { background: rgba(243, 201, 105, 0.2); color: var(--warm); }
.pill-late { background: #f5a493; color: #4b0c14; }
.pill-out { background: #f5a493; color: #4b0c14; }
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--head-dim); padding: 3px 10px 3px 0; border-bottom: 1px solid rgba(244, 232, 203, 0.4); white-space: nowrap; }
.table td { padding: 4px 10px 4px 0; border-bottom: 1px solid rgba(244, 232, 203, 0.12); }
td.num { white-space: nowrap; }
.ledger h3 { margin-bottom: 1px; }
.ledger-terms { font-size: 13px; color: var(--head-dim); margin-bottom: 4px; }
.ledger-done { margin-top: 6px; font-size: 13.5px; }
details > summary { cursor: pointer; font-weight: 700; padding: 6px 0; min-height: 34px; }

/* Prices */
.price-list { display: grid; }
.price-row { display: grid; grid-template-columns: 110px minmax(0, 1.6fr) minmax(130px, 0.9fr) auto; gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(244, 232, 203, 0.14); }
.price-items { font-size: 13.5px; line-height: 1.3; }
.price-read { display: grid; justify-items: start; gap: 2px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.btn-step { width: 44px; min-height: 44px; padding: 0; font-size: 22px; }
.price-value { min-width: 50px; text-align: center; font-family: var(--display); font-size: 18px; }

/* Staff */
.staff-list { display: grid; }
.staff-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(244, 232, 203, 0.14); }
.staff-row[data-hired="yes"] { background: linear-gradient(90deg, rgba(232, 184, 74, 0.13), transparent 70%); }
.portrait { width: 64px; height: 64px; display: block; background: #6a3a1d; border-radius: 3px; }
.staff-note { font-size: 13px; color: var(--head-dim); line-height: 1.25; margin-bottom: 3px; }
.staff-meters { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; max-width: 370px; }
.mini-meter { display: grid; grid-template-columns: auto minmax(40px, 1fr); gap: 6px; align-items: center; font-size: 12.5px; color: var(--head-dim); }
.staff-side { display: grid; justify-items: end; gap: 3px; text-align: right; }
.staff-wage { font-size: 14.5px; white-space: nowrap; }

/* Marketing */
.levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.level { text-align: left; padding: 7px 9px; border: 1.5px solid rgba(244, 232, 203, 0.3); border-radius: 4px; background: rgba(10, 6, 2, 0.2); cursor: pointer; display: grid; gap: 1px; align-content: start; }
.level:hover { border-color: var(--head); }
.level[aria-checked="true"] { border-color: var(--gilt); background: rgba(232, 184, 74, 0.18); box-shadow: inset 0 0 0 1px var(--gilt); }
.level strong { font-size: 14px; line-height: 1.15; }
.level-cost { font-weight: 700; font-size: 13.5px; color: var(--gilt-hot); }
.level-note { font-size: 12.5px; color: var(--head-dim); line-height: 1.25; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.one-off { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 8px 10px; background: rgba(10, 6, 2, 0.22); }
.one-off .small-note { flex: 1; }
.why-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; font-size: 13.5px; }
.why-list li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted rgba(244, 232, 203, 0.2); padding-bottom: 2px; }
.why-list span { color: var(--head-dim); }
.why-list li[data-tone="up"] strong::before { content: "\25B2 "; color: var(--kelp); font-size: 10.5px; }
.why-list li[data-tone="down"] strong::before { content: "\25BC "; color: var(--alert); font-size: 10.5px; }
.posts { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 7px; }
.post { padding: 6px 9px; background: #f4e8cb; color: #2a1505; border-radius: 3px; border-left: 4px solid #3f8a56; }
.post-bad { background: #f9dacf; border-left-color: var(--oxblood); }
.post-who { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.post-who span { color: #5c4630; }
.post-text { font-size: 14px; line-height: 1.28; margin: 1px 0; }
.post-meta { font-size: 12px; color: #5c4630; }

/* Interior */
.upgrade-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0 18px; }
.upgrade { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(244, 232, 203, 0.14); }
.upgrade[data-done="yes"] h4::after { content: " \2713"; color: var(--kelp); }
.upgrade[data-done="yes"] .small-note { color: rgba(214, 199, 164, 0.75); }
.upgrade-stats { font-size: 12.5px; font-weight: 700; color: var(--gilt-hot); }
.upgrade .btn { white-space: nowrap; font-size: 13.5px; padding: 6px 10px; }

/* Books */
.books-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 22px; }
.ledgerlines { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0; font-size: 13.5px; }
.ledgerlines dt { color: var(--head-dim); }
.ledgerlines dd { margin: 0; font-weight: 700; text-align: right; }
.miles { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 18px; }
.miles li { font-size: 13px; line-height: 1.25; color: var(--head-dim); }
.miles strong { display: block; color: var(--head); font-size: 14px; }
.miles .done strong { color: var(--gilt-hot); }
.mobile-feed { display: none; }
.who-list { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 18px; font-size: 13px; color: var(--head-dim); }
.who-list strong { color: var(--head); }

/* Dialogs */
.dlg { background: var(--petrol-deep); color: var(--head); border: 3px solid var(--gilt); border-radius: 5px; padding: 0; width: min(680px, calc(100vw - 20px)); max-height: calc(100dvh - 24px); }
.dlg-small { width: min(420px, calc(100vw - 20px)); }
.dlg::backdrop { background: rgba(6, 4, 2, 0.68); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid rgba(244, 232, 203, 0.25); position: sticky; top: 0; background: var(--petrol-deep); z-index: 1; }
.dlg-head h2 { color: var(--gilt-hot); font-size: 20px; }
.dlg-body { padding: 12px 16px 16px; }
.rules section + section { margin-top: 12px; }
.rules p, .rules li { font-size: 15px; max-width: 68ch; }
.rules p + p { margin-top: 5px; }
.rules ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.menu-body { display: grid; gap: 8px; }
.keys { font-size: 13.5px; color: var(--head-dim); }
.keys strong { color: var(--head); }

/* End: a clipping from the local paper */
.dlg-end { background: #efe3c3; color: #24150b; border-color: #4a2f16; width: min(820px, calc(100vw - 20px)); }
.dlg-end::backdrop { background: rgba(6, 4, 2, 0.78); }
.clipping { padding: 16px 20px 8px; }
.paper-name { font-family: var(--display); font-size: 15px; border-bottom: 3px double #24150b; padding-bottom: 4px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.paper-name span { font-family: var(--body); font-size: 12.5px; }
#end-title { font-size: clamp(25px, 4.6vw, 38px); line-height: 1.05; margin-bottom: 10px; }
.clipping-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; align-items: start; }
#end-photo { width: 100%; height: auto; display: block; border: 1px solid #24150b; background: #2a1a10; }
.end-story { font-size: 15px; line-height: 1.38; margin-bottom: 8px; }
.end-stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0; font-size: 13.5px; }
.end-stats dt { color: #4d3722; }
.end-stats dd { margin: 0; font-weight: 700; text-align: right; }
.end-milestones { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: 13px; font-weight: 600; }
.end-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 20px 16px; }
.dlg-end .btn-plain { color: #24150b; border-color: #4a2f16; background: transparent; }
.dlg-end :focus-visible { outline-color: #0e3b43; }
.end-note { font-size: 13px; flex-basis: 100%; }

/* ---------- Panel contents follow the panel's own width, so a small iframe behaves like a phone ---------- */
@container panel (max-width: 720px) {
  .lever-summary { grid-template-columns: 1fr; padding: 8px 9px; }
  .stock-row { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; padding: 8px 0; }
  .stock-id { grid-column: 1; }
  .stock-levels { grid-column: 1 / -1; grid-row: 2; }
  .stock-counts { grid-auto-flow: column; justify-content: space-between; gap: 8px; align-items: baseline; }
  .stock-forecast { grid-column: 1 / -1; grid-row: 3; grid-template-columns: auto minmax(0, 1fr); column-gap: 7px; align-items: baseline; }
  .stock-rate { grid-column: 1 / -1; }
  .stock-actions { grid-column: 2; grid-row: 1; flex-direction: column; align-items: stretch; gap: 4px; }
  .stock-icon { width: 30px; height: 30px; }
  .btn-order { min-height: 44px; padding: 4px 8px; font-size: 13px; }
  .price-row { grid-template-columns: minmax(0, 1fr) auto; }
  .price-name { grid-column: 1; }
  .stepper { grid-column: 2; grid-row: 1 / span 2; }
  .price-items { grid-column: 1 / -1; grid-row: 3; }
  .price-read { grid-column: 1; grid-row: 2; }
  .staff-row { grid-template-columns: 54px minmax(0, 1fr); }
  .portrait { width: 54px; height: 54px; }
  .staff-side { grid-column: 1 / -1; grid-auto-flow: column; justify-content: space-between; align-items: center; justify-items: start; text-align: left; }
  .staff-meters { grid-template-columns: 1fr; }
  .levels { grid-template-columns: 1fr; }
  .level { grid-template-columns: minmax(0, 1fr) auto; min-height: 44px; }
  .level-note { grid-column: 1 / -1; }
  .two-up, .two-up-wide { grid-template-columns: 1fr; }
  .upgrade-list { grid-template-columns: 1fr; }
  .upgrade { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; }
  .upgrade-icon svg { width: 36px; height: 36px; }
  .upgrade .btn { min-height: 44px; white-space: normal; max-width: 96px; font-size: 13px; padding: 4px 7px; }
  .books-grid { grid-template-columns: 1fr; }
}

/* ---------- Narrower laptops: trends sit under the fascia ---------- */
@media (max-width: 1080px) {
  .clock-text span { font-size: 12px; }
  .desk-only.btn { display: none; }
  .front { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (max-height: 640px) and (min-width: 821px) {
  .front { grid-template-rows: minmax(200px, 46%) minmax(0, 1fr); }
}

/* ---------- Phone and small tablet: one column, the window stays in view ---------- */
@media (max-width: 820px) {
  html, body { overflow: hidden; }
  .pub { min-height: 0; }
  .fascia { flex-wrap: wrap; padding: 5px 10px 6px; gap: 3px 10px; min-height: 0; border-bottom-width: 3px; }
  .corbel { display: none; }
  .sign-name { font-size: 20px; }
  .clock { margin-left: auto; gap: 6px; }
  .dial { width: 26px; height: 26px; }
  .clock-text strong { font-size: 13px; }
  .clock-text span { font-size: 11.5px; }
  .controls { width: 100%; margin: 0; gap: 6px; justify-content: space-between; }
  .btn-pause { min-width: 66px; min-height: 42px; padding: 6px 8px; }
  .speed { flex: 1; }
  .speed-btn { flex: 1; min-width: 40px; min-height: 42px; }
  .btn-icon { min-height: 42px; padding: 3px 7px; font-size: 12.5px; line-height: 1.05; flex: none; }
  #btn-sound { width: 48px; }
  .front { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .window { flex: none; height: clamp(170px, 30dvh, 262px); border-width: 0 0 3px; outline: 0; }
  .sim-badge { font-size: 11px; }
  .toast { font-size: 13px; padding: 5px 9px; }
  .door { flex: none; border-left: 0; overflow: visible; display: contents; }
  .goal { order: 1; flex: none; padding: 5px 10px 6px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; }
  .goal-head { grid-column: 1; margin: 0; justify-content: flex-start; gap: 8px; }
  .goal-head h2 { font-size: 14px; white-space: nowrap; }
  .goal-days { font-size: 12.5px; white-space: nowrap; }
  .goal-bars { grid-column: 1; margin: 0; gap: 1px; }
  .goal-row { grid-template-columns: 70px 1fr auto; font-size: 12px; gap: 5px; }
  #btn-freehold { grid-column: 2; grid-row: 1 / span 2; width: auto; max-width: 102px; min-height: 40px; padding: 4px 8px; font-size: 12px; }
  .arrears { grid-column: 1 / -1; margin-top: 3px; font-size: 12.5px; padding: 3px 7px; }
  .trends { order: 2; flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px 6px; background: var(--petrol); gap: 0; }
  .trend { padding: 2px 5px; border-bottom: 0; border-right: 1px solid rgba(244, 232, 203, 0.18); min-width: 0; }
  .trend:last-child { border-right: 0; }
  .trend-head h3 { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #trend-sat .trend-head h3 { font-size: 0; }
  #trend-sat .trend-head h3::before { content: "Satisfaction"; font-size: 11.5px; }
  .trend-arrow { font-size: 0; }
  .trend-arrow::first-letter { font-size: 11px; }
  .trend-value { font-size: 15.5px; white-space: nowrap; }
  .spark-box { height: 20px; margin: 1px 0 0; }
  .trend-note { display: none; }
  .feed.desk-only { display: none; }
  .riser { order: 3; flex: 1; min-height: 220px; border: 0; }
  .tab { padding: 6px 6px; font-size: 13px; min-height: 44px; gap: 3px; }
  .tab-flag { width: 13px; height: 13px; }
  .tab-flag::after { font-size: 11px; line-height: 13px; }
  .toasts { top: 4px; gap: 0; }
  .toast + .toast { display: none; }
  .toast:has(+ .toast) { display: none; }
  .toast + .toast:last-child { display: block; }
  .panel { padding: 8px 10px 22px; }
  .mobile-feed { display: block; }
  .clipping { padding: 12px 14px 6px; }
  .clipping-grid { grid-template-columns: 1fr; }
  .end-actions { padding: 8px 14px 14px; }
  .start-card { padding: 14px 16px 16px; }
  .start-lede { font-size: 15.5px; }
  .start-goal { font-size: 14px; }
  .start-actions .btn-large { flex: 1 1 100%; }
  .start-actions .btn-plain:not(.btn-large) { flex: 1; }
}
@media (max-width: 820px) and (max-height: 640px) {
  .window { height: 150px; }
  html, body { overflow: auto; }
  .pub { height: auto; }
  .riser { min-height: 340px; }
  .panels { min-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  #btn-freehold.is-ready { animation: none; box-shadow: 0 0 0 3px rgba(248, 220, 140, 0.55); }
  .sign-name { transition: none; }
}
body[data-calm="yes"] #btn-freehold.is-ready { animation: none; box-shadow: 0 0 0 3px rgba(248, 220, 140, 0.55); }
@media (forced-colors: active) {
  .btn, .level, .tab, .speed-btn { border: 1px solid ButtonText; }
  .meter i, .bar-shelf, .bar-water { background: Highlight; forced-color-adjust: none; }
}

/* Short frames, such as a landscape phone or a small iframe: let the page scroll rather than clip anything. */
@media (max-height: 560px) {
  html, body { overflow: auto; height: auto; }
  .pub { height: auto; min-height: 100dvh; }
  .front { flex: none; height: 640px; }
}
@media (max-width: 820px) and (max-height: 560px) {
  .front { height: auto; }
}

/* Too narrow for one fascia row: stack the sign and clock over the controls. */
@media (max-width: 1000px) and (min-width: 821px) {
  .fascia { flex-wrap: wrap; padding: 5px 12px 6px; gap: 3px 12px; min-height: 0; }
  .corbel { display: none; }
  .sign-name { font-size: 21px; }
  .clock { margin-left: auto; }
  .controls { width: 100%; margin: 0; }
  .speed { flex: 1; }
  .speed-btn { flex: 1; }
}
