/* One deliberate light look (calendar paper), no dark variant: every colour is set explicitly below.
   Layout: the page is the 3D board full-screen. On top sits either the boring calendar (an app
   screen, opaque) or the control-room chrome (white cards over the toy model, like the viral
   "business app as a strategy game" clips). Light theme on purpose: the calendar is paper. */
:root {
  --night: #241d4a;
  --purple: #4b3f8c;
  --cream: #f2e6c9;
  --cream-dark: #c4b28a;
  --gold: #f5c542;
  --orange: #e8722a;
  --teal: #2e8b8b;
  --ink: #1d1a2e;
  --paper: #fbf6ea;
  --ground: color-mix(in srgb, var(--cream) 55%, var(--paper));
  --line: color-mix(in srgb, var(--paper) 58%, var(--cream-dark));
  --muted: color-mix(in srgb, var(--ink) 62%, var(--paper));
  --card: color-mix(in srgb, var(--paper) 88%, var(--cream));
  --shadow: 0 1px 0 color-mix(in srgb, var(--cream-dark) 40%, transparent), 0 6px 18px color-mix(in srgb, var(--ink) 10%, transparent);
  --text: "Chivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --label: "Silkscreen", "Courier New", ui-monospace, monospace;
  --gutter: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: 15px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.num { font-variant-numeric: tabular-nums; }
button { font-family: var(--text); color: var(--ink); cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
svg { display: block; }

#scene { position: fixed; inset: 0; display: block; z-index: 0; touch-action: none; }

/* ------------------------------------------------------------------ the boring calendar */
#cal {
  position: fixed; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  background: var(--paper);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.appbar {
  flex: 0 0 auto; height: 56px;
  display: flex; align-items: center; gap: 14px;
  padding-block: 0; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-size: 15px; white-space: nowrap;
}
.appbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ab-icon { color: var(--muted); }
.ab-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 18px; }
.ab-logo svg { color: var(--purple); }
.ab-today { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 14px; }
.ab-nav { display: inline-flex; gap: 2px; color: var(--muted); }
.ab-month { font-size: 18px; }
.ab-grow { flex: 1; }
.ab-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 14px; }
.ab-seg span { padding: 6px 12px; color: var(--muted); }
.ab-seg span.on { background: color-mix(in srgb, var(--purple) 14%, var(--paper)); color: var(--purple); font-weight: 600; }
.ab-avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--purple); color: var(--paper); font-weight: 600; font-size: 14px; }

.cal-sub { flex: 0 0 auto; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 20px 8px 78px; }
.cal-week { display: inline-flex; align-items: baseline; gap: 10px; }
.cal-week b { font-size: 20px; font-weight: 900; }
.cal-range, .cal-total { color: var(--muted); font-size: 14px; }

.cal-frame { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0 20px 0 20px; }
.cal-head { flex: 0 0 auto; display: grid; grid-template-columns: 58px repeat(5, 1fr); height: 40px; align-items: center; border-bottom: 1px solid var(--line); }
.ch-day { font-size: 14px; color: var(--muted); padding-left: 6px; }
.ch-dn { font-weight: 600; color: var(--ink); }
.cal-body { flex: 1 1 auto; min-height: 0; display: flex; position: relative; }
.cal-gutter { flex: 0 0 58px; position: relative; }
.cg-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cg-hour:first-child { transform: none; }
.cal-days { flex: 1 1 auto; position: relative; border-left: 1px solid var(--line); }
.cd-col { position: absolute; top: 0; bottom: 0; width: 20%; border-right: 1px solid var(--line); }
.cd-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line); }
.cd-lunch { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--paper) 90%, var(--cream-dark)); }
.cal-event {
  position: absolute; overflow: hidden;
  border-left: 3px solid; border-radius: 5px;
  padding: 3px 6px; display: flex; flex-direction: column; gap: 1px;
  font-size: 13px; line-height: 1.2;
}
.ce-t { font-weight: 600; overflow-wrap: normal; }
.ce-h { font-size: 12px; color: color-mix(in srgb, var(--ink) 70%, transparent); font-variant-numeric: tabular-nums; }
.cal-event.short { flex-direction: row; flex-wrap: wrap; gap: 0 6px; align-items: baseline; padding-top: 2px; }
.cal-cta { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 20px 40px; }
.cal-premise { margin: 0; font-size: 17px; font-weight: 600; text-align: center; text-wrap: balance; max-width: 46ch; }
#btn-play {
  min-height: 52px; padding: 0 26px; border-radius: 12px; border: 0;
  background: var(--gold); color: var(--ink); font-weight: 900; font-size: 17px;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--gold) 50%, var(--ink)), var(--shadow);
}
#btn-play:active { transform: translateY(1px); }
body:not(.mode-calendar) #cal { pointer-events: none; }

