/* ===================================================================
   Pleasant Hollow — ledger & storefront aesthetic
   cream paper, ink type, terracotta accents, mono ledger figures
   =================================================================== */

:root {
  --paper:      #f4ecdc;
  --paper-deep: #ece1c9;
  --paper-card: #faf4e6;
  --ink:        #2c2113;
  --ink-soft:   #6f5d44;
  --ink-faint:  #a4937a;
  --rule:       #d8c9ab;
  --accent:     #bc4a23;
  --accent-deep:#93371a;
  --sage:       #7d9762;
  --gold:       #c8932b;
  --bad:        #a33327;
  --good:       #4a7240;

  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "Spline Sans Mono", "Courier New", monospace;

  --shadow-card: 0 1px 0 rgba(255,255,255,.7) inset, 0 2px 10px rgba(60,42,18,.10), 0 1px 2px rgba(60,42,18,.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  /* faint paper grain */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.15 0 0 0 0 0.05 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

/* =================== HEADER =================== */

#topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 16px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 46px; height: 46px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.5px;
  background: var(--accent);
  color: var(--paper-card);
  box-shadow: 2px 2px 0 var(--ink);
}

.brand-words h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.4px;
  line-height: 1.05;
  white-space: nowrap;
}

.tagline {
  font-size: 10px;
  white-space: nowrap;
  color: var(--ink-faint);
  letter-spacing: .08em;
  font-style: italic;
  font-family: var(--font-display);
}

.hud { display: flex; gap: 8px; margin-left: auto; }

.hud-stat {
  min-width: 108px;
  padding: 5px 12px 6px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background:
    linear-gradient(var(--paper-card), var(--paper-card)) padding-box,
    var(--rule);
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-faint);
}

.hud-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.hud-cash .hud-value { color: var(--accent-deep); }
.hud-cash.broke .hud-value { color: var(--bad); }

.hud-sub {
  font-size: 10px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

#hud-county[hidden] { display: none; }
#hud-county .hud-value { color: var(--sage); }

.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--good);
  margin-right: 5px;
  vertical-align: 1px;
  animation: live-pulse 2.2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,114,64,.5); }
  50% { opacity: .55; box-shadow: 0 0 0 3px rgba(74,114,64,0); }
}
.hud-sub.up   { color: var(--good); }
.hud-sub.down { color: var(--bad); }

#postcard-btn {
  height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--accent);
  color: var(--paper-card);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(44,33,19,.25);
  transition: transform .08s ease, box-shadow .08s ease;
}
#postcard-btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(44,33,19,.3); }
#postcard-btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(44,33,19,.25); }

#feedback-btn {
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(44,33,19,.25);
  transition: transform .08s ease, box-shadow .08s ease;
}
#feedback-btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(44,33,19,.3); }
#feedback-btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(44,33,19,.25); }

.speed-controls { display: flex; align-items: center; gap: 6px; }

.speed-btn {
  width: 38px; height: 38px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: transform .08s ease, background .12s ease;
  box-shadow: 2px 2px 0 rgba(44,33,19,.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.speed-btn:hover { transform: translate(-1px,-1px); }
.speed-btn.active {
  background: var(--ink);
  color: var(--paper-card);
  box-shadow: none;
  transform: translate(1px,1px);
}

.day-dial {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: conic-gradient(var(--gold) 0deg, var(--gold) 0deg, var(--paper-deep) 0deg);
  position: relative;
  margin-left: 4px;
  overflow: hidden;
}
.day-dial-fill {
  position: absolute; inset: 0;
  border-radius: 50%;
}
.day-dial::after {
  content: "";
  position: absolute; inset: 7px;
  border-radius: 50%;
  background: var(--paper-card);
  border: 1px solid var(--rule);
}

/* =================== LAYOUT =================== */

#layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 286px;
  gap: 10px;
}

.card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -.2px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 9px;
}

.card-footnote {
  font-size: 9.5px;
  color: var(--ink-faint);
  margin-top: 8px;
  font-style: italic;
  font-family: var(--font-display);
}

