/* ========== 《微·危》古风样式 ========== */

:root {
  --bg-dark: #1a1a2e;
  --bg-paper: #f5f0e1;
  --bg-paper-dark: #e8dcc8;
  --ink: #2c2c2c;
  --ink-light: #5a5a5a;
  /* 绿方：己方实力/敌妄念/敌弱点/己方天时地利人和 */
  --own: #2d8a4e;
  --own-bg: #1a4a2e;
  --own-text: #7dd89f;
  /* 红方：敌方实力/己方妄念/己方掣肘/敌方天时地利人和 */
  --enemy: #c0392b;
  --enemy-bg: #4a1a1a;
  --enemy-text: #f08070;
  /* 中立 */
  --neutral: #7f8c8d;
  --neutral-bg: #2a2a30;
  --neutral-text: #a0a8b0;
  --gold: #c9a84c;
  --border: #8b7355;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html {
  font-size: 18px;
}

@media (max-width: 640px) {
  html { font-size: 17px; }
}

body {
  font-family: "KaiTi", "STKaiti", "AR PL UKai CN", "Noto Serif SC", serif;
  background: var(--bg-paper);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ========== 欢迎页 ========== */
#screen-welcome {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  position: relative;
}

.welcome-bg {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(201,168,76,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(184,51,42,0.06) 0%, transparent 50%);
  pointer-events: none;
}

.welcome-content {
  text-align: center;
  z-index: 1;
  padding: 2rem;
}

.title {
  font-size: 4.5rem;
  color: var(--gold);
  letter-spacing: 1rem;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 30px rgba(201,168,76,0.4);
  font-weight: normal;
  font-family: "LiSu", "STLiti", "KaiTi", cursive;
}

.subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.2rem;
}

/* --- 简介卡 --- */
.intro-card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 10px;
  padding: 1.5rem 2rem;
  margin: 0 auto 2rem;
  max-width: 520px;
  text-align: left;
  line-height: 1.6;
}

.intro-card h3 {
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: normal;
  text-align: center;
  margin-bottom: 1rem;
  letter-spacing: 0.15rem;
}

.intro-section {
  margin-bottom: 0.7rem;
}

.intro-label {
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 0.15rem;
}

.intro-text {
  color: rgba(255,255,255,0.7);
  font-size: 0.82rem;
  line-height: 1.5;
}

.btn-start {
  font-size: 1.2rem;
  padding: 0.7rem 3rem;
  letter-spacing: 0.2rem;
}

/* --- 剧本选择页 --- */
#screen-scenarios {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  position: relative;
}

.page-title {
  font-size: 3rem;
  color: var(--gold);
  letter-spacing: 0.5rem;
  margin-bottom: 2rem;
  font-weight: normal;
  font-family: "LiSu", "STLiti", "KaiTi", cursive;
}

.btn-back {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  z-index: 2;
}

.btn-back-hero {
  color: var(--ink-light);
  font-size: 1rem;
}

.scenario-list {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.scenario-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 8px;
  padding: 2rem 3rem;
  cursor: pointer;
  transition: all 0.3s;
  min-width: 200px;
}

.scenario-card:hover {
  background: rgba(201,168,76,0.15);
  border-color: var(--gold);
  transform: translateY(-4px);
}

.scenario-card h3 {
  color: var(--gold);
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  font-weight: normal;
  font-family: "LiSu", "STLiti", "KaiTi", cursive;
}

.scenario-card p {
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
}

/* ========== 英雄选择页 ========== */
#screen-hero {
  min-height: 100vh;
  padding: 2rem;
  background: var(--bg-paper);
}

.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.hero-header h2 {
  color: var(--ink);
  font-weight: normal;
  font-size: 1.5rem;
}

.btn-text {
  background: none;
  border: none;
  color: var(--ink-light);
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
}

.hero-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-card {
  background: var(--bg-paper-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.hero-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(-4px);
}

.hero-portrait {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.8rem;
  filter: contrast(1.1);
}

.hero-card h3 {
  font-size: 1.4rem;
  font-weight: normal;
  margin-bottom: 0.5rem;
  font-family: "LiSu", "STLiti", "KaiTi", cursive;
}

.trait-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.trait-tag {
  background: var(--border);
  color: var(--bg-paper);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 0.8rem;
}

.hand-limit {
  font-size: 0.8rem;
  color: var(--ink-light);
}

/* ========== 游戏页 ========== */
#screen-game {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  background: var(--bg-paper);
}

