/* ==========================================
   《浙江一万年：文明探源》样式表 v3
   80年代像素风格 · 8-bit Game Edition
   ========================================== */

/* --- 全局重置 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pixel-size: 4px;
  --bg:         #0d0d1a;
  --bg-dark:    #151530;
  --bg-panel:   #1a1a35;
  --text:       #ffffff;
  --text-light: #aaaadd;
  --accent:     #ffcc00;
  --accent2:    #ff8800;
  --gold:       #ffdd44;
  --danger:     #ff4444;
  --success:    #44ff44;
  --border:     #444488;
  --shadow:     4px 4px 0 #000;
  --shadow-sm:  2px 2px 0 #000;
  --radius:     0px;
  --font:       "Press Start 2P", "Zpix", "Fusion Pixel", "Courier New", monospace;
  --font-cn:    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Zpix", sans-serif;
}

html { font-size: 15px; image-rendering: pixelated; }
body {
  font-family: var(--font-cn);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 2px, transparent 2px);
  background-size: 8px 8px;
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 2;
  word-break: break-word;
  overflow-wrap: break-word;
  image-rendering: pixelated;
}
#app { min-height: 100dvh; }

/* --- 像素字体用于英文/数字 --- */
h1, h2, h3, strong, .btn, .era-badge, .turn-info strong, .res-val, .dash-item, .tab-btn, .btn-action {
  font-family: var(--font);
  letter-spacing: 1px;
}

/* --- 屏幕切换 --- */
.screen { display: none; flex-direction: column; min-height: 100dvh; }
.screen.active { display: flex; }

/* --- 面板 --- */
.panel { display: none; flex-direction: column; height: 100%; }
.panel.active { display: flex; }

/* --- 像素按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 16px; border: 3px solid var(--border);
  font-family: var(--font); font-size: 0.75rem; cursor: pointer;
  text-align: center; user-select: none; background: var(--bg-panel);
  color: var(--text); box-shadow: var(--shadow-sm);
  image-rendering: pixelated;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-primary {
  background: var(--accent); color: #000; border-color: var(--accent2);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: #ffdd44; }
.btn-primary:active { background: #ffaa00; transform: translate(2px, 2px); box-shadow: none; }

.btn-secondary {
  background: var(--bg-dark); border-color: var(--border);
}
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 0.65rem; }

.btn-action {
  width: 100%; min-height: 48px; padding: 12px; font-size: 0.7rem;
  background: var(--accent2); color: #000; border-color: var(--accent);
  box-shadow: var(--shadow);
}
.btn-action:hover { background: #ffaa00; }
.btn-action:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-choice {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; margin: 6px 0; min-height: 48px; padding: 10px 14px;
  font-size: 0.7rem; background: var(--bg-dark);
  border: 2px solid var(--border); color: #eeeeff;
  box-shadow: var(--shadow-sm);
}
.btn-choice:hover { border-color: var(--accent); }
.btn-choice:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-tech {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; margin: 4px 0; min-height: 44px; padding: 10px 14px;
  background: var(--bg-dark); border: 2px solid var(--border);
  font-size: 0.6rem;
}
.btn-tech.owned { border-color: var(--success); color: var(--success); }
.btn-tech.affordable { border-color: var(--gold); animation: pixelPulse 1.5s infinite; }
.btn-tech.locked { color: #666688; cursor: not-allowed; border-color: #2a2a44; }
.btn-tech:hover:not(.locked):not(.owned) { border-color: var(--accent); }
.btn-tech:active:not(.locked):not(.owned) { transform: translate(2px, 2px); box-shadow: none; }
.btn-tech .tech-cost { color: #ccccdd; }
.btn-tech.locked .tech-cost { color: #555577; }
.btn-tech.owned .tech-cost { color: #88cc88; }

/* --- 启动画面 --- */
#splash-screen { justify-content: center; align-items: center; }
.splash-inner { text-align: center; padding: 40px 20px; }
.splash-title {
  font-family: var(--font); font-size: 1.8rem; color: var(--accent);
  text-shadow: 4px 4px 0 #000; letter-spacing: 2px;
}
.splash-subtitle {
  font-family: var(--font); font-size: 0.8rem; color: var(--accent2);
  margin: 12px 0 20px;
}
.splash-desc { font-size: 0.7rem; color: var(--text-light); margin-bottom: 32px; line-height: 2; }
#splash-screen .btn { margin: 8px; min-width: 200px; }

