*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #e4d7c4;
  color: #1c1915;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body.modal-open { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { cursor: default; }

:focus-visible {
  outline: 3px solid #e2b657;
  outline-offset: 2px;
}

::selection { background: #e2b657; color: #1c1915; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  background: #f3ecdf;
  box-shadow: 0 0 0 1px rgba(80, 50, 20, 0.06), 0 18px 50px rgba(60, 40, 20, 0.08);
}

h1, h2, .dayrow strong, .chance, .tile b {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.15;
  margin: 18px 0 8px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

.hint {
  margin: 0 0 10px;
  color: #4e483f;
  font-size: 0.92rem;
}

.center { text-align: center; }

.kicker {
  display: block;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9c4a28;
}

#screen-title { min-height: 100dvh; }

.title-hero {
  background: #1e3f36;
  color: #f4efe6;
  padding: calc(22px + env(safe-area-inset-top)) 16px 22px;
}

.title-hero .eyebrow { opacity: 0.75; }

.title-hero h1 {
  margin: 6px 0;
  font-size: 2.15rem;
  line-height: 1.05;
  color: #f4efe6;
}

.title-hero .addr {
  margin: 0;
  opacity: 0.88;
}

.mark { width: 72px; height: 58px; display: block; }

.title-body { padding: 16px 16px 28px; }

.lede { margin: 0 0 14px; }

.household {
  margin: 0 0 12px;
  padding: 12px 14px 4px;
  border-radius: 16px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 6px;
}

.stepper strong {
  min-width: 1.4ch;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  text-align: center;
}

.stepper button {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: #1e3f36;
  color: #f4efe6;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
}

.stepper button:disabled { opacity: 0.35; }

.scenario {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 108px;
  margin: 0 0 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.scenario .action-name,
.choice .action-name,
.action .action-name {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  margin: 2px 0;
}

.scenario .action-detail,
.choice .action-detail,
.action .action-detail,
.action .action-why {
  display: block;
  font-size: 0.92rem;
}

.scenario .action-detail,
.choice .action-detail,
.action .action-detail { color: #4e483f; }

.action-why {
  color: #8e2f24;
  font-weight: 700;
  margin-top: 2px;
}

.scenario.on { box-shadow: inset 0 0 0 3px #1e3f36; }

.scenario:active,
.action:active:not(:disabled),
.choice:active,
.primary:active:not(:disabled) { transform: scale(0.99); }

.primary:disabled,
.choice:disabled { opacity: 0.5; }

.secondary,
.danger,
.linkish,
.primary {
  display: block;
  width: 100%;
  border-radius: 14px;
  font-weight: 700;
}

.secondary {
  min-height: 52px;
  margin-top: 4px;
  border: 1px solid #1e3f36;
  background: transparent;
  color: #1e3f36;
}

.danger {
  min-height: 52px;
  margin-top: 8px;
  border: 1px solid #8e2f24;
  background: transparent;
  color: #8e2f24;
}

.linkish {
  min-height: 48px;
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: #1e3f36;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.primary {
  min-height: 56px;
  border: 0;
  background: #1e3f36;
  color: #f4efe6;
  font-size: 1.05rem;
  line-height: 1.2;
}

.primary .sub {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  opacity: 0.88;
}

#screen-game {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

body.playing {
  overflow: hidden;
  height: 100dvh;
}

body.playing .app {
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #1e3f36;
  color: #f4efe6;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
}

.topbar p { margin: 0; }

.topbar .addr {
  opacity: 0.82;
  font-size: 0.88rem;
}

.dayrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 6px 0;
}

.dayrow strong { font-size: 1.7rem; line-height: 1; }

.dayrow span { font-weight: 700; }

.lightbar {
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.lightbar > span {
  display: block;
  height: 100%;
  background: #e2b657;
  border-radius: inherit;
}

.lightlabel, .statusline {
  font-size: 0.85rem;
  margin-top: 4px !important;
}

.statusline.hot { color: #f0d78c; font-weight: 700; }

.flash {
  margin: 12px 12px 0;
  padding: 10px 12px;
  background: #fffaf4;
  border: 1px solid #e4d9c8;
  border-radius: 12px;
  color: #3f382f;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.flash:empty { display: none; }

.pad { padding: 4px 12px 12px; }

.banner {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8e4dc;
  color: #6e241c;
  font-weight: 700;
}

.ribbon {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #e5f2ea;
  color: #1e3f36;
  font-weight: 700;
}

.vital { margin: 0 0 10px; }

.vital-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}

.bar {
  height: 12px;
  margin-top: 4px;
  border-radius: 99px;
  background: #e7dccb;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stockline {
  margin: 0 0 8px;
  font-weight: 700;
}

.inv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tile {
  min-height: 74px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.tile.wide { grid-column: 1 / -1; }

.tile b {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tile span {
  display: block;
  margin-top: 4px;
  color: #4e483f;
  font-size: 0.82rem;
}

.tile em {
  font-style: normal;
  color: #6d675e;
}

.tile.zero {
  background: #f8e4dc;
  border-color: #e7c2b8;
}

.tile.zero b { color: #8e2f24; }

.chance {
  margin: 0;
  font-size: 2.6rem;
  line-height: 1;
}

.action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  margin: 0 0 8px;
  padding: 12px;
  text-align: left;
  border-radius: 16px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.action-main { flex: 1 1 auto; min-width: 0; }

.action-cost {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 999px;
  background: #f3e6d4;
  color: #6a3d22;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  max-width: 5.6rem;
}

.action:disabled { opacity: 0.55; }

#map {
  height: 320px;
  margin: 12px 12px 0;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  background: #d9cbb6;
  z-index: 0;
}

.map-fallback {
  margin: 0;
  padding: 16px;
}

.map-tools {
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
}

.map-tools button {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
  font-weight: 700;
}

.map-hint { padding: 8px 16px 0; }

.place-card {
  margin: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.place-card h2 { margin-top: 4px; }

.place-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 8px;
}

.place-list button {
  width: 100%;
  min-height: 58px;
  padding: 10px 8px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e4d9c8;
  border-radius: 0;
}

.place-list button[aria-current="true"] {
  background: #fffaf4;
  box-shadow: inset 3px 0 0 #1e3f36;
}

.place-name { display: block; font-weight: 700; }

.place-meta { display: block; color: #4e483f; font-size: 0.85rem; }

.log {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log li {
  padding: 10px 0;
  border-bottom: 1px solid #e4d9c8;
  overflow-wrap: anywhere;
}

.stamp {
  display: block;
  margin-bottom: 2px;
  color: #9c4a28;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.chrome {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  width: min(520px, 100%);
  transform: translateX(-50%);
  background: #f3ecdf;
  border-top: 1px solid #e4d9c8;
  box-shadow: 0 -8px 24px rgba(40, 30, 15, 0.06);
}

.dock { padding: 8px 12px 4px; }

.dock-note {
  margin: 0;
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  color: #6e241c;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar button {
  min-height: 52px;
  border: 0;
  border-top: 3px solid transparent;
  background: transparent;
  color: #5c564c;
  font-weight: 700;
}

.tabbar button[aria-selected="true"] {
  color: #1e3f36;
  border-top-color: #1e3f36;
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(28, 24, 20, 0.48);
}

.sheet {
  width: min(520px, 100%);
  max-height: min(85dvh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: #fffaf4;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
}

.sheet h2 { margin: 0 0 8px; }

.sheet p { margin: 0 0 10px; }

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.choice {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  text-align: left;
  border-radius: 16px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
}

.choice:disabled { opacity: 0.5; }

.leaflet-div-icon.pin-wrap {
  background: #1e3f36;
  color: #f4efe6;
  border: 2px solid #f4efe6;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.02em;
}

.leaflet-div-icon.pin-home {
  background: #9c4a28;
  font-size: 11px;
}

.leaflet-div-icon.pin-on {
  box-shadow: 0 0 0 3px #e2b657, 0 2px 8px rgba(0, 0, 0, 0.28);
}

.pin-label { pointer-events: none; line-height: 1; text-align: center; }

.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255, 250, 244, 0.92) !important;
}

.noscript {
  padding: 16px;
  font-weight: 700;
}

@media (min-width: 700px) {
  .modal-back { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; }
}

@media (max-width: 360px) {
  .tile b { font-size: 1.45rem; }
  .dayrow strong { font-size: 1.45rem; }
  .title-hero h1 { font-size: 1.85rem; }
  .chance { font-size: 2.2rem; }
}

.scenario.on {
  box-shadow: inset 0 0 0 3px #1e3f36;
}

.stock-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}

.stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 52px;
  padding: 4px 6px 4px 10px;
  border-radius: 12px;
  border: 1px solid #e4d9c8;
  background: #fffaf4;
  font-weight: 700;
}

.stock-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stock-ctrl b {
  min-width: 1.6ch;
  text-align: center;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.15rem;
}

.stock-ctrl button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #1e3f36;
  color: #f4efe6;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}

.stock-ctrl button:disabled { opacity: 0.35; }

.status-bar {
  min-height: 0;
  max-height: 46vh;
  overflow: auto;
  background: #1e3f36;
  color: #f4efe6;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}

.status-bar p { margin: 0; }

.status-top, .status-mid {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.status-top strong {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

.status-mid, .stores, .flash-line, .warn-line {
  font-size: 0.78rem;
  line-height: 1.25;
}

.status-mid { margin-top: 2px; opacity: 0.92; }

.status-mid.hot { color: #f0d78c; font-weight: 700; }

.meters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.meters span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
}

.meters .bar { height: 7px; background: rgba(255, 255, 255, 0.22); }

.stores { margin-top: 6px; }

.stat-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.stat-box {
  min-width: 0;
  padding: 6px 6px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.stat-box span {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.15;
  opacity: 0.82;
}

.stat-box strong {
  display: block;
  margin-top: 3px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-box.hot strong { color: #f0d78c; }

.flash-line {
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  line-height: 1.3;
  min-height: calc(1.3em * 3);
  opacity: 0.92;
}

.warn-line { margin-top: 2px; color: #f0d78c; font-weight: 700; }

.title-link {
  border: 0;
  background: transparent;
  color: #f4efe6;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0;
}

.scene {
  min-height: 0;
  display: grid;
  overflow: hidden;
  background: #1a2a22;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.stage .lot {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
}

.map-label {
  position: absolute;
  z-index: 1;
  transform: translate(-50%, -50%);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(20, 16, 8, 0.45);
}

.on-house { left: 48%; top: 46%; color: #f7f4ee; }
.on-lake { left: 94%; top: 7%; color: #e7f3f4; }
.on-road {
  left: 26%;
  top: 64%;
  color: #f7f4ee;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  transform: translate(-50%, -50%) rotate(-62deg);
}

.aerial-credit {
  position: absolute;
  z-index: 3;
  left: 6px;
  bottom: 4px;
  max-width: calc(100% - 12px);
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(16, 20, 14, 0.62);
  color: #f4efe6;
  font-size: 0.58rem;
  line-height: 1.2;
  pointer-events: none;
}

.chip {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  min-width: 64px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 2px solid #1e3f36;
  background: #fffaf4;
  color: #1c1915;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(40, 30, 10, 0.28);
}

.chip.lake {
  background: #e7f3f6;
  border-color: #143642;
}

@media (max-width: 700px) {
  .chip {
    min-width: 0;
    min-height: 32px;
    padding: 3px 7px;
    font-size: 0.72rem;
    border-width: 1.5px;
  }
}

.chip:disabled { opacity: 0.45; }

.picker, .driveway {
  position: absolute;
  z-index: 5;
  width: min(280px, 88%);
  max-height: 74%;
  overflow: auto;
  padding: 8px;
  border-radius: 14px;
  background: #fffaf4;
  border: 1px solid #e4d9c8;
  box-shadow: 0 10px 28px rgba(20, 16, 8, 0.28);
}

.picker {
  left: 8px;
  right: 8px;
  top: 8px;
  width: auto;
  max-height: calc(100% - 16px);
  transform: none;
}

.morning {
  position: absolute;
  z-index: 6;
  left: 8px;
  right: 8px;
  top: 8px;
  max-height: 58%;
  overflow: auto;
  padding: 10px;
  border-radius: 14px;
  background: #fffaf4;
  border: 1px solid #e4d9c8;
  box-shadow: 0 10px 28px rgba(20, 16, 8, 0.28);
}

.morning:empty { display: none; }

.morning h2 { margin: 0 0 6px; font-size: 1.15rem; }

.morning p { margin: 0 0 6px; font-size: 0.9rem; }

.morning .primary { margin-top: 4px; }

.driveway {
  left: 50%;
  bottom: 3%;
  max-height: 82%;
  transform: translateX(-50%);
}

.driveway .choice { min-height: 0; padding: 6px 8px; }
.driveway .choice .action-detail { font-size: 0.75rem; }

.picker:empty, .driveway:empty { display: none; }

.picker .choice, .driveway .choice {
  min-height: 44px;
  padding: 8px;
  margin: 0 0 6px;
}

.picker p, .driveway p { margin: 0 0 6px; font-size: 0.82rem; }

.picker h2, .driveway h2 { margin: 0 0 4px; font-size: 1.05rem; }

.day-dock {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: #f3ecdf;
  border-top: 1px solid #e4d9c8;
}

.day-dock .primary { min-height: 44px; }

.day-dock .lightlabel { margin: 0; font-weight: 700; }

.day-dock .lightbar { background: #e7dccb; }

.day-dock .dock-note {
  margin: 0;
  text-align: center;
  font-weight: 700;
}

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