/* ------------------------------------------------------------------ the control room */
#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#hud[hidden] { display: none; }
#hud > * { pointer-events: auto; }
#hud > #toast { pointer-events: none; }
body.mode-transform #hud { opacity: 0; }
body.mode-game #hud { animation: hud-in .5s ease-out both; }
@keyframes hud-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.appbar.game { position: absolute; left: 0; right: 0; top: 0; height: calc(56px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); }
.ab-week { color: var(--muted); font-size: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; background: var(--paper); }
#clock {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border-radius: 10px; border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--paper));
  background: color-mix(in srgb, var(--teal) 10%, var(--paper));
  font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
}
#clock .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cream-dark); }
#clock.running .dot { background: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
#clock .x { color: var(--teal); }

#stats { position: absolute; top: calc(72px + env(safe-area-inset-top, 0px)); left: max(24px, env(safe-area-inset-left, 0px)); display: flex; gap: 12px; }
.stat {
  width: 172px; padding: 10px 14px 10px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
  display: grid; gap: 1px;
}
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { display: flex; align-items: baseline; gap: 5px; }
.stat .v b { font-size: 28px; font-weight: 900; line-height: 1.05; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .s { font-size: 12px; color: var(--muted); white-space: nowrap; }
#stat-focus .v b { color: var(--teal); }
#stat-focus.low .v b { color: var(--orange); }
#stat-free .v b { color: color-mix(in srgb, var(--gold) 55%, var(--ink)); }
.bump { animation: bump .35s ease-out; }
@keyframes bump { 30% { transform: scale(1.06); } 60% { transform: scale(.98); } }

#stepper { position: absolute; top: calc(72px + env(safe-area-inset-top, 0px)); right: max(24px, env(safe-area-inset-right, 0px)); width: 300px; padding: 10px 14px 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.st-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.st-head span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#st-days { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
#st-days::before { content: ""; position: absolute; left: 10%; right: 10%; top: 9px; height: 2px; background: var(--line); }
#st-days li { position: relative; display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
#st-days i { width: 20px; height: 20px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line); }
#st-days li.done i { background: var(--teal); border-color: var(--teal); }
#st-days li.now i { border-color: var(--teal); box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 10px var(--teal); }
#st-days li.now span, #st-days li.done span { color: var(--ink); }

#hud.ended #list, #hud.ended #stepper { visibility: hidden; }
#list { position: absolute; right: max(24px, env(safe-area-inset-right, 0px)); top: calc(184px + env(safe-area-inset-top, 0px)); width: 300px; padding: 10px 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.ls-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; padding: 2px 2px 6px; }
.ls-head span { font-size: 12px; color: var(--muted); }
#ls-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
#ls-items li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 2px 8px; align-items: center; padding: 6px 2px; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
#ls-items li:first-child { border-top: 0; }
#ls-items .sw { width: 12px; height: 12px; border-radius: 3px; grid-row: 1 / 3; }
#ls-items .lt { display: grid; min-width: 0; }
#ls-items .lt b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: clip; }
#ls-items .lt span { font-size: 12px; color: var(--muted); }
#ls-items .pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.road { background: color-mix(in srgb, var(--orange) 16%, var(--paper)); color: color-mix(in srgb, var(--orange) 70%, var(--ink)); }
.pill.slow { background: color-mix(in srgb, var(--purple) 15%, var(--paper)); color: var(--purple); }
.pill.wait { background: color-mix(in srgb, var(--cream-dark) 22%, var(--paper)); color: var(--muted); }
#ls-items .bar { grid-column: 3; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
#ls-items .bar i { display: block; height: 100%; background: var(--teal); }

#dock { position: absolute; left: calc((100% - 342px) / 2 + 12px); bottom: calc(34px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; }
#build { display: flex; gap: 10px; }
.build-btn {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 10px; align-items: center; text-align: left;
  min-height: 64px; width: 214px; padding: 8px 12px; border-radius: 12px;
  background: var(--card); border: 2px solid transparent; box-shadow: var(--shadow);
}
.build-btn .bb-icon { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.build-btn .bb-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.build-btn .bb-text { display: grid; min-width: 0; }
.bb-name { font-weight: 900; font-size: 14px; white-space: nowrap; }
.bb-blurb { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bb-cost { grid-column: 2; font-size: 12px; color: var(--muted); }
.bb-cost b { color: var(--ink); font-size: 13px; }
.build-btn.c-gold .bb-icon { background: var(--gold); color: var(--ink); }
.build-btn.c-purple .bb-icon { background: var(--purple); color: var(--gold); }
.build-btn.c-teal .bb-icon { background: var(--teal); color: var(--paper); }
.build-btn[aria-pressed="true"].c-gold { border-color: color-mix(in srgb, var(--gold) 70%, var(--ink)); background: color-mix(in srgb, var(--gold) 14%, var(--paper)); }
.build-btn[aria-pressed="true"].c-purple { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 10%, var(--paper)); }
.build-btn[aria-pressed="true"].c-teal { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 10%, var(--paper)); }
.build-btn.poor .bb-cost b { color: var(--orange); }
#build { position: relative; }
#build::before {
  content: attr(data-label); position: absolute; left: 0; bottom: calc(100% + 8px); white-space: nowrap;
  font-size: 13px; font-weight: 900; padding: 4px 10px; border-radius: 999px;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.build-btn.locked { opacity: .45; cursor: not-allowed; }
.build-btn.locked .bb-icon { filter: grayscale(.6); }
#build.nudge .build-btn:not(.poor) { animation: nudge .9s ease-in-out 3; }
@keyframes nudge { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 70%, transparent), var(--shadow); transform: translateY(-2px); } }
#btn-start {
  min-height: 64px; min-width: 170px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--purple); color: var(--paper); font-weight: 900; font-size: 15px; box-shadow: var(--shadow);
}
#btn-start:disabled { background: color-mix(in srgb, var(--purple) 30%, var(--paper)); color: var(--purple); cursor: default; }

