/* ========================================
   月雅湖畔毕业指南 - 主样式
   No.1956 Graduation Guide - Main Styles
   ======================================== */

:root {
  --primary: #1a3a5c;
  --primary-light: #2a4a6c;
  --primary-dark: #0f2640;
  --secondary: #c9a84c;
  --secondary-light: #e0c06a;
  --secondary-dark: #a08030;
  --accent: #8b0000;
  --success: #2d5a3f;
  --bg: #f5f1e8;
  --bg-warm: #ebe5d8;
  --card: #ffffff;
  --card-hover: #faf8f4;
  --text: #2c2c2c;
  --text-light: #666666;
  --text-lighter: #999999;
  --border: #d4cdb8;
  --shadow: rgba(26, 58, 92, 0.12);
  --shadow-strong: rgba(26, 58, 92, 0.25);
  --gold-glow: rgba(201, 168, 76, 0.3);

  --font-serif: 'Noto Serif SC', 'Songti SC', serif;
  --font-sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-display: 'Cinzel', 'Noto Serif SC', serif;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #4a90d9;
  --primary-light: #6aa8e8;
  --primary-dark: #2a6099;
  --secondary: #e8d5a3;
  --secondary-light: #f5e8c0;
  --secondary-dark: #c4b070;
  --accent: #ff4444;
  --success: #4caf50;
  --bg: #12121e;
  --bg-warm: #1a1a2e;
  --card: #1e1e3a;
  --card-hover: #2a2a4a;
  --text: #e8e8f0;
  --text-light: #a0a0b8;
  --text-lighter: #707090;
  --border: #3a3a5a;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  --gold-glow: rgba(232, 213, 163, 0.2);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ===== 页面系统 ===== */
.page {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.page.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

/* ===== 开始页 ===== */
#page-start {
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow-y: auto;
}

/* ===== 专业选择页 ===== */
#page-major {
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(201,168,76,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(26,58,92,0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  z-index: 0;
}

.start-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a84c' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.start-content {
  position: relative;
  z-index: 1;
  max-width: 640px;
  width: 90%;
  padding: 2rem;
}

.lang-switch {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-display);
}

.lang-switch button {
  background: none;
  border: none;
  color: var(--text-lighter);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color var(--transition);
  font-family: var(--font-display);
}

.lang-switch button.active,
.lang-switch button:hover {
  color: var(--secondary);
}

.game-title {
  margin-bottom: 1rem;
}

.title-zh {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 900;
  color: var(--primary);
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
  text-shadow: 0 2px 8px var(--shadow);
}

.title-en {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  font-weight: 400;
  color: var(--secondary-dark);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.title-divider {
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--secondary), transparent);
  margin: 1rem auto;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  letter-spacing: 0.1em;
}

.start-quote {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: italic;
  min-height: 3rem;
  margin-bottom: 2.5rem;
  padding: 0 1rem;
  line-height: 1.8;
  opacity: 0.8;
}

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}

.start-footer {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.domain {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--secondary);
  letter-spacing: 0.2em;
}

.credit {
  font-size: 0.7rem;
  color: var(--text-lighter);
}

/* ===== 按钮系统 ===== */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.85rem 2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  outline: none;
  min-width: 180px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 16px var(--shadow-strong);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--shadow-strong);
}

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

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}

.btn-secondary:hover {
  border-color: var(--secondary);
  color: var(--secondary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  border-color: var(--secondary);
  transform: scale(1.1);
  box-shadow: 0 2px 12px var(--gold-glow);
}

/* ===== 属性分配页 ===== */
#page-allocate .page-content {
  max-width: 520px;
  width: 90%;
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
}

#page-allocate h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

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

.stat-pool {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--secondary-dark);
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
}

.stat-pool #stat-pool-value {
  font-size: 1.8rem;
  color: var(--secondary);
}

.allocate-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.allocate-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--card);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
}

.allocate-row .stat-icon {
  font-size: 1.4rem;
  width: 32px;
  text-align: center;
}

