/* Death by Alignment — pixel management-sim styling.
   Hard edges, hard shadows, no radius, no blur. Phone-first; a fixed
   960×600 panel on large screens. */

:root {
  --page-top: #05060a;
  --page-mid: #0c1120;
  --page-bottom: #18223b;

  --frame: #0f1424;       /* game panel */
  --surface: #1e2640;     /* inner panels */
  --surface-2: #2b3554;   /* buttons, raised */
  --sunken: #0a0e19;
  --edge: #3d4a70;        /* inner highlight line */
  --outline: #000;

  --ink: #fff1e8;
  --muted: #a49fb8;
  --dark-ink: #111520;

  --blue: #29adff;
  --green: #00e436;
  --yellow: #ffec27;
  --orange: #ffa300;
  --red: #ff004d;
  --pink: #ff77a8;
  --plum: #7e2553;
  --navy: #1d2b53;
  --forest: #008751;
  --grey: #5f574f;
  --paper: #fff1e8;

  --px: 3px; /* border unit */
  /* Jersey 15 for everything you read: a pixel face with a tall x-height.
     It has one weight, so emphasis comes from size and colour, never bold.
     Pixelify Sans is kept for the big headings. */
  --font-display: 'Pixelify Sans', ui-monospace, Menlo, Consolas, monospace;
  --font-body: 'Jersey 15', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* no double-tap zoom */
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--page-mid) linear-gradient(165deg, var(--page-top) 0%, var(--page-mid) 55%, var(--page-bottom) 100%) fixed;
  color: var(--ink);
  font: 20px/1.2 var(--font-body);
  font-synthesis: none;
}

[hidden] { display: none !important; }

/* ---------- Panels and buttons ---------- */

.panel {
  background: var(--surface);
  border: var(--px) solid var(--outline);
  box-shadow: inset 0 0 0 2px var(--edge), 4px 4px 0 rgba(0, 0, 0, 0.55);
}

button {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: var(--px) solid var(--outline);
  border-radius: 0;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
  min-height: 44px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  button:hover:not(:disabled) { filter: brightness(1.12); }
}
button:active:not(:disabled) {
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(2px);
}
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
button:disabled { cursor: default; opacity: 0.45; }

.btn-primary, button.primary {
  background: var(--blue);
  color: var(--dark-ink);
}
.btn-big { font-size: 1.25em; padding: 12px 28px; text-align: center; }