#card {
  position: absolute; right: max(24px, env(safe-area-inset-right, 0px)); top: calc(184px + env(safe-area-inset-top, 0px)); width: 300px; z-index: 2;
  padding: 12px 14px 14px; border-radius: 12px; background: var(--paper); box-shadow: var(--shadow);
  border-top: 4px solid var(--gold);
}
#card[hidden] { display: none; }
#card.c-purple { border-top-color: var(--purple); }
#card.c-teal { border-top-color: var(--teal); }
.cd-head { display: grid; grid-template-columns: 38px minmax(0, 1fr) 40px; gap: 10px; align-items: center; }
.cd-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--gold); }
#card.c-purple .cd-icon { background: var(--purple); color: var(--gold); }
#card.c-teal .cd-icon { background: var(--teal); color: var(--paper); }
.cd-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cd-title { display: grid; }
.cd-title b { font-size: 16px; font-weight: 900; }
.cd-title span { font-size: 12px; color: var(--muted); }
#btn-close { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-size: 20px; line-height: 1; }
.cd-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.cd-stats span { display: grid; background: var(--card); border-radius: 8px; padding: 6px 8px; }
.cd-stats small { font-size: 12px; color: var(--muted); }
.cd-stats b { font-size: 18px; font-weight: 900; }
.cd-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cd-actions button { min-height: 44px; border-radius: 10px; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: var(--paper); }
#btn-upgrade { background: var(--gold); border-color: transparent; font-weight: 900; }
#btn-upgrade:disabled { background: var(--card); color: var(--muted); cursor: default; }

