* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #0a1018;
  color: #f5e6c8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
}
#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.hidden { display: none !important; }
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

/* ---- HUD ---- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* Flowing top cluster: stats row + goal strip (no overlap on wrap) */
#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    0
    max(8px, env(safe-area-inset-left));
  pointer-events: none;
}
#top-bar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
#stats {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}
.stat {
  background: rgba(12, 18, 28, 0.82);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 999px;
  padding: 3px 9px;
  backdrop-filter: blur(6px);
  min-width: 0;
  height: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.stat.hud-meta { display: none !important; }
.stat-label {
  display: block;
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9a227;
  margin-bottom: 0;
  line-height: 1.1;
}
.stat-value {
  font-size: 12px;
  font-weight: 700;
  color: #f5e6c8;
  line-height: 1.15;
  white-space: nowrap;
}
.stat.money .stat-value { color: #7dffb0; }
.stat.phase { max-width: 34vw; }
.stat.phase .stat-value {
  font-size: 10px;
  color: #e8c44a;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat.rep,
.stat.hunger {
  display: grid;
  grid-template-columns: minmax(40px, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 5px;
  align-items: center;
  min-width: 86px;
  max-width: 118px;
  border-radius: 12px;
  height: auto;
  min-height: 34px;
  padding: 3px 7px;
}
.stat.rep .stat-label,
.stat.hunger .stat-label { grid-column: 1 / -1; }
.rep-bar {
  height: 5px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  overflow: hidden;
  min-width: 40px;
}
#rep-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #c0392b, #e8c44a, #27ae60);
  border-radius: 4px;
  transition: width 0.35s ease;
}
.stat.income .stat-value { color: #7dffb0; font-size: 12px; }
.stat.income .stat-label { letter-spacing: 0.08em; }

#top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  pointer-events: auto;
}
#staff-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(12, 18, 28, 0.82);
  border: 1px solid rgba(201, 162, 39, 0.4);
  backdrop-filter: blur(6px);
  line-height: 1.1;
  white-space: nowrap;
}
#staff-chip .chip-label {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9a227;
}
#staff-chip .chip-value {
  font-size: 12px;
  font-weight: 700;
  color: #e8dcc0;
}

.hud-btn {
  position: static;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  background: rgba(12, 18, 28, 0.82);
  color: #e8c44a;
  font-size: 16px;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}

/* Slim goal strip below top stats row */
#next-goal {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  max-width: none;
  width: 100%;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 4px 12px;
  background: rgba(18, 28, 22, 0.82);
  border: 1px solid rgba(39, 174, 96, 0.5);
  border-left: 3px solid #27ae60;
  border-radius: 8px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
  pointer-events: none;
}
#next-goal.hidden { display: none !important; }
#next-goal .label {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7dffb0;
  margin: 0;
}
#next-goal .obj {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #e8f8ee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Investing Levels — collapsed by default; only near Lesson Board / lessons */
#mission {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 86px);
  left: max(8px, env(safe-area-inset-left));
  right: auto;
  width: min(300px, calc(100vw - 16px));
  max-width: min(300px, calc(100vw - 16px));
  background: rgba(12, 18, 28, 0.88);
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-left: 4px solid #c9a227;
  border-radius: 8px;
  padding: 8px 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  z-index: 17;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#mission.collapsed {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}
#mission .label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c9a227;
  margin-bottom: 4px;
}
.level-stars {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.level-star {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 39, 0.5);
  background: rgba(255,255,255,0.06);
  color: #8a7a5a;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-star.done {
  background: rgba(39, 174, 96, 0.35);
  border-color: #27ae60;
  color: #7dffb0;
}
.level-star.current {
  background: rgba(201, 162, 39, 0.35);
  border-color: #e8c44a;
  color: #f5d76e;
  box-shadow: 0 0 8px rgba(232, 196, 74, 0.4);
}
#mission .obj {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: #f5e6c8;
}
#mission .step {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

/* Legacy staff panel removed from permanent HUD */
#staff-panel { display: none !important; }
#staff-list.hidden { display: none !important; }

