/* ============================================================
   无间游戏 — 样式
   配色严格依据规则书 §8.1：
     剧情叙事 #b0bec5（青灰、雾感）｜面板标题 #26c6da｜面板数值 #eceff1
     环境简报 #ffb300（琥珀）｜结算信息 #ff7043（橙·警示）
     死亡/失败 #ef5350（红）｜可选行动 #4fc3f7 / #e1f5fe
   ============================================================ */

:root {
  --bg: #0a0e11;
  --bg-panel: #121a1f;
  --bg-panel-2: #0e1519;
  --border: #1e2c33;
  --narrative: #b0bec5;
  --panel-title: #26c6da;
  --panel-value: #eceff1;
  --brief-title: #ffb300;
  --settle-title: #ff7043;
  --danger: #ef5350;
  --action-title: #4fc3f7;
  --action-text: #e1f5fe;
  --muted: #607d8b;
  --gold: #d4af37;
}

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

body {
  background: var(--bg);
  color: var(--narrative);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Source Han Sans CN', sans-serif;
  font-size: 16px;
  line-height: 1.85;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 雾感背景 */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(38, 198, 218, 0.05), transparent 70%),
    radial-gradient(ellipse 60% 40% at 20% 100%, rgba(38, 50, 56, 0.4), transparent 70%);
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---------------- 通用 ---------------- */
.hidden { display: none !important; }

.section-title {
  color: var(--panel-title);
  font-size: 15px; font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before { content: ''; width: 3px; height: 14px; background: currentColor; display: inline-block; }

/* ---------------- 标题屏 ---------------- */
.title-screen { text-align: center; padding: 40px 0 20px; animation: fadeIn 1.2s ease; }
.game-title {
  font-size: 52px; font-weight: 900; letter-spacing: 14px;
  color: #cfd8dc; margin-bottom: 6px;
  text-shadow: 0 0 30px rgba(38, 198, 218, 0.35), 0 0 60px rgba(0,0,0,0.9);
}
.game-subtitle { color: var(--muted); font-size: 13px; letter-spacing: 5px; margin-bottom: 8px; }
.game-source { color: #37474f; font-size: 12px; letter-spacing: 1px; margin-bottom: 34px; }

.warning-box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--settle-title);
  background: var(--bg-panel-2);
  padding: 14px 16px; margin: 0 auto 30px;
  text-align: left; font-size: 13.5px; color: #90a4ae; line-height: 1.9;
  max-width: 620px;
}
.warning-box strong { color: var(--settle-title); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: block; width: 100%; text-align: left;
  background: var(--bg-panel); color: var(--action-text);
  border: 1px solid var(--border); border-left: 3px solid transparent;
  padding: 15px 18px; margin-bottom: 11px;
  font-size: 15.5px; font-family: inherit; line-height: 1.6;
  cursor: pointer; transition: all .18s ease;
}
.btn:hover, .btn:active {
  background: #17232a; border-left-color: var(--action-title);
  transform: translateX(3px);
}
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--bg-panel); border-left-color: transparent; transform: none; }

.btn-num { color: var(--action-title); font-weight: 700; margin-right: 8px; }
.btn-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.6; }

.btn-center { text-align: center; border-left: none; }
.btn-center:hover { transform: none; border-color: var(--action-title); }

.btn-danger { border-left-color: transparent; }
.btn-danger:hover { border-left-color: var(--danger); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 130px; }