/* how to play: the coach takes the place of the bottom controls, so it never covers the board */
#btn-help { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-weight: 600; font-size: 14px; }
.hl-q { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--purple); color: var(--paper); font-size: 13px; font-weight: 900; }
#hud.coaching #dock { display: none; }
#coach {
  position: absolute; left: calc((100% - 342px) / 2 + 12px); bottom: calc(34px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(760px, calc(100% - 48px)); display: flex; align-items: center; gap: 18px;
  padding: 12px 14px 12px 18px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow);
  border: 2px solid var(--gold);
}
#coach[hidden] { display: none; }
.co-text { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.co-step { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
#coach-title { font-size: 17px; font-weight: 900; }
#coach-body { font-size: 14px; color: color-mix(in srgb, var(--ink) 80%, var(--paper)); text-wrap: pretty; }
.co-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.co-actions button { min-height: 46px; padding: 0 16px; border-radius: 10px; font-weight: 900; font-size: 15px; border: 0; white-space: nowrap; }
#coach-skip { background: none; color: var(--muted); font-weight: 600; border: 1px solid var(--line); }
#coach-next { background: var(--gold); }
#coach-start { background: var(--purple); color: var(--paper); }
.co-actions button[hidden] { display: none; }
.lbl.coach-tap { background: var(--gold); color: var(--ink); font-size: 14px; font-weight: 900; padding: 7px 12px; box-shadow: 0 3px 10px color-mix(in srgb, var(--ink) 25%, transparent); }
.lbl.coach-tap::after { content: "↓"; display: inline-block; margin-left: 6px; animation: bob .9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#toast {
  position: absolute; left: 50%; top: calc(178px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -8px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: opacity .2s, transform .2s;
  width: max-content; max-width: calc(100vw - 32px); text-align: center; text-wrap: balance;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ pills on the board */
#labels { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 5px 9px; border-radius: 999px;
  background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px color-mix(in srgb, var(--ink) 14%, transparent);
}
.lbl.day { font-size: 13px; padding: 6px 11px; }
.lbl.place { background: var(--purple); color: var(--paper); }
.lbl.place.you { background: var(--teal); display: inline-flex; align-items: center; gap: 7px; }
.lbl.you .en { width: 46px; height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--paper) 30%, transparent); overflow: hidden; }
.lbl.you .en i { display: block; height: 100%; width: 100%; background: var(--gold); transition: width .3s; }
.lbl.you .pct { font-variant-numeric: tabular-nums; }
.lbl.you.low { background: var(--orange); }
.lbl.you.low .en i { background: var(--paper); }
.lbl.lunch { background: color-mix(in srgb, var(--paper) 70%, var(--cream)); color: var(--muted); box-shadow: none; }
.lbl.tag.boss { background: var(--orange); color: var(--paper); font-size: 13px; }
.lbl.up { background: var(--gold); color: var(--ink); font-weight: 900; font-variant-numeric: tabular-nums; }
.lbl.float { font-weight: 900; font-variant-numeric: tabular-nums; box-shadow: none; }
.lbl.gain { background: var(--gold); color: var(--ink); }
.lbl.spend { background: var(--ink); color: var(--paper); }
.lbl.loss { background: var(--orange); color: var(--paper); font-size: 14px; }
.lbl.bonus { background: var(--teal); color: var(--paper); font-size: 13px; }

/* ------------------------------------------------------------------ end card */
#end, #report { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ink) 30%, transparent); }
#end[hidden], #report[hidden] { display: none; }
#report .end-bar { background: var(--purple); }
#report.bad .end-bar { background: var(--orange); }
#report-title { font-size: 26px; font-weight: 900; margin: 16px 16px 4px; letter-spacing: -.01em; }
#report-sub, #report-next { margin: 0 20px 4px; font-size: 15px; color: color-mix(in srgb, var(--ink) 78%, var(--paper)); text-wrap: balance; }
#report-next { margin: 0 20px 16px; font-weight: 600; color: var(--ink); }
#btn-plan { min-height: 52px; padding: 0 28px; border-radius: 12px; border: 0; background: var(--gold); font-weight: 900; font-size: 16px; }
.end-win { width: min(440px, 100%); background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; text-align: center; padding-bottom: 20px; }
.end-bar { background: var(--teal); color: var(--paper); font-family: var(--label); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; padding: 8px 12px; }
#end.lost .end-bar { background: var(--orange); }
#end-title { font-size: 28px; font-weight: 900; margin: 18px 16px 4px; letter-spacing: -.01em; }
#end-sub { margin: 0 20px 4px; font-size: 15px; color: color-mix(in srgb, var(--ink) 78%, var(--paper)); text-wrap: balance; }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 16px 18px; }
.end-stats div { display: grid; background: var(--card); border-radius: 10px; padding: 10px 6px; }
.end-stats small { font-size: 12px; color: var(--muted); font-weight: 600; }
.end-stats b { font-size: 26px; font-weight: 900; }
.end-stats span { font-size: 12px; color: var(--muted); }
#btn-again { min-height: 52px; padding: 0 28px; border-radius: 12px; border: 0; background: var(--gold); font-weight: 900; font-size: 16px; }

#footer {
  position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 4;
  font-size: 12px; color: var(--muted); white-space: nowrap; pointer-events: none;
}

