/* game.css — 火种 FireSeed 游戏样式 */

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

:root {
  --bg: #f5f0e8;
  --topbar-bg: #3e2723;
  --topbar-text: #f5f0e8;
  --panel-bg: #fffaf5;
  --panel-border: #d7ccc8;
  --accent: #e67e22;
  --accent2: #8d6e63;
  --text: #3e2723;
  --text-dim: #8d6e63;
  --btn-bg: #efebe9;
  --btn-active: #e67e22;
  --btn-active-text: #fff;
  --danger: #c0392b;
  --transition-bg: rgba(62, 39, 35, 0.92);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* ============================================================
   顶栏
   ============================================================ */

#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  font-size: 13px;
  flex-shrink: 0;
  gap: 16px;
}

#top-bar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

#top-bar .brand .icon {
  margin-right: 4px;
}

#top-bar .info {
  display: flex;
  gap: 16px;
  align-items: center;
  opacity: 0.9;
}

#top-bar .info span {
  white-space: nowrap;
}

#panel-toggle {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
  color: var(--topbar-text);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 32px;
  text-align: center;
}

#help-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
  color: var(--topbar-text);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 32px;
  text-align: center;
}

#help-toggle:hover {
  background: rgba(255,255,255,0.28);
}

.res-compact {
  display: none;
  font-size: 11px;
  opacity: 0.85;
  letter-spacing: 0.5px;
}

/* ============================================================
   主区域
   ============================================================ */

#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

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

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ============================================================
   右侧面板
   ============================================================ */

#side-panel {
  width: 200px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* 资源 */
.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}

.resource-row .res-icon {
  width: 20px;
  text-align: center;
}

.resource-row .res-name {
  flex: 1;
  color: var(--text-dim);
}

.resource-row .res-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sell-btn {
  margin-top: 6px;
  width: 100%;
  height: 30px;
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.sell-btn:hover {
  background: #d7ccc8;
}

/* 建筑菜单 */
#build-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.build-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 6px;
  font-size: 12px;
}

.build-item:hover {
  background: rgba(230, 126, 34, 0.1);
}

.build-item.selected {
  background: var(--btn-active);
  color: var(--btn-active-text);
}

.build-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.build-name {
  flex: 1;
  font-weight: 500;
}

.build-cost {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.build-item.selected .build-cost {
  color: rgba(255,255,255,0.8);
}

/* 面板内行动按钮（桌面端隐藏） */
.panel-actions {
  display: none;
}

/* 跃迁关键物特殊标记 */
.build-transition {
  border: 1px dashed var(--accent);
  background: rgba(230, 126, 34, 0.06);
}

.build-empty {
  color: var(--text-dim);
  font-style: italic;
  font-size: 12px;
  padding: 8px 0;
}

/* 事件日志 */
#event-log {
  max-height: 160px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.5;
}

.log-entry {
  padding: 2px 0;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

/* ============================================================
   底栏
   ============================================================ */

#bottom-bar {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 8px;
  background: #fffaf5;
  border-top: 1px solid var(--panel-border);
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

#bottom-bar .mode-group {
  display: flex;
  gap: 2px;
  border-right: 1px solid var(--panel-border);
  padding-right: 8px;
  margin-right: 4px;
}

#bottom-bar button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.15s;
}

#bottom-bar button:hover {
  background: #d7ccc8;
}

#bottom-bar button.active {
  background: var(--btn-active);
  color: var(--btn-active-text);
  border-color: var(--btn-active);
}

#bottom-bar .action-group {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

#bottom-bar .action-group button {
  font-size: 11px;
  padding: 0 8px;
}

#info-tip {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   跃迁动画
   ============================================================ */

#transition-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--transition-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

#transition-overlay.show {
  opacity: 1;
}

#transition-overlay .age-name {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
  animation: agePulse 0.6s ease-out;
}

@keyframes agePulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   帮助说明
   ============================================================ */

#help-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

#help-overlay.show {
  display: flex;
}

.help-box {
  width: min(560px, 92vw);
  max-height: 82vh;
  background: #fffaf5;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

#help-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
}

.help-body {
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.help-body h4 {
  font-size: 13px;
  color: var(--accent);
  margin: 12px 0 4px;
}

.help-body h4:first-child {
  margin-top: 0;
}

.help-body p {
  margin: 0 0 4px;
}

.help-body b {
  color: var(--danger);
  font-weight: 600;
}

/* ============================================================
   响应式（移动端）
   ============================================================ */

@media (max-width: 768px) {
  /* 面板切换按钮显示 */
  #panel-toggle {
    display: block;
  }

  /* 顶栏紧凑资源 */
  .res-compact {
    display: inline;
  }

  /* 右侧面板滑入覆盖 */
  #side-panel {
    position: fixed;
    right: 0;
    top: 40px;
    bottom: 48px;
    width: 200px;
    transform: translateX(100%);
    transition: transform 0.25s;
    z-index: 100;
    box-shadow: -2px 0 12px rgba(0,0,0,0.15);
  }

  #side-panel.open {
    transform: translateX(0);
  }

  /* 面板打开时遮住底栏的遮罩 */
  #panel-overlay {
    display: none;
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 48px;
    background: rgba(0,0,0,0.3);
    z-index: 99;
  }

  #panel-overlay.show {
    display: block;
  }

  /* 底栏：仅保留模式和提示 */
  #bottom-bar {
    height: auto;
    min-height: 44px;
    padding: 4px 6px;
    gap: 3px;
  }

  #bottom-bar button {
    height: 28px;
    padding: 0 7px;
    font-size: 11px;
  }

  #bottom-bar .mode-group {
    border-right: none;
    padding-right: 4px;
    margin-right: 0;
  }

  #bottom-bar .action-group {
    display: none;
  }

  #info-tip {
    width: 100%;
    order: 10;
    margin-left: 0;
    text-align: center;
    font-size: 11px;
    padding: 2px 0;
  }

  #top-bar {
    font-size: 11px;
    padding: 0 6px;
    gap: 4px;
  }

  #top-bar .brand {
    font-size: 13px;
  }

  #top-bar .info {
    gap: 6px;
    overflow: hidden;
    flex: 1;
    justify-content: flex-end;
  }

  /* 在面板内显示行动按钮 */
  .panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .panel-actions button {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
  }
}
