:root {
  --bg: #0d1418;
  --bg-2: #121d23;
  --panel: rgba(22, 32, 38, .88);
  --panel-strong: #18242b;
  --line: rgba(202, 214, 210, .14);
  --text: #e8e1d2;
  --muted: #91a2a7;
  --jade: #53b79d;
  --jade-dark: #287968;
  --gold: #c9a357;
  --paper: #d8cab0;
  --red: #c84d43;
  --orange: #d98648;
  --shadow: rgba(0, 0, 0, .34);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 10%, rgba(78, 132, 120, .14), transparent 32%),
    linear-gradient(135deg, #0b1114 0%, #132026 50%, #0b1114 100%);
  color: var(--text);
  font-family: "HarmonyOS Sans SC", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 4px;
}

.start-screen {
  --start-min-height: calc(100vh - 8px);
  --start-min-height: calc(100svh - 8px);
  --start-pad: clamp(10px, 3.6vw, 18px);
  --start-art-opacity: .28;
  position: relative;
  isolation: isolate;
  min-height: var(--start-min-height);
  display: block;
  overflow: hidden;
  border: 1px solid rgba(216, 202, 176, .12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(9, 18, 23, .96), rgba(7, 14, 17, .98)),
    rgba(8, 16, 20, .92);
}

.start-screen::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5, 12, 15, .7) 0%, rgba(5, 12, 15, .42) 24%, rgba(5, 12, 15, .74) 62%, rgba(5, 12, 15, .98) 100%),
    linear-gradient(90deg, rgba(5, 12, 15, .86), rgba(5, 12, 15, .38) 50%, rgba(5, 12, 15, .86));
}

.start-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.start-art svg {
  width: 100%;
  height: 100%;
  display: block;
  opacity: var(--start-art-opacity);
  filter: saturate(.9) contrast(1.05);
}

.start-copy {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 620px;
  min-height: var(--start-min-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--start-pad);
  text-shadow: 0 2px 18px rgba(0, 0, 0, .72);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: .04em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(34px, 12.5vw, 56px);
  line-height: 1;
  font-weight: 900;
  max-width: 8.2em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(19px, 6vw, 26px);
}

#identityLine {
  position: relative;
  isolation: isolate;
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px 5px 0;
  line-height: 1.18;
}

#identityLine::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -8px;
  right: 0;
  top: 50%;
  height: 64%;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(83, 183, 157, .34), rgba(201, 163, 87, .4)) 0 0 / var(--age-progress, 0%) 100% no-repeat,
    rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .08);
  transform: translateY(-50%);
  transition: background-size .36s ease;
}

.tagline {
  color: #c8d2cf;
  font-size: clamp(14px, 4.2vw, 16px);
  line-height: 1.7;
  margin-bottom: 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 25, 31, .78);
  color: var(--text);
  padding: 0 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  backdrop-filter: blur(10px);
}

.primary-action {
  width: min(100%, 184px);
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #c9a357, #e6d4a3);
  color: #111715;
  padding: 0 24px;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(201, 163, 87, .22);
}

.game-screen {
  min-height: calc(100svh - 8px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  font-size: 13px;
}

.is-hidden {
  display: none;
}

.topbar,
.status-strip,
.left-panel,
.story-panel,
.detail-panel,
.tabs {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 58px;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.topbar .eyebrow {
  margin-bottom: 4px;
  font-size: 11px;
}

.topbar h2 {
  font-size: clamp(17px, 5.4vw, 23px);
}

.top-actions {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 6px;
  z-index: 30;
}

.icon-button,
.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  background: #111a20;
  font-weight: 800;
  font-size: 13px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
}

.text-button {
  padding: 0 10px;
}

#saveButton {
  justify-self: start;
}

#resetButton {
  justify-self: center;
}

.info-menu-wrap {
  position: relative;
  justify-self: end;
}

.status-strip {
  border-radius: 8px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  overflow: visible;
}

.stat-card,
.metric-card,
.asset-card,
.bill-row,
.timeline-row,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .015));
}

.stat-card {
  min-width: 0;
  min-height: 54px;
  padding: 7px 6px;
}

.label {
  color: var(--muted);
  font-size: 10px;
}

.value {
  margin-top: 5px;
  font-family: "JetBrains Mono", "Roboto Mono", Consolas, monospace;
  font-size: clamp(12px, 3.5vw, 15px);
  font-weight: 800;
  white-space: nowrap;
}