/* ------------------------------------------------------------------ medium screens */
@media (max-width: 1099px) {
  #list { display: none; }
  #card { top: calc(168px + env(safe-area-inset-top, 0px)); }
  #dock, #coach { left: 50%; }
  #stepper { display: none; }
}

/* ------------------------------------------------------------------ phone */
@media (max-width: 699px) {
  .appbar { height: 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 10px; }
  .appbar.game { height: calc(48px + env(safe-area-inset-top, 0px)); }
  .ab-today, .ab-nav, .ab-seg, .ab-week { display: none; }
  .ab-month { font-size: 16px; }
  .ab-logo { font-size: 17px; }
  .ab-avatar { width: 28px; height: 28px; }
  .cal-sub { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); flex-wrap: wrap; }
  .cal-week b { font-size: 18px; }
  .cal-frame { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(4px, env(safe-area-inset-left, 0px)); }
  .cal-head { grid-template-columns: 26px repeat(5, 1fr); height: 34px; }
  .cg-mm { display: none; }
  .ch-day { font-size: 12px; padding-left: 3px; display: grid; line-height: 1.1; }
  .cal-gutter { flex-basis: 26px; }
  .cg-hour { right: 4px; }
  .cal-event, .cal-event.short { flex-direction: column; flex-wrap: nowrap; padding: 1px 3px; font-size: 12px; line-height: 14px; border-left-width: 2px; border-radius: 4px; }
  /* phones: titles only (the hour column has the times), cut at whole lines */
  .cal-event .ce-h { display: none; }
  .cal-event .ce-t { -webkit-hyphens: auto; hyphens: auto; max-height: calc(var(--lines, 1) * 14px); overflow: hidden; flex: 0 0 auto; }
  .cal-cta { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 34px max(16px, env(safe-area-inset-left, 0px)); }
  #btn-play { width: 100%; }
  .cal-premise { font-size: 15px; }
  #build::before { font-size: 12px; padding: 3px 9px; bottom: calc(100% + 6px); }

  .appbar.game { gap: 8px; }
  .appbar.game .ab-avatar { display: none; }
  #stats { top: calc(56px + env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  #stat-beaten { display: none; }
  .stat { width: auto; padding: 7px 10px; border-radius: 10px; }
  .stat .k { font-size: 12px; }
  .stat .v b { font-size: 21px; }
  .stat .v small { font-size: 12px; }
  .stat .s { display: none; }
  #dock { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); transform: none; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); flex-direction: column; gap: 8px; }
  #build { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .build-btn { width: auto; min-height: 64px; grid-template-columns: 1fr; grid-template-rows: auto auto auto; justify-items: center; text-align: center; padding: 6px 4px; gap: 2px; }
  .build-btn .bb-icon { grid-row: auto; width: 30px; height: 30px; border-radius: 8px; }
  .build-btn .bb-icon svg { width: 18px; height: 18px; }
  .bb-name { font-size: 12px; white-space: normal; line-height: 1.1; }
  .bb-blurb { display: none; }
  .bb-cost { grid-column: auto; }
  #btn-start { min-height: 48px; min-width: 0; width: 100%; }
  #card { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); top: auto; width: auto; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  #hud.card-open #dock, #hud.card-open #coach { visibility: hidden; }
  #coach { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); width: auto; transform: none; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  #coach-title { font-size: 16px; }
  #coach-body { font-size: 13px; }
  .co-actions button { flex: 1 1 0; min-height: 44px; }
  .hl-t { display: none; }
  #btn-help { width: 40px; padding: 0; justify-content: center; border: 0; background: none; }
  #toast { top: calc(130px + env(safe-area-inset-top, 0px)); }
  #footer { right: auto; left: 50%; transform: translateX(-50%); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  #end-title, #report-title { font-size: 24px; }
  .end-stats b { font-size: 22px; }
}

