:root {
  --ink: #1a1a1a;
  --paper: #f5e6c8;
  --paper-deep: #ead3a5;
  --cinnabar: #c0392b;
  --green: #2d5a3d;
  --muted: #766a56;
  --line: rgba(26, 26, 26, 0.22);
  --shadow: rgba(26, 26, 26, 0.16);
  font-family: 'Songti SC', 'STSong', 'Noto Serif SC', serif;
  color: var(--ink);
  background: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(245, 230, 200, 0.16), transparent 28rem),
    linear-gradient(160deg, #111 0%, #242018 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100vw, 820px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr auto;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.38);
}

.status-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  background: #1f1b16;
  color: var(--paper);
  border-bottom: 2px solid var(--cinnabar);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.status-cell {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-cell strong {
  color: #fff7dd;
  font-weight: 700;
}

.game-view {
  min-width: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-block {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--line);
}

.game-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 239, 0.54);
  box-shadow: 0 4px 14px var(--shadow);
}

.scene-panel {
  padding: 14px;
}

.scene-title {
  margin: 0 0 8px;
  font-size: 22px;
}

.scene-desc {
  margin: 0;
  color: #30291f;
  line-height: 1.72;
  white-space: pre-line;
}

.section-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.option-list {
  display: grid;
  gap: 8px;
}

.ancient-btn,
.tab-btn,
.small-btn {
  border: 1px solid rgba(26, 26, 26, 0.42);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.84), rgba(232, 205, 155, 0.9));
  border-radius: 7px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.45), 0 2px 0 rgba(26, 26, 26, 0.24);
  cursor: pointer;
}

.ancient-btn {
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.35;
}

.ancient-btn.primary {
  color: #fff8e6;
  background: linear-gradient(180deg, #cb4d3e, #982b21);
}

.ancient-btn:disabled,
.small-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.small-btn {
  min-height: 34px;
  padding: 6px 10px;
}

.form-grid,
.list-grid,
.shop-grid,
.save-grid {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff9ea;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.segmented button.active,
.tab-btn.active {
  color: #fff8e6;
  border-color: rgba(26, 26, 26, 0.55);
  background: linear-gradient(180deg, #356b49, #244a32);
}

.data-list {
  display: grid;
  gap: 8px;
}

.data-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 252, 242, 0.68);
}

.data-row h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.data-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(26, 26, 26, 0.18);
}

.meter i {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--cinnabar);
}

.meter.mp i {
  background: var(--green);
}

.tab-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  background: #1f1b16;
  border-top: 2px solid var(--cinnabar);
}

.tab-btn {
  min-width: 0;
  min-height: 42px;
  padding: 6px 4px;
  font-size: 13px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 9px 12px;
  border-radius: 8px;
  color: #fff8e6;
  background: rgba(26, 26, 26, 0.92);
  z-index: 40;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.scene-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-size: cover;
  background-position: center;
  background-color: #2a221a;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px var(--shadow);
  overflow: hidden;
  animation: hero-fade 380ms ease-out;
}

@keyframes hero-fade {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(20, 14, 6, 0.78) 100%);
}

.hero-tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fff8e6;
  letter-spacing: 2px;
  background: rgba(192, 57, 43, 0.78);
  border-radius: 4px;
  border: 1px solid rgba(255, 248, 230, 0.5);
}

.npc-btn {
  display: flex;
  align-items: center;
  gap: 10px;
}

.npc-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(26, 26, 26, 0.42);
  background: #2a221a;
}