.trend {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.positive {
  color: var(--jade);
}

.negative {
  color: var(--red);
}

.warn {
  color: var(--orange);
}

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "story";
  gap: 6px;
}

.left-panel,
.story-panel,
.detail-panel {
  border-radius: 8px;
  padding: 8px;
}

.left-panel {
  display: none;
  gap: 8px;
}

.panel-section {
  min-width: 0;
}

.section-title {
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--paper);
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.risk-stamp {
  min-width: 54px;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--jade);
  padding: 2px 7px;
  transform: rotate(-2deg);
  text-align: center;
  font-size: 12px;
}

.risk-stamp.danger,
.risk-stamp.collapse {
  color: var(--red);
}

.risk-stamp.warning {
  color: var(--orange);
}

.risk-stamp.success {
  color: var(--gold);
  border-color: rgba(201, 163, 87, .8);
  background: rgba(201, 163, 87, .12);
}

.vitals {
  display: grid;
  gap: 7px;
}

.vital-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 38px;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--jade);
}

.bar.warn > i {
  background: var(--orange);
}

.bar.danger > i {
  background: var(--red);
}

canvas {
  width: 100%;
  border-radius: 8px;
  background: rgba(5, 11, 14, .34);
}

.story-panel {
  grid-area: story;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(390px, auto);
  gap: 6px;
}

.phone-feed {
  min-height: 28px;
  max-height: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
  border: 1px solid rgba(216, 202, 176, .14);
  border-radius: 8px;
  background: rgba(5, 11, 14, .38);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.phone-feed-track {
  width: max-content;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-inline: 10px;
  animation: feed-scroll 34s linear infinite;
  will-change: transform;
}

.phone-feed:hover .phone-feed-track {
  animation-play-state: paused;
}

@keyframes feed-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.notice {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: nowrap;
}

.notice.milestone {
  color: var(--gold);
  box-shadow: none;
}

.notice.milestone span {
  color: var(--paper);
  font-weight: 700;
}

.notice strong {
  display: inline;
  margin: 0 4px 0 0;
  color: var(--paper);
}

.notice span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.event-card {
  min-height: 390px;
  max-height: none;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(216, 202, 176, .2);
  background:
    linear-gradient(180deg, rgba(216, 202, 176, .06), rgba(255, 255, 255, .015)),
    rgba(12, 19, 23, .78);
  padding: 14px;
}

.event-source {
  color: var(--gold);
  font-size: 12px;
}

.auto-choice-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.auto-choice-hint strong {
  color: var(--gold);
  font-size: 12px;
}

.event-card h3 {
  margin: 7px 0 12px;
  font-size: clamp(22px, 7.2vw, 30px);
  line-height: 1.16;
}

.event-card p {
  color: #d7ded9;
  line-height: 1.72;
  font-size: 14px;
}

.event-loading {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
}

.event-loading h3 {
  margin: 0;
}

.event-loading p {
  max-width: 560px;
  margin: 0 auto;
}

.loader {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(216, 202, 176, .16);
  border-top-color: var(--gold);
  animation: spin .9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.choice-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.choice-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 31, 37, .88);
  color: var(--text);
  text-align: left;
  padding: 11px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.choice-card:hover {
  transform: translateY(-2px);
  border-color: rgba(201, 163, 87, .58);
  background: rgba(28, 42, 49, .95);
}

.choice-card:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.choice-title {
  display: block;
  color: var(--paper);
  font-weight: 800;
  line-height: 1.42;
  font-size: 14px;
}

.choice-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.pill {
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
}

.tabs {
  border-radius: 8px;
  display: none;
  padding: 6px;
  gap: 5px;
}

.tabs.is-open {
  display: grid;
}

.info-menu {
  position: fixed;
  z-index: 1000;
  width: 132px;
  background: rgba(13, 22, 27, .98);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .42);
}

.tab {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  min-height: 30px;
  font-size: 13px;
}

.tab.is-active {
  border-color: rgba(201, 163, 87, .42);
  background: rgba(201, 163, 87, .12);
  color: var(--paper);
}

.detail-panel {
  min-height: 0;
  max-height: min(62vh, 520px);
  overflow: auto;
  padding: 8px;
}

.detail-vitals {
  gap: 9px;
}

