/* 末日城堡 UI - 灰烬风暴后的视觉语言 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #0a0908;
  color: #d4cdb8;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { cursor: pointer; font-family: inherit; }

/* 固定整体布局 */
#app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  max-width: 760px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(120,40,30,0.20), transparent 60%),
    linear-gradient(180deg, #110d0a 0%, #0a0807 100%);
  box-shadow: 0 0 80px rgba(120,30,20,0.15) inset;
  position: relative;
}
#app::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 80px, rgba(255,255,255,0.012) 81px, rgba(255,255,255,0.012) 82px),
    repeating-linear-gradient(-45deg, transparent, transparent 80px, rgba(255,255,255,0.012) 81px, rgba(255,255,255,0.012) 82px);
  pointer-events: none;
}

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(120,40,30,0.4);
  background: linear-gradient(180deg, rgba(20,12,8,0.8), transparent);
  z-index: 2;
}
.title-block h1 {
  font-size: 22px; letter-spacing: 4px;
  color: #dabb86;
  text-shadow: 0 0 12px rgba(180,100,40,0.3), 0 2px 0 #2a1a10;
}
.title-block .subtitle {
  font-size: 11px; color: #8b7960; letter-spacing: 1px; margin-top: 2px;
}
.countdown { text-align: right; }
.countdown .label { font-size: 10px; color: #8b7960; letter-spacing: 1px; }
.countdown .value {
  font-size: 18px; color: #d8633c;
  font-family: "Consolas", "Courier New", monospace;
  font-weight: 700; letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(216,99,60,0.4);
}
.countdown.warning .value { color: #e34a26; animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%,100% { text-shadow: 0 0 8px rgba(216,99,60,0.4); }
  50% { text-shadow: 0 0 20px rgba(227,74,38,0.8); }
}

/* 资源条 */
.resources {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 12px;
  border-bottom: 1px solid rgba(80,30,20,0.4);
  background: rgba(8,6,4,0.6);
  gap: 1px;
  background-clip: padding-box;
}
.res {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 2px;
  background: rgba(40,20,15,0.4);
  border-left: 2px solid transparent;
  transition: background 0.3s;
}
.res span {
  font-size: 11px; color: #8b7960; letter-spacing: 1px;
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 2px;
}
.res b {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 15px; font-weight: 700;
  color: #e8d8b6;
}
.res small { font-size: 10px; color: #6b5940; }
.res.food b { color: #d4a55a; }
.res.water b { color: #5a9cc4; }
.res.materials b { color: #b8a070; }
.res.energy b { color: #d4c043; }
.res.medicine b { color: #c45a82; }
.res.hope b { color: #d8b04c; text-shadow: 0 0 8px rgba(216,176,76,0.5); }
.res.pop b { color: #84b06a; }
.res.warn { background: rgba(120,40,30,0.5); }
.res.warn b { color: #e34a26; }

/* 主区域 */
.feed {
  overflow-y: auto;
  padding: 16px 14px 80px;
  position: relative;
  scroll-behavior: smooth;
}
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-track { background: rgba(8,6,4,0.5); }
.feed::-webkit-scrollbar-thumb { background: rgba(120,80,60,0.4); border-radius: 4px; }

.card {
  background: rgba(28,18,12,0.85);
  border: 1px solid rgba(120,40,30,0.3);
  border-left: 3px solid #a05838;
  border-radius: 2px;
  padding: 14px 16px 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,200,150,0.04);
  animation: rise 0.4s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.card.beat { border-left-color: #c45a32; background: rgba(34,20,14,0.9); }
.card.micro { border-left-color: #787060; }
.card.system { border-left-color: #84b06a; background: rgba(20,28,16,0.85); }
.card.choice { border-left-color: #d4c043; background: rgba(34,28,12,0.85); }
.card.recap { border-left-color: #a05838; background: rgba(20,14,10,0.95); font-size: 13px; }
.card.recurit { border-left-color: #d8633c; }
.card .label {
  display: inline-block;
  font-size: 10px; letter-spacing: 2px;
  padding: 2px 8px;
  margin-bottom: 8px;
  background: rgba(120,40,30,0.3);
  color: #d4cdb8;
  border-radius: 2px;
  text-transform: uppercase;
}
.card.beat .label { background: rgba(196,90,50,0.4); color: #dabb86; }
.card.system .label { background: rgba(132,176,106,0.4); color: #a8d090; }
.card .title {
  font-size: 16px; font-weight: 600;
  color: #dabb86; letter-spacing: 1px;
  margin-bottom: 8px;
}
.card .text {
  color: #a89c84; line-height: 1.7; margin-bottom: 12px;
  font-size: 13.5px;
}
.card .text em { color: #d4a55a; font-style: normal; }
.card .options { display: flex; flex-direction: column; gap: 6px; }
.card .opt {
  background: rgba(60,38,28,0.5);
  border: 1px solid rgba(120,80,60,0.3);
  color: #d4cdb8;
  padding: 16px 16px;
  font-size: 14.5px; line-height: 1.5;
  border-radius: 3px;
  text-align: left;
  transition: all 0.18s;
  min-height: 52px;
}
.card .opt:not(:disabled):hover {
  background: rgba(120,60,30,0.4);
  border-color: #c45a32;
  transform: translateX(2px);
}
.card .opt:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.card .opt-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  margin-right: 8px;
  border-radius: 2px;
  background: rgba(120,40,30,0.4);
  color: #d4a55a;
}
.card .opt-tag.kind { background: rgba(60,40,30,0.4); color: #b89c70; }

/* 结算/recap 行 */
.settle-row {
  display: flex; justify-content: space-between; padding: 4px 0;
  border-bottom: 1px dashed rgba(120,80,60,0.2);
  font-size: 12px;
  color: #8b7960;
}
.settle-row b { color: #d4cdb8; font-family: "Consolas", monospace; }
.settle-row .neg { color: #e34a26; }
.settle-row .pos { color: #84b06a; }

/* 底部 tab */
.tabs {
  display: grid; grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid rgba(120,40,30,0.4);
  background: rgba(8,6,4,0.9);
  z-index: 2;
}
.tab {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(120,40,30,0.2);
  color: #8b7960;
  padding: 12px 4px;
  font-size: 12px;
  letter-spacing: 1px;
  transition: color 0.2s;
}
.tab:last-child { border-right: none; }
.tab.on { color: #d4a55a; background: rgba(120,40,30,0.15); }

/* 各面板的卡片 */
.npc-card {
  background: rgba(28,18,12,0.85);
  border: 1px solid rgba(120,40,30,0.3);
  border-left-width: 3px;
  border-radius: 2px;
  padding: 12px 14px; margin-bottom: 10px;
}
.npc-card.notmet { opacity: 0.4; filter: grayscale(0.5); }
.npc-card h3 { font-size: 15px; color: #dabb86; margin-bottom: 4px; }
.npc-card .ttl { font-size: 11px; color: #c45a32; letter-spacing: 2px; margin-bottom: 6px; }
.npc-card .story { font-size: 12px; color: #a89c84; line-height: 1.5; margin-bottom: 8px; }
.bar {
  height: 8px; background: rgba(60,38,28,0.4);
  border-radius: 4px; margin: 6px 0; overflow: hidden;
}
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #d4a55a, #d4c043); transition: width 0.5s; }
.bar i.warn { background: linear-gradient(90deg, #e34a26, #d8633c); }
.bar i.bad { background: linear-gradient(90deg, #c45a32, #a04020); }
.bar i.good { background: linear-gradient(90deg, #84b06a, #5a8c4a); }
.aff-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #8b7960; margin-bottom: 4px;
}
.aff-row b { font-family: "Consolas", monospace; color: #d4cdb8; }
.bonus-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(212,165,90,0.2);
  color: #d4a55a;
  border: 1px solid rgba(212,165,90,0.3);
  border-radius: 2px;
  margin: 2px 4px 2px 0;
}
.bonus-tag.max { background: rgba(216,176,76,0.3); color: #d8b04c; }

/* 科技树 */
.tech-cat { margin-bottom: 16px; }
.tech-cat h3 { font-size: 13px; color: #c45a32; letter-spacing: 2px; margin-bottom: 8px; }
.tech-row {
  background: rgba(28,18,12,0.85);
  border: 1px solid rgba(120,40,30,0.3);
  padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.tech-row.researched { border-color: #84b06a; background: rgba(20,28,16,0.85); }
.tech-row .tname { font-size: 13px; color: #d4cdb8; }
.tech-row .tname small { display: block; color: #8b7960; font-size: 11px; margin-top: 2px; }
.tech-row .cost { font-size: 11px; color: #a89c84; text-align: right; }
.tech-row button {
  background: rgba(120,40,30,0.4);
  border: 1px solid #c45a32;
  color: #d4a55a;
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 2px;
}
.tech-row.researched button { background: rgba(132,176,106,0.3); border-color: #84b06a; color: #84b06a; }
.tech-row button:disabled { opacity: 0.3; }

/* 领地 */
.ter-row {
  background: rgba(28,18,12,0.85);
  border: 1px solid rgba(120,40,30,0.3);
  padding: 12px;
  margin-bottom: 8px;
}
.ter-row.current { border-color: #d4a55a; background: rgba(34,28,12,0.85); }
.ter-row h4 { font-size: 14px; color: #dabb86; margin-bottom: 4px; }
.ter-row .cost { color: #8b7960; font-size: 12px; }
.ter-row button {
  background: rgba(120,40,30,0.4);
  border: 1px solid #c45a32;
  color: #d4a55a;
  padding: 6px 12px;
  font-size: 12px;
  margin-top: 6px;
  border-radius: 2px;
}
.ter-row.current button { display: none; }

/* 终结页 */
#ending-screen {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 99;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 40px 30px;
  text-align: center;
}
#ending-screen.hidden { display: none; }
#ending-screen h2 {
  font-size: 36px;
  letter-spacing: 8px;
  color: #d8633c;
  margin-bottom: 24px;
  text-shadow: 0 0 24px rgba(216,99,60,0.6);
}
#ending-screen .body {
  max-width: 480px;
  color: #a89c84;
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 32px;
}
#ending-screen .stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
  margin-bottom: 32px;
  font-size: 12px;
  color: #8b7960;
}
#ending-screen .stats b { color: #d4cdb8; font-family: "Consolas", monospace; }
#ending-screen button {
  background: rgba(120,40,30,0.4);
  border: 1px solid #c45a32;
  color: #d4a55a;
  padding: 12px 24px;
  font-size: 14px;
  letter-spacing: 2px;
  border-radius: 2px;
}

/* 进入下个月主按钮 + 收尾按钮 */
.opt.continue-btn {
  font-size: 16px !important;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 22px 14px !important;
  margin: 14px 0 22px;
  text-align: center !important;
  background: linear-gradient(180deg, rgba(212,165,90,0.22), rgba(120,40,30,0.18));
  border: 1px solid #d4a55a !important;
  border-radius: 3px;
  color: #d4a55a !important;
  cursor: pointer;
  transition: transform 0.12s, background 0.18s;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.opt.continue-btn:hover {
  background: linear-gradient(180deg, rgba(212,165,90,0.35), rgba(120,40,30,0.28));
  transform: translateY(-1px);
}
.opt.continue-btn:active { transform: translateY(0); }

.hidden { display: none !important; }
.muted { color: #6b5940; }
.danger { color: #e34a26; }

/* mod */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal/* 进入下个月主按钮 + 收尾按钮 */
.opt.continue-btn {
  font-size: 16px !important;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 22px 14px !important;
  margin: 14px 0 22px;
  text-align: center !important;
  background: linear-gradient(180deg, rgba(212,165,90,0.22), rgba(120,40,30,0.18));
  border: 1px solid #d4a55a !important;
  border-radius: 3px;
  color: #d4a55a !important;
  cursor: pointer;
  transition: transform 0.12s, background 0.18s;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.opt.continue-btn:hover {
  background: linear-gradient(180deg, rgba(212,165,90,0.35), rgba(120,40,30,0.28));
  transform: translateY(-1px);
}
.opt.continue-btn:active { transform: translateY(0); }

.hidden { display: none !important; }
.modal .inner {
  background: rgba(28,18,12,0.95);
  border: 1px solid #c45a32;
  padding: 24px;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
}
.modal h3 { color: #dabb86; margin-bottom: 12px; letter-spacing: 2px; }
.modal p { color: #a89c84; line-height: 1.6; margin-bottom: 12px; }

/* 末日飞溅 */
.crash-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 60%, rgba(200,40,20,0.4), rgba(0,0,0,0.95) 80%);
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadein 3s ease-out forwards;
}
@keyframes fadein { 0% { opacity: 0; } 100% { opacity: 1; } }
.crash-overlay .crash-text { font-size: 64px; color: #e34a26; letter-spacing: 16px; }
.crash-overlay .crash-sub { color: #d4a55a; font-size: 16px; margin-top: 16px; letter-spacing: 3px; }

@media (max-width: 480px) {
  .resources { grid-template-columns: repeat(2, 1fr); }
  .title-block h1 { font-size: 18px; letter-spacing: 2px; }
  .countdown .value { font-size: 14px; }
}