#disclaimer-bar {
  position: absolute;
  top: auto;
  bottom: max(2px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(98vw, 640px);
  text-align: center;
  font-size: 8px;
  line-height: 1.25;
  color: rgba(200, 184, 152, 0.7);
  background: rgba(8, 12, 18, 0.5);
  border: 1px solid rgba(201, 162, 39, 0.18);
  border-radius: 6px;
  padding: 3px 8px;
  pointer-events: none;
  z-index: 11;
}

#interact-hint {
  pointer-events: auto;
  touch-action: manipulation;
  position: absolute;
  bottom: max(168px, calc(env(safe-area-inset-bottom) + 148px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 18, 28, 0.85);
  border: 1px solid #c9a227;
  color: #f5d76e;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 14;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toasts / banners stacked top-center below goal strip */
#toast-stack {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 86px);
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
}
#banner,
#phase-banner,
#toast,
#ach-toast {
  position: static;
  top: auto;
  left: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  max-width: 100%;
  text-align: center;
  pointer-events: none;
}
#banner {
  background: rgba(10, 14, 20, 0.9);
  border: 1px solid #c9a227;
  color: #f5d76e;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#toast {
  background: rgba(20, 40, 28, 0.92);
  border: 1px solid #27ae60;
  color: #a8ffc8;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
#toast.bad {
  background: rgba(40, 16, 16, 0.92);
  border-color: #c0392b;
  color: #ffb0a8;
}

/* ---- Title / end ---- */
#title-screen, #end-screen, #login-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(90, 30, 40, 0.5), transparent 58%),
    linear-gradient(180deg, #2a1820 0%, #121820 55%, #0a1018 100%);
  pointer-events: auto;
}
.title-card {
  text-align: center;
  padding: 24px 20px;
  max-width: 420px;
}
.eyebrow {
  font-size: 13px;
  letter-spacing: 0.35em;
  color: #f0e6d0;
  margin-bottom: 4px;
}
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 14vw, 72px);
  line-height: 1;
  background: linear-gradient(180deg, #fff2b0 0%, #e8c44a 45%, #a67c1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(2px 3px 0 #5a3a08);
  margin-bottom: 8px;
}
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 8vw, 40px);
  color: #e8c44a;
  margin-bottom: 8px;
}
.maga {
  font-size: clamp(11px, 3.2vw, 14px);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f5f5f5;
  margin-bottom: 12px;
}
.tagline {
  font-size: 13px;
  color: #c8b898;
  margin-bottom: 14px;
}
.divider {
  width: 64px;
  height: 3px;
  background: #c9a227;
  margin: 0 auto 14px;
  border-radius: 2px;
}
.prompt {
  font-size: 16px;
  color: #e8c44a;
  margin-bottom: 20px;
}
.blink { animation: blink 1.2s steps(1) infinite; }
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}
.disclaimer {
  font-size: 10px;
  line-height: 1.45;
  opacity: 0.7;
  color: #c8b898;
  max-width: 320px;
  margin: 0 auto;
}
.end-detail {
  font-size: 13px;
  color: #c8b898;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ---- Modal ---- */
#modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  pointer-events: auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.modal-card {
  width: min(440px, 100%);
  max-height: min(78vh, 580px);
  overflow-y: auto;
  background: linear-gradient(180deg, #1a2434 0%, #121820 100%);
  border: 1px solid rgba(201, 162, 39, 0.65);
  border-radius: 16px 16px 12px 12px;
  padding: 18px 16px 14px;
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.modal-card h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  color: #e8c44a;
  margin-bottom: 6px;
}
.modal-desc {
  font-size: 13px;
  color: #c8b898;
  line-height: 1.45;
  margin-bottom: 12px;
  white-space: pre-line;
}
#modal-body {
  margin-bottom: 12px;
}
#modal-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.4);
  background: rgba(255,255,255,0.06);
  color: #f5e6c8;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-btn:active, .choice-btn:hover {
  background: rgba(201, 162, 39, 0.22);
  border-color: #c9a227;
}
.choice-btn .sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  margin-top: 3px;
}
.choice-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}
.choice-btn.correct-ish {
  border-color: #27ae60;
}
.btn-ghost {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  background: transparent;
  color: #a89878;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #c9a227;
  background: rgba(201, 162, 39, 0.28);
  color: #f5d76e;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.learn-box {
  background: rgba(39, 174, 96, 0.12);
  border: 1px solid rgba(39, 174, 96, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #a8ffc8;
  margin-bottom: 8px;
}
.learn-box strong { color: #7dffb0; }
.risk-meter {
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
}
.risk-fill {
  height: 100%;
  width: 33%;
  background: linear-gradient(90deg, #27ae60, #e8c44a, #c0392b);
  border-radius: 6px;
  transition: width 0.2s ease;
}
.alloc-row {
  margin-bottom: 10px;
}
.alloc-row label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
  color: #e8dcc0;
}
.alloc-row input[type="range"] {
  width: 100%;
  accent-color: #c9a227;
}
.alloc-total {
  font-size: 12px;
  color: #c8b898;
  margin: 6px 0 10px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 110px;
  padding: 8px 4px 0;
  border-bottom: 1px solid rgba(201, 162, 39, 0.35);
  margin-bottom: 8px;
}
.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, #e8c44a, #27ae60);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  opacity: 0.9;
}
.chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #a89878;
  margin-bottom: 8px;
}
.slider-block label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #e8dcc0;
  margin-bottom: 4px;
}
.slider-block {
  margin-bottom: 10px;
}
.slider-block input[type="range"] {
  width: 100%;
  accent-color: #c9a227;
}
.quiz-q {
  font-size: 14px;
  font-weight: 600;
  color: #f5e6c8;
  margin-bottom: 10px;
  line-height: 1.35;
}