/* --- 时间轴 --- */
.splash-timeline {
  position: relative; height: 6px; background: var(--border);
  margin: 0 auto 24px; max-width: 400px; border: 2px solid var(--border);
}
.tl-line {
  position: absolute; top: 0; left: 0; height: 100%; width: 0%;
  background: var(--accent); animation: tlGrow 2s steps(10) forwards;
}
.tl-dot {
  position: absolute; top: -3px; width: 10px; height: 10px;
  background: var(--bg); border: 2px solid var(--border);
  transform: translateX(-50%); animation: tlDotIn 0.3s steps(1) forwards; opacity: 0;
}
.tl-dot:nth-child(1){animation-delay:0.1s}.tl-dot:nth-child(2){animation-delay:0.2s}
.tl-dot:nth-child(3){animation-delay:0.3s}.tl-dot:nth-child(4){animation-delay:0.4s}
.tl-dot:nth-child(5){animation-delay:0.5s}.tl-dot:nth-child(6){animation-delay:0.6s}
.tl-dot:nth-child(7){animation-delay:0.7s}.tl-dot:nth-child(8){animation-delay:0.8s}
.tl-dot:nth-child(9){animation-delay:0.9s}.tl-dot:nth-child(10){animation-delay:1.0s}
@keyframes tlGrow { to { width: 100%; } }
@keyframes tlDotIn { to { opacity: 1; background: var(--accent); border-color: var(--accent); } }
.splash-footer { position: absolute; bottom: 16px; width: 100%; text-align: center; font-size: 0.55rem; color: var(--text-light); }

/* --- 顶部状态栏 --- */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg-dark);
  border-bottom: 3px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.era-badge {
  background: var(--accent); color: #000; padding: 3px 12px;
  font-size: 0.6rem; border: 2px solid var(--accent2);
  box-shadow: var(--shadow-sm);
}
.turn-info { font-size: 0.65rem; color: var(--text-light); }
.turn-info strong { color: var(--accent); font-size: 0.75rem; }

/* --- 进度条 --- */
.era-progress { height: 6px; background: var(--border); margin: 0 12px; border: 2px solid var(--border); }
.era-progress-fill { height: 100%; background: var(--accent); transition: width 0.3s steps(10); }

