/* ==========================================================
   我的押金一分都别想扣 · 「南城像素手帐」视觉系统
   方向：像素场景 + 租客手帐。纸面、墨线、硬阴影、台灯暖黄、印章红。
   ========================================================== */

:root {
  /* palette */
  --paper: #efe5d0;
  --paper-grid: #e3d6bb;
  --card: #fbf6ea;
  --card-2: #f5ecd8;
  --ink: #26241f;
  --ink-2: #4b4840;
  --ink-3: #7a7364;
  --night: #1c3335;
  --night-2: #284748;
  --night-3: #3a5d5c;
  --lamp: #f2b84b;
  --lamp-soft: #fbe3a8;
  --stamp: #c4432d;
  --stamp-soft: #f6d8cf;
  --leaf: #3d7a52;
  --leaf-soft: #d6ead9;
  --sky: #8fc3c1;

  /* type */
  --font-display: "ZCOOL QingKe HuangYou", "PingFang SC", "Microsoft Yahei", sans-serif;
  --font-pixel: "VT323", ui-monospace, "SF Mono", monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: clamp(20px, 1.2rem + .6vw, 26px);
  --text-hero: clamp(34px, 1.4rem + 4.2vw, 58px);

  /* shape */
  --line: 2px solid var(--ink);
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 2px 2px 0 var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);

  /* space & motion */
  --gutter: 16px;
  --hud-h: 64px;
  --nav-h: 64px;
  --ease: cubic-bezier(.2, .9, .3, 1.2);
  --fast: 120ms;
  --normal: 220ms;

  color-scheme: light;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--night);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--night);
  font-size: var(--text-base);
  line-height: 1.6;
}
#app, main, .card, .receipt { min-width: 0; overflow-wrap: anywhere; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
h1, h2, h3, p { margin: 0 0 12px; }
h1, h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: .02em; line-height: 1.15; }
h1 { font-size: var(--text-hero); }
h2 { font-size: var(--text-lg); }
h3 { font-size: 18px; line-height: 1.35; }
p { line-height: 1.7; }
small, .muted { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.55; }
b { font-weight: 700; }

/* ---------- page shell ---------- */
#app {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  box-shadow: 0 0 0 2px var(--ink), 0 30px 80px #0006;
}

