:root {
  --bg-deep: #0e1118;
  --bg-panel: rgba(20, 24, 34, 0.86);
  --bg-card: rgba(29, 34, 48, 0.88);
  --gold: #f0b857;
  --gold-bright: #ffd98a;
  --sandstone: #c9975b;
  --vermilion: #d64531;
  --vermilion-glow: rgba(214, 69, 49, 0.35);
  --jade: #3dd5a3;
  --text-main: #f4efe6;
  --text-muted: #b5ad9f;
  --border-gold: rgba(240, 184, 87, 0.28);
  --shadow-heavy: 0 20px 55px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* 顶部导航栏 */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 58px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(12, 15, 22, 0.92), rgba(12, 15, 22, 0.35));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(240, 184, 87, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #161410;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  padding: 4px 8px;
  border-radius: 5px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-main);
}

.stage-pills {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill:hover {
  color: var(--text-main);
  background: rgba(240, 184, 87, 0.12);
}

.pill.active {
  background: linear-gradient(135deg, var(--vermilion), #b53220);
  color: #fff;
  box-shadow: 0 2px 10px var(--vermilion-glow);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(240, 184, 87, 0.25);
  color: var(--text-main);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(240, 184, 87, 0.18);
  border-color: var(--gold);
}

/* 游戏内 HUD */
.game-hud {
  position: fixed;
  top: 68px;
  left: 20px;
  right: 20px;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  gap: 10px;
}

.hud-card {
  background: rgba(16, 20, 30, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 128px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.hud-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.hud-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.hud-value.gold {
  color: var(--gold-bright);
}

.hud-bar-wrap {
  width: 120px;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin: 5px 0 3px;
}

.hud-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--vermilion), var(--gold), var(--jade));
  border-radius: 999px;
  transition: width 0.2s ease;
}

.hud-sub {
  font-size: 11px;
  color: var(--gold-bright);
  font-weight: 700;
}

.hud-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 16px;
}

.toast-banner {
  background: rgba(24, 20, 18, 0.88);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 520px;
  text-align: center;
}

.toast-banner.show {
  opacity: 1;
  transform: translateY(0);
}

/* 全屏覆盖界面 */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 24px;
  background: radial-gradient(circle at center, rgba(16, 18, 28, 0.45), rgba(10, 12, 18, 0.82));
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

/* 序章主卡片 */
.hero-card, .briefing-card, .clear-card {
  width: 100%;
  max-width: 740px;
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: var(--shadow-heavy);
  position: relative;
  overflow: hidden;
}

.hero-card::before, .briefing-card::before, .clear-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--vermilion), var(--gold), transparent);
}

.hero-eyebrow, .brief-tag, .clear-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  background: rgba(240, 184, 87, 0.12);
  border: 1px solid rgba(240, 184, 87, 0.32);
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #fff5dc 0%, var(--gold) 55%, #e38642 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.hero-subtitle strong {
  color: var(--gold-bright);
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.mode-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.22s ease;
}

.mode-card:hover {
  border-color: rgba(240, 184, 87, 0.55);
  transform: translateY(-2px);
}

.mode-card.selected {
  background: linear-gradient(135deg, rgba(240, 184, 87, 0.16), rgba(214, 69, 49, 0.14));
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(240, 184, 87, 0.18);
}

.mode-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.mode-name {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--gold-bright);
}

.mode-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.chapter-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}

.chapter-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
}

.ch-num {
  font-size: 18px;
  font-weight: 900;
  color: var(--vermilion);
  line-height: 1;
}

.chapter-item strong {
  display: block;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 3px;
}

.chapter-item p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 按钮 */
.primary-btn {
  background: linear-gradient(135deg, #e7513b 0%, #c83823 55%, #a82818 100%);
  color: #fffaf0;
  border: 1px solid rgba(255, 217, 138, 0.5);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 13px 32px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(214, 69, 49, 0.42);
  transition: all 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 30px rgba(214, 69, 49, 0.56);
}

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

.pulse {
  animation: btnPulse 2.2s infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 8px 26px rgba(214, 69, 49, 0.42); }
  50% { box-shadow: 0 8px 34px rgba(240, 184, 87, 0.55); }
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  border: 1px solid rgba(240, 184, 87, 0.32);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: rgba(240, 184, 87, 0.16);
  border-color: var(--gold);
}

/* 指引卡片 */
.briefing-card {
  max-width: 620px;
}

.brief-title, .clear-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 12px;
}

.brief-story, .clear-message {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-main);
  margin-bottom: 18px;
}

.brief-controls {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(240, 184, 87, 0.22);
  border-radius: 14px;
  padding: 14px 18px;
  text-align: left;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.brief-controls strong {
  color: var(--gold-bright);
}

.brief-controls kbd {
  display: inline-block;
  background: rgba(240, 184, 87, 0.18);
  border: 1px solid rgba(240, 184, 87, 0.45);
  color: #fff;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  margin: 0 2px;
}

.brief-quote {
  font-size: 13px;
  font-style: italic;
  color: var(--sandstone);
  margin-bottom: 22px;
}

/* 结算统计 */
.clear-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(240, 184, 87, 0.22);
  border-radius: 12px;
  padding: 12px 10px;
}

.stat-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.clear-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* 终章海报界面 */
.finale-card {
  width: 100%;
  max-width: 960px;
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: 24px;
  padding: 28px 30px;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: center;
  box-shadow: var(--shadow-heavy);
}

.finale-title {
  font-size: 30px;
  font-weight: 900;
  background: linear-gradient(135deg, #fff4d4, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}

.finale-summary {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.finale-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.poster-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.poster-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
}

.poster-form input,
.poster-form select {
  background: rgba(12, 15, 22, 0.85);
  border: 1px solid rgba(240, 184, 87, 0.35);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

.poster-form input:focus,
.poster-form select:focus {
  border-color: var(--gold-bright);
}

.finale-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.finale-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#posterCanvas {
  width: 100%;
  max-width: 310px;
  height: auto;
  border-radius: 14px;
  border: 1.5px solid rgba(240, 184, 87, 0.45);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

.poster-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* 底部触控/快捷条 */
.touch-controls {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(560px, calc(100vw - 32px));
}

.touch-group {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.touch-btn {
  flex: 1;
  background: rgba(20, 25, 36, 0.82);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(240, 184, 87, 0.45);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  padding: 14px 18px;
  border-radius: 14px;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, background 0.15s;
}

.touch-btn:active {
  transform: scale(0.96);
  background: rgba(240, 184, 87, 0.25);
}

.touch-btn.accent {
  background: linear-gradient(135deg, rgba(240, 184, 87, 0.25), rgba(214, 69, 49, 0.35));
  border-color: var(--gold-bright);
  color: #fff6df;
}

.touch-btn.fire {
  background: linear-gradient(135deg, #e7513b, #c5341f);
  border-color: var(--gold-bright);
  color: #fff;
}

/* 响应式 */
@media (max-width: 820px) {
  .stage-pills {
    display: none;
  }
  .mode-selector,
  .chapter-preview {
    grid-template-columns: 1fr;
  }
  .hero-card, .briefing-card, .clear-card {
    padding: 22px 18px;
  }
  .finale-card {
    grid-template-columns: 1fr;
    padding: 20px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }
  .game-hud {
    top: 62px;
    left: 10px;
    right: 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .hud-card {
    min-width: auto;
    padding: 6px 10px;
  }
  .hud-value {
    font-size: 14px;
  }
}