/* ---- Touch controls ---- */
#touch {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: none;
}
@media (pointer: coarse), (max-width: 900px) {
  #touch { display: block; }
  #opt-shadows { bottom: max(148px, calc(env(safe-area-inset-bottom) + 132px)); }
  /* Keep disclaimer glued to the true bottom — do not lift into play view */
  #disclaimer-bar {
    bottom: max(2px, env(safe-area-inset-bottom));
    width: min(98vw, 640px);
    font-size: 8px;
    padding: 2px 6px;
  }
}
#stick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 42%;
  pointer-events: auto;
  touch-action: none;
}
#stick-base {
  position: absolute;
  left: 28px;
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(201, 162, 39, 0.55);
  background: rgba(20, 16, 8, 0.35);
}
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(232, 196, 74, 0.55);
  border: 2px solid #c9a227;
  pointer-events: none;
  transition: none;
}
#btn-interact {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 16px));
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid #c9a227;
  background: rgba(201, 162, 39, 0.28);
  color: #f5d76e;
  font-size: 34px;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
#btn-interact:active, #btn-interact.active {
  background: rgba(201, 162, 39, 0.6);
  transform: scale(0.95);
}
#btn-interact.near {
  background: rgba(201, 162, 39, 0.5);
  box-shadow: 0 0 18px rgba(232, 196, 74, 0.45);
}

.opt {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 16;
  font-size: 11px;
  color: #c8b898;
  background: rgba(0,0,0,.4);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.opt input { accent-color: #c9a227; }

@media (max-width: 480px) {
  #top-bar {
    flex-wrap: wrap;
    align-items: center;
  }
  #top-actions {
    margin-left: auto;
  }
  #stats {
    flex: 1 1 calc(100% - 120px);
    gap: 5px;
  }
  .stat { padding: 2px 7px; height: 32px; }
  .stat-value { font-size: 11px; }
  .stat.rep, .stat.hunger { min-width: 78px; max-width: 104px; min-height: 32px; }
  #staff-chip { padding: 2px 7px; height: 32px; }
  .hud-btn { width: 32px; height: 32px; }
}