.top-bar {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-paper-dark);
  border-radius: 6px;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-light);
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* --- 英雄信息栏 --- */
.hero-info {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  background: var(--bg-paper-dark);
  border-radius: 6px;
  margin-bottom: 0.3rem;
  border: 1px solid var(--border);
}

.hero-info-portrait {
  width: 40px;
  height: 53px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.hero-info-name {
  font-size: 1rem;
  font-weight: bold;
  color: var(--ink);
  white-space: nowrap;
  margin-right: 0.3rem;
}

.hero-info-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  flex: 1;
}

.hero-info-trait {
  background: var(--bg-paper-dark);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 0.75rem;
}

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

#enemy-info {
  color: var(--enemy);
  font-size: 0.82rem;
}

@media (max-width: 768px) {
  .title { font-size: 2.8rem; letter-spacing: 0.6rem; }
  .page-title { font-size: 2.2rem; letter-spacing: 0.3rem; }
  .scenario-list { flex-direction: column; align-items: center; }
  .scenario-card { min-width: auto; padding: 1.2rem 2rem; }
  .intro-card { padding: 1rem 1.2rem; max-width: 95%; }
  .intro-text { font-size: 0.85rem; }
  .hero-list { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.8rem; }
}

@media (max-width: 640px) {
  /* 欢迎页 */
  .title { font-size: 3rem; letter-spacing: 0.5rem; }
  .subtitle { font-size: 0.85rem; margin-bottom: 1rem; }
  .intro-card { padding: 0.8rem 1rem; }
  .intro-card h3 { font-size: 1rem; }
  .intro-text { font-size: 0.8rem; }
  .btn-start { font-size: 1rem; padding: 0.6rem 2rem; }
  .page-title { font-size: 1.6rem; }

  /* 英雄选择 */
  .hero-header h2 { font-size: 1.2rem; }
  .hero-list { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.6rem; }
  .hero-card { padding: 0.6rem; }
  .hero-card h3 { font-size: 1rem; }
  .trait-tag { font-size: 0.85rem; padding: 1px 6px; }

  /* 游戏界面 */
  #screen-game { padding: 0.3rem; }
  .top-bar { font-size: 0.9rem; padding: 0.3rem 0.6rem; gap: 0.2rem; }
  .top-bar span { white-space: nowrap; }

  /* 棋盘 */
  .board { gap: 2px; padding: 3px; max-width: 100%; aspect-ratio: 1; }
  .cell { font-size: 1.1rem; border-radius: 3px; }
  .card-cat { font-size: 1.1rem; }
  .card-level { font-size: 0.85rem; }

  /* 手牌 */
  .hand-area { gap: 4px; padding: 0.3rem; min-height: 64px; }
  .hand-card { width: 44px; height: 62px; font-size: 1rem; border-width: 1.5px; }
  .hand-slot { width: 44px; height: 62px; }

  /* 英雄信息 */
  .hero-info { padding: 0.25rem 0.5rem; gap: 0.3rem; }
  .hero-info-portrait { width: 28px; height: 37px; }
  .hero-info-name { font-size: 0.9rem; }
  .hero-info-trait { font-size: 0.8rem; padding: 1px 5px; }

  /* 按钮 */
  .btn-action { padding: 0.35rem 0.8rem; font-size: 0.82rem; }
  .controls { gap: 0.3rem; }

  /* 状态 */
  .status-bar { font-size: 0.78rem; }
  .log-area { font-size: 0.68rem; }

  /* 弹窗 */
  .modal-content { padding: 1rem; max-width: 95%; }
  .showdown-result h2 { font-size: 1.8rem; }
  .calc-line { font-size: 0.8rem; }

  /* 提示 */
  .tooltip { font-size: 0.7rem; max-width: 180px; }
}

/* --- 棋盘 --- */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1;
  padding: 8px;
  background: var(--bg-dark);
  border-radius: 8px;
  border: 2px solid var(--border);
}

.cell {
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  font-size: 1rem;
  min-height: 0;
}

/* 可见牌 */
.visible-card {
  border: 2px solid;
}

.faction-own {
  background: var(--own-bg);
  border-color: var(--own);
  color: var(--own-text);
}

.faction-enemy {
  background: var(--enemy-bg);
  border-color: var(--enemy);
  color: var(--enemy-text);
}

.faction-neutral {
  background: var(--neutral-bg);
  border-color: var(--neutral);
  color: var(--neutral-text);
}

