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

:root {
  --bg: #0a0c0f;
  --bg-card: #12161c;
  --bg-hover: #1a2029;
  --text: #d4d8de;
  --text-dim: #7a8494;
  --accent: #c0392b;
  --accent-glow: rgba(192, 57, 43, 0.35);
  --success: #27ae60;
  --warning: #e67e22;
  --border: #2a3340;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
}

/* 噪点纹理 */
.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 9999;
}

#app {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

.screen {
  display: none;
  min-height: calc(100vh - 2rem);
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ── 开始界面 ── */
.start-card {
  margin: auto;
  width: 100%;
  padding: 2.5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: fadeUp 0.6s ease;
}

.start-card h1 {
  font-size: 1.8rem;
  color: var(--accent);
  margin: 0.5rem 0 0.25rem;
  letter-spacing: 0.05em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.sys-tag {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--warning);
}

.start-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.start-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.start-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.hint {
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.hint strong {
  color: var(--accent);
}

/* ── HUD ── */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

#hud-name {
  font-weight: 600;
  font-size: 1rem;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
}

.lives {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
}

/* ── 物品栏 ── */
.inventory {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.inventory.hidden {
  display: none;
}

.inv-label {
  color: var(--text-dim);
  margin-right: 0.25rem;
}

#inventory-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

#inventory-list li {
  padding: 0.2rem 0.55rem;
  background: var(--bg-hover);
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ── 剧情区 ── */
.story {
  flex: 1;
}

#scene-title {
  font-size: 1.15rem;
  color: var(--warning);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.scene-text {
  font-size: 1rem;
  white-space: pre-wrap;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.4s ease;
}

.scene-text em {
  color: var(--warning);
  font-style: normal;
}

.scene-text .quote {
  display: block;
  margin: 0.75rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
  font-style: italic;
}

/* ── 选项 ── */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.choice-btn {
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1.5;
}

.choice-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateX(4px);
}

.choice-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.choice-btn .req {
  display: block;
  font-size: 0.75rem;
  color: var(--warning);
  margin-top: 0.25rem;
}

.choice-btn.death-risk {
  border-color: rgba(192, 57, 43, 0.3);
}

/* ── 按钮 ── */
.btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

.footer-bar {
  padding: 1.5rem 0 0.5rem;
  text-align: center;
}

/* ── 弹层 ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 40px var(--accent-glow);
  text-align: center;
  animation: fadeUp 0.4s ease;
}

.overlay-tag {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 1rem;
  font-weight: 700;
}

.overlay-text {
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.7;
}

.overlay-card .btn {
  width: auto;
  min-width: 160px;
}

.overlay-card.win .overlay-tag {
  color: var(--success);
}

.overlay-card.win {
  border-color: var(--success);
  box-shadow: 0 0 40px rgba(39, 174, 96, 0.25);
}

/* ── 动画 ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── 响应式 ── */
@media (max-width: 480px) {
  .start-card { padding: 1.5rem 1.25rem; }
  .start-card h1 { font-size: 1.4rem; }
  #scene-title { font-size: 1rem; }
}