/* ---- sidebar ---- */

#sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}

#build-list { display: flex; flex-direction: column; gap: 5px; }

.build-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  color: var(--ink);
  transition: background .1s ease, border-color .1s ease;
}
.build-item:hover { background: var(--paper-deep); }
.build-item.selected {
  border-color: var(--accent);
  background: #f7e3d6;
  box-shadow: 0 0 0 1px var(--accent);
}
.build-item.locked, .build-item.cant-afford { opacity: .45; cursor: not-allowed; }

.build-item.nudge { animation: nudge-pulse 1.6s ease-in-out infinite; }
@keyframes nudge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(188,74,35,0); border-color: var(--rule); }
  50% { box-shadow: 0 0 0 3px rgba(188,74,35,.25); border-color: var(--accent); }
}

.build-emoji {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 17px;
  background: var(--paper-deep);
  border-radius: 7px;
  border: 1px solid var(--rule);
  flex: 0 0 auto;
}

.build-info { flex: 1 1 auto; min-width: 0; }
.build-name { font-size: 12px; font-weight: 700; display: block; }
.build-need { font-size: 9.5px; color: var(--ink-faint); display: block; }
.build-cost { font-size: 11.5px; font-weight: 700; color: var(--accent-deep); white-space: nowrap; }
.build-lock { font-size: 9.5px; color: var(--ink-faint); white-space: nowrap; }

.tool-row { display: flex; gap: 5px; margin-top: 6px; }

.tool-btn {
  flex: 1;
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tool-btn svg { flex: 0 0 auto; }
.tool-btn:hover { background: var(--paper-deep); }
.tool-btn.selected {
  border-color: var(--accent);
  background: #f7e3d6;
  box-shadow: 0 0 0 1px var(--accent);
}
.tool-cost { color: var(--accent-deep); font-weight: 700; }

/* ---- demand ---- */

.demand-row { margin-bottom: 7px; }

.demand-head {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  margin-bottom: 2px;
}
.demand-name { font-weight: 700; }
.demand-figures { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.demand-none { color: var(--bad); font-weight: 700; }

.demand-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  overflow: hidden;
  display: flex;
}
.demand-met   { background: var(--sage); height: 100%; }
.demand-unmet { background: var(--bad); opacity: .65; height: 100%; }

/* ---- extras ---- */

#extras-card { display: flex; flex-direction: column; gap: 8px; }

.toggle-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; cursor: pointer;
}
.toggle-row input { accent-color: var(--accent); }

.ghost-btn {
  padding: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: transparent;
  border: 1px dashed var(--ink-faint);
  border-radius: 8px;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ghost-btn svg { flex: 0 0 auto; }
.ghost-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ---- map ---- */

#map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #5e7a4a;
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(44,33,19,.25), 0 0 0 4px var(--paper-deep);
  overflow: hidden;
}

#map {
  display: block;
  cursor: crosshair;
}

#tile-tip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper-card);
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 5;
  transform: translate(-50%, -130%);
}

/* ---- inspector ---- */

#inspector {
  min-height: 0;
  overflow-y: auto;
}

.inspector-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  color: var(--ink-faint);
  padding: 20px 8px;
  gap: 10px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
}
.inspector-empty-mark { font-size: 34px; }

.insp-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }

.insp-emoji {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 9px;
  flex: 0 0 auto;
}

.insp-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: -.2px;
}

.insp-type { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .1em; }

.insp-rep { font-size: 12px; color: var(--gold); letter-spacing: 2px; margin: 2px 0 8px; }
.insp-rep .rep-word { color: var(--ink-soft); font-size: 10px; letter-spacing: normal; margin-left: 5px; }

.insp-stats {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 8px 0;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.insp-stat.wide { grid-column: 1 / -1; }
.insp-stat .k { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); display: block; }
.insp-stat .v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.v.pos { color: var(--good); }
.v.neg { color: var(--bad); }

.insp-control { margin-bottom: 11px; }