.revealed-delusion {
  background: #3a1010 !important;
  border-color: var(--enemy) !important;
  color: #ff6050 !important;
  animation: pulse 1s;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.card-cat {
  font-size: 1rem;
  font-weight: bold;
  writing-mode: vertical-rl;
  letter-spacing: 2px;
}

.card-level {
  font-size: 0.85rem;
  letter-spacing: 1px;
}

/* 隐藏牌 */
.hidden-card {
  background: rgba(60,60,80,0.6);
  border: 1px solid rgba(100,100,120,0.4);
  color: rgba(150,150,170,0.5);
}

.hidden-mark {
  font-size: 0.9rem;
  opacity: 0.5;
}

/* 空位 */
.empty {
  background: rgba(30,30,50,0.3);
  border: 1px dashed rgba(100,100,120,0.2);
}

.empty-revealed {
  border: 1px dashed rgba(100,100,120,0.4);
}

.void-mark {
  font-size: 0.6rem;
  color: rgba(100,100,120,0.3);
}

/* 选中/高亮 */
.cell.selected {
  box-shadow: 0 0 0 3px var(--gold);
  z-index: 2;
}

.cell.highlight {
  box-shadow: 0 0 0 2px rgba(201,168,76,0.5);
}

/* --- 手牌 --- */
.hand-area {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 640px;
  padding: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 80px;
}

.hand-card {
  width: 56px;
  height: 78px;
  background: var(--bg-paper-dark);
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.3rem;
}

.hand-card:hover {
  border-color: var(--gold);
  transform: translateY(-6px);
}

.hand-card.selected {
  border-color: var(--gold);
  background: rgba(201,168,76,0.2);
  transform: translateY(-10px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.hand-slot {
  width: 56px;
  height: 78px;
  border: 2px dashed rgba(139,115,85,0.2);
  border-radius: 6px;
}

/* --- 按钮 --- */
.controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-action {
  background: var(--bg-paper-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

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

.btn-primary {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  color: #fff;
}

.btn-cancel {
  border-color: var(--enemy);
  color: var(--enemy);
}

/* --- 状态栏 --- */
.status-bar {
  width: 100%;
  max-width: 640px;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-light);
  min-height: 1.5rem;
}

/* --- 操作日志 --- */
.log-area {
  width: 100%;
  max-width: 640px;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  color: var(--ink-light);
  min-height: 1rem;
}

.log-line {
  padding: 1px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.log-line:last-child {
  color: var(--ink);
  font-weight: bold;
}

/* ========== 弹窗 ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-paper);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.showdown-result {
  text-align: center;
  margin-bottom: 1.5rem;
}

.result-win { color: var(--own); }
.result-draw { color: var(--gold); }
.result-lose { color: var(--enemy); }

.showdown-result h2 {
  font-size: 2.5rem;
  font-weight: normal;
  letter-spacing: 0.3rem;
  font-family: "LiSu", "STLiti", "KaiTi", cursive;
}

.ending-detail {
  color: var(--ink-light);
  margin-top: 0.5rem;
}

.calc-block {
  background: var(--bg-paper-dark);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.calc-block.own { border-left-color: var(--own); }
.calc-block.enemy { border-left-color: var(--enemy); }

.calc-block h3 {
  font-weight: normal;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.calc-line {
  font-size: 0.9rem;
  padding: 2px 0;
  color: var(--ink-light);
}

.calc-line.penalty {
  color: var(--enemy);
  font-size: 0.85rem;
}

.neutral-shifts {
  background: var(--bg-paper-dark);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--neutral);
}

.neutral-shifts h4 {
  font-weight: normal;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  color: var(--neutral-text);
}

.shift-own { color: var(--own-text); }
.shift-enemy { color: var(--enemy-text); }
.shift-neutral { color: var(--neutral-text); }

.power-loss {
  background: var(--bg-paper-dark);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--enemy);
}

.power-loss h4 {
  font-weight: normal;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  color: var(--enemy);
}

.loss-own { color: var(--enemy-text); }
.loss-enemy { color: var(--own-text); }

.calc-line.subtotal {
  border-top: 1px solid rgba(0,0,0,0.1);
  margin-top: 4px;
  padding-top: 4px;
  color: var(--ink);
}

.calc-line.total {
  font-size: 1.1rem;
  color: var(--ink);
  font-weight: bold;
  margin-top: 4px;
}

.calc-compare {
  display: flex;
  justify-content: space-around;
  padding: 1rem;
  background: var(--bg-paper-dark);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ========== 说明浮层 ========== */
.tooltip {
  position: fixed;
  background: rgba(20,20,30,0.95);
  color: #fff;
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 200;
  max-width: 240px;
  pointer-events: none;
  line-height: 1.4;
}

/* ========== 响应式 ==========