.allocate-row .stat-label {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.allocate-row .stat-label .en {
  font-size: 0.75rem;
  color: var(--text-lighter);
  margin-left: 0.3rem;
  font-family: var(--font-display);
}

.allocate-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.allocate-controls button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.allocate-controls button:hover:not(:disabled) {
  border-color: var(--secondary);
  background: var(--bg-warm);
}

.allocate-controls button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.allocate-value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  font-family: var(--font-display);
}

.allocate-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ===== 天赋抽取页 ===== */
#page-talent .page-content {
  max-width: 800px;
  width: 90%;
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
}

#page-talent h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.talent-subtitle {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.talent-cards {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  perspective: 1000px;
}

.talent-card {
  width: 220px;
  height: 300px;
  cursor: pointer;
  perspective: 1000px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  border-radius: var(--radius-lg);
}

.talent-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.talent-card.selected .card-inner {
  box-shadow: 0 0 30px var(--gold-glow);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px solid var(--border);
}

.card-front {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--secondary);
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 700;
}

.card-back {
  background: var(--card);
  transform: rotateY(180deg);
  text-align: center;
}

.talent-rarity {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.talent-rarity[data-rarity="UR"] { color: #ff6b35; }
.talent-rarity[data-rarity="SSR"] { color: #c9a84c; }
.talent-rarity[data-rarity="SR"] { color: #8b5cf6; }
.talent-rarity[data-rarity="R"] { color: #3b82f6; }
.talent-rarity[data-rarity="N"] { color: #6b7280; }

.talent-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.talent-desc {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.6;
}

.refresh-talents {
  margin-bottom: 1rem;
}

/* ===== 游戏主界面 ===== */
#page-game {
  background: var(--bg);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 20;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#semester-display {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

#campus-display {
  font-size: 0.75rem;
  color: var(--text-light);
}

.header-right {
  display: flex;
  gap: 0.4rem;
}

.game-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 属性面板 */
.stats-panel {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 15;
}

.stat-bar {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-bar .stat-icon {
  font-size: 1.2rem;
  margin-right: 0.3rem;
}

.stat-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.stat-label .en {
  font-size: 0.7rem;
  color: var(--text-lighter);
  margin-left: 0.2rem;
  font-family: var(--font-display);
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  transition: color 0.3s;
}

.stat-value.changed {
  color: var(--secondary);
  animation: statBounce 0.5s ease;
}

.stat-bar-track {
  height: 6px;
  background: var(--bg-warm);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-bar[data-attr="笃学"] .stat-bar-fill { background: linear-gradient(90deg, #1a3a5c, #2d5a8c); }
.stat-bar[data-attr="力行"] .stat-bar-fill { background: linear-gradient(90deg, #8b6914, #c9a84c); }
.stat-bar[data-attr="守正"] .stat-bar-fill { background: linear-gradient(90deg, #5a1a3a, #8c2d5a); }
.stat-bar[data-attr="求新"] .stat-bar-fill { background: linear-gradient(90deg, #1a5a3a, #2d8c5a); }
.stat-bar[data-attr="体质"] .stat-bar-fill { background: linear-gradient(90deg, #3a1a5a, #5a2d8c); }

.talent-display {
  margin-top: auto;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--border);
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
}

.talent-display .talent-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--secondary-dark);
  margin-top: 0.2rem;
}

/* 故事区域 */
.story-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
  overflow-y: auto;
  gap: 1rem;
}

.event-image {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255,255,255,0.3);
  overflow: hidden;
  position: relative;
}

.event-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.03' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}

.event-meta {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.event-type-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: var(--bg-warm);
  color: var(--text-light);
  border: 1px solid var(--border);
  font-weight: 500;
}

.event-type-badge.type-world { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.event-type-badge.type-exam { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.event-type-badge.type-easter { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }
.event-type-badge.type-ending { background: #fce7f3; color: #9d174d; border-color: #f9a8d4; }

.event-location {
  font-size: 0.75rem;
  color: var(--text-lighter);
}

.event-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
  padding: 0.5rem 0;
  min-height: 3rem;
}

.event-text .title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.6rem;
  display: block;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.choice-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.choice-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--secondary);
  opacity: 0;
  transition: opacity var(--transition);
}

.choice-card:hover:not(.locked) {
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.choice-card:hover:not(.locked)::before {
  opacity: 1;
}

.choice-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg-warm);
}

.choice-card.locked::after {
  content: '🔒';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.9rem;
}

.choice-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.choice-hint {
  font-size: 0.75rem;
  color: var(--text-lighter);
}

.choice-effects {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.effect-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-warm);
  color: var(--text-light);
}

.effect-tag.positive { color: var(--success); }
.effect-tag.negative { color: var(--accent); }

/* 日志面板 */
.log-panel {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  flex-shrink: 0;
  max-height: 36px;
  transition: max-height var(--transition);
  overflow: hidden;
  z-index: 20;
}

.log-panel.expanded {
  max-height: 200px;
}

.log-toggle {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.log-toggle:hover {
  color: var(--secondary-dark);
}

.log-entries {
  margin-top: 0.5rem;
  overflow-y: auto;
  max-height: 150px;
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.6;
  padding-right: 0.5rem;
}

.log-entry {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow-strong);
  border: 1px solid var(--border);
}

.modal-content h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 1rem;
  text-align: center;
}

/* 检定弹窗 */
.check-content {
  text-align: center;
  max-width: 400px;
}

.dice-area {
  margin: 1.5rem 0;
}

.dice {
  font-size: 4rem;
  animation: diceShake 0.5s ease infinite;
}

.dice.stopped {
  animation: none;
}

.dice-value {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

.check-details {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.check-result {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  min-height: 2rem;
}

.check-result.success { color: var(--success); }
.check-result.fail { color: var(--accent); }

/* 地图弹窗 */
.map-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.map-item {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  text-align: center;
  transition: all var(--transition);
  background: var(--bg);
}

.map-item.unlocked {
  background: var(--card);
  cursor: pointer;
}

.map-item.unlocked:hover {
  border-color: var(--secondary);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.map-item.locked {
  opacity: 0.4;
}

.map-item .map-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.map-item .map-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.map-item .map-status {
  font-size: 0.7rem;
  color: var(--text-lighter);
}

/* 七秩记忆弹窗 */
.fragments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.fragment-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  text-align: center;
  transition: all var(--transition);
  background: var(--bg);
}

.fragment-item.collected {
  background: var(--card);
  border-color: var(--secondary);
}

.fragment-item .fragment-year {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--secondary);
}

.fragment-item .fragment-title {
  font-size: 0.75rem;
  color: var(--text);
  margin-top: 0.3rem;
}

.fragment-item .fragment-status {
  font-size: 0.65rem;
  color: var(--text-lighter);
  margin-top: 0.2rem;
}

/* ===== 结局页 ===== */
#page-ending {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--bg);
}

.ending-bg {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background: radial-gradient(circle at center, var(--secondary) 0%, transparent 70%);
}

.ending-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  width: 90%;
  padding: 2rem;
}

.ending-rarity {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.ending-rarity[data-rarity="UR"] { color: #ff6b35; }
.ending-rarity[data-rarity="SSR"] { color: #c9a84c; }
.ending-rarity[data-rarity="SR"] { color: #8b5cf6; }
.ending-rarity[data-rarity="R"] { color: #3b82f6; }
.ending-rarity[data-rarity="N"] { color: #6b7280; }
.ending-rarity[data-rarity="???"] { color: var(--accent); }

.ending-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.ending-divider {
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--secondary), transparent);
  margin: 1rem auto;
}

.ending-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 2;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.ending-stats {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.ending-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ===== 图鉴/成就页 ===== */
#page-archive-full .page-content {
  max-width: 800px;
  width: 90%;
  margin: auto;
  padding: 2rem 1rem;
}

.archive-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--text-light);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.tab-btn.active,
.tab-btn:hover {
  background: var(--bg-warm);
  color: var(--primary);
}

.tab-btn.active {
  font-weight: 600;
}

.archive-body {
  min-height: 300px;
}

/* ===== 加载层 ===== */
.loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ===== 工具类 ===== */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  html { font-size: 14px; }

  .title-zh { font-size: 1.5rem; letter-spacing: 0.1em; }
  .title-en { font-size: 0.8rem; letter-spacing: 0.15em; }
  .subtitle { font-size: 0.85rem; margin-bottom: 1.2rem; }
  .start-quote { font-size: 0.85rem; min-height: 2rem; margin-bottom: 1.5rem; }

  .game-header {
    padding: 0.3rem 0.6rem;
    min-height: 40px;
  }
  #semester-display { font-size: 0.85rem; }
  #campus-display { font-size: 0.65rem; }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    border-width: 1px;
  }

  .game-body {
    flex-direction: column;
  }

  /* 属性面板：手机端重新设计为紧凑状态条 */
  .stats-panel {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 0.25rem 0.4rem;
    gap: 0.15rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .stat-bar {
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    min-width: auto;
  }
  .stat-bar .stat-icon {
    font-size: 0.9rem;
    width: auto;
    margin: 0;
  }
  .stat-info {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }
  .stat-label {
    font-size: 0.6rem;
    line-height: 1;
  }
  .stat-label .en {
    display: none; /* 手机端隐藏英文缩写，节省空间 */
  }
  .stat-value {
    font-size: 0.8rem;
  }
  .stat-bar-track {
    height: 2px;
    width: 100%;
  }

  .talent-display {
    display: none;
  }

  .story-area {
    padding: 0.5rem 0.6rem;
    gap: 0.4rem;
  }

  .event-image {
    height: 48px;
    font-size: 1.6rem;
    border-radius: var(--radius-sm);
  }

  .event-meta {
    gap: 0.3rem;
  }
  .event-type-badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.35rem;
  }
  .event-location {
    font-size: 0.65rem;
  }

  .event-text {
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 0.2rem 0 0.8rem;
  }
  .event-text .title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }

  /* 选项卡片：单列，但增大点击区域 */
  .choices-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-bottom: 2rem;
  }

  .choice-card {
    padding: 0.7rem 0.8rem;
    border-radius: var(--radius-sm);
  }
  .choice-card:active:not(.locked) {
    transform: scale(0.98);
    background: var(--bg-warm);
  }
  .choice-text {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    line-height: 1.5;
  }
  .choice-hint {
    font-size: 0.7rem;
  }
  .choice-effects {
    margin-top: 0.2rem;
    gap: 0.25rem;
  }
  .effect-tag {
    font-size: 0.6rem;
    padding: 0.05rem 0.3rem;
  }

  .log-panel {
    padding: 0.2rem 0.5rem;
    max-height: 26px;
  }
  .log-toggle {
    font-size: 0.7rem;
  }
  .log-entries {
    font-size: 0.7rem;
    max-height: 90px;
  }

  /* 天赋页：更紧凑 */
  .talent-cards {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
  }

  .talent-card {
    width: 110px;
    height: 150px;
  }

  .card-front, .card-back {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
  }
  .card-front { font-size: 2rem; }

  .talent-rarity { font-size: 0.6rem; margin-bottom: 0.15rem; }
  .talent-name { font-size: 0.8rem; margin-bottom: 0.3rem; }
  .talent-desc { font-size: 0.65rem; }

  #page-talent .page-content {
    overflow-y: auto;
    padding: 1rem 0.8rem 4rem;
  }
  #page-talent h2 { font-size: 1.3rem; }
  .talent-subtitle { font-size: 0.8rem; margin-bottom: 1.2rem; }

  .talent-actions {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .talent-actions button {
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
  }

  .map-grid {
    grid-template-columns: 1fr;
  }

  .ending-content {
    padding: 1.2rem;
  }
  .ending-title {
    font-size: 1.4rem;
  }
  .ending-text {
    font-size: 0.9rem;
    line-height: 1.7;
  }
  .ending-stats {
    font-size: 0.75rem;
    gap: 0.5rem;
  }
  .ending-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
  }

  .btn-primary, .btn-secondary {
    min-width: 140px;
    padding: 0.65rem 1.2rem;
    font-size: 0.9rem;
  }

  .modal-content {
    padding: 1rem;
    max-width: 92vw;
  }
  .modal-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.6rem;
  }

  .allocate-row {
    padding: 0.5rem 0.7rem;
  }
  .allocate-row .stat-icon {
    font-size: 1.1rem;
    width: 24px;
  }
  .allocate-controls button {
    width: 26px;
    height: 26px;
    font-size: 0.9rem;
  }
  .allocate-value {
    font-size: 0.95rem;
    min-width: 22px;
  }

  .start-user-box {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .username-input {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  .save-item {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  .save-item .save-meta {
    font-size: 0.7rem;
  }

  .dice { font-size: 2.5rem; }
  .dice-value { font-size: 2rem; }
  .check-content { max-width: 92vw; padding: 1rem; }
  .check-details { font-size: 0.8rem; }
  .check-result { font-size: 1rem; }

  /* 专业选择页 */
  #page-major h2 { font-size: 1.4rem; }
  #page-major .allocate-subtitle { font-size: 0.85rem; margin-bottom: 1.2rem; }
  #page-major .page-content {
    padding: 1rem 0.8rem 4rem;
    overflow-y: visible;
  }
  .major-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .major-card {
    padding: 0.6rem 0.3rem;
    border-radius: var(--radius-sm);
  }
  .major-card .major-icon {
    font-size: 1.5rem;
    margin-bottom: 0.15rem;
  }
  .major-card .major-name {
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
  }
  .major-card .major-effects {
    font-size: 0.65rem;
  }
}

@media (max-width: 480px) {
  html { font-size: 13px; }
  .title-zh { font-size: 1.3rem; }
  .stats-panel {
    padding: 0.2rem 0.3rem;
    gap: 0.1rem;
  }
  .stat-bar .stat-icon { font-size: 0.8rem; }
  .stat-label { font-size: 0.55rem; }
  .stat-value { font-size: 0.75rem; }
  .event-image { height: 40px; font-size: 1.4rem; }
  .talent-card { width: 100px; height: 140px; }
  .choice-card { padding: 0.6rem 0.7rem; }
  .choice-text { font-size: 0.85rem; }
  .game-header { padding: 0.2rem 0.4rem; min-height: 36px; }
  .icon-btn { width: 28px; height: 28px; font-size: 0.8rem; }
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-lighter);
}


/* ===== 用户名与存档系统 ===== */
.start-user-box {
  max-width: 360px;
  width: 90%;
  margin: 0 auto 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.username-input {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  text-align: center;
  outline: none;
  transition: border-color var(--transition);
}

.username-input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.username-input::placeholder {
  color: var(--text-lighter);
}

.start-user-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.start-user-actions .btn-primary,
.start-user-actions .btn-secondary {
  min-width: auto;
  flex: 1;
  padding: 0.7rem 1rem;
}

.import-btn {
  position: relative;
  cursor: pointer;
}

.import-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
}

.save-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.save-item:hover {
  border-color: var(--secondary);
  background: var(--card-hover);
}

.save-item .save-name {
  font-weight: 600;
  color: var(--primary);
}

.save-item .save-meta {
  font-size: 0.75rem;
  color: var(--text-light);
}

.save-item .save-delete {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.save-item .save-delete:hover {
  opacity: 1;
}

.save-content {
  max-width: 420px;
}

.save-current-user {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--border);
}

.save-current-user strong {
  color: var(--primary);
  font-family: var(--font-display);
}

.save-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.save-actions button {
  min-width: auto;
  flex: 1;
  padding: 0.7rem 1rem;
}

.save-list-modal {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.save-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #fff;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: 0 4px 16px var(--shadow-strong);
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 300;
  pointer-events: none;
}

.save-toast.version-toast {
  pointer-events: auto;
  cursor: pointer;
}

.save-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .start-user-actions {
    flex-direction: column;
  }

  .save-actions {
    flex-direction: column;
  }
}


/* ===== 专业选择 ===== */
#page-major .page-content {
  max-width: 800px;
  width: 90%;
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
}

#page-major h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.major-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
  max-width: 600px;
  margin: 0 auto;
}

.major-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.major-card:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.major-card .major-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.major-card .major-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.major-card .major-effects {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ===== 天赋动作区 ===== */
.talent-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.talent-actions button {
  min-width: auto;
}

/* ===== 云端登录弹窗 ===== */
.cloud-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.cloud-form input {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
}

.cloud-form input:focus {
  border-color: var(--secondary);
}