.insp-control-label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  margin-bottom: 4px;
}
.insp-control-label .k { text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.insp-control-label .v { font-weight: 700; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 28px; height: 28px;
  border: 1.5px solid var(--ink);
  background: var(--paper-card);
  border-radius: 7px;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font-mono);
  color: var(--ink);
}
.stepper button:hover:not(:disabled) { background: var(--paper-deep); }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.stepper .stepper-val { font-weight: 700; font-size: 14px; min-width: 20px; text-align: center; }
.stepper .stepper-note { font-size: 10px; color: var(--ink-faint); }

.seg { display: flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1;
  padding: 6px 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  border-right: 1px solid var(--rule);
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--ink); color: var(--paper-card); }

.quality-pips { display: flex; gap: 4px; align-items: center; }
.pip {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
}
.pip.filled { background: var(--gold); }

.action-btn {
  width: 100%;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(44,33,19,.25);
  transition: transform .08s ease;
  margin-top: 6px;
}
.action-btn:hover:not(:disabled) { transform: translate(-1px,-1px); }
.action-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.action-btn.danger { color: var(--bad); border-color: var(--bad); }

.insp-note { font-size: 10.5px; color: var(--ink-soft); font-style: italic; font-family: var(--font-display); margin-top: 8px; }

.needbar-row { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; font-size: 10.5px; }
.needbar-row .nb-name { width: 64px; color: var(--ink-soft); }
.needbar-track { flex: 1; height: 6px; background: var(--paper-deep); border-radius: 3px; overflow: hidden; border: 1px solid var(--rule); }
.needbar-fill { height: 100%; border-radius: 3px; }

/* =================== LEDGER LOG =================== */

#ledger {
  flex: 0 0 auto;
  height: 92px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.ledger-title {
  position: absolute;
  top: -8px; left: 16px;
  background: var(--paper-card);
  padding: 0 8px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ink-faint);
}

#partyline-btn {
  position: absolute;
  top: -14px; right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--paper-card);
  color: var(--accent-deep);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(44,33,19,.18);
  transition: transform .08s ease, background .12s ease;
  z-index: 2;
}
#partyline-btn:hover { transform: translate(-1px,-1px); background: #f7e3d6; }
#partyline-btn:active { transform: translate(1px,1px); box-shadow: none; }

#log-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  font-size: 11px;
}

.log-line {
  padding: 1.5px 0;
  border-bottom: 1px dotted var(--rule);
  color: var(--ink-soft);
}
.log-line .log-day { color: var(--ink-faint); margin-right: 8px; font-size: 9.5px; }
.log-line.good { color: var(--good); }
.log-line.bad  { color: var(--bad); }
.log-line.money { color: var(--accent-deep); font-weight: 500; }
.log-line.hand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink);
}

/* =================== TOASTS =================== */

#toasts {
  position: fixed;
  top: 86px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: var(--paper-card);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  max-width: 290px;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  border-left: 4px solid var(--gold);
  animation: toast-in .3s cubic-bezier(.2,.9,.3,1.2), toast-out .4s ease 5s forwards;
}
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--sage); }

@keyframes toast-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(20px); opacity: 0; } }

/* =================== OVERLAYS =================== */

#overlay[hidden], #gameover[hidden], #partyline[hidden], #register[hidden] { display: none; }

#overlay, #gameover, #partyline, #register {
  position: fixed;
  inset: 0;
  background: rgba(44,33,19,.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
}

.overlay-card {
  width: min(480px, 92vw);
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 8px 8px 0 rgba(44,33,19,.45);
  padding: 30px 36px;
  text-align: center;
  animation: card-in .45s cubic-bezier(.2,.9,.3,1.15);
}

@keyframes card-in { from { transform: translateY(26px) scale(.96); opacity: 0; } }

.overlay-rule {
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 14px);
  margin: 6px 0 14px;
}
.overlay-card .overlay-rule:last-child { margin: 18px 0 0; }

.overlay-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 38px;
  letter-spacing: -1px;
  line-height: 1;
}

.overlay-sub {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 4px 0 16px;
}

.overlay-county {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .06em;
  margin: -10px 0 14px;
}