.label {
  display: block;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Game panel (phone first) ---------- */

#game {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* viewport-fit=cover: keep clear of the notch and home indicator */
  padding:
    max(8px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: var(--frame);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* The title screen shows just the office behind the title card. */
#game[data-mode="title"] .stats,
#game[data-mode="title"] .actions,
#game[data-mode="title"] .feed { display: none; }
#game[data-mode="title"] .stage { display: flex; }
#game[data-mode="title"] .scene { flex: 1; aspect-ratio: auto; max-height: none; }

/* ---------- Stats bar ---------- */

.stats {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "top top"
    "ready ready"
    "cap status"
    "work work";
  gap: 6px 12px;
  padding: 8px 10px;
  background: var(--surface);
  border: var(--px) solid var(--outline);
  box-shadow: inset 0 0 0 2px var(--edge);
}
.stats-top { grid-area: top; display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.stat-readiness { grid-area: ready; }
.stat-capital { grid-area: cap; }
.stat-status { grid-area: status; }
.stat-workarounds { grid-area: work; }

.stat-week { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week { font-size: 1.3em; color: var(--yellow); }
.phase-chip {
  padding: 1px 6px;
  font-size: 16px;
  color: var(--dark-ink);
  background: var(--muted);
  border: 2px solid var(--outline);
}
.phase-chip.phase-2 { background: var(--blue); }
.phase-chip.phase-3 { background: var(--pink); }
.phase-chip.phase-4 { background: var(--orange); }
.phase-chip.phase-5 { background: var(--yellow); }
.stat-competitor { color: var(--muted); font-size: 17px; }
.stat-competitor.late { color: var(--red); }

.stat-readiness {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr 3.2em;
  align-items: center;
  gap: 8px;
}
.stat-readiness .value { text-align: right; font-weight: 400; font-size: 1.1em; }
.bar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 2px;
  height: 16px;
  padding: 2px;
  background: var(--sunken);
  border: 2px solid var(--outline);
}
.seg { background: #1a2136; }
.seg.on { background: var(--green); }
.phase-5 .seg.on { background: var(--yellow); }
.tick {
  position: absolute;
  top: -7px;
  width: 2px;
  height: 4px;
  background: var(--muted);
  transform: translateX(-1px);
}
.delta {
  position: absolute;
  right: 0;
  top: -18px;
  font-weight: 400;
  pointer-events: none;
  animation: float-up 1.2s steps(6) forwards;
}
.delta.down { color: var(--red); text-shadow: 2px 2px 0 var(--outline); }
.delta.up { color: var(--green); text-shadow: 2px 2px 0 var(--outline); }

.stat-capital { display: flex; flex-direction: column; gap: 3px; }
.pips { display: flex; gap: 3px; }
.pip { width: 10px; height: 14px; background: var(--sunken); border: 2px solid var(--outline); }
.pip.on { background: var(--yellow); }
.stat-capital.empty .label { color: var(--red); }

.stat-workarounds { display: flex; align-items: center; gap: 10px; }
.workaround-icons { display: flex; gap: 4px; }
.wicon {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid var(--outline);
}
.wicon .icon { width: 16px; height: 16px; }
.wicon.used { opacity: 0.25; }
.wicon-count {
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 14px;
  padding: 0 2px;
  font-size: 14px;
  line-height: 13px;
  text-align: center;
  color: var(--dark-ink);
  background: var(--yellow);
  border: 1px solid var(--outline);
}

.stat-status { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 17px; color: var(--orange); }
.status-dot { width: 8px; height: 8px; background: var(--orange); animation: blink 2s steps(1) infinite; }

/* ---------- Stage: scene, feed, call ---------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene {
  position: relative;
  flex: none;
  aspect-ratio: 16 / 9;
  max-height: 34vh;
  background: #83769c;
  border: var(--px) solid var(--outline);
  overflow: hidden;
}
.scene-art { display: block; width: 100%; height: 100%; }
.scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--red);
  opacity: 0;
  pointer-events: none;
}

.feed { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.feed-title {
  margin: 0;
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sunken);
  border-bottom: 2px solid var(--outline);
}
.log {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 6px 10px 10px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 18px;
}
.log li { padding: 1px 0; }
.log-weekStart { margin-top: 8px; color: var(--muted); }
.log-call { color: var(--blue); }
.log-phaseChange, .log-competitorLaunched { color: var(--yellow); }
.log-needle { color: var(--muted); }
.log-lost, .log-bad { color: var(--red); }
.log-won, .log-wonTerminal { color: var(--green); }

/* Call window (Teams-style) */
.call {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(5, 6, 10, 0.6);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.call-window {
  width: 100%;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  animation: pop-in 0.18s steps(3);
}
.call-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 17px;
  color: var(--muted);
  background: var(--sunken);
  border-bottom: 2px solid var(--outline);
}
.call-live { width: 8px; height: 8px; background: var(--red); animation: blink 1s steps(1) infinite; }
.call-incoming { flex: 1; }
.call-clock { font-variant-numeric: tabular-nums; }
.call-main { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.call-side { display: flex; flex-direction: column; gap: 10px; }
.call-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}
.call-tile .avatar {
  flex: none;
  width: 64px;
  height: 64px;
  border: var(--px) solid var(--outline);
  background: var(--sunken);
}
.call-name { font-weight: 400; }
.call-text { margin: 0; font-size: 21px; line-height: 1.25; }
.call-terminal { margin: 0; color: var(--red); }
.call-body { display: flex; flex-direction: column; gap: 8px; }
.call-or, .call-note { margin: 2px 0 0; color: var(--muted); font-size: 17px; }
.btn-handle, .btn-action { display: flex; flex-direction: column; }
.action-label { font-weight: 400; }
.action-hint { font-size: 16px; opacity: 0.8; }
.workarounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.btn-workaround { width: 100%; display: flex; align-items: center; gap: 10px; }
.btn-workaround .icon { flex: none; width: 24px; height: 24px; }
.workaround-text { display: flex; flex-direction: column; }
.workaround-note { color: var(--muted); font-size: 16px; }
.call-outcome { display: flex; flex-direction: column; gap: 2px; font-size: 21px; }
.call-outcome p { margin: 0; }

/* ---------- Actions ---------- */

.actions { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-action { min-height: 60px; justify-content: center; }
.btn-crackOn { background: var(--green); color: var(--dark-ink); }
.btn-align { background: var(--blue); color: var(--dark-ink); }

/* ---------- Title and ending screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 6, 10, 0.72);
  overflow-y: auto;
}
.title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 560px;
}
.title {
  margin: 0;
  font-size: clamp(30px, 9vw, 52px);
  line-height: 1.05;
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--plum), 6px 6px 0 var(--outline);
}
.tagline { margin: 0; color: var(--ink); font-size: 22px; }
.title-card .btn-big { background: var(--green); color: var(--dark-ink); }

.ending { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 440px; margin: auto; }
.card {
  width: 100%;
  padding: 18px 20px 14px;
  color: var(--dark-ink);
  background: var(--paper);
  box-shadow: inset 0 0 0 2px #d9cbbd, 6px 6px 0 rgba(0, 0, 0, 0.6);
}
.card-kicker { margin: 0; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; color: #6b6478; }
.card-title { margin: 2px 0 8px; font-size: 28px; line-height: 1.1; }
.card-line { margin: 0 0 12px; font-size: 21px; line-height: 1.25; }
.summary { margin: 0 0 12px; display: grid; gap: 3px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px dotted #c9bcae; padding-bottom: 2px; }
.summary dt { color: #5f574f; }
.summary dd { margin: 0; font-weight: 400; text-align: right; }
.card-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0 10px; }
.card-status .label { color: #5f574f; }
.stamp {
  display: inline-block;
  padding: 4px 10px;
  font-size: 20px;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--red);
  border: 3px solid currentColor;
  transform: rotate(-5deg);
}
.stamp-launched, .stamp-launchedLate { color: var(--forest); }
.stamp-burnout { color: var(--plum); }
.stamp-freelance { color: var(--navy); }
.card-seed { margin: 0; font-size: 15px; color: #8a8296; }
.ending .btn-big { background: var(--yellow); color: var(--dark-ink); }

/* ---------- Tutorial ---------- */

.tutorial { position: absolute; inset: 0; z-index: 30; background: rgba(5, 6, 10, 0.6); }
.tut-focus {
  position: relative;
  z-index: 31;
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
  background-color: var(--surface);
}
.tut-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  padding: 12px 14px;
}
.tut-count { margin: 0; font-size: 16px; color: var(--muted); }
.tut-text { margin: 4px 0 12px; font-size: 21px; line-height: 1.25; }
.tut-controls { display: flex; gap: 8px; }
.tut-skip { margin-right: auto; }

/* ---------- How to play (below the game) ---------- */

.how-to-play {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  color: var(--ink);
}
.how-title { margin: 0 0 10px; font-family: var(--font-display); font-size: 26px; color: var(--yellow); }
.how-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 20px; line-height: 1.3; }
.how-list li { position: relative; padding-left: 22px; }
.how-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 10px;
  height: 10px;
  background: var(--orange);
}

/* ---------- Mini-games ---------- */

.minigame { display: flex; flex-direction: column; gap: 10px; }
.mg-instruction { margin: 0; font-weight: 400; }
.mg-timer { height: 12px; padding: 2px; background: var(--sunken); border: 2px solid var(--outline); }
.mg-timer-bar { height: 100%; background: var(--yellow); transform-origin: left center; }
.mg-feedback { margin: 0; min-height: 1.35em; font-weight: 400; }
.mg-won .mg-feedback { color: var(--green); }
.mg-lost .mg-feedback { color: var(--red); }
.minigame-name { margin: 0; color: var(--muted); }

/* Approval Email */
.ae-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ae-chip { font-size: 17px; line-height: 1.2; }
.ae-chip[aria-pressed="true"] { background: var(--blue); color: var(--dark-ink); }
.ae-chip.ae-trap { background: var(--red); color: var(--ink); opacity: 1; }
.ae-preview { margin: 0; padding: 6px 8px; font-size: 17px; color: var(--dark-ink); background: var(--paper); border: 2px solid var(--outline); }

/* Time Zone Tetris */
.tz-slots { display: flex; flex-direction: column; gap: 3px; max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.tz-row { display: grid; grid-template-columns: 4em repeat(4, 1fr); gap: 4px; align-items: center; }
.tz-head { color: var(--muted); font-size: 16px; padding: 0 15px; }
.tz-slot { padding: 6px 12px; min-height: 44px; }
.tz-cell { height: 24px; background: var(--green); border: 2px solid var(--outline); }
.tz-busy { background: var(--grey); }
.tz-picked { background: var(--green); }
.tz-wrong { background: var(--red); }
.tz-answer { outline: 3px dashed var(--yellow); outline-offset: -3px; }

/* Spot the Non-Compliant Asset */
.na-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.na-tile { display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--paper); color: var(--dark-ink); }
.na-art { position: relative; display: flex; align-items: flex-end; width: 100%; aspect-ratio: 4 / 3; padding: 10px; }
.na-logo { position: absolute; width: 18px; height: 18px; border: 3px solid #fff; border-radius: 50%; }
.na-headline { color: #fff; font-weight: 400; font-size: 18px; line-height: 1.15; }
.na-strap { font-size: 16px; }
.na-picked { outline: 4px solid var(--green); }
.na-wrong { outline: 4px solid var(--red); }

/* Forecast Reconciliation */
.fr-readout { margin: 0; font-size: 30px; font-weight: 400; text-align: center; }
.fr-track { position: relative; height: 96px; touch-action: none; cursor: pointer; }
.fr-band { position: absolute; top: 34px; height: 28px; background: rgba(0, 228, 54, 0.45); transition: opacity 0.3s steps(3); }
.fr-band.fr-hidden { opacity: 0; }
.fr-marker { position: absolute; top: 30px; height: 36px; border-left: 2px dashed var(--muted); }
.fr-marker-label { position: absolute; top: -26px; transform: translateX(-50%); white-space: nowrap; font-size: 16px; color: var(--muted); }
.fr-group .fr-marker-label { top: auto; bottom: -26px; }
.fr-slider { position: absolute; top: 34px; left: 0; width: 100%; height: 28px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; pointer-events: none; }
.fr-slider:focus-visible { outline: 3px solid var(--yellow); }
.fr-slider::-webkit-slider-runnable-track { height: 6px; background: var(--muted); border: 1px solid var(--outline); }
.fr-slider::-moz-range-track { height: 6px; background: var(--muted); border: 1px solid var(--outline); }
.fr-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 44px; margin-top: -20px; background: var(--ink); border: 3px solid var(--outline); border-radius: 0; }
.fr-slider::-moz-range-thumb { width: 28px; height: 44px; background: var(--ink); border: 3px solid var(--outline); border-radius: 0; }
.fr-submit { width: 100%; text-align: center; }

/* Alignment Whack-a-Mole */
.wam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.wam-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  touch-action: manipulation;
}
.wam-tile .avatar { width: 64px; height: 64px; align-self: center; border: 2px solid var(--outline); }
.wam-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  background: var(--green);
  border: 2px solid var(--outline);
}
.wam-meter { height: 8px; background: var(--sunken); border: 2px solid var(--outline); }
.wam-fill { display: block; height: 100%; background: var(--green); transform-origin: left center; }
.wam-title { font-size: 14px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wam-tile[data-state="amber"] .wam-dot, .wam-tile[data-state="amber"] .wam-fill { background: var(--orange); }
.wam-tile[data-state="red"] { background: var(--red); }
.wam-tile[data-state="red"] .wam-dot, .wam-tile[data-state="red"] .wam-fill { background: var(--red); }
.wam-tile[data-state="red"] .wam-dot { animation: blink 0.6s steps(1) infinite; }
.wam-touched { animation: touched 0.25s steps(2); }
@keyframes touched { 0% { background: var(--green); } }

/* Signature Chase */
.sc-sheet { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--paper); color: var(--dark-ink); border: 2px solid var(--outline); }
/* Phones: name and status on one line, the lane full width beneath. */
.sc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name status" "lane lane";
  align-items: center;
  gap: 4px 8px;
  padding: 6px 8px;
  color: var(--dark-ink);
  background: #f3e6d8;
}
.sc-name { grid-area: name; }
.sc-lane { grid-area: lane; }
.sc-status { grid-area: status; }
@media (min-width: 600px) {
  .sc-row { grid-template-columns: 7.5em 1fr 3.6em; grid-template-areas: "name lane status"; }
}
.sc-name { display: flex; flex-direction: column; font-size: 17px; line-height: 1.1; }
.sc-note { font-size: 14px; color: var(--plum); }
.sc-lane { position: relative; height: 22px; overflow: hidden; background: #c9bcae; border: 2px solid var(--outline); }
.sc-strip { position: absolute; top: 0; bottom: 0; }
.sc-in { position: absolute; top: 2px; bottom: 2px; background: var(--forest); }
.sc-now { position: absolute; top: -2px; bottom: -2px; left: 15%; width: 3px; background: var(--red); }
.sc-status { font-size: 16px; color: var(--forest); text-align: right; }
.sc-signed { background: #d6ecd2; }
.sc-signed .sc-lane { opacity: 0.4; }
.sc-bounced { animation: shake 0.3s steps(3); }

/* Translation Roulette */
.tr-original { padding: 8px 10px; background: var(--paper); color: var(--dark-ink); border: 2px solid var(--outline); }
.tr-original .label { color: #6b6478; }
.tr-claim { margin: 2px 0 0; font-size: 22px; }
.tr-options { display: grid; gap: 6px; }
.tr-option { font-size: 18px; line-height: 1.2; }
.tr-option.tr-right { background: var(--green); color: var(--dark-ink); opacity: 1; }
.tr-option.tr-wrong { background: var(--red); opacity: 1; }

/* The Dashboard (a light, generic web app) */
.db { position: relative; color: #1b1f29; background: #f4f5f8; border: 2px solid var(--outline); }
.db-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; background: #dfe3ec; border-bottom: 2px solid var(--outline); }
.db-name { font-size: 16px; color: #49506a; }
.db-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.db-top { min-width: 60px; padding: 6px 10px; font-size: 17px; color: #1b1f29; background: #fff; text-align: center; }
.db-top::after { content: ' ▾'; font-size: 12px; }
.db-panel {
  position: absolute;
  right: 8px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: #fff;
  border: 2px solid var(--outline);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
}
.db-item { color: #1b1f29; background: #fff; border-width: 0 0 2px; box-shadow: none; font-size: 18px; }
.db-has-sub::after { content: ' ›'; float: right; }
.db-back { color: #49506a; }
.db-request { margin: 0; padding: 6px 8px; font-size: 16px; color: #49506a; }
.db-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.db-table th, .db-table td { padding: 6px 8px; text-align: left; border-top: 1px solid #c8ccd8; }
.db-table th { color: #49506a; font-weight: 400; }
.db-empty { color: #8a8fa3; }

/* Budget Shuffle */
.bs-board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; touch-action: none; user-select: none; }
.bs-pot { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 4px; cursor: grab; background: var(--surface-2); border: 2px solid var(--outline); }
.bs-column { position: relative; height: 180px; background: var(--sunken); border: 2px solid var(--outline); }
.bs-cap { position: absolute; left: -2px; right: -2px; height: 3px; background: var(--yellow); transform: translateY(50%); z-index: 1; }
.bs-block { position: absolute; left: 3px; right: 3px; height: calc(100% / 9 - 3px); background: var(--green); border: 2px solid var(--outline); }
.bs-block-over { background: var(--red); }
.bs-count { text-align: center; font-size: 16px; }
.bs-label { text-align: center; font-size: 14px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.bs-over { border-color: var(--red); }
.bs-over .bs-count { color: var(--red); }
.bs-selected { outline: 3px solid var(--yellow); outline-offset: -3px; }
.bs-arrived .bs-column { animation: red-flash-bg 0.4s steps(2); }
@keyframes red-flash-bg { 0% { background: #3a2030; } }
.bs-ghost { position: fixed; left: 0; top: 0; z-index: 50; width: 28px; height: 28px; background: var(--green); border: 3px solid var(--outline); pointer-events: none; }

/* ---------- Feedback animations ---------- */

#game.hit .stat-readiness { animation: shake 0.4s steps(4); }
#game.hit .seg.on, #game.big-hit .seg.on { background: var(--red); }
#game.big-hit { animation: shake-big 0.5s steps(5); }
#game.big-hit .scene::after { animation: red-flash 0.6s steps(3); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
@keyframes shake-big {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(6px, -2px); }
  60% { transform: translate(-4px, 0); }
  80% { transform: translate(3px, 1px); }
}
@keyframes red-flash { 0% { opacity: 0.5; } 100% { opacity: 0; } }
@keyframes float-up {
  0% { transform: translateY(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(-18px); opacity: 0; }
}
@keyframes blink { 50% { opacity: 0.2; } }
/* No opacity here: if animations are paused the window must still show. */
@keyframes pop-in {
  0% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Phone: hide actions during a call so it gets the room ---------- */

#game[data-call] .actions { display: none; }

/* ---------- Large screens: fixed 960×600 panel ---------- */

@media (min-width: 900px) and (min-height: 640px) {
  #game {
    width: 960px;
    height: 600px;
    /* centred in the first screen, with How to play below */
    margin: max(24px, calc((100svh - 608px) / 2)) auto 0;
    padding: 10px;
    gap: 10px;
    border: 4px solid var(--outline);
    box-shadow: 0 0 0 4px var(--surface-2), 14px 14px 0 rgba(0, 0, 0, 0.5);
  }

  .stats {
    grid-template-columns: 1.7fr 1fr auto auto;
    grid-template-areas:
      "top top top top"
      "ready cap work status";
    gap: 6px 18px;
  }
  .stat-workarounds { flex-direction: column; align-items: flex-start; gap: 3px; }

  .stage { display: grid; grid-template-columns: 1.55fr 1fr; gap: 10px; }
  .scene { aspect-ratio: auto; max-height: none; height: 100%; }

  .call { align-items: center; padding: 10px; }
  .call-window { max-width: 900px; max-height: 100%; margin: 0; }
  .call-main { min-height: 0; overflow-y: auto; padding: 12px 14px; gap: 10px; }
  .call-side {
    display: grid;
    grid-template-columns: 112px 1fr;
    grid-template-rows: auto 1fr;
    gap: 6px 16px;
    align-items: start;
  }
  .call-tile {
    grid-row: 1 / span 2;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--sunken);
    border: var(--px) solid var(--outline);
  }
  .call-tile .avatar { width: 100%; height: auto; aspect-ratio: 1; border: 0; }
  .call-name {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 4px;
    padding: 1px 4px;
    font-size: 15px;
    line-height: 1.2;
    background: rgba(0, 0, 0, 0.75);
  }
  .call-text { font-size: 22px; }
  .workarounds { grid-template-columns: 1fr 1fr; }

  /* While a mini-game runs, the caller shrinks to give it the room. */
  .playing .call-side { grid-template-columns: 56px 1fr; }
  .playing .call-name { display: none; }
  .playing .call-text { font-size: 18px; }
  .tz-slots { max-height: 300px; }
}

/* ---------- Phones on their side, and short windows: two columns ---------- */

@media (orientation: landscape) and (max-height: 639px) {
  #game {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "stats feed"
      "scene feed"
      "actions feed";
  }
  /* The stage's children join the panel grid, and the call covers the panel. */
  .stage, #game[data-mode="title"] .stage { display: contents; }
  .stats { grid-area: stats; padding: 6px 8px; gap: 4px 10px; }
  .scene { grid-area: scene; aspect-ratio: auto; max-height: none; min-height: 0; }
  .feed { grid-area: feed; }
  .actions { grid-area: actions; }
  .btn-action { min-height: 48px; }
  #game[data-mode="title"] .scene { grid-area: 1 / 1 / -1 / -1; }
  #game[data-call] .actions { display: grid; }

  .call { padding: 8px; }
  .call-window { margin: 0 auto; }
  .call-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 14px; }
  .tz-slots { max-height: none; }
}

/* ---------- Display font ---------- */

.title, .card-title, .stamp {
  font-family: var(--font-display);
  font-weight: 700;
}
