/* 《平行人生：宇宙分岔》- 整体视觉与响应式样式表 */

:root {
  --bg-dark: #0f111a;
  --bg-panel: #171926;
  --bg-card: #202436;
  --primary-accent: #4facfe;
  --secondary-accent: #00f2fe;
  --border-color: #2e344e;
  --text-main: #f0f3f8;
  --text-muted: #8c9ba5;
  --accent-gold: #ffd166;
  --accent-red: #ef476f;
  --accent-green: #06d6a0;
  --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* 顶部状态栏 */
#top-bar {
  height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

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

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #4facfe, #00f2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(79, 172, 254, 0.15);
  color: var(--primary-accent);
  border: 1px solid rgba(79, 172, 254, 0.3);
}

.state-indicators {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.indicator-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.highlight {
  color: var(--accent-gold);
  font-weight: 600;
}

.controls-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: #2b3147;
  border-color: var(--primary-accent);
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, #2b5876, #4e4376);
  border-color: #6b7280;
}

.select-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}

/* 主内容布局：左中右下 */
#main-container {
  display: grid;
  grid-template-columns: 1fr 360px;
  grid-template-rows: calc(100vh - 48px - 170px) 170px;
  height: calc(100vh - 48px);
}

/* 像素小镇视图容器 */
#town-pane {
  position: relative;
  overflow: hidden;
  background: #18231c;
  border-right: 1px solid var(--border-color);
}

#town-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.town-overlay-tips {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 17, 26, 0.75);
  backdrop-filter: blur(4px);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* 侧边信息栏 (人物/日志/因果/干预) */
#sidebar-pane {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #141622;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.tab-btn.active {
  color: var(--primary-accent);
  border-bottom: 2px solid var(--primary-accent);
  background: rgba(79, 172, 254, 0.05);
  font-weight: 600;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.tab-pane {
  display: none;
}

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

/* 属性卡片 */
.stat-group {
  margin-bottom: 14px;
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.stat-row {
  margin-bottom: 8px;
}

.stat-row:last-child {
  margin-bottom: 0;
}

.stat-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 3px;
}

.bar-bg {
  height: 6px;
  background: #10121a;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary-accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* 亲友列表 */
.npc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 12px;
}

.npc-name {
  color: var(--accent-gold);
}

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

/* 日志流 */
#log-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-line {
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 8px;
  background: var(--bg-card);
  border-left: 3px solid var(--primary-accent);
  border-radius: 0 4px 4px 0;
}

/* 因果溯源 */
.causal-item {
  padding: 8px;
  background: var(--bg-card);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.causal-date {
  color: var(--accent-gold);
  font-weight: 600;
}

.causal-dim {
  color: #00f2fe;
  margin-left: 6px;
}

.causal-reason {
  display: block;
  margin-top: 4px;
  color: var(--text-main);
}

/* 上帝干预面板 */
.intervention-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.card-item:hover {
  transform: translateY(-2px);
  border-color: var(--primary-accent);
}

.card-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.nl-intervention-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nl-input {
  background: #11131c;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  resize: none;
}

/* 底部时间轴面板 */
#timeline-pane {
  grid-column: 1 / -1;
  background: #11131e;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

.timeline-toolbar {
  height: 34px;
  background: #161824;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.filter-group {
  display: flex;
  gap: 4px;
}

.filter-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.filter-btn.active {
  background: rgba(79, 172, 254, 0.15);
  border-color: var(--primary-accent);
  color: var(--primary-accent);
}

#timeline-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* 弹窗通用样式 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 12px;
}

.modal-narrative {
  font-size: 14px;
  line-height: 1.6;
  color: #d1d5db;
  margin-bottom: 18px;
  background: var(--bg-card);
  padding: 12px;
  border-radius: 8px;
}

.decision-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.decision-opt-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-main);
}

.decision-opt-btn:hover {
  border-color: var(--primary-accent);
  background: #23283c;
  transform: translateX(3px);
}

.opt-text {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

/* 多宇宙对比弹窗 */
.compare-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.compare-col {
  background: var(--bg-card);
  border: 2px solid;
  border-radius: 8px;
  padding: 12px;
}

.col-header {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.col-stat {
  font-size: 12px;
  margin-bottom: 6px;
}

.compare-switch-btn {
  margin-top: 10px;
  width: 100%;
  background: #2b3147;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}

.compare-switch-btn:hover {
  background: var(--primary-accent);
  color: #fff;
}

/* 提示通知 Toast */
#toast-msg {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(23, 25, 38, 0.95);
  border: 1px solid var(--primary-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

/* 手机竖屏自适应 */
@media (max-width: 768px) {
  #main-container {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh calc(60vh - 48px - 140px) 140px;
  }
  #sidebar-pane {
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}