.overlay-body {
  text-align: left;
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 20px;
}
.overlay-body strong { color: var(--ink); }
.overlay-fineprint {
  font-size: 10px !important;
  color: var(--ink-faint) !important;
  font-style: italic;
  font-family: var(--font-display);
  text-align: center;
  margin-top: 4px;
}
.overlay-body em { font-family: var(--font-display); }

.primary-btn {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 28px;
  background: var(--accent);
  color: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.primary-btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.primary-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

/* scrollbars, in keeping */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* =================== RESPONSIVE =================== */

/* tighter desktop — shrink chrome before anything reflows */
@media (max-width: 1380px) {
  #topbar { gap: 12px; }
  .hud { gap: 6px; }
  .hud-stat { min-width: 84px; padding: 5px 9px 6px; }
  .hud-value { font-size: 15px; }
  #postcard-btn, #feedback-btn { padding: 0 10px; font-size: 11px; gap: 5px; }
  #layout { grid-template-columns: 208px minmax(0, 1fr) 248px; }
}

/* small laptops & half-screens — the page scrolls, the map goes on top */
@media (max-width: 1150px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
  #topbar { flex-wrap: wrap; row-gap: 8px; }
  .hud { margin-left: 0; flex-wrap: wrap; }
  #layout { grid-template-columns: 1fr 1fr; }
  #map-wrap {
    grid-row: 1;
    grid-column: 1 / -1;
    width: 100%;
    aspect-ratio: 936 / 612;
  }
  #sidebar { overflow: visible; }
  #inspector { max-height: none; min-height: 220px; overflow: visible; }
  .inspector-empty { height: auto; padding: 30px 8px; }
  #ledger { height: auto; }
  #log-scroll { max-height: 110px; min-height: 70px; }
}

/* phones & narrow windows — single column */
@media (max-width: 700px) {
  #app { padding: 8px; gap: 8px; }
  #topbar { padding: 8px 10px; }
  .brand-words h1 { font-size: 17px; }
  .tagline { display: none; }
  .brand-mark { width: 36px; height: 36px; font-size: 12px; }
  .hud-stat { flex: 1 1 30%; min-width: 0; }
  #layout { grid-template-columns: 1fr; gap: 8px; }
  #postcard-btn, #feedback-btn { height: 34px; }
  .speed-btn, .day-dial { width: 34px; height: 34px; }
}

/* =================== THE BOOKS =================== */

.books-breakdown {
  border-top: 1px solid var(--rule);
  padding-top: 8px;
  margin-bottom: 10px;
  font-size: 11px;
}
.bb-row { display: flex; justify-content: space-between; padding: 1.5px 0; color: var(--ink-soft); }
.bb-row .pos { color: var(--good); }
.bb-row .neg { color: var(--bad); }
.bb-total { border-top: 1px dotted var(--rule); margin-top: 3px; padding-top: 4px; font-weight: 700; color: var(--ink); }

.spark-wrap { margin-bottom: 10px; }
.spark-wrap canvas { display: block; width: 100%; }

.books-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }

.books-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 7px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  text-align: left;
}
.books-row:hover { background: var(--paper-deep); }
.books-ic { color: var(--ink-soft); display: grid; place-items: center; }
.books-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.books-trend { width: 14px; text-align: center; color: var(--ink-faint); }
.books-trend.pos { color: var(--good); }
.books-trend.neg { color: var(--bad); }
.books-net { font-variant-numeric: tabular-nums; font-weight: 700; }
.books-net.pos { color: var(--good); }
.books-net.neg { color: var(--bad); }
.books-alert { color: var(--gold); }

.books-opp {
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--paper-deep);
  border: 1px dashed var(--rule);
  border-radius: 7px;
  padding: 7px 9px;
  margin-bottom: 8px;
}
.books-opp strong { color: var(--accent-deep); }

.books-neighbors {
  font-size: 10px;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-display);
  margin-bottom: 6px;
}


/* =================== PARTY LINE =================== */

.partyline-card { width: min(440px, 92vw); padding: 24px 28px; }