.chart-stack {
  display: grid;
  gap: 10px;
}

.detail-panel .value {
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.15;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.metric-card,
.asset-card {
  padding: 8px;
}

.metric-card strong,
.asset-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--paper);
  font-size: 13px;
}

.metric-card p,
.asset-card p {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.38;
  font-size: 11px;
}

.bill-list,
.timeline {
  display: grid;
  gap: 6px;
}

.bill-row,
.timeline-row {
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  align-items: center;
  font-size: 12px;
}

.timeline-row {
  grid-template-columns: 1fr;
}

.info-modal {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 7, 9, .62);
  backdrop-filter: blur(8px);
}

.info-modal.is-hidden {
  display: none;
}

.info-modal-card {
  width: min(420px, 100%);
  max-height: 78vh;
  border: 1px solid rgba(216, 202, 176, .18);
  border-radius: 8px;
  background: rgba(13, 21, 26, .98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .48);
  overflow: hidden;
}

.info-modal-head {
  min-height: 42px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.info-modal-head h3 {
  margin: 0;
  color: var(--paper);
  font-size: 16px;
}

.modal-close {
  font-size: 18px;
  line-height: 1;
}

.app-shell.state-warning {
  --panel: rgba(29, 33, 32, .9);
  --line: rgba(217, 134, 72, .22);
}

.app-shell.state-danger {
  --bg-2: #21171a;
  --panel: rgba(31, 24, 25, .92);
  --line: rgba(200, 77, 67, .28);
}

.app-shell.state-collapse {
  --panel: rgba(34, 28, 28, .95);
  --line: rgba(200, 77, 67, .38);
  filter: saturate(.82);
}

.app-shell.state-collapse .asset-card.seized,
.app-shell.state-collapse .stat-card {
  text-decoration: line-through;
  text-decoration-color: rgba(200, 77, 67, .8);
}

.app-shell.state-ending-good {
  --panel: rgba(24, 35, 31, .92);
  --line: rgba(201, 163, 87, .26);
}

@media (min-width: 760px) {
  .app-shell {
    width: min(560px, 100%);
    padding: 8px;
  }

  .start-screen {
    --start-min-height: calc(100vh - 16px);
    --start-min-height: calc(100svh - 16px);
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 3px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .setup-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .start-screen {
    --start-pad: 10px;
    --start-art-opacity: .25;
  }

  .primary-action {
    width: 100%;
  }

  .event-card {
    min-height: 390px;
    padding: 16px;
  }

  .stat-card {
    flex-basis: 124px;
  }
}

@media (max-height: 720px) {
  .app-shell {
    padding-block: 2px;
  }

  .start-screen {
    --start-min-height: calc(100vh - 4px);
    --start-min-height: calc(100svh - 4px);
    --start-pad: 10px;
    --start-art-opacity: .2;
  }

  .start-screen::before {
    background:
      linear-gradient(180deg, rgba(5, 12, 15, .64) 0%, rgba(5, 12, 15, .86) 34%, rgba(5, 12, 15, .98) 100%),
      linear-gradient(90deg, rgba(5, 12, 15, .94), rgba(5, 12, 15, .52) 50%, rgba(5, 12, 15, .94));
  }

  .eyebrow {
    margin-bottom: 7px;
    font-size: 12px;
  }

  h1 {
    margin-bottom: 12px;
    font-size: clamp(32px, 11.5vw, 46px);
  }

  .tagline {
    line-height: 1.58;
  }

  .setup-grid {
    gap: 10px;
    margin: 16px 0 12px;
  }

  label {
    gap: 6px;
    font-size: 13px;
  }

  select {
    min-height: 46px;
  }

  .primary-action {
    min-height: 48px;
  }
}

@media (max-width: 380px) and (max-height: 680px) {
  .start-screen {
    --start-pad: 8px;
    --start-art-opacity: .18;
  }

  h1 {
    font-size: clamp(30px, 10.8vw, 40px);
  }

  .tagline {
    font-size: 13px;
    line-height: 1.48;
  }

  select {
    min-height: 42px;
  }
}

@media (min-height: 780px) {
  .start-screen {
    --start-art-opacity: .32;
  }
}

@media (min-height: 860px) {
  .start-screen {
    --start-art-opacity: .34;
  }
}

@media (prefers-reduced-motion: reduce) {
  .phone-feed-track {
    animation: none;
  }
}