/* --- 资源条 --- */
.resource-bar {
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px; background: var(--bg-panel);
  border-bottom: 3px solid var(--border); gap: 2px; flex-wrap: wrap;
}
.res-item { display: flex; align-items: center; gap: 3px; font-size: 0.6rem; color: var(--text); }
.res-icon { font-size: 1rem; }
.res-val { font-family: var(--font); font-weight: bold; min-width: 20px; text-align: center; }
.resource-bar.warning { background: #2a1111; }

/* --- 主内容区 --- */
.main-content { flex: 1; overflow-y: auto; padding-bottom: 4px; }
.panel-scroll {
  flex: 1; overflow-y: auto; padding: 12px;
  background-image: linear-gradient(rgba(255,255,255,0.01) 2px, transparent 2px);
  background-size: 8px 8px;
}
.panel-actions { padding: 8px 12px; border-bottom: 3px solid var(--border); }
.panel-actions .btn { margin-bottom: 6px; }

/* --- 仪表盘 --- */
.era-dashboard {
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 12px; background: var(--bg-dark); border-bottom: 2px solid var(--border);
  font-size: 0.6rem; color: #ccccdd;
}
.dash-item { font-family: var(--font); color: #ffffff; }

/* --- 科技树 --- */
.tech-section h3, .event-log h3 {
  font-size: 0.65rem; color: var(--accent); margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 2px dashed var(--border);
}
.tech-name { font-size: 0.65rem; color: #ffffff; }
.tech-cost { font-size: 0.55rem; color: #ccccdd; }
.tech-effect { font-size: 0.55rem; color: var(--success); }

/* --- 事件记录 --- */
.event-log { margin-top: 16px; }
.log-entry {
  padding: 8px 10px; margin: 3px 0; background: var(--bg-dark);
  font-size: 0.65rem; color: #ddddff; border-left: 4px solid var(--border);
}
.log-entry.story { border-left-color: var(--gold); }
.log-entry.discovery { border-left-color: var(--success); }
.log-entry.crisis { border-left-color: var(--danger); }

/* --- 探索卡片 --- */
.explore-challenge-card {
  background: var(--bg-dark); border: 2px solid var(--border);
  padding: 14px; margin: 8px 0; box-shadow: var(--shadow-sm);
}
.challenge-question { font-size: 0.7rem; margin-bottom: 12px; color: #ffffff; line-height: 1.8; }
.challenge-result { font-weight: bold; margin-top: 8px; padding: 8px; text-align: center; font-size: 0.6rem; }
.challenge-result.correct { background: #0a2a0a; color: var(--success); border: 2px solid var(--success); }
.challenge-result.wrong { background: #2a0a0a; color: var(--danger); border: 2px solid var(--danger); }

/* --- 图鉴 --- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 12px; }
.relic-card {
  background: var(--bg-dark); border: 2px solid var(--border);
  padding: 12px; text-align: center; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform 0.1s;
}
.relic-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.relic-card:active { transform: translateY(1px); }
.relic-card.locked { opacity: 0.3; filter: grayscale(0.8); cursor: default; }
.relic-icon { font-size: 2rem; margin-bottom: 6px; }
.relic-name { font-size: 0.6rem; font-family: var(--font); color: #ffffff; }
.relic-era { font-size: 0.55rem; color: #bbbbdd; }

/* --- 空状态 --- */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-light); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state-text { font-size: 0.7rem; line-height: 2; color: #bbbbdd; }

/* --- 底部导航 --- */
.tab-nav {
  display: flex; border-top: 3px solid var(--border);
  background: var(--bg-dark); position: sticky; bottom: 0; z-index: 10;
}
.tab-btn {
  flex: 1; min-height: 48px; padding: 8px 4px; border: none; background: transparent;
  font-family: var(--font); font-size: 0.55rem; color: var(--text-light);
  cursor: pointer; border-top: 3px solid transparent; position: relative;
}
.tab-btn.active { color: var(--accent); border-top-color: var(--accent); background: var(--bg); }
.tab-btn:active { background: var(--bg); }

/* --- Tab红点 --- */
.tab-dot {
  display: none; width: 6px; height: 6px; background: var(--danger);
  position: absolute; top: 6px; right: 6px; animation: pixelPulse 1.5s infinite;
}
.tab-dot.show { display: block; }

/* --- 浮动按钮 --- */
.fab-btn {
  position: fixed; bottom: 64px; right: 12px; z-index: 20;
  width: 48px; height: 48px; border: 3px solid var(--accent);
  background: var(--bg-dark); color: var(--accent); font-size: 1rem;
  box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
}
.fab-btn:active { transform: translate(2px, 2px); box-shadow: none; }
@media (min-width: 768px) { .fab-btn { right: calc((100vw - 860px) / 2 + 12px); } }

/* --- 通关画面 --- */
#ending-screen { justify-content: center; align-items: center; }
.ending-inner { text-align: center; padding: 40px 20px; max-width: 480px; }
#ending-title { font-family: var(--font); font-size: 1.2rem; color: var(--accent); margin-bottom: 12px; text-shadow: 3px 3px 0 #000; }
#ending-score { font-size: 0.65rem; color: var(--text-light); margin-bottom: 20px; line-height: 2; }

/* --- 弹窗 --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; justify-content: center; align-items: center; z-index: 100;
}
.modal-box {
  background: var(--bg-panel);
  background-image: linear-gradient(rgba(255,255,255,0.02) 2px, transparent 2px);
  background-size: 6px 6px;
  padding: 20px; max-width: 400px; width: 92%;
  box-shadow: 0 0 0 4px var(--border), 0 0 0 8px #000;
  text-align: center; max-height: 85vh; overflow-y: auto;
  border: 2px solid var(--accent);
}
.modal-body { font-size: 0.7rem; line-height: 2; margin-bottom: 16px; color: #eeeeff; }
.modal-box .btn { min-width: 100px; }

/* --- 引导遮罩 --- */
.guide-overlay { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.guide-spotlight {
  position: absolute; box-shadow: 0 0 0 9999px rgba(0,0,0,0.7); pointer-events: none;
}
.guide-tip {
  position: absolute; background: var(--bg-panel); padding: 12px 16px;
  border: 2px solid var(--accent); box-shadow: var(--shadow);
  font-size: 0.6rem; max-width: 220px; pointer-events: auto; text-align: center; line-height: 1.8;
}
.guide-tip .btn { margin-top: 8px; }

/* --- 像素动画 --- */
@keyframes pixelPulse {
  0%,100%{opacity:1}50%{opacity:0.3}
}
@keyframes popIn {
  0%{transform:scale(1.5);opacity:0}100%{transform:scale(1);opacity:1}
}
@keyframes floatUp {
  0%{transform:translate(-50%,-50%) scale(1);opacity:1}
  100%{transform:translate(-50%,-150%) scale(1.5);opacity:0}
}

/* --- 移动端 --- */
@media (max-width: 600px) {
  .splash-title { font-size: 1.2rem; }
  .splash-subtitle { font-size: 0.6rem; }
  .resource-bar { padding: 6px 2px; }
  .res-item { font-size: 0.5rem; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .tab-btn { font-size: 0.45rem; padding: 6px 1px; }
  .modal-box { width: 95%; padding: 14px; }
  .btn { font-size: 0.6rem; }
}

/* --- 大屏 --- */
@media (min-width: 768px) {
  #game-screen { max-width: 860px; margin: 0 auto; border-left: 3px solid var(--border); border-right: 3px solid var(--border); }
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- 减少动画 --- */
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important}
}

/* --- 暗色模式（像素风自动适配） --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d1a; --bg-dark: #151530; --bg-panel: #1a1a35;
    --text: #ffffff; --text-light: #aaaadd;
    --accent: #ffcc00; --accent2: #ff8800;
    --gold: #ffdd44; --danger: #ff4444; --success: #44ff44;
    --border: #444488;
  }
}