/* ---------------- 难度 / 开局选择 ---------------- */
.choice-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-left: 3px solid transparent;
  padding: 17px 19px; margin-bottom: 13px; cursor: pointer; transition: all .18s ease;
}
.choice-card:hover { background: #17232a; border-left-color: var(--panel-title); }
.choice-card.locked { opacity: .4; cursor: not-allowed; }
.choice-card.locked:hover { background: var(--bg-panel); border-left-color: transparent; }
.choice-name {
  color: var(--panel-value); font-size: 17px; font-weight: 700;
  margin-bottom: 7px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.choice-text { color: #8fa3ad; font-size: 14px; line-height: 1.85; }
.tag {
  font-size: 11px; padding: 2px 8px; border: 1px solid currentColor;
  font-weight: 400; letter-spacing: .5px;
}
.tag-rec { color: var(--panel-title); }
.tag-lock { color: var(--muted); }
.tag-deep { color: var(--gold); }

/* ---------------- 状态面板 ---------------- */
.panel {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  padding: 15px 17px; margin-bottom: 16px;
}
.panel-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 9px 18px;
}
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13.5px; }
.stat-label { color: var(--muted); white-space: nowrap; }
.stat-value { color: var(--panel-value); font-weight: 600; text-align: right; }

/* 数值条 */
.bar-wrap { margin-bottom: 11px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-head .bar-label { color: var(--muted); }
.bar-head .bar-num { color: var(--panel-value); font-weight: 600; }
.bar { height: 5px; background: #14202600; background-color: #16232a; overflow: hidden; }
.bar-fill { height: 100%; transition: width .5s ease; }
.bar-erosion { background: linear-gradient(90deg, #4a148c, #ab47bc); }
.bar-humanity { background: linear-gradient(90deg, #1b5e20, #66bb6a); }
.bar-calamity { background: linear-gradient(90deg, #bf360c, #ff7043); }
.bar-profile  { background: linear-gradient(90deg, #01579b, #4fc3f7); }
.bar-sanity   { background: linear-gradient(90deg, #4a148c, #7e57c2); }

.cap-hint { color: #546e7a; font-size: 11.5px; }

/* ---------------- 叙事 ---------------- */
.narrative {
  background: linear-gradient(180deg, rgba(18,26,31,.75), rgba(10,14,17,.4));
  border: 1px solid var(--border); border-left: 3px solid #37474f;
  padding: 20px 21px; margin-bottom: 18px;
  color: var(--narrative); font-size: 16px; line-height: 2.05;
  white-space: pre-wrap; word-break: break-word;
}
.narrative .speech { color: #cfd8dc; }
.narrative .em { color: #e0f7fa; font-weight: 600; }
.narrative .ghost-text { color: #b39ddb; letter-spacing: 2px; }

.scene-head {
  color: var(--muted); font-size: 12px; letter-spacing: 3px;
  margin-bottom: 13px; padding-bottom: 9px; border-bottom: 1px dashed #26353c;
}

/* ---------------- 环境简报 ---------------- */
.brief .section-title { color: var(--brief-title); }
.brief-item { font-size: 13.5px; margin-bottom: 6px; color: #a1b0b8; }
.brief-item .k { color: var(--brief-title); opacity: .85; }
.threat-level { font-weight: 700; }
.lv-C { color: #9ccc65; } .lv-B { color: #ffca28; }
.lv-A { color: #ff7043; } .lv-S { color: var(--danger); }

/* ---------------- 结算信息 ---------------- */
.settle {
  background: rgba(255, 112, 67, .05);
  border: 1px solid rgba(255, 112, 67, .28);
  border-left: 3px solid var(--settle-title);
  padding: 15px 17px; margin-bottom: 18px;
}
.settle .section-title { color: var(--settle-title); }
.settle-line {
  font-family: 'SF Mono', Consolas, 'Courier New', monospace;
  font-size: 12.5px; line-height: 1.95; color: #ffab91;
  white-space: pre-wrap; word-break: break-word; margin-bottom: 5px;
}
.settle-line.fail { color: var(--danger); font-weight: 600; }
.settle-line.ok { color: #a5d6a7; }
.settle-line.dim { color: #8d6e63; }
.settle-detail {
  color: #bcaaa4; font-size: 13.5px; font-style: italic;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(255,112,67,.25);
}

/* ---------------- 行动 ---------------- */
.actions .section-title { color: var(--action-title); }

.custom-action { margin-top: 14px; padding-top: 14px; border-top: 1px dashed #26353c; }
.custom-action textarea {
  width: 100%; background: var(--bg-panel-2); color: var(--action-text);
  border: 1px solid var(--border); padding: 12px;
  font-family: inherit; font-size: 14.5px; line-height: 1.7; resize: vertical; min-height: 76px;
}
.custom-action textarea:focus { outline: none; border-color: var(--action-title); }
.custom-hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ---------------- 死亡 / 结局 ---------------- */
.death-screen { text-align: center; padding: 44px 16px; animation: fadeIn 1s ease; }
.death-title {
  font-size: 46px; font-weight: 900; letter-spacing: 16px;
  color: var(--danger); margin-bottom: 22px;
  text-shadow: 0 0 34px rgba(239, 83, 80, .45);
}
.death-reason {
  color: #ef9a9a; font-size: 16px; line-height: 2;
  margin: 0 auto 26px; max-width: 560px;
}
.death-rule {
  color: var(--muted); font-size: 12.5px; font-style: italic;
  margin-bottom: 30px; line-height: 1.9;
}

.ending-screen { padding: 34px 4px; animation: fadeIn 1.2s ease; }
.ending-grade {
  text-align: center; font-size: 13px; letter-spacing: 6px;
  color: var(--muted); margin-bottom: 12px;
}
.ending-title {
  text-align: center; font-size: 34px; font-weight: 900; letter-spacing: 5px;
  color: var(--panel-title); margin-bottom: 8px;
  text-shadow: 0 0 26px rgba(38, 198, 218, .3);
}
.ending-block {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  border-left: 3px solid var(--panel-title);
  padding: 17px 19px; margin: 16px 0;
}
.ending-block h3 { color: var(--panel-title); font-size: 15px; margin-bottom: 9px; letter-spacing: 1px; }
.ending-block p { font-size: 14.5px; line-height: 1.95; color: #a1b0b8; }
.ending-cost { color: #ffab91; font-size: 13.5px; margin-top: 10px; line-height: 1.85; }
.ending-block.personal { border-left-color: var(--brief-title); }
.ending-block.personal h3 { color: var(--brief-title); }

/* ---------------- 设置 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  z-index: 100; animation: fadeIn .2s ease;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border);
  max-width: 520px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 22px;
}
.modal h2 { color: var(--panel-title); font-size: 19px; margin-bottom: 6px; letter-spacing: 1px; }
.modal .modal-desc { color: var(--muted); font-size: 13px; line-height: 1.85; margin-bottom: 18px; }
.field { margin-bottom: 15px; }
.field label { display: block; color: #90a4ae; font-size: 13px; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; background: var(--bg-panel-2); color: var(--panel-value);
  border: 1px solid var(--border); padding: 11px; font-family: inherit; font-size: 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--panel-title); }
.field .hint { color: #546e7a; font-size: 11.5px; margin-top: 5px; line-height: 1.7; }

.top-bar { display: flex; justify-content: flex-end; gap: 9px; margin-bottom: 14px; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 13px; font-size: 12.5px; cursor: pointer; font-family: inherit; transition: all .15s;
}
.icon-btn:hover { color: var(--panel-title); border-color: var(--panel-title); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--bg-panel); border: 1px solid var(--panel-title);
  color: var(--action-text); padding: 12px 22px; font-size: 14px;
  z-index: 200; animation: fadeIn .2s ease; max-width: 90vw; text-align: center;
}

.loading { color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }
.loading::after { content: '…'; animation: dots 1.4s infinite; }

/* 被盯上的氛围提示（§4 劫难≥70） */
.watched-hint {
  color: #ef9a9a; font-size: 13px; font-style: italic;
  padding: 10px 14px; margin-bottom: 16px;
  border-left: 3px solid var(--danger); background: rgba(239,83,80,.06);
  animation: pulse 3.5s infinite;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: .72; } 50% { opacity: 1; } }
@keyframes dots { 0%,20% { content: '.'; } 40% { content: '..'; } 60%,100% { content: '…'; } }

/* ---------------- 道具卡片 ---------------- */
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px;
}
.item-card {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  padding: 12px 14px; cursor: pointer; transition: all .15s;
}
.item-card:hover { border-color: var(--panel-title); }
.item-card.expanded { border-color: var(--panel-title); background: rgba(38,198,218,.06); }
.item-name { font-size: 14.5px; color: var(--panel-value); margin-bottom: 6px; font-weight: 600; }
.item-meta { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.item-desc {
  font-size: 12.5px; color: #90a4ae; line-height: 1.7;
  display: none;
}
.item-card.expanded .item-desc { display: block; margin-top: 4px; padding-top: 8px; border-top: 1px dashed rgba(38,198,218,.2); }
.item-card.mundane .item-name { color: #b0bec5; }
.item-card.grade-C .item-name { color: #81c784; }
.item-card.grade-B .item-name { color: #64b5f6; }
.item-card.grade-A .item-name { color: #ba68c8; }
.item-card.grade-S .item-name { color: #ffb74d; }
.item-use-btn {
  margin-top: 10px; width: 100%; padding: 7px 12px;
  background: rgba(38,198,218,.15); border: 1px solid var(--panel-title);
  color: var(--panel-title); font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.item-use-btn:hover { background: rgba(38,198,218,.3); }

/* ---------------- 移动端 ---------------- */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  #app { padding: 14px 12px 44px; }
  .game-title { font-size: 34px; letter-spacing: 8px; }
  .game-subtitle { font-size: 11.5px; letter-spacing: 3px; }
  .death-title { font-size: 32px; letter-spacing: 10px; }
  .ending-title { font-size: 25px; letter-spacing: 3px; }
  .narrative { padding: 16px 15px; font-size: 15.5px; line-height: 1.95; }
  .panel-grid { grid-template-columns: repeat(2, 1fr); gap: 8px 12px; }
  .stat { font-size: 12.5px; }
  .btn { padding: 13px 15px; font-size: 15px; }
  .settle-line { font-size: 11.5px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
}

@media (max-width: 380px) {
  .game-title { font-size: 28px; letter-spacing: 5px; }
  .panel-grid { grid-template-columns: 1fr; }
}
