/* Eco Life: viewport-safe game chrome. Keep this after the feature stylesheets. */
:root {
  --finish-topbar: 76px;
  --finish-gutter: 18px;
  --finish-panel: 300px;
  --finish-controls: 78px;
  --finish-paper: #fcfcf4;
  --finish-border: #d8e0cc;
  --finish-shadow: 0 8px 28px #25463318, 0 1px 3px #2546330c;
}

html, body { height: 100%; overflow: hidden; }
body { background: #c4d8a4; }
.topbar {
  height: var(--finish-topbar);
  gap: clamp(16px, 2.2vw, 36px);
  padding: 0 24px;
  background: #fcfcf7;
  box-shadow: 0 2px 12px #32513b08;
}
.brand { flex-shrink: 0; }
.top-stats { gap: 25px; }
.top-stats > div { padding-left: 22px; }
.top-stats span { color: #6f806a; font-size: 9px; }
.top-stats strong { font-size: 21px; font-variant-numeric: tabular-nums; }
.game {
  height: calc(100dvh - var(--finish-topbar));
  min-height: 0;
  isolation: isolate;
}

/* One fixed control strip leaves the inspector its own bounded scroll region. */
#inspector {
  top: var(--finish-gutter);
  right: var(--finish-gutter);
  bottom: calc(var(--finish-gutter) + var(--finish-controls) + 16px);
  width: var(--finish-panel);
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--finish-paper);
  border: 1px solid #ffffffc7;
  border-radius: 16px;
  box-shadow: var(--finish-shadow);
}
.inspect-cover { height: 98px; min-height: 74px; flex: 0 0 98px; }
.inspector-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9bae88 #edf0e2;
  padding: 18px 17px 14px 20px;
}
.inspect-eyebrow { color: #72836b; line-height: 1.6; }
.inspect-title { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.inspect-desc { display: block; color: #748269; font-size: 11px; line-height: 1.7; }
.operation { gap: 8px; align-items: flex-start; }
.operation-label { min-width: 0; line-height: 1.5; }
.operation small { flex-shrink: 0; line-height: 1.7; color: #748269; }
.detail-grid { gap: 10px; }
.detail-grid span { color: #7b886e; line-height: 1.5; }
.detail-grid strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.manager-thought { padding: 11px; background: #eff0e1; border: 1px solid #e3e6d3; }
.manager-thought p { color: #697c5c; }
.stock-row { padding: 9px 0; gap: 8px; }
.stock-row > span:nth-child(2) { min-width: 0; }
.stock-row small { display: block; color: #7d8b70; line-height: 1.45; }
.stock-row strong { white-space: nowrap; }
.stock-heading { gap: 10px; line-height: 1.6; }
.stock-heading span { white-space: nowrap; }
.switch-row { min-height: 32px; gap: 12px; line-height: 1.5; }
.switch { flex-shrink: 0; width: 32px; height: 20px; padding: 3px; }
.switch i { width: 14px; height: 14px; }
.switch.on i { transform: translateX(12px); }
.firm-strategy .price-row { gap: 12px; line-height: 1.6; }
.firm-strategy output { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.price-note { color: #7f8c70; font-size: 10px; line-height: 1.65; }
.strategy-grid { gap: 10px; margin: 16px 0; }
.strategy-grid label { min-width: 0; color: #6b805e; line-height: 1.5; }
.strategy-grid select { min-height: 38px; padding: 8px; }
.strategy-apply { min-height: 38px; }
.upgrade-btn { min-height: 42px; gap: 12px; line-height: 1.6; align-items: center; }
.upgrade-btn > span { min-width: 0; }
.upgrade-btn small { max-width: 45%; text-align: right; line-height: 1.6; }
.inspect-footer { display: flex; gap: 10px; line-height: 1.7; color: #76876a; }
.inspect-footer button { min-height: 32px; white-space: nowrap; color: #587849; }
.inspector-people { min-height: 42px; margin-top: 5px; }
.mobile-detail-close {
  display: grid;
  place-items: center;
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border: 1px solid #ffffffd9;
  border-radius: 50%;
  background: #fcfcf1e8;
  color: #557649;
}
.mobile-detail-close svg { width: 15px; height: 15px; }

.rail {
  top: var(--finish-gutter);
  bottom: var(--finish-gutter);
  left: 16px;
  width: 58px;
  gap: 7px;
  padding: 8px 5px;
  border-color: #ffffffb8;
  box-shadow: var(--finish-shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b7c6a1 transparent;
}
.nav-btn { width: 40px; height: 40px; min-height: 40px; color: #6c8563; }
.nav-btn.active { color: #f8fae9; background: #2c5c45; }
.rail-divider { margin: 3px 5px; }
.rail-bottom { margin-top: auto; }
.map-heading { left: 96px; top: 24px; max-width: calc(100% - 450px); }
.map-heading h1 { font-size: 31px; }
.map-heading p { color: #4e765a; }
.eyebrow { color: #55765b; }
.weather { color: #406a51; margin-top: 12px; flex-wrap: wrap; row-gap: 5px; }
.live-population { color: #5e7f59; line-height: 1.6; }
.reality-pill { color: #4f714d; background: #f7f8ecdc; border-color: #ffffffa3; max-width: 100%; }
.reality-pill > span:last-child { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.map-tools {
  right: calc(var(--finish-panel) + var(--finish-gutter) + 18px);
  top: var(--finish-gutter);
  padding: 5px;
  border: 1px solid #ffffffa8;
  box-shadow: var(--finish-shadow);
}
.map-tools button { width: 32px; height: 34px; }

.build-dock {
  left: 94px;
  right: calc(var(--finish-panel) + var(--finish-gutter) + 18px);
  bottom: var(--finish-gutter);
  width: auto;
  max-width: none;
  min-height: var(--finish-controls);
  height: var(--finish-controls);
  padding: 10px;
  gap: 10px;
  border: 1px solid #ffffffbf;
  border-radius: 14px;
  background: #fcfcf5f7;
  box-shadow: var(--finish-shadow);
}
.dock-title { display: none; }
.build-options {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  gap: 7px;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #a4b690 transparent;
  height: 100%;
  padding: 0 1px 6px;
  scroll-padding-inline: 8px;
  scroll-snap-type: x proximity;
}
.build-item {
  flex: 0 0 104px;
  min-width: 104px;
  min-height: 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px;
  text-align: left;
  scroll-snap-align: start;
  background: #fffef5;
  border-color: #dfe5d2;
}
.build-item svg { flex-shrink: 0; width: 22px; height: 22px; color: #ac8857; }
.build-item strong { font-size: 9px; line-height: 1.35; }
.build-item small { font-size: 8px; color: #78896a; line-height: 1.4; }
.build-item.active { background: #e7efda; border-color: #799d63; box-shadow: inset 0 0 0 1px #799d6333; }
.save-btn { flex: 0 0 34px; min-width: 34px; min-height: 42px; padding: 7px; border-radius: 8px; color: #647f56; }
.time-controls {
  left: auto;
  right: var(--finish-gutter);
  bottom: var(--finish-gutter);
  width: var(--finish-panel);
  height: var(--finish-controls);
  min-height: var(--finish-controls);
  padding: 12px;
  gap: 6px;
  border: 1px solid #244c3c;
  background: #2b5241;
  border-radius: 14px;
  box-shadow: var(--finish-shadow);
}
.time-controls > div { display: block; min-width: 0; }
.time-controls strong { font-size: 10px; line-height: 1.5; }
.time-controls small { font-size: 8px; line-height: 1.5; margin-top: 3px; color: #bfd0b3; }
.time-controls > button:first-child { min-width: 31px; height: 38px; }
.time-controls .speed { flex-shrink: 0; min-width: 30px; min-height: 34px; padding: 7px 5px; }
.activity-card {
  display: block;
  left: 96px;
  right: auto;
  bottom: calc(var(--finish-gutter) + var(--finish-controls) + 20px);
  width: 286px;
  max-width: calc(100% - 460px);
  padding: 13px 15px;
  background: #fcfcf3f0;
  border: 1px solid #ffffffab;
  box-shadow: 0 5px 18px #25463310;
}
.activity-title { color: #677e5c; font-size: 8px; line-height: 1.6; gap: 7px; }
.activity-title button { display: grid; place-items: center; min-width: 28px; min-height: 28px; margin: -5px -4px -5px auto; border-radius: 7px; }
#activity { margin-top: 8px; }
#activity p { color: #74876a; }
.map-legend { left: 98px; bottom: calc(var(--finish-gutter) + var(--finish-controls) + 129px); color: #446a4e; gap: 14px; line-height: 1.6; }
.map-hint { left: 98px; bottom: calc(var(--finish-gutter) + var(--finish-controls) + 5px); color: #4f7353; }

#mapLabels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.map-label {
  min-height: 30px;
  max-width: 230px;
  padding: 7px 10px;
  font-size: 10px;
  line-height: 1.45;
  color: #3f6247;
  background: #fcfcf3f5;
  border-color: #ffffffe0;
  box-shadow: 0 3px 10px #2d4c3024;
}
.map-label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.map-label small { font-size: 7px; color: #758769; opacity: 1; }
.map-label.public { font-size: 9px; color: #63785a; background: #f9faedee; }
.map-label.selected { background: #285b43; border-color: #f5f7dbd9; color: #fffef0; box-shadow: 0 4px 14px #2449342e; }
.map-label.selected small { color: #d2e1b9; }

/* Finance panels keep their independent appearance. */
.modal:not(.finance-modal) { scrollbar-width: thin; scrollbar-color: #a2b48c #f0f2e4; overscroll-behavior: contain; }
.modal:not(.finance-modal) .modal-header { gap: 14px; }
.modal:not(.finance-modal) .modal-header h2 { line-height: 1.25; }
.modal:not(.finance-modal) .modal-header small { line-height: 1.7; color: #718364; }
.modal:not(.finance-modal) .close-btn { min-width: 36px; min-height: 36px; }
.modal:not(.finance-modal) :where(input:not([type=range]):not([type=file]):not([type=checkbox]), select, textarea) { min-height: 40px; border-color: #cfdcbd; }
.modal:not(.finance-modal) :where(.primary-btn,.secondary-btn,.person-link) { min-height: 38px; line-height: 1.5; }
.modal:not(.finance-modal) .module-card p { color: #6d8062; }
.modal:not(.finance-modal) .notice { line-height: 1.8; }
:where(.topbar,.rail,#inspector,.build-dock,.time-controls,.map-tools,.map-heading,.modal:not(.finance-modal)) :where(button,a,input,select,textarea,summary):focus-visible {
  outline: 3px solid #cb8a52;
  outline-offset: 3px;
}
.map-label:focus-visible { outline: 3px solid #cb8a52; outline-offset: 3px; }
.firm-strategy input[type=range],.modal:not(.finance-modal) input[type=range] { cursor: pointer; }
#toasts { top: 18px; max-width: min(470px,calc(100% - 40px)); }
.toast { border: 1px solid #ffffff29; box-shadow: 0 8px 28px #1f3e3326; }

@media (min-width: 1500px) {
  :root { --finish-panel: 314px; --finish-gutter: 24px; --finish-controls: 84px; }
  .dock-title { display: flex; min-width: 174px; flex: 0 0 174px; }
  .dock-title strong { max-width: none; }
  .dock-title small { max-width: none; }
  .build-dock { padding: 12px; gap: 15px; }
  .inspect-cover { height: 116px; flex-basis: 116px; }
  .inspector-body { padding: 22px 20px 16px 23px; }
  .build-item { flex-basis: 112px; min-width: 112px; }
}

@media (max-width: 1100px) and (min-width: 761px) {
  :root { --finish-panel: 276px; --finish-gutter: 14px; --finish-controls: 76px; }
  .topbar { padding: 0 18px; gap: 18px; }
  .world-status { display: none; }
  .top-stats { gap: 18px; }
  .top-stats > div { padding-left: 18px; }
  .rail { left: 12px; width: 54px; padding: 7px 3px; gap: 6px; }
  .nav-btn { width: 40px; height: 40px; }
  .map-heading { left: 82px; top: 23px; max-width: calc(100% - 390px); }
  .map-heading h1 { font-size: 27px; }
  .map-tools { flex-direction: row; }
  .map-tools button { width: 29px; height: 32px; }
  .tool-label { display: none; }
  .build-dock { left: 80px; }
  .build-item { flex-basis: 98px; min-width: 98px; }
  .inspect-cover { height: 86px; min-height: 70px; flex-basis: 86px; }
  .inspector-body { padding: 15px 13px 12px 17px; }
  .inspect-title { font-size: 18px; }
  .time-controls { gap: 4px; padding: 10px; }
  .time-controls .speed { min-width: 28px; padding: 6px 4px; }
  .time-controls small { font-size: 7px; }
  .activity-card { left: 82px; width: 258px; max-width: calc(100% - 390px); }
  .map-legend,.map-hint { left: 84px; }
  .map-legend { flex-direction: row; gap: 10px; font-size: 8px; }
}

/* 1280 x 720: the world never grows beyond the visible viewport. */
@media (max-height: 760px) and (min-width: 761px) {
  :root { --finish-topbar: 64px; --finish-controls: 70px; --finish-gutter: 14px; }
  .topbar { height: var(--finish-topbar); }
  .brand-symbol { width: 32px; height: 38px; }
  .brand-word { font-size: 25px; }
  .brand-word small { margin-top: 5px; }
  .top-stats strong { font-size: 19px; }
  .map-heading { top: 20px; }
  .map-heading h1 { font-size: 27px; margin-top: 8px; }
  .map-heading p { font-size: 10px; }
  .live-population { margin-top: 5px; }
  .reality-pill { margin-top: 6px; padding-top: 5px; padding-bottom: 5px; }
  .weather { margin-top: 9px; }
  .inspect-cover { height: 80px; min-height: 66px; flex-basis: 80px; }
  .inspector-body { padding-top: 14px; }
  .build-dock { padding-top: 7px; padding-bottom: 7px; }
  .build-item { min-height: 0; }
  .activity-card { padding: 10px 13px; width: 258px; }
  #activity { margin-top: 6px; }
  #activity p { -webkit-line-clamp: 2; }
  .map-legend { bottom: calc(var(--finish-gutter) + var(--finish-controls) + 118px); }
  .map-hint { display: none; }
}

/* Narrow screens keep all module buttons in one horizontally scrollable row. */
@media (max-width: 760px) {
  :root { --finish-topbar: 64px; --finish-gutter: 10px; }
  .topbar { height: var(--finish-topbar); padding: 0 14px; gap: 12px; }
  .brand { min-width: 124px; gap: 8px; }
  .brand-symbol { width: 29px; height: 35px; }
  .brand-word { font-size: 24px; }
  .brand-word small { margin-top: 5px; font-size: 6px; letter-spacing: 1.8px; }
  .world-status { display: none; }
  .top-stats { gap: 0; margin-left: auto; }
  .top-stats > div { padding: 0; border: 0; }
  .top-stats span { font-size: 7px; letter-spacing: .9px; margin-bottom: 3px; }
  .top-stats strong { font-size: 17px; }
  .top-stats .cashflow,.top-stats .employee-stat { display: none; }
  .profile { width: 32px; height: 32px; font-size: 12px; }
  .game { height: calc(100dvh - var(--finish-topbar)); min-height: 0; }
  .map-heading { left: 16px; top: 20px; max-width: calc(100% - 80px); }
  .map-heading h1 { font-size: 26px; margin: 7px 0 5px; }
  .map-heading h1 > span { font-size: 20px; margin-left: 8px; }
  .eyebrow { font-size: 7px; letter-spacing: 1.3px; }
  .map-heading p { font-size: 10px; max-width: 250px; line-height: 1.6; }
  .live-population { font-size: 8px; margin-top: 5px; }
  .reality-pill { font-size: 8px; margin-top: 7px; padding: 6px 8px; }
  .weather { margin-top: 9px; font-size: 9px; gap: 7px; }
  .weather i { margin: 0; }
  .map-tools { top: 16px; right: 12px; flex-direction: column; padding: 4px; border-radius: 11px; }
  .map-tools button { width: 32px; height: 34px; }
  .tool-label { display: none; }
  .rail {
    top: auto;
    bottom: 140px;
    left: 10px;
    right: 10px;
    width: auto;
    height: 50px;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    border-radius: 12px;
  }
  .nav-btn { width: 39px; height: 38px; min-height: 38px; scroll-snap-align: start; }
  .rail-bottom { margin-top: 0; }
  .rail-divider { width: 1px; height: 24px; margin: 0 2px; }
  .build-dock {
    left: 10px;
    right: 10px;
    bottom: 60px;
    width: auto;
    max-width: none;
    height: 70px;
    min-height: 70px;
    padding: 7px;
    gap: 6px;
    border-radius: 12px;
  }
  .dock-title { display: none; }
  .build-options { gap: 6px; padding-bottom: 6px; }
  .build-item { flex: 0 0 100px; min-width: 100px; min-height: 0; padding: 7px; gap: 7px; flex-direction: row; text-align: left; }
  .build-item svg { width: 20px; height: 20px; }
  .build-item strong { font-size: 9px; }
  .build-item small { font-size: 8px; margin-top: 3px; }
  .save-btn { flex-basis: 32px; min-width: 32px; min-height: 44px; padding: 5px; }
  .time-controls {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: 40px;
    min-height: 40px;
    padding: 5px 9px;
    gap: 7px;
    border-radius: 10px;
  }
  .time-controls > button:first-child { width: 28px; min-width: 28px; height: 28px; }
  .time-controls > div { display: flex; align-items: center; gap: 8px; }
  .time-controls strong { font-size: 9px; }
  .time-controls small { font-size: 7px; margin-top: 0; }
  .time-controls .speed { min-width: 31px; min-height: 28px; padding: 4px 6px; }
  .activity-card {
    display: block;
    left: 12px;
    right: 12px;
    bottom: 200px;
    width: auto;
    max-width: none;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 9px;
  }
  .activity-title { font-size: 7px; letter-spacing: .7px; min-height: 18px; }
  #activity { display: none; }
  .activity-title button { min-height: 28px; min-width: 32px; }
  .map-legend { left: 16px; bottom: 244px; gap: 10px; flex-direction: row; font-size: 7px; }
  .map-hint { display: none; }
  #inspector {
    top: 184px;
    right: 12px;
    bottom: 254px;
    width: min(300px,calc(100% - 28px));
    max-height: none;
    border-radius: 13px;
  }
  .inspect-cover { height: 74px; min-height: 64px; flex: 0 0 74px; }
  .inspector-body { padding: 14px 13px 12px 17px; }
  .inspect-title { font-size: 19px; }
  .inspect-desc { display: block; font-size: 10px; margin: 7px 0 12px; }
  .inspect-eyebrow { font-size: 8px; }
  .stock-row,.switch-row { font-size: 10px; }
  .stock-row small { display: block; font-size: 8px; }
  .stock-row { padding: 8px 0; }
  .detail-grid span { font-size: 8px; }
  .detail-grid strong { font-size: 12px; }
  .inspect-footer { display: flex; }
  .mobile-detail-close { width: 34px; height: 34px; bottom: 7px; }
  .ownership { left: 12px; top: 11px; }
  .level-tag { right: 12px; top: 11px; }
  #mapLabels { clip-path: inset(0 0 240px 0); }
  .map-label { min-height: 32px; max-width: 196px; padding: 7px 9px; font-size: 9px; }
  .map-label.public { font-size: 8px; }
  .map-label small { display: none; }
  .modal-backdrop:has(> .modal:not(.finance-modal)) { padding: 10px; }
  .modal:not(.finance-modal) { padding: 20px 16px; max-height: calc(100% - 4px); border-radius: 14px; }
  .modal:not(.finance-modal) .modal-header h2 { font-size: 21px; }
  .modal:not(.finance-modal) .system-form { padding: 17px; }
  .modal:not(.finance-modal) .stat-cards { grid-template-columns: 1fr; gap: 9px; }
  .modal:not(.finance-modal) .stat-card { padding: 14px; }
  .modal:not(.finance-modal) .stat-card strong { font-size: 20px; }
  .modal:not(.finance-modal) .table-wrap { margin: 0 -4px; padding: 0 4px 5px; }
  .modal:not(.finance-modal) .policy-options { grid-template-columns: 1fr; }
  .modal:not(.finance-modal) .policy { padding: 15px; }
  .modal:not(.finance-modal) .policy span { display: inline-block; margin: 7px 10px 0 0; }
  #toasts { top: 190px; width: calc(100% - 28px); max-width: none; }
}

@media (max-width: 420px) {
  .topbar { gap: 9px; padding: 0 12px; }
  .top-stats strong { font-size: 16px; }
  .profile { width: 30px; height: 30px; border-width: 3px; }
  .time-controls { gap: 5px; }
  .time-controls > div { gap: 5px; }
  .time-controls small { max-width: 70px; line-height: 1.3; font-size: 6px; }
  .time-controls strong { font-size: 8px; white-space: nowrap; }
  .time-controls .speed { min-width: 29px; }
  .activity-title { letter-spacing: .4px; font-size: 7px; }
}

@media (max-width: 760px) and (max-height: 700px) {
  #inspector { top: 145px; bottom: 242px; }
  .inspect-cover { min-height: 52px; height: 52px; flex-basis: 52px; }
  .level-tag { right: 52px; }
  .mobile-detail-close { bottom: 8px; }
  .map-heading { top: 16px; }
  .map-heading h1 { font-size: 23px; }
  .map-heading p { display: none; }
  .weather { margin-top: 7px; }
  .reality-pill { margin-top: 5px; }
  .map-legend { bottom: 239px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 760px) {
    .time-controls { bottom: calc(10px + env(safe-area-inset-bottom)); }
    .build-dock { bottom: calc(60px + env(safe-area-inset-bottom)); }
    .rail { bottom: calc(140px + env(safe-area-inset-bottom)); }
    .activity-card { bottom: calc(200px + env(safe-area-inset-bottom)); }
    #inspector { bottom: calc(254px + env(safe-area-inset-bottom)); }
  }
}