#partyline-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 48vh;
  overflow-y: auto;
  text-align: left;
}

.partyline-msg {
  padding: 8px 11px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13.5px;
  text-align: left;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}
.partyline-msg:hover { background: var(--paper-deep); border-color: var(--accent); }


/* =================== CLIPPINGS =================== */

#clipping[hidden] { display: none; }

#clipping {
  position: fixed;
  bottom: 118px;
  left: 50%;
  width: min(540px, 84vw);
  transform: translateX(-50%) rotate(-0.6deg);
  background: var(--paper-card);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 5px 0 rgba(44,33,19,.3), 0 10px 30px rgba(44,33,19,.25);
  padding: 12px 18px 13px;
  z-index: 60;
  cursor: pointer;
  animation: clipping-in .5s cubic-bezier(.2,.9,.3,1.15);
}

@keyframes clipping-in {
  from { transform: translateX(-50%) translateY(26px) rotate(-0.6deg); opacity: 0; }
}

.clipping-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .2em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

#clipping-text {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink);
}

#clipping.hand #clipping-text {
  font-style: italic;
  font-size: 17px;
}

/* fresh ink: the newest ledger line announces itself */
.log-line.newest {
  color: var(--ink);
  font-weight: 500;
  animation: log-flash 1.4s ease;
}
.log-line.newest.good { color: var(--good); }
.log-line.newest.bad { color: var(--bad); }
.log-line.newest.money { color: var(--accent-deep); }

@keyframes log-flash {
  0% { background: #f3e2c8; }
  100% { background: transparent; }
}


/* =================== COUNTY REGISTER =================== */

.register-card { width: min(560px, 94vw); padding: 24px 28px; }

#register-list {
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.register-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.register-row .rn { color: var(--ink-faint); min-width: 64px; }
.register-row .rstats { flex: 1; }
.register-row .rlive { font-size: 10px; color: var(--good); }
.register-row.me { border-color: var(--accent); background: #f7e3d6; }
.register-row.me .rn { color: var(--accent-deep); font-weight: 700; }
.register-row.dead { opacity: .55; }
.register-row.dead .rstats { text-decoration: line-through; }
.register-row.dead .rlive { color: var(--bad); }

#hud-county { cursor: pointer; }
#hud-county:hover { background: var(--paper-deep); }
#hud-cash { cursor: pointer; }
#hud-cash:hover { background: var(--paper-deep); }

.back-books {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 4px 8px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: transparent;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  color: var(--ink-soft);
  cursor: pointer;
}
.back-books:hover { border-color: var(--ink); color: var(--ink); }

/* =================== EMERGENCY BROADCAST =================== */

#broadcast[hidden] { display: none; }

#broadcast {
  position: fixed;
  inset: 0;
  z-index: 400;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, #131a10 0%, #060904 75%);
  display: grid;
  place-items: center;
  animation: bc-on .35s steps(3) , bc-flicker 4s steps(2) infinite;
  cursor: none;
}

@keyframes bc-on { from { opacity: 0; transform: scaleY(0.02); } }
@keyframes bc-flicker { 0%, 100% { opacity: 1; } 92% { opacity: 1; } 94% { opacity: .82; } 96% { opacity: 1; } }

.bc-inner {
  text-align: center;
  font-family: var(--font-mono);
  color: #cfe6c0;
  text-shadow: 0 0 8px rgba(160,230,150,.6);
  max-width: 720px;
  padding: 20px;
}

.bc-head {
  font-size: 13px;
  letter-spacing: .22em;
  border-top: 2px solid #cfe6c0;
  border-bottom: 2px solid #cfe6c0;
  padding: 8px 0;
  margin-bottom: 34px;
}

#bc-lines p {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .1em;
  margin: 14px 0;
  opacity: 0;
  animation: bc-line .25s steps(2) forwards;
}

@keyframes bc-line { to { opacity: 1; } }

.bc-foot {
  margin-top: 40px;
  font-size: 10.5px;
  letter-spacing: .18em;
  color: rgba(207,230,192,.55);
}
