/* ====================================
   M-PALACE · 宫廷视觉风格
   暗红+金色主题 · 古风字体 · 逐字动画
   ==================================== */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary:    #1a0a0a;
  --bg-secondary:  #0d0d1a;
  --gold:          #c9a96e;
  --gold-light:    #e8d5a3;
  --danger:        #8b0000;
  --text-primary:  #f5f0e8;
  --text-secondary:#a0937d;
  --border-gold:   rgba(201,169,110,0.15);
  --border-gold-md:rgba(201,169,110,0.3);
  --glow-gold:     rgba(201,169,110,0.25);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- Background Texture ---------- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139,0,0,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201,169,110,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(13,13,26,0.6) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Layout ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
}

/* ---------- Typography ---------- */
.serif {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', 'STSong', serif;
}

h1, h2, h3 { color: var(--gold); font-weight: 400; }

/* ---------- Golden Divider ---------- */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 1.5rem 0;
  opacity: 0.4;
}

.divider-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

/* ====================================
   INDEX PAGE — Quick Start
   ==================================== */
.start-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
}

.start-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px var(--glow-gold));
}

.start-title {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  font-size: 2.2rem;
  letter-spacing: 0.8rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.start-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  letter-spacing: 0.2rem;
}

/* Form Card */
.start-card {
  background: rgba(26,10,10,0.85);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(8px);
}

.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

select, input[type="text"] {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(13,13,26,0.6);
  border: 1px solid var(--border-gold-md);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}

select:focus, input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--glow-gold);
}

select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: rgba(139,0,0,0.3);
  color: var(--gold);
  font-size: 1rem;
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.15rem;
}

.btn:hover {
  background: rgba(139,0,0,0.6);
  box-shadow: 0 0 16px var(--glow-gold);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn-primary {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.btn-small {
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
}

/* Load Section */
.load-section {
  width: 100%;
  max-width: 420px;
  margin-top: 1rem;
}

.load-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.load-row input { flex: 1; }

/* Footer */
.start-footer {
  margin-top: 3rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ====================================
   GAME PAGE — Main Narrative
   ==================================== */
.game-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--border-gold);
  background: rgba(26,10,10,0.9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar-title {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  font-size: 1rem;
  color: var(--gold);
}

.top-bar-actions {
  display: flex;
  gap: 0.5rem;
}

/* Narrative Area */
.narrative-area {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.chapter-title {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  font-size: 1.4rem;
  color: var(--gold);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.3rem;
}

.narrative-text {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text-primary);
  text-align: justify;
  margin-bottom: 2rem;
  min-height: 120px;
}

/* Typewriter Animation */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Choices Area */
.choices-area {
  padding: 0 1.5rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.choices-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
  padding-left: 0.3rem;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 0.9rem 1.2rem;
  margin-bottom: 0.6rem;
  background: rgba(139,0,0,0.15);
  border: 1px solid var(--border-gold-md);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s;
}

.choice-btn:hover {
  background: rgba(139,0,0,0.35);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--glow-gold);
  transform: translateX(4px);
}

.choice-btn:active {
  transform: translateX(2px);
}

.choice-btn .choice-num {
  color: var(--gold);
  margin-right: 0.5rem;
  font-weight: 600;
}

/* Free Input */
.free-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.free-input-row input {
  flex: 1;
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
}

/* Status Bar */
.status-bar {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-gold);
  background: rgba(13,13,26,0.6);
  backdrop-filter: blur(6px);
}

.status-toggle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 0.5rem;
  user-select: none;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1.5rem;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.stat-icon { width: 1.2rem; text-align: center; }

.stat-label {
  width: 3rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stat-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(201,169,110,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.stat-bar-fill.power   { background: linear-gradient(90deg, #8b0000, #c9a96e); }
.stat-bar-fill.status  { background: linear-gradient(90deg, #6b21a8, #c9a96e); }
.stat-bar-fill.emotion { background: linear-gradient(90deg, #b8860b, #e8d5a3); }
.stat-bar-fill.conflict{ background: linear-gradient(90deg, #4a1a2e, #8b0000); }

.stat-value {
  width: 1.8rem;
  text-align: right;
  color: var(--gold-light);
  font-size: 0.8rem;
}

/* Bottom Bar */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-gold);
  background: rgba(26,10,10,0.9);
}

/* Status collapsed */
.status-bar.collapsed .status-grid { display: none; }

/* ====================================
   SAVE PAGE
   ==================================== */
.save-page {
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.save-page h1 {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  text-align: center;
  margin-bottom: 2rem;
  letter-spacing: 0.4rem;
}

.save-list {
  max-width: 600px;
  margin: 0 auto;
}

.save-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
  background: rgba(26,10,10,0.7);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  transition: border-color 0.3s;
}

.save-item:hover {
  border-color: var(--gold);
}

.save-info { flex: 1; }

.save-id {
  font-family: 'Noto Serif SC', 'Source Han Serif CN', serif;
  font-size: 1rem;
  color: var(--gold);
}

.save-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.save-actions {
  display: flex;
  gap: 0.4rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

/* ====================================
   LOADING & TRANSITIONS
   ==================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--text-secondary);
}

.loading-dot {
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* Fade transition */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Toast notification */
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: 0.8rem 1.5rem;
  background: rgba(26,10,10,0.95);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold-light);
  font-size: 0.9rem;
  z-index: 100;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ====================================
   Responsive
   ==================================== */
@media (max-width: 600px) {
  .start-card { padding: 1.5rem; }
  .start-title { font-size: 1.8rem; letter-spacing: 0.5rem; }
  .status-grid { grid-template-columns: 1fr; }
  .top-bar-title { font-size: 0.85rem; }
}
