/* ═══════════════════════════════════════════════════════════
   铁锈镇纪事 · 样式表
   ═══════════════════════════════════════════════════════════ */

/* ── 变量 ─────────────────────────────────────────────── */
:root {
  --bg-color: #1a1a2e;
  --bg-dark: #16162a;
  --text-color: #e8e8f0;
  --text-muted: #a0a0b0;
  --accent: #c9a227;
  --accent-dark: #a08020;
  --danger: #c04040;
  --success: #40a060;
  --panel-bg: rgba(30, 30, 50, 0.95);
  --border: rgba(201, 162, 39, 0.3);
  --shadow: rgba(0, 0, 0, 0.5);
}

/* ── 基础 ─────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
}

/* ── 屏幕切换 ─────────────────────────────────────────── */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: opacity;
  transform: translateZ(0);
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.screen.visible {
  opacity: 1;
}

/* ── 标题界面 ─────────────────────────────────────────── */
#screen-title {
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
}

.title-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pixel-art-castle {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: 
    linear-gradient(to right, #2a2a40 0%, #2a2a40 100%) 80px 160px / 40px 40px,
    linear-gradient(to right, #2a2a40 0%, #2a2a40 100%) 60px 120px / 80px 40px,
    linear-gradient(to right, #2a2a40 0%, #2a2a40 100%) 40px 80px / 120px 40px,
    linear-gradient(to right, #3a3a50 0%, #3a3a50 100%) 20px 40px / 160px 40px;
  background-repeat: no-repeat;
  opacity: 0.3;
}

.title-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px;
}

.title-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 4px;
  margin-bottom: 16px;
}

.title-main {
  font-size: 48px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(201, 162, 39, 0.5);
  margin-bottom: 12px;
}

.title-tagline {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 48px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.title-version {
  margin-top: 32px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── 按钮 ─────────────────────────────────────────────── */
.btn-pixel {
  padding: 16px 48px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid var(--border);
  background: var(--panel-bg);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
}

.btn-pixel:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(201, 162, 39, 0.3);
  transform: translateY(-2px);
}

.btn-pixel:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.2), rgba(201, 162, 39, 0.05));
  border-color: var(--accent);
}

.btn-secondary {
  background: linear-gradient(135deg, rgba(100, 100, 150, 0.2), rgba(100, 100, 150, 0.05));
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
}

.full-width {
  width: 100%;
}

/* ── 职业选择界面 ───────────────────────────────────────── */
#screen-class {
  justify-content: center;
  align-items: center;
  background: var(--bg-dark);
}

.class-content {
  text-align: center;
  padding: 40px;
  max-width: 800px;
}

.section-title {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 12px;
}

.section-hint {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.class-card {
  padding: 24px 16px;
  background: var(--panel-bg);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.class-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.class-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(201, 162, 39, 0.3);
}

.class-card-emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
}

.class-card-name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}

.class-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.class-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.class-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 30px;
}

.class-stat-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.class-stat-fill {
  height: 100%;
  background: var(--accent);
}

.back-btn {
  min-width: 120px;
  padding: 12px 24px;
}

/* ── 游戏界面 ─────────────────────────────────────────── */
#screen-game {
  background: var(--bg-color);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-center {
  text-align: center;
}

.player-name {
  font-weight: bold;
}

.player-class {
  color: var(--text-muted);
  font-size: 14px;
}

.location-icon {
  font-size: 24px;
  display: block;
}

.location-name {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 14px;
}

.stat-icon {
  font-size: 12px;
}

/* ── 场景插图 ─────────────────────────────────────────── */
.scene-art {
  position: relative;
  height: 120px;
  background: linear-gradient(180deg, #2a2a40 0%, var(--bg-color) 100%);
  overflow: hidden;
}

.scene-art-inner {
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scene-art-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(to top, var(--bg-color), transparent);
}

/* 场景类 */
.scene-town { background: linear-gradient(180deg, #3a3a50 0%, #2a2a40 100%); }
.scene-ruins { background: linear-gradient(180deg, #2a2a30 0%, #1a1a20 100%); }
.scene-forest { background: linear-gradient(180deg, #2a3a2a 0%, #1a2a1a 100%); }
.scene-cave { background: linear-gradient(180deg, #1a1a20 0%, #0a0a10 100%); }
.scene-magic { background: linear-gradient(180deg, #3a2a4a 0%, #2a1a3a 100%); }

/* ── 叙述区 ───────────────────────────────────────────── */
.narrative-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

.narrative-scroll {
  max-height: 120px;
  overflow-y: auto;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.narrative-current {
  flex: 1;
  position: relative;
}

.speaker-label {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

.narrative-text {
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.typing-cursor {
  display: inline-block;
  color: var(--accent);
}

.typing-cursor.hidden {
  display: none;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ── 选项区 ───────────────────────────────────────────── */
.choices-area {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-btn {
  padding: 16px 20px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text-color);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.1);
}

.choice-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.choice-btn.danger {
  border-color: rgba(192, 64, 64, 0.5);
}

.choice-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(201, 162, 39, 0.2);
  border-radius: 4px;
}

/* ── 底部工具栏 ────────────────────────────────────────── */
.game-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
}

.footer-btn {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.footer-btn:hover {
  border-color: var(--accent);
  color: var(--text-color);
}

/* ── 面板 ─────────────────────────────────────────────── */
.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 400px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
}

.panel.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.panel-close:hover {
  color: var(--text-color);
}

.panel-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 99;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ── 日志条目 ──────────────────────────────────────────── */
.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: var(--text-muted);
}

.log-entry:last-child {
  border-bottom: none;
}

/* ── 物品栏 ───────────────────────────────────────────── */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.inventory-item-icon {
  font-size: 24px;
}

.inventory-item-name {
  font-size: 13px;
  font-weight: bold;
}

.inventory-item-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* ── 结局界面 ─────────────────────────────────────────── */
#screen-ending {
  justify-content: center;
  align-items: center;
  background: var(--bg-dark);
}

.ending-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
}

.ending-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px;
  max-width: 600px;
}

.ending-label {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 8px;
  margin-bottom: 16px;
}

.ending-title {
  font-size: 36px;
  margin-bottom: 24px;
}

.ending-title.hero { color: var(--accent); }
.ending-title.flee { color: var(--text-muted); }
.ending-title.guardian { color: var(--success); }

.ending-text {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.ending-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}

.ending-stat {
  text-align: center;
}

.ending-stat-val {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
}

/* ── 关于界面 ─────────────────────────────────────────── */
#screen-about {
  justify-content: center;
  align-items: center;
  background: var(--bg-dark);
}

.about-content {
  text-align: center;
  padding: 40px;
  max-width: 500px;
}

.about-content h2 {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 24px;
}

.about-body {
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 32px;
}

.about-body p {
  margin-bottom: 12px;
}

.about-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Toast 通知 ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.warn {
  border-color: var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ── 响应式 ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .class-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .title-main {
    font-size: 36px;
  }
  
  .game-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .header-center {
    order: -1;
    width: 100%;
  }
}
