/* ====== 全局样式 ====== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap');

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2234;
  --bg-card-hover: #1f2b42;
  --border-color: #2a3a5c;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --blue-glow: rgba(59, 130, 246, 0.4);
  --green: #10b981;
  --green-light: #34d399;
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-glow: rgba(139, 92, 246, 0.4);
  --red: #ef4444;
  --gray: #6b7280;
  --crit-color: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ====== 顶部资源栏 ====== */
#top-bar {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.game-title {
  font-size: 1.3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  letter-spacing: 2px;
}

.resource-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  padding: 4px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}

.resource-item .icon { font-size: 1.1rem; }
.resource-item .label { color: var(--text-muted); font-size: 0.78rem; }
.resource-item .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.resource-item .value.gold-color { color: var(--gold-light); }
.resource-item .value.green-color { color: var(--green-light); }
.resource-item .value.blue-color { color: var(--blue-light); }

/* ====== 主体三栏布局 ====== */
#main-container {
  display: grid;
  grid-template-columns: 200px 1fr 320px;
  gap: 0;
  height: calc(100vh - 56px - 140px);
  min-height: 400px;
}

/* ====== 左侧层级 ====== */
#left-panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 16px 12px;
  overflow-y: auto;
}

#left-panel h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.layer-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: all 0.3s;
  border: 1px solid transparent;
  font-size: 0.85rem;
  position: relative;
  overflow: hidden;
}

.layer-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px;
  transition: background 0.3s;
}

.layer-item.completed {
  background: rgba(16, 185, 129, 0.08);
  color: var(--green);
}
.layer-item.completed::before { background: var(--green); }

.layer-item.current {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.1));
  border-color: var(--blue);
  color: var(--text-primary);
  box-shadow: 0 0 20px rgba(59,130,246,0.15);
}
.layer-item.current::before { background: var(--blue); }

.layer-item.locked {
  background: rgba(255,255,255,0.02);
  color: var(--text-muted);
  opacity: 0.6;
}
.layer-item.locked::before { background: var(--gray); }

.layer-name { font-weight: 600; }
.layer-status { font-size: 0.75rem; margin-top: 2px; opacity: 0.8; }

/* ====== 中间游戏区域 ====== */
#center-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center bottom, rgba(59,130,246,0.05), transparent 70%);
}

.layer-title {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.layer-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* 山体 */
.mountain-container {
  width: 100%;
  max-width: 500px;
  position: relative;
  margin-bottom: 24px;
}

.mountain-visual {
  width: 100%;
  height: 200px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mountain-svg {
  width: 100%;
  height: 100%;
}

/* 进度条 */
.progress-container {
  width: 100%;
  max-width: 500px;
  margin-bottom: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 20px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 20px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  z-index: 1;
  top: 0;
}

/* 收益显示 */
.income-display {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 20px var(--gold-glow);
  margin-bottom: 8px;
}

.resource-remaining {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* 工人动画区域 */
.workers-area {
  width: 100%;
  max-width: 500px;
  height: 60px;
  position: relative;
  margin-top: 16px;
  overflow: hidden;
}

.worker-sprite {
  position: absolute;
  bottom: 0;
  font-size: 1.4rem;
  animation: workerMove 3s ease-in-out infinite alternate;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@keyframes workerMove {
  0% { transform: translateX(0) scaleX(1); }
  50% { transform: translateX(20px) scaleX(1); }
  100% { transform: translateX(0) scaleX(-1); }
}

/* 金币飘字 */
.float-text {
  position: absolute;
  font-weight: 700;
  font-size: 1rem;
  color: var(--gold-light);
  pointer-events: none;
  animation: floatUp 1.5s ease-out forwards;
  z-index: 50;
  text-shadow: 0 0 8px var(--gold-glow);
}

.float-text.crit {
  font-size: 1.4rem;
  color: var(--crit-color);
  text-shadow: 0 0 12px rgba(255,107,107,0.6);
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-80px) scale(0.6); }
}

/* 切层按钮 */
.next-layer-btn {
  margin-top: 16px;
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--green), #059669);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(16,185,129,0.3);
  display: none;
}

.next-layer-btn.visible { display: block; }

.next-layer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(16,185,129,0.5);
}

/* ====== 右侧升级面板 ====== */
#right-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 0;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.panel-tab {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  transition: all 0.3s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active {
  color: var(--blue-light);
  border-bottom-color: var(--blue);
}

.tab-content {
  padding: 16px;
  display: none;
}

.tab-content.active { display: block; }

/* 卡片样式 */
.upgrade-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.upgrade-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.1);
}

.upgrade-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.upgrade-card-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.upgrade-card-level {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 10px;
}

.upgrade-card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* 按钮样式 */
.btn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #1a1a2e;
  box-shadow: 0 4px 15px var(--gold-glow);
}
.btn-gold:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--gold-glow);
}

.btn-blue {
  background: linear-gradient(135deg, var(--blue), #2563eb);
  color: white;
  box-shadow: 0 4px 15px var(--blue-glow);
}
.btn-blue:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--blue-glow);
}

.btn-purple {
  background: linear-gradient(135deg, var(--purple), #7c3aed);
  color: white;
  box-shadow: 0 4px 15px var(--purple-glow);
}
.btn-purple:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--purple-glow);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
  border-color: var(--text-secondary);
}

/* 自动化开关 */
.auto-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.auto-toggle:hover { background: var(--bg-card-hover); }

.auto-toggle-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.toggle-switch {
  width: 40px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 11px;
  position: relative;
  transition: background 0.3s;
}

.toggle-switch.on {
  background: var(--green);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle-switch.on::after {
  transform: translateX(18px);
}

/* ====== 底部日志区域 ====== */
#bottom-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  height: 140px;
  overflow-y: auto;
  padding: 10px 20px;
}

#bottom-bar h4 {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.log-list {
  list-style: none;
}

.log-item {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  animation: logFadeIn 0.3s ease;
}

.log-item .log-time {
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 0.7rem;
}

.log-item.crit { color: var(--crit-color); }
.log-item.success { color: var(--green-light); }
.log-item.info { color: var(--blue-light); }
.log-item.rebirth { color: var(--purple-light); }

@keyframes logFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== 离线收益弹窗 ====== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-title { font-size: 1.3rem; font-weight: 900; margin-bottom: 8px; }
.modal-earnings {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 30px var(--gold-glow);
  margin: 16px 0;
}
.modal-desc { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 20px; }

.modal-btn {
  padding: 12px 40px;
  background: linear-gradient(135deg, var(--gold), #d97706);
  border: none;
  border-radius: var(--radius);
  color: #1a1a2e;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s;
}
.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--gold-glow);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ====== 操作按钮区 ====== */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ====== 滚动条美化 ====== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ====== 响应式 ====== */
@media (max-width: 900px) {
  #main-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }
  #left-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
  }
  #left-panel h3 { display: none; }
  .layer-item { min-width: 100px; margin-bottom: 0; }
  #right-panel { border-left: none; border-top: 1px solid var(--border-color); }
  #bottom-bar { height: 100px; }
}