/* ------------------------------------------------------------------ phone held sideways (set by JS: height < 520 and wider than tall) */
body.short #cal .appbar { height: 44px; }
body.short .cal-sub { padding-top: 6px; padding-bottom: 4px; }
body.short .cal-head { height: 30px; }
/* squeezed: 30-minute meetings become plain bars, the rest keep one clean line */
body.short .cal-event { padding: 0 6px; line-height: 15px; }
body.short .cal-event.short .ce-t, body.short .cal-event.short .ce-h { visibility: hidden; }
body.short .cal-event .ce-t { white-space: nowrap; overflow: hidden; max-height: 15px; }
body.short .cal-event .ce-h { display: none; }
body.short .cal-cta { padding: 4px 20px 22px; flex-direction: row; justify-content: center; gap: 16px; }
body.short .cal-premise { font-size: 14px; text-align: left; max-width: 36ch; }
body.short #build::before { display: none; }
body.short #btn-play { min-height: 44px; }
body.short .appbar.game { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); height: auto; padding: 0; gap: 0; background: none; border: 0; backdrop-filter: none; }
body.short .appbar.game > :not(#clock):not(#btn-help) { display: none; }
body.short .appbar.game { gap: 6px; }
body.short #btn-help { width: 40px; padding: 0; justify-content: center; }
body.short .hl-t { display: none; }
body.short #coach { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(60px + env(safe-area-inset-top, 0px)); bottom: auto; transform: none; width: 188px; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
body.short #coach-title { font-size: 15px; }
body.short #coach-body { font-size: 13px; }
body.short .co-actions { flex-direction: column-reverse; gap: 6px; }
body.short .co-actions button { min-height: 44px; }
body.short #hud.card-open #coach { visibility: hidden; }
body.short #stats { top: calc(8px + env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px)); gap: 6px; }
body.short .stat { width: 116px; padding: 6px 10px; border-radius: 10px; }
body.short .stat .k { font-size: 12px; }
body.short .stat .v b { font-size: 20px; }
body.short .stat .v small { font-size: 12px; }
body.short .stat .s, body.short #stat-beaten, body.short #list, body.short #stepper { display: none; }
body.short #dock { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(60px + env(safe-area-inset-top, 0px)); bottom: auto; transform: none; width: 188px; flex-direction: column; gap: 6px; }
body.short #build { flex-direction: column; gap: 6px; }
body.short .build-btn { width: 100%; min-height: 50px; padding: 5px 10px; grid-template-columns: 30px minmax(0, 1fr); gap: 0 8px; }
body.short .build-btn .bb-icon { width: 30px; height: 30px; border-radius: 8px; }
body.short .build-btn .bb-icon svg { width: 18px; height: 18px; }
body.short .bb-blurb { display: none; }
body.short #btn-start { min-height: 46px; min-width: 0; width: 100%; font-size: 14px; }
body.short #card { right: max(16px, env(safe-area-inset-right, 0px)); top: calc(60px + env(safe-area-inset-top, 0px)); width: 188px; padding: 10px; }
body.short #card .cd-stats { grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin: 8px 0; }
body.short #card .cd-stats b { font-size: 15px; }
body.short #card .cd-actions { grid-template-columns: 1fr; }
body.short #hud.card-open #dock { visibility: hidden; }
body.short #toast { top: 64px; left: calc((100% - 196px) / 2); }
body.short #footer { right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }

/* recording: no chrome except the stat cards and the clock */
body.rec #hud { animation: none !important; }
body.rec #cal { bottom: auto; height: 84.5vh; } /* the calendar fits the Reel window's band too */
body.rec #report .end-win { transform: scale(1.12); }
body.rec #coach, body.rec #btn-help, body.rec .cal-premise, body.rec #footer, body.rec #dock, body.rec #list, body.rec #stepper, body.rec #card, body.rec #toast, body.rec .cal-cta { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  body.mode-game #hud, .bump, .lbl.coach-tap::after, #build.nudge .build-btn { animation: none; }
  #toast { transition: none; }
}
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; }
