/* ========================================
   《如果你去这个城市读大学》样式
   移动端优先 · 纯 CSS · 无框架
   ======================================== */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-elevated: #242836;
  --text: #f0f2f8;
  --text-muted: #9aa3b8;
  --primary: #6c8cff;
  --primary-dark: #4a6ae8;
  --accent: #ff8c6c;
  --accent-soft: #ffb89a;
  --success: #5dd9a8;
  --warning: #ffd166;
  --danger: #ff6b8a;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

#app {
  height: 100%;
  position: relative;
}

/* ---- 视图切换 ---- */
.view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(108, 140, 255, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(108, 140, 255, 0.45);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* ---- 开场页 ---- */
#view-splash {
  position: relative;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(108, 140, 255, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(255, 140, 108, 0.12), transparent),
    var(--bg);
  z-index: 0;
}

.splash-content {
  position: relative;
  z-index: 1;
  max-width: 360px;
}

.splash-eyebrow {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 16px;
}

.splash-title {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.splash-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
  line-height: 1.7;
}

.splash-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- 设定页 ---- */
#view-setup {
  overflow-y: auto;
  padding: calc(16px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.view-header {
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: 24px;
  margin-top: 8px;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.label-fun {
  font-weight: 400;
  color: var(--accent);
}

.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.option-card {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.option-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}

.option-card:active .option-card-inner,
.option-card-inner:active {
  transform: scale(0.98);
}

.option-card.selected .option-card-inner {
  border-color: var(--primary);
  background: rgba(108, 140, 255, 0.12);
}

.option-icon {
  font-size: 24px;
}

.option-label {
  font-size: 14px;
  font-weight: 600;
}

.option-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---- 游戏页 ---- */
#view-game {
  padding-top: var(--safe-top);
}

.game-header {
  padding: 12px 16px 8px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.game-city {
  font-weight: 700;
  font-size: 15px;
}

.game-chapter {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 10px;
  border-radius: 20px;
}

.game-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 8px;
  background: var(--bg-elevated);
  border-radius: 20px;
  white-space: nowrap;
}

.stat-pill .stat-bar {
  width: 32px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.stat-pill .stat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.stat-float {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  animation: statFloat 1s ease forwards;
  z-index: 100;
}

@keyframes statFloat {
  0% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -80px); }
}

.game-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.event-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--accent), #e86c4a);
  border-radius: 20px;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.story-text {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  min-height: 120px;
}

.story-text.typing::after {
  content: "▋";
  animation: blink 0.8s step-end infinite;
  color: var(--primary);
}

@keyframes blink {
  50% { opacity: 0; }
}

.choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-bottom: 8px;
}

.choice-btn {
  width: 100%;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  line-height: 1.5;
}

.choice-btn:hover {
  background: var(--bg-elevated);
  border-color: rgba(108, 140, 255, 0.4);
}

.choice-btn:active {
  transform: scale(0.98);
}

.choice-btn .choice-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.game-footer {
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.progress-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- 毕业页 ---- */
#view-graduation {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 30%, rgba(108, 140, 255, 0.15), transparent),
    var(--bg);
}

.graduation-year {
  font-size: 14px;
  color: var(--primary);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.graduation-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 20px;
}

.graduation-text {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 340px;
  margin-bottom: 36px;
}

/* ---- 结局页（铺满整页） ---- */
#view-ending {
  overflow: hidden;
}

.ending-scroll {
  height: 100%;
  overflow-y: auto;
  padding: calc(20px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
  background:
    radial-gradient(ellipse 100% 40% at 50% 0%, rgba(108, 140, 255, 0.2), transparent),
    radial-gradient(ellipse 60% 30% at 90% 60%, rgba(255, 140, 108, 0.15), transparent),
    var(--bg);
}

.ending-hero {
  text-align: center;
  padding: 24px 8px 32px;
}

.ending-eyebrow {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 12px;
}

.ending-title {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff, var(--accent-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ending-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}

.ending-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.ending-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.ending-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}

.radar-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
}

.stats-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-detail-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stat-detail-item .stat-name {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-detail-item .stat-value {
  font-size: 22px;
  font-weight: 700;
}

.stat-detail-item .stat-comment {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ending-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ending-list li {
  font-size: 14px;
  line-height: 1.6;
  padding-left: 20px;
  position: relative;
}

.ending-list li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 12px;
}

.ending-quote-card {
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.12), rgba(255, 140, 108, 0.08));
  border-color: rgba(108, 140, 255, 0.25);
}

.ending-quote {
  font-size: 17px;
  font-style: italic;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 8px;
}

.ending-quote + cite,
cite {
  font-size: 12px;
  color: var(--text-muted);
  font-style: normal;
}

.ending-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ending-tag {
  font-size: 13px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
}

.ending-tag.highlight {
  background: rgba(108, 140, 255, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.ending-share-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  word-break: break-all;
}

.ending-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- 加载 & Toast ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-text {
  font-size: 14px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 300;
  white-space: nowrap;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden {
  display: none !important;
}

/* ---- 响应式 ---- */
@media (min-width: 480px) {
  .ending-scroll {
    max-width: 480px;
    margin: 0 auto;
  }

  #view-setup {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
}