/* ---- Login ---- */
#login-screen { z-index: 25; }
.login-card { max-width: 380px; width: 100%; }
.login-label {
  display: block;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #c9a227;
  margin: 4px 0 8px;
}
#login-name {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  background: rgba(12, 18, 28, 0.85);
  color: #f5e6c8;
  font-size: 16px;
  outline: none;
  margin-bottom: 8px;
}
#login-name:focus {
  border-color: #e8c44a;
  box-shadow: 0 0 0 2px rgba(232, 196, 74, 0.25);
}
#login-name::placeholder { color: #7a6e58; }
.login-error {
  font-size: 12px;
  color: #ffb0a8;
  margin: 4px 0 8px;
  text-align: left;
  min-height: 1.2em;
}
.title-hello {
  font-size: 15px;
  font-weight: 600;
  color: #7dffb0;
  margin-bottom: 10px;
}
.title-change-name {
  width: auto;
  display: inline-block;
  margin: 0 auto 14px;
  padding: 6px 12px;
  pointer-events: auto;
  color: #c9a227;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.stat.player .stat-value {
  color: #e8c44a;
  font-size: 14px;
}


/* ---- Expanded game UI ---- */
#news-ticker {
  position: absolute;
  top: auto;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 44px));
  right: 10px;
  left: auto;
  width: min(260px, 42vw);
  background: rgba(12, 18, 28, 0.82);
  border: 1px solid rgba(39, 174, 96, 0.45);
  border-radius: 8px;
  padding: 4px 8px;
  overflow: hidden;
  pointer-events: none;
  z-index: 12;
}
#news-ticker .ticker-label {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #27ae60;
}
.ticker-track {
  overflow: hidden;
  white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
#ticker-text {
  display: inline-block;
  font-size: 11px;
  color: #c8e8d0;
  animation: ticker-scroll 18s linear infinite;
  padding-left: 100%;
}
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

#save-pill {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 44px);
  right: max(8px, env(safe-area-inset-right));
  z-index: 22;
  font-size: 10px;
  color: #7dffb0;
  background: rgba(20, 40, 28, 0.9);
  border: 1px solid #27ae60;
  border-radius: 12px;
  padding: 3px 10px;
  pointer-events: none;
}

#ach-toast {
  background: rgba(40, 30, 10, 0.95);
  border: 1px solid #e8c44a;
  color: #f5d76e;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
#ach-toast .sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #c8b898;
  margin-top: 4px;
}

#pause-menu, #confirm-modal {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  pointer-events: auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.pause-card, .confirm-card {
  width: min(420px, 100%);
  max-height: min(82vh, 640px);
}
.pause-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.choice-btn.danger {
  border-color: rgba(192, 57, 43, 0.55);
  color: #ffb0a8;
}
.choice-btn.danger:hover, .choice-btn.danger:active {
  background: rgba(192, 57, 43, 0.22);
  border-color: #c0392b;
}

.title-save-hint {
  font-size: 12px;
  color: #a8c8b0;
  margin-bottom: 10px;
}

.level-star.locked { opacity: 0.35; }
.level-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.level-pick .choice-btn {
  padding: 8px 10px;
  font-size: 12px;
}
.level-pick .choice-btn .sub { font-size: 10px; }