/* ---------- HUD ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 10px;
  background: var(--night);
  color: #f5ecd8;
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--night-3);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; image-rendering: pixelated; }
.brand strong { font-family: var(--font-display); font-weight: 400; font-size: 21px; line-height: 1; letter-spacing: .04em; white-space: nowrap; }
.brand strong span { color: var(--lamp); margin-left: 4px; }
.hud-stats { display: flex; align-items: center; gap: 8px; }
.stat {
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 10px;
  border: 2px solid #0b1718;
  border-radius: var(--radius);
  background: var(--night-2);
  box-shadow: inset 0 -2px 0 #0003;
  white-space: nowrap;
}
.stat small { color: #b9c7c0; font-size: 12px; }
.stat b { font-family: var(--font-pixel); font-weight: 400; font-size: 25px; line-height: .8; color: var(--lamp); letter-spacing: .02em; }
.deadlineInfo b { color: var(--sky); }
.meters { gap: 12px; align-items: center; }
.meter { display: inline-flex; align-items: center; gap: 3px; }
.meter em { font-style: normal; font-size: 12px; color: #b9c7c0; margin-right: 3px; }
.meter i { width: 8px; height: 12px; background: #0f2122; box-shadow: inset 0 0 0 1px #4a6766; }
.meter i.on { background: var(--leaf-soft); box-shadow: inset 0 -3px 0 #8fbf9a; }
.meter .trend { font-family: var(--font-pixel); font-size: 18px; margin-left: 2px; }
.meter .trend.up { color: #9fe0ad; }
.meter .trend.down { color: #ff9a85; }
.detailsBtn {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: var(--radius);
  background: var(--night-2);
  border: 2px solid #0b1718;
  color: #f5ecd8;
  transition: background var(--fast);
}
.detailsBtn:hover { background: var(--night-3); }
.detailsBtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.save-warning:not([hidden]) {
  position: fixed; left: 0; right: 0; top: var(--hud-h); z-index: 30;
  padding: 6px var(--gutter); background: var(--stamp); color: #fff; font-size: var(--text-sm); text-align: center;
}
body[data-phase="intro"] .hud-stats { display: none; }
body[data-phase="intro"] .brand strong span { display: inline; }

/* ---------- scene ---------- */
#scene {
  position: relative;
  margin: var(--gutter) var(--gutter) 0;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  background: #121d1f;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 4;
}
canvas { display: block; }
#world { width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; }
#sceneLabel {
  position: absolute; left: 10px; top: 10px;
  max-width: calc(100% - 20px);
  padding: 3px 10px 4px;
  background: var(--lamp);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 700;
  transform: rotate(-1.5deg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scene-tip {
  position: absolute; right: 10px; bottom: 10px;
  padding: 3px 9px;
  border-radius: 3px;
  background: #0d1a1bd9;
  color: var(--lamp-soft);
  font-size: 12px;
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--normal), transform var(--normal);
  pointer-events: none;
}
#scene.is-interactive #world { cursor: crosshair; }
#scene.is-interactive .scene-tip { opacity: 1; transform: none; }
.scene-hotspots { display: none; }
.scene-flash { position: absolute; inset: 0; background: #fff; pointer-events: none; animation: flash .35s ease-out forwards; z-index: 4; }

/* keep the room in view while inspecting / photographing / at move-out */
.stage { position: relative; z-index: 4; }
body[data-phase="inspect"] .stage,
body[data-phase="photo"] .stage,
body[data-phase="moveout"] .stage { position: sticky; top: calc(var(--hud-h) + 8px); }
.stage-info { display: none; }

/* ---------- content column ---------- */
main {
  padding: 22px var(--gutter) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px));
  max-width: 760px;
  margin: 0 auto;
}

.stepper {
  display: flex; gap: 4px;
  margin: 0 0 18px; padding: 0;
  list-style: none;
  counter-reset: step;
}
.stepper li {
  flex: 1; min-width: 0;
  padding-top: 8px;
  border-top: 4px solid #cbbd9f;
  color: var(--ink-3);
  font-size: 12px; text-align: center; white-space: nowrap;
}
.stepper li.done { border-color: var(--night-3); color: var(--ink-2); }
.stepper li.now { border-color: var(--lamp); color: var(--ink); font-weight: 800; }
.stepper li.now::before { content: "▶ "; color: var(--stamp); font-size: 10px; }

.tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 9px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: var(--leaf);
  background: var(--card);
  font-size: 12px; font-weight: 700;
  white-space: normal;
}
.money { font-family: var(--font-pixel); font-weight: 400; font-size: 34px; color: var(--stamp); line-height: 1.1; }
.hint { color: #a1661a; font-weight: 700; }
.world-note { font-size: var(--text-sm); color: var(--ink-3); }

/* cards */
.card {
  margin: 14px 0;
  padding: 16px 18px;
  background: var(--card);
  border: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card > b:first-child { font-family: var(--font-display); font-weight: 400; font-size: 20px; letter-spacing: .03em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.row > * { flex: 1 1 150px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choices { display: grid; gap: 10px; margin: 14px 0; }
.choices .btn { text-align: left; }

/* buttons: chunky ink outline + hard shadow that presses down */
.btn {
  position: relative;
  min-height: 46px;
  padding: 11px 16px;
  border: var(--line);
  border-radius: var(--radius);
  background: var(--night);
  color: #fbf3df;
  font-weight: 800;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); background: var(--night-2); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn.alt { background: var(--card); color: var(--ink); }
.btn.alt:hover:not(:disabled) { background: var(--lamp-soft); }
.btn.warn { background: var(--stamp); color: #fff; }
.btn.warn:hover:not(:disabled) { background: #a93522; }
.btn:disabled { cursor: not-allowed; opacity: .5; box-shadow: none; }
.btn.photo-done:disabled, .btn.spot.clear:disabled { opacity: 1; background: var(--leaf-soft); color: #23573a; border-color: #23573a; }
.btn.spot.found:disabled { opacity: 1; background: var(--stamp-soft); color: #8e2a1a; border-color: #8e2a1a; }
.btn.photo-missed:disabled { opacity: .55; background: #ddd3bf; color: var(--ink-3); border-style: dashed; }

/* speech */
.dialog {
  position: relative;
  margin: 12px 0;
  padding: 12px 15px;
  background: #fffdf6;
  border: var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  line-height: 1.65;
}
.dialog b { color: var(--night-3); }
.dialog.danger, .result-item.danger { background: var(--stamp-soft); border-color: var(--stamp); color: #6f2214; }
.dialog.danger b { color: var(--stamp); }
.portraitRow { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.portraitRow canvas {
  width: 60px; height: 60px; flex: 0 0 60px;
  image-rendering: pixelated;
  background: var(--sky);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.portraitRow .dialog { flex: 1; min-width: 0; margin: 0; }
.portraitRow .dialog::before {
  content: ""; position: absolute; left: -9px; top: 18px;
  width: 14px; height: 14px;
  background: inherit;
  border-left: var(--line); border-bottom: var(--line);
  transform: rotate(45deg);
}
.portraitRow + .portraitRow .dialog { background: var(--card-2); }

.result-item {
  margin: 10px 0;
  padding: 10px 13px;
  border: 2px solid var(--leaf);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: var(--leaf-soft);
  color: #1f4630;
  line-height: 1.6;
  animation: phase-in .25s ease-out both;
}
.result-item.danger { border-left-width: 6px; }
.finding-log { margin: 4px 0 12px; }
.finding-log summary { cursor: pointer; color: var(--ink-3); font-size: var(--text-sm); padding: 4px 0; }
.finding-log .result-item { animation: none; opacity: .85; font-size: 15px; }

select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: var(--line) !important;
  border-radius: var(--radius) !important;
  background: #fffdf6;
  color: var(--ink);
  font: inherit;
}

.actionDock {
  position: sticky;
  bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  display: flex; gap: 10px;
  margin: 16px calc(var(--gutter) * -1) 0;
  padding: 10px var(--gutter);
  background: linear-gradient(#efe5d000, var(--paper) 30%);
}
.actionDock .btn { flex: 1; min-width: 0; }

/* ---------- listings (browse) ---------- */
.rental-search {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0 12px; padding: 12px 14px;
  background: #fffdf6;
  border: var(--line);
  border-radius: 999px;
  color: var(--ink-3); font-size: var(--text-sm);
}
.rental-search b { color: var(--ink); }
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.filterbar button {
  min-height: 36px;
  padding: 5px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px; font-weight: 700;
  transition: background var(--fast);
}
.filterbar button:hover { background: var(--lamp-soft); }
.filterbar button.active { background: var(--ink); color: var(--lamp); }
.grid:has(> .listing) { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.listing { display: flex; flex-direction: column; margin: 0; padding: 0; overflow: hidden; transition: transform var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
.listing:hover { transform: translate(-2px, -2px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.listing .body { display: flex; flex-direction: column; flex: 1; padding: 12px 14px 14px; }
.listing .body .btn { margin-top: auto; }
.listing h3 { margin: 6px 0 4px; font-size: 17px; }
.listing .money { font-size: 32px; color: var(--ink); }
.listing .money small { font-family: var(--font-body); color: var(--ink-3); }
.listing .muted { margin: 6px 0 12px; line-height: 1.6; }
.listing.excluded { filter: grayscale(1); opacity: .55; }
.photo {
  position: relative;
  aspect-ratio: 1.6;
  border-bottom: var(--line);
  background-image: linear-gradient(var(--photo-tint, transparent), var(--photo-tint, transparent)), var(--listing-image);
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
}
.photo .adbed, .photo .adplant, .photo .adfurniture { display: none; }
.photo .adbadge {
  position: absolute; left: 8px; top: 8px; z-index: 2;
  padding: 2px 8px;
  background: var(--lamp);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 3px;
  font-size: 11px; font-weight: 800;
  transform: rotate(-2deg);
}

/* ---------- chat ---------- */
.chat-preview {
  display: flex; width: 100%; align-items: center; gap: 12px;
  margin: 0 0 18px; padding: 10px 14px;
  text-align: left;
  background: var(--night);
  color: #f5ecd8;
  border: var(--line);
  border-radius: 14px 14px 14px 4px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--fast) var(--ease);
}
.chat-preview:hover { transform: translateY(-1px); }
.chat-preview .bubble-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; background: var(--lamp); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; }
.chat-preview .bubble-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.chat-preview strong, .chat-preview small { display: block; }
.chat-preview strong { font-size: 13px; color: var(--lamp); }
.chat-preview small { color: #d8e1dc; margin-top: 2px; font-size: 14px; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-preview .chat-arrow { margin-left: auto; color: var(--lamp); font-size: 22px; }
.chat-thread .btn { margin-bottom: 8px; }
.chat-thread .dialog { margin: 8px 0; border-radius: 4px 14px 14px 14px; }
.chat-thread .muted { font-size: 15px; font-family: var(--font-pixel); }

/* ---------- bottom nav ---------- */
.phonebar {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; gap: 6px;
  min-height: var(--nav-h);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--night);
  border-top: 3px solid var(--ink);
}
.phonebar button {
  position: relative;
  flex: 1 1 0; min-width: 0; min-height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: var(--radius);
  background: transparent;
  color: #a9bab4;
  font-size: 13px; font-weight: 700; line-height: 1;
  transition: background var(--fast), color var(--fast);
}
.phonebar button:hover { background: var(--night-2); color: #f5ecd8; }
.phonebar button.active { background: var(--lamp); color: var(--ink); }
.phonebar svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: square; stroke-linejoin: miter; }
.navLabel { display: block; }
.chatBadge {
  position: absolute; top: 2px; right: calc(50% - 26px);
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--stamp); color: #fff;
  border: 2px solid var(--night);
  border-radius: 9px;
  font-family: var(--font-pixel); font-size: 15px; line-height: 14px;
}
.newmsg { animation: messagePop .35s ease-out; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 16px;
  background: #0d1a1bcc;
  backdrop-filter: blur(3px);
  overflow: auto;
  animation: fade-in .18s ease-out both;
}
.modal > div {
  width: 100%;
  max-width: min(560px, calc(100vw - 32px));
  max-height: min(86dvh, calc(100dvh - 32px));
  overflow: auto;
  padding: 22px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 8px 8px 0 #000a;
  animation: pop-in .26s var(--ease) both;
}
.modal h2 { padding-bottom: 10px; border-bottom: 2px dashed #cbbd9f; }
.modal .btn { margin-top: 8px; }
.modal .row .btn { margin-top: 0; }

/* ---------- evidence / album ---------- */
.evidenceGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.evidenceCard {
  padding: 7px 7px 10px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast);
}
.evidenceCard:nth-child(odd) { transform: rotate(-1deg); }
.evidenceCard:nth-child(even) { transform: rotate(1deg); }
.evidenceCard:hover { transform: rotate(0) translateY(-3px); box-shadow: var(--shadow); }
.evidenceCard b, .evidenceCard small { display: block; margin-top: 6px; line-height: 1.35; }
.evidenceCard b { font-size: 14px; }
.evidenceCard small { font-size: 14px; font-family: var(--font-pixel); }
.evidencePreview { display: block; height: 70px; background: #c3b69a center / cover no-repeat; image-rendering: pixelated; }
.documentShot { display: block; height: 100%; padding: 7px; background: var(--card-2); color: var(--ink-2); overflow: hidden; font-size: 10px; font-weight: 700; }
.documentShot strong { display: block; color: var(--night-3); font-size: 11px; }
.documentShot i { display: block; margin-top: 4px; height: 3px; background: #cbbd9f; }
.documentShot i:nth-of-type(2) { width: 72%; }
.documentShot i:nth-of-type(3) { width: 86%; }
.polaroid {
  display: inline-block; width: 160px; margin: 8px; padding: 9px 9px 16px;
  background: #fff; border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
  vertical-align: top;
  line-height: 1.35; font-size: 14px;
}
.polaroid small { font-family: var(--font-pixel); font-size: 14px; }
.polaroid .shot { display: block; height: 84px; margin-bottom: 6px; background: #c5b89c; color: #594d3f; padding: 12px; font-weight: 700; image-rendering: pixelated; }
.polaroid.stamp { animation: proof-slam .4s ease-out both; }
.photo-toast {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  width: 118px; padding: 6px 6px 16px;
  background: #fff; border: 2px solid var(--ink); box-shadow: var(--shadow);
  font-size: 12px; color: var(--ink-2);
  transform: rotate(2deg); animation: photo-in .45s ease-out; pointer-events: none;
}
.photo-toast img { display: block; width: 100%; margin-bottom: 4px; image-rendering: pixelated; }

/* ---------- receipt ---------- */
.receipt {
  position: relative;
  max-width: 460px;
  margin: 18px auto 28px;
  padding: 24px 24px 30px;
  background: #fffef7;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
  --zig: 10px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--zig) 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--zig) 100%;
}
.receipt h1, .receipt h2 { text-align: center; }
.receipt h2 { letter-spacing: .3em; }
.receipt hr { border: 0; border-top: 2px dashed #b9ad94; margin: 14px 0; }
.receipt p { line-height: 1.95; }
.receipt .refund-value { font-family: var(--font-pixel); font-weight: 400; font-size: 40px; line-height: 1; color: var(--leaf); }
.receipt .deduct-value { font-family: var(--font-pixel); font-weight: 400; font-size: 30px; line-height: 1; color: var(--stamp); }
.stamp { animation: slam .35s ease-out; }
.victory-banner {
  position: relative; overflow: hidden;
  background: var(--lamp); color: var(--ink);
  border-color: var(--ink);
}
.victory-banner h2 { color: var(--ink); font-size: clamp(26px, 1.2rem + 2vw, 36px); }
.victory-banner .tag { background: var(--ink); color: var(--lamp); border-color: var(--ink); }
.victory-banner::after { content: "✦ ✧ ✦"; position: absolute; right: 14px; top: 10px; color: var(--stamp); font-size: 18px; animation: confetti .7s ease-out both; }

.progress { height: 12px; margin: 6px 0 12px; background: #ddd0b3; border: 2px solid var(--ink); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--lamp) 0 8px, #e2a535 8px 10px); }

/* ---------- intro ---------- */
body[data-phase="intro"] main > .tag { background: var(--ink); color: var(--lamp); border-color: var(--ink); }
body[data-phase="intro"] main > h1 { margin: 10px 0 18px; }
body[data-phase="intro"] main > h1 br + * , body[data-phase="intro"] main > h1 { text-shadow: 3px 3px 0 var(--lamp-soft); }
body[data-phase="intro"] main > p { font-size: 17px; color: var(--ink-2); max-width: 36em; }
body[data-phase="intro"] main > .card { background: var(--night); color: #f5ecd8; transform: rotate(-.6deg); margin-top: 22px; }
body[data-phase="intro"] main > .card .muted { color: #b9c7c0; }
body[data-phase="intro"] main > .card b:first-child { color: var(--lamp); font-size: 24px; }
body[data-phase="intro"] main > .card .btn { background: var(--lamp); color: var(--ink); font-size: 18px; padding: 12px 22px; }
body[data-phase="intro"] main > .card .btn:hover { background: #ffd174; }

/* ---------- motion ---------- */
.phase-enter { animation: phase-in .22s ease-out both; }
@keyframes phase-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes messagePop { 0% { transform: scale(.94); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes slam { from { transform: scale(.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes confetti { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
@keyframes photo-in { from { opacity: 0; transform: translateY(45px) rotate(6deg); } to { opacity: 1; transform: translateY(0) rotate(2deg); } }
@keyframes proof-slam { from { opacity: 0; transform: translateY(-28px) rotate(4deg) scale(1.12); } to { opacity: 1; transform: translateY(0) rotate(-2deg) scale(1); } }

/* ---------- desktop: room on the left, notebook on the right ---------- */
@media (min-width: 960px) {
  #app {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "hud hud" "scene main" "nav nav";
    column-gap: 8px;
  }
  .hud { grid-area: hud; }
  .stage,
  body[data-phase] .stage {
    grid-area: scene;
    align-self: start;
    position: sticky;
    top: calc(var(--hud-h) + 24px);
    margin: 24px 0 24px 24px;
    max-height: calc(100vh - var(--hud-h) - var(--nav-h) - 40px);
    max-height: calc(100dvh - var(--hud-h) - var(--nav-h) - 40px);
    overflow-y: auto;
    padding: 0 8px 8px 0;
    scrollbar-width: thin;
  }
  #scene { margin: 0; }
  .stage-info:not([hidden]) { display: block; margin-top: 22px; }
  main { grid-area: main; width: 100%; max-width: none; padding: 24px 28px calc(var(--nav-h) + 40px); }
  .phonebar { grid-area: nav; justify-content: center; }
  .phonebar button { flex: 0 1 140px; flex-direction: row; gap: 8px; font-size: 14px; }
  .actionDock { margin: 18px -28px 0; padding: 12px 28px; }
  .grid:has(> .listing) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .budgetInfo { display: none; }
}
@media (max-width: 600px) {
  :root { --gutter: 12px; }
  .hud { gap: 10px; flex-wrap: wrap; padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-bottom: 8px; }
  .brand { flex: 1 1 auto; }
  .brand strong { font-size: 18px; }
  .brand strong span { display: none; }
  .brand-mark { width: 24px; height: 24px; }
  .hud-stats { order: 3; flex: 1 1 100%; gap: 6px; }
  .stat { padding: 4px 7px; gap: 4px; }
  .stat small { font-size: 11px; }
  .stat b { font-size: 22px; }
  .deadlineInfo b { font-size: 16px; font-family: var(--font-body); font-weight: 800; line-height: 1.1; }
  .stat { flex: none; }
  .meters { min-width: 0; flex: 1 1 auto; padding-inline: 6px; }
  .meters { flex: 1; justify-content: space-around; gap: 6px; }
  .meter { gap: 2px; }
  .meter em { font-size: 11px; margin-right: 2px; }
  .meter i { width: 5px; height: 11px; }
  .detailsBtn { width: 38px; height: 38px; }
  #scene { margin: 10px var(--gutter) 0; box-shadow: var(--shadow); }
  #sceneLabel { font-size: 12px; left: 8px; top: 8px; }
  main { padding-top: 16px; }
  .stepper li { font-size: 11px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grid:has(> .listing) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .listing .body { padding: 10px; }
  .listing h3 { font-size: 15px; }
  .listing .money { font-size: 28px; }
  .listing .muted { font-size: 13px; }
  .listing .btn { padding: 9px 8px; }
  .card { padding: 14px; }
  .btn { padding: 10px 12px; }
  .portraitRow canvas { width: 50px; height: 50px; flex-basis: 50px; }
  .phonebar button { font-size: 12px; }
}
@media (max-width: 360px) {
  .grid:has(> .listing) { grid-template-columns: 1fr; }
  .meter em { display: none; }
}
/* very short screens: don't pin the room, it would eat the whole viewport */
@media (max-width: 959px) and (max-height: 700px) {
  body[data-phase] .stage { position: relative; top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* move-out: old wear settled in one batch by the move-in photos */
.batch-card { background: var(--leaf-soft); border-color: #23573a; }
.batch-card h3 { margin: 6px 0; font-family: var(--font-display); font-weight: 400; font-size: 22px; color: #1f4630; }
.batch-list { margin: 0 0 10px; padding: 0; list-style: none; columns: 2; column-gap: 16px; font-size: 15px; color: #23573a; }
.batch-list li { break-inside: avoid; padding: 2px 0; }
.batch-total { margin: 0; }
.batch-total b { font-family: var(--font-pixel); font-weight: 400; font-size: 30px; color: var(--leaf); }
.wear-note { display: block; margin-top: 4px; color: #8e2a1a; }
.btn.alt.wear-seen { border-style: dashed; border-color: var(--stamp); color: #8e2a1a; background: #fff3ee; }

/* ---------- tenant notebook under the room (desktop) ---------- */
.stage-info {
  position: relative;
  padding: 18px 20px 16px 26px;
  background: var(--card);
  border: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  background-image: linear-gradient(90deg, transparent 13px, #e5a79a 13px, #e5a79a 15px, transparent 15px);
}
.stage-info::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 92px; height: 22px;
  transform: translateX(-50%) rotate(-2deg);
  background: #f2b84bcc; border: 1px solid #c8932a66;
}
.si-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 2px dashed #cbbd9f; }
.si-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: .03em; }
.si-tag { flex: none; padding: 1px 8px; background: var(--ink); color: var(--lamp); border-radius: 3px; font-size: 12px; font-weight: 800; }
.si-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid #e6dcc6; font-size: 15px; }
.si-row span { color: var(--ink-2); }
.si-row b { font-family: var(--font-pixel); font-weight: 400; font-size: 24px; line-height: 1; white-space: nowrap; }
.si-row b.big { font-size: 28px; color: var(--night); }
.si-row b.lamp { color: #b07b12; }
.si-row b.leaf { color: var(--leaf); }
.si-row b.stamp { color: var(--stamp); }
.si-foot { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.si-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: si; }
.si-steps li { counter-increment: si; position: relative; padding: 8px 0 8px 40px; border-bottom: 1px solid #e6dcc6; font-size: 15px; color: var(--ink-2); }
.si-steps li::before { content: counter(si); position: absolute; left: 0; top: 7px; width: 28px; height: 28px; display: grid; place-items: center; background: var(--night); color: var(--lamp); border-radius: 4px; font-family: var(--font-pixel); font-size: 22px; }
.si-steps b { display: block; color: var(--ink); font-size: 16px; }
.si-spots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.si-spot { padding: 5px 9px; border: 1.5px dashed #bfb197; border-radius: 4px; font-size: 14px; color: var(--ink-3); }
.si-spot.clear { border-style: solid; border-color: #23573a; background: var(--leaf-soft); color: #23573a; }
.si-spot.found { border-style: solid; border-color: var(--stamp); background: var(--stamp-soft); color: #8e2a1a; font-weight: 700; }
.si-cells { display: flex; gap: 4px; margin: 4px 0 12px; }
.si-cells i { flex: 1; height: 14px; background: #e3d6bb; border: 1.5px solid #bfb197; }
.si-cells i.on { background: var(--night-3); border-color: var(--ink); }
.si-cells.film i { height: 22px; border-radius: 3px; }
.si-cells.film i.on { background: var(--lamp); }
.si-list { display: grid; gap: 4px; font-size: 15px; }
.si-list .ok { color: var(--leaf); font-weight: 700; }
.si-list .miss { color: var(--stamp); font-weight: 700; }
.si-bar { height: 12px; margin: 8px 0 2px; background: #ddd0b3; border: 2px solid var(--ink); border-radius: 3px; overflow: hidden; }
.si-bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--leaf) 0 8px, #2f6744 8px 10px); }
