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

:root {
  --primary: #1a5c9a;
  --primary-dark: #0f3d6b;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --radius: 12px;
  --font: "Lexend", "PingFang SC", "Microsoft YaHei", sans-serif;
  --positive: #16a34a;
  --negative: #dc2626;
  --neutral: #d97706;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  z-index: 100;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* Screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Select screen */
.game-header {
  text-align: center;
  padding: 48px 24px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.game-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.game-header .subtitle { font-size: 1rem; opacity: 0.85; }

.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  padding: 40px 24px;
  flex: 1;
}

.character-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 260px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: center;
  position: relative;
}
.character-card:hover:not(.disabled) {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border-color: var(--primary);
}
.character-card:focus {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.character-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.char-emoji { font-size: 3rem; margin-bottom: 12px; display: block; }
.char-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.char-desc { font-size: 0.85rem; color: var(--text-muted); white-space: pre-line; }
.coming-soon-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--text-muted);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
}

.game-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
}
.back-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

/* Game screen */
.game-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  min-height: 36px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }

.char-info { font-size: 0.9rem; font-weight: 600; }
.stats-bar {
  margin-left: auto;
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.stat-item { display: flex; align-items: center; gap: 4px; }

.game-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  width: 100%;
}

/* Chapter card */
.chapter-card {
  text-align: center;
  padding: 60px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.chapter-label { font-size: 0.85rem; opacity: 0.8; margin-bottom: 8px; }
.chapter-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 16px; }
.btn-next {
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.6);
  color: #fff;
  padding: 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 44px;
  transition: background 0.15s;
}
.btn-next:hover { background: rgba(255,255,255,0.35); }

/* Dialogue card */
.dialogue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.scene-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.speaker {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.dialogue-text {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 20px;
}
.btn-continue {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  min-height: 44px;
  transition: background 0.15s;
}
.btn-continue:hover { background: var(--primary-dark); }

/* Choice card */
.choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.choice-prompt {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 20px;
}
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.choice-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.92rem;
  text-align: left;
  line-height: 1.5;
  min-height: 44px;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
}
.choice-btn:hover {
  border-color: var(--primary);
  background: #eef4fb;
}
.choice-btn:focus {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Result card */
.result-card {
  background: var(--surface);
  border-left: 4px solid var(--neutral);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.result-card.positive { border-left-color: var(--positive); }
.result-card.negative { border-left-color: var(--negative); }
.result-text {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 16px;
}
.effect-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.effect-tag {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.effect-tag.up { color: var(--positive); border-color: var(--positive); }
.effect-tag.down { color: var(--negative); border-color: var(--negative); }

/* Knowledge link */
.knowledge-link {
  background: #eef4fb;
  border: 1px solid #a8d4f5;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  cursor: pointer;
}
.knowledge-link summary {
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.knowledge-link summary::before { content: "📖"; }
.knowledge-body {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}
.knowledge-tips {
  margin-top: 8px;
  padding-left: 16px;
}
.knowledge-tips li { margin-bottom: 4px; }

/* Ending card */
.ending-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--primary);
}
.ending-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
}
.ending-text {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-line;
  margin-bottom: 28px;
}
.btn-restart {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  min-height: 44px;
  transition: background 0.15s;
}
.btn-restart:hover { background: var(--primary-dark); }

@media (max-width: 600px) {
  .game-header h1 { font-size: 1.5rem; }
  .character-card { width: 100%; max-width: 320px; }
  .game-content { padding: 20px 16px 60px; }
}