.market-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.market-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(201, 162, 39, 0.25);
}
.market-row .name { font-weight: 700; font-size: 13px; color: #f5e6c8; }
.market-row .meta { font-size: 11px; color: #a89878; }
.market-row .price { font-weight: 700; color: #7dffb0; font-size: 13px; text-align: right; }
.market-row .chg.up { color: #7dffb0; }
.market-row .chg.down { color: #ffb0a8; }
.spark {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 28px;
  margin-top: 2px;
}
.spark i {
  flex: 1;
  background: rgba(39, 174, 96, 0.55);
  border-radius: 1px 1px 0 0;
  min-height: 2px;
}
.market-actions {
  display: flex;
  gap: 6px;
  grid-column: 1 / -1;
}
.market-actions button {
  flex: 1;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.4);
  background: rgba(201, 162, 39, 0.15);
  color: #f5d76e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ach-list, .goal-list {
  list-style: none;
  margin: 0 0 8px;
  max-height: 240px;
  overflow-y: auto;
}
.ach-list li, .goal-list li {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201, 162, 39, 0.2);
  margin-bottom: 6px;
  font-size: 12px;
}
.ach-list li.locked { opacity: 0.45; }
.ach-list li .title, .goal-list li .title { font-weight: 700; color: #e8c44a; }
.goal-list li.done { border-color: rgba(39,174,96,0.45); }
.goal-list li.done .title { color: #7dffb0; }

.staff-manage .choice-btn { margin-bottom: 0; }

.earnings-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #e8dcc0;
  margin-bottom: 8px;
  white-space: pre-line;
}
.earnings-box strong { color: #e8c44a; }

.dca-box, .plan-box {
  font-size: 12px;
  color: #c8b898;
  margin-bottom: 8px;
}

@media (max-width: 720px) {
  #news-ticker {
    top: auto;
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 88px));
    left: 10px;
    right: 10px;
    width: auto;
  }
}
@media (pointer: coarse), (max-width: 900px) {
  #news-ticker { bottom: max(150px, calc(env(safe-area-inset-bottom) + 138px)); }
  #interact-hint {
    bottom: max(198px, calc(env(safe-area-inset-bottom) + 178px));
    font-size: 12px;
    padding: 7px 12px;
    max-width: min(78vw, 320px);
    z-index: 15;
  }
}

/* ---- Empire / Phase / Hunger polish ---- */
.hunger-bar { min-width: 52px; }
#hunger-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c0392b, #e67e22, #f1c40f);
  border-radius: 4px;
  transition: width 0.35s ease;
}
.stat.hunger.critical #hunger-fill {
  background: linear-gradient(90deg, #7b241c, #c0392b);
  animation: hunger-pulse 1.1s ease-in-out infinite;
}
@keyframes hunger-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#phase-banner {
  background: linear-gradient(180deg, rgba(20, 16, 8, 0.94), rgba(10, 14, 20, 0.94));
  border: 2px solid #e8c44a;
  color: #f5d76e;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 32px rgba(201, 162, 39, 0.35);
  pointer-events: none;
  letter-spacing: 0.04em;
}
#phase-banner .sub {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #c8b898;
  letter-spacing: 0;
}

.biz-panel { font-size: 12px; color: #e8dcc0; }
.biz-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201, 162, 39, 0.28);
}
.biz-row.locked { opacity: 0.45; }
.biz-row .biz-title { font-weight: 700; color: #e8c44a; font-size: 13px; }
.biz-row .biz-meta { opacity: 0.85; line-height: 1.4; }
.biz-eff {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.biz-eff > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c0392b, #e8c44a, #27ae60);
  border-radius: 3px;
}
.biz-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.biz-actions .mini-btn {
  flex: 1 1 auto;
  min-width: 90px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.12);
  color: #f5e6c8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.biz-actions .mini-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.biz-actions .mini-btn.fix {
  border-color: rgba(231, 76, 60, 0.55);
  background: rgba(192, 57, 43, 0.18);
  color: #ffb4a8;
}
.issue-list { list-style: none; margin: 8px 0; padding: 0; }
.issue-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(192, 57, 43, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.35);
  font-size: 12px;
  color: #f5d0c8;
}
.issue-list li .title { font-weight: 700; color: #ffb4a8; }
.phase-list { list-style: none; margin: 0; padding: 0; }
.phase-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201, 162, 39, 0.22);
  font-size: 12px;
  color: #c8b898;
}
.phase-list li.current {
  border-color: #e8c44a;
  background: rgba(201, 162, 39, 0.16);
  color: #f5e6c8;
}
.phase-list li.done { border-color: rgba(39,174,96,0.4); }
.phase-list li .title { font-weight: 700; color: #e8c44a; }
.welcome-offline {
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #c8f0d8;
}
.welcome-offline strong { color: #7dffb0; }
.legacy-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(201, 162, 39, 0.25);
  border: 1px solid rgba(201, 162, 39, 0.55);
  color: #e8c44a;
  vertical-align: middle;
}

@media (max-width: 720px) {
  .stat.phase { max-width: 38vw; }
  #top-bar { flex-wrap: nowrap; }
  #toast-stack, #mission:not(.collapsed) {
    top: calc(max(8px, env(safe-area-inset-top)) + 120px);
  }
}

