:root {
  --bg-start: #0d47a1;
  --bg-mid: #1565c0;
  --bg-end: #1976d2;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: #ffffff;
  --text-main: #0d1b2a;
  --text-light: #f5f9ff;
  --accent-red: #e53935;
  --accent-green: #43a047;
  --accent-blue: #1e88e5;
  --accent-black: #263238;
  --accent-yellow: #fdd835;
  --accent-purple: #8e24aa;
  --accent-orange: #fb8c00;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text-light);
  background: radial-gradient(circle at 20% 10%, var(--bg-mid), var(--bg-start) 60%),
              linear-gradient(135deg, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* 通用容器 */
.page { min-height: 100vh; padding: 24px; }
.container { max-width: 1200px; margin: 0 auto; }

/* 标题 */
.title-xl { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 900; margin: 0 0 12px; letter-spacing: -1px; }
.title-lg { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; margin: 0 0 12px; }
.title-md { font-size: 1.4rem; font-weight: 700; margin: 0 0 8px; }
.subtitle { font-size: 1.1rem; opacity: 0.92; line-height: 1.6; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border-radius: 999px; font-weight: 700; font-size: 1rem;
  border: 2px solid rgba(255,255,255,0.5); cursor: pointer; transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  color: #fff; background: linear-gradient(135deg, var(--accent-blue), #0d47a1);
  box-shadow: 0 6px 0 #0a357a, 0 8px 20px rgba(0,0,0,0.25);
  user-select: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0a357a, 0 3px 8px rgba(0,0,0,0.25); }
.btn:hover { filter: brightness(1.1); }
.btn-red { background: linear-gradient(135deg, var(--accent-red), #b71c1c); box-shadow: 0 6px 0 #7f0000, 0 8px 20px rgba(0,0,0,0.25); }
.btn-red:active { box-shadow: 0 2px 0 #7f0000, 0 3px 8px rgba(0,0,0,0.25); }
.btn-green { background: linear-gradient(135deg, var(--accent-green), #1b5e20); box-shadow: 0 6px 0 #0d3b10, 0 8px 20px rgba(0,0,0,0.25); }
.btn-green:active { box-shadow: 0 2px 0 #0d3b10, 0 3px 8px rgba(0,0,0,0.25); }
.btn-yellow { background: linear-gradient(135deg, var(--accent-yellow), #f57f17); color: #1a1a1a; box-shadow: 0 6px 0 #bc5100, 0 8px 20px rgba(0,0,0,0.25); }
.btn-yellow:active { box-shadow: 0 2px 0 #bc5100, 0 3px 8px rgba(0,0,0,0.25); }
.btn-purple { background: linear-gradient(135deg, var(--accent-purple), #4a148c); box-shadow: 0 6px 0 #240b36, 0 8px 20px rgba(0,0,0,0.25); }
.btn-purple:active { box-shadow: 0 2px 0 #240b36, 0 3px 8px rgba(0,0,0,0.25); }
.btn-dark { background: linear-gradient(135deg, #37474f, #102027); box-shadow: 0 6px 0 #000a12, 0 8px 20px rgba(0,0,0,0.25); }
.btn-dark:active { box-shadow: 0 2px 0 #000a12, 0 3px 8px rgba(0,0,0,0.25); }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }

/* 卡片 */
.card {
  background: var(--card-bg); color: var(--text-main); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(0,0,0,0.4); }
.card-dark { background: rgba(13, 27, 42, 0.85); color: var(--text-light); border: 1px solid rgba(255,255,255,0.15); }

/* 颜色标识 */
.tag { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; color: #fff; font-size: 0.75rem; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.tag-red { background: var(--accent-red); }
.tag-green { background: var(--accent-green); }
.tag-blue { background: var(--accent-blue); }
.tag-black { background: #37474f; }
.tag-yellow { background: var(--accent-yellow); color: #000; }
.tag-purple { background: var(--accent-purple); }
.tag-orange { background: var(--accent-orange); }

/* 网格 */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* 动画 */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); } 50% { box-shadow: 0 0 24px 8px rgba(255,255,255,0.15); } }
@keyframes neonBorder { 0%,100% { border-color: rgba(255,255,255,0.6); } 50% { border-color: rgba(255,255,255,1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.animate-in { animation: fadeIn 0.6s ease both; }
.animate-pop { animation: fadeInScale 0.4s ease both; }
.glow { animation: pulseGlow 2s infinite; }
.shake { animation: shake 0.35s ease; }
.float { animation: float 3s ease-in-out infinite; }

/* 步骤指示器 */
.steps {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 16px 0;
}
.step {
  flex: 1; min-width: 90px; text-align: center; padding: 10px 8px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); font-size: 0.85rem; font-weight: 700;
  transition: all 0.3s ease; position: relative;
}
.step.active { background: rgba(255,255,255,0.95); color: var(--bg-start); transform: scale(1.05); box-shadow: 0 0 20px rgba(255,255,255,0.3); }
.step.done { background: rgba(67,160,71,0.35); color: #fff; }

/* 顶部状态栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; background: rgba(0,0,0,0.25); border-radius: var(--radius); margin-bottom: 16px; backdrop-filter: blur(6px);
}
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.15); font-weight: 700; font-size: 0.9rem;
}

/* 沙盘盘面布局 */
.board {
  display: grid; grid-template-columns: 220px 1fr 220px; gap: 16px; align-items: stretch;
}
@media (max-width: 980px) { .board { grid-template-columns: 1fr; } }

.board-panel {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.panel-title { font-weight: 800; font-size: 1rem; color: #fff; margin-bottom: 4px; text-align: center; }

/* 目标市场网格 */
.market-grid {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px;
}
.market-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800;
  background: rgba(255,255,255,0.12); border-radius: 6px; border: 1px solid rgba(255,255,255,0.15);
  transition: all 0.2s ease; cursor: pointer;
}
.market-cell:hover { background: rgba(255,255,255,0.25); transform: scale(1.08); }
.market-cell.unlocked { background: rgba(67,160,71,0.6); color: #fff; box-shadow: 0 0 10px rgba(67,160,71,0.4); }
.market-cell.active { background: rgba(253,216,53,0.85); color: #000; }

/* 资源条 */
.resource-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.resource-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.15); font-weight: 700; font-size: 0.85rem;
}

/* 小卡槽 */
.slot-grid { display: grid; gap: 8px; }
.slot { min-height: 48px; background: rgba(0,0,0,0.2); border-radius: var(--radius-sm); border: 1px dashed rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.slot.filled { background: rgba(255,255,255,0.15); border-style: solid; color: #fff; font-weight: 700; }

/* 科技树 / 服务树 */
.tree-svg { width: 100%; height: auto; background: rgba(255,255,255,0.06); border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.15); }
.tree-node { cursor: pointer; transition: transform 0.2s ease; }
.tree-node:hover { transform: scale(1.12); }
.tree-node.unlocked .node-box { fill: rgba(67,160,71,0.85); stroke: #fff; }
.tree-node.locked .node-box { fill: rgba(255,255,255,0.1); stroke: rgba(255,255,255,0.4); }
.tree-node.target .node-box { stroke: #fdd835; stroke-width: 3; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: #fff; color: var(--text-main); border-radius: var(--radius); width: min(900px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 25px 80px rgba(0,0,0,0.5); transform: scale(0.95); transition: transform 0.3s ease; }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: 18px 24px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; }
.modal-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: #666; line-height: 1; }

/* Toast / 通知 */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: rgba(13,27,42,0.95); color: #fff; padding: 14px 18px; border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4); border-left: 4px solid var(--accent-blue);
  animation: slideInRight 0.35s ease both; max-width: 320px; font-size: 0.95rem;
}
.toast.success { border-left-color: var(--accent-green); }
.toast.warn { border-left-color: var(--accent-yellow); }
.toast.error { border-left-color: var(--accent-red); }
@keyframes slideInRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.08); }
.table th { background: rgba(0,0,0,0.05); font-weight: 800; }
.table-dark th, .table-dark td { border-color: rgba(255,255,255,0.12); }
.table-dark th { background: rgba(255,255,255,0.08); }

/* 表单 */
input, select, textarea {
  padding: 10px 14px; border-radius: var(--radius-sm); border: 2px solid rgba(0,0,0,0.12);
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--text-main);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-blue); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.5); }

/* 光效覆盖层 */
.light-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 900; opacity: 0; transition: opacity 0.4s ease;
}
.light-overlay.active { opacity: 1; }
.light-flash { background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, transparent 60%); }
.light-red { background: radial-gradient(circle, rgba(229,57,53,0.25) 0%, transparent 60%); }
.light-green { background: radial-gradient(circle, rgba(67,160,71,0.25) 0%, transparent 60%); }

/* 粒子画布 */
#fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 950; }

/* 响应式 */
@media (max-width: 640px) {
  .page { padding: 16px; }
  .title-xl { font-size: 2rem; }
  .market-grid { grid-template-columns: repeat(5, 1fr); }
  .btn { padding: 12px 20px; }
}