@media (min-width: 900px) {
  #stats { gap: 8px; }
  .stat { height: 38px; padding: 4px 12px; }
  #next-goal { max-width: 560px; }
}


/* —— Update / maintenance screen (US English) —— */
#update-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(201, 162, 39, 0.18), transparent 55%),
    linear-gradient(160deg, #1a0f14 0%, #0b1018 45%, #120c10 100%);
}
#update-screen.hidden { display: none !important; }
body.update-mode #app > *:not(#update-screen) {
  visibility: hidden;
  pointer-events: none;
}
.update-card {
  width: min(92vw, 420px);
  text-align: center;
  background: rgba(12, 16, 24, 0.92);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 16px;
  padding: 28px 22px 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.update-card .eyebrow {
  letter-spacing: 0.22em;
  font-size: 11px;
  color: #c9a227;
  margin: 0 0 10px;
}
.update-card h2 {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.25;
  color: #f5e6c8;
  font-weight: 700;
}
.update-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(201, 162, 39, 0.25);
  border-top-color: #c9a227;
  animation: lt-spin 0.9s linear infinite;
}
@keyframes lt-spin { to { transform: rotate(360deg); } }
.update-message {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(230, 220, 200, 0.88);
}
.update-hint {
  margin: 0;
  font-size: 12px;
  color: rgba(200, 184, 152, 0.7);
}


/* Quiet sponsor line — Business Empire only */
.biz-sponsor {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid rgba(201, 162, 39, 0.08);
  font-size: 8px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: rgba(168, 158, 140, 0.38);
  text-align: center;
  word-break: break-all;
  user-select: text;
  pointer-events: auto;
}

/* Mission panel (pause → Missions) */
.mission-panel .goal-list { margin-top: 6px; }
.mission-panel strong { color: #f0d78c; font-size: 13px; letter-spacing: 0.02em; }
.mission-panel .biz-meta { margin: 4px 0 8px; opacity: 0.85; }


/* West Wing mini-games */
.mg-hub .biz-row { margin-bottom: 10px; }
.mg-dash { text-align: center; padding: 4px 0 8px; }
.mg-progress {
  height: 18px;
  border-radius: 9px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(212,175,55,0.35);
  overflow: hidden;
  margin: 10px 0 8px;
}
.mg-progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ecc71, #f1c40f);
  transition: width 0.08s linear;
}
.mg-status {
  font-size: 14px;
  font-weight: 700;
  color: #f5e6c8;
  margin: 6px 0 12px;
}
.mg-big-btn {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 18px 16px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-radius: 14px;
  border: 2px solid #d4af37;
  background: linear-gradient(180deg, #c0392b, #8b1e1e);
  color: #fff8e7;
  box-shadow: 0 4px 0 #5a1212, 0 8px 18px rgba(0,0,0,0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.mg-big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #5a1212, 0 4px 10px rgba(0,0,0,0.3);
}


/* Leaderboard ($/sec) */
.lb-summary {
  margin: 0 0 10px;
  font-weight: 700;
  color: #f0d78c;
  font-size: 14px;
}
.lb-list {
  max-height: min(46vh, 360px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}
.lb-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr auto;
  gap: 6px 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(0, 0, 0, 0.28);
  font-size: 13px;
}
.lb-row.you {
  border-color: rgba(241, 196, 15, 0.75);
  background: rgba(212, 175, 55, 0.18);
  box-shadow: inset 0 0 0 1px rgba(241, 196, 15, 0.25);
}
.lb-rank {
  font-weight: 800;
  color: #e8c44a;
  font-variant-numeric: tabular-nums;
}
.lb-name {
  font-weight: 700;
  color: #f5e6c8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-rate {
  font-weight: 700;
  color: #7dffb0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.lb-net {
  grid-column: 2 / -1;
  font-size: 11px;
  opacity: 0.8;
  color: #c8b896;
}
.lb-empty {
  opacity: 0.85;
  margin: 8px 0;
}
