/* styles.css — 异星哨站 · 最后的幸存者
   art direction: deep-space research station / alien infestation / survival horror.
   仅负责布局、状态、缺件兜底；主题令牌集中在 :root。 */

:root {
  --c-bg: #0a0e14;
  --c-panel: #131b26;
  --c-panel-2: #0e141d;
  --c-line: #26384a;
  --c-cyan: #45d8c9;
  --c-amber: #f0a63a;
  --c-bio: #7fe04a;
  --c-red: #e0483c;
  --c-sanity: #9b6cff;
  --c-text: #dbe6f0;
  --c-dim: #7d90a4;
  --font-head: 'Orbitron', 'Rajdhani', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Rajdhani', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'Segoe UI', system-ui, sans-serif;
  --radius: 4px;
  --shadow: 0 6px 22px rgba(0, 0, 0, .55);
  --glow: 0 0 12px;
  --m-fast: 140ms;
  --m: 260ms;
  --m-slow: 520ms;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .3px;
}
#game { display: none; }         /* 弃用 Phaser 容器 */

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(69, 216, 201, .06), transparent 60%),
    var(--c-bg);
}
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* 扫描线覆盖层（CRT 质感） */
#app::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.10) 2px 4px);
  mix-blend-mode: multiply; opacity: .5;
}

button { font-family: var(--font-body); cursor: pointer; color: var(--c-text); }
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: 1px; }
.clip { clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); }

/* ============================= 标题屏 ============================= */
#screen-title { flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#title-bg {
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(180deg, rgba(10,14,20,.35), rgba(10,14,20,.82)),
              radial-gradient(80% 60% at 50% 35%, #16303a, #0a0e14 75%);
  background-size: cover; background-position: center;
}
#title-bg.has-art { background-blend-mode: normal; }
.title-inner { position: relative; z-index: 2; padding: 24px; max-width: 720px; width: 92%; }
.title-badge {
  display: inline-block; font-family: var(--font-head); font-size: 12px; letter-spacing: 3px;
  color: #1a1205; font-weight: 800; background: var(--c-amber);
  padding: 5px 16px; border-radius: 2px; margin-bottom: 18px; text-transform: uppercase;
  box-shadow: 0 0 0 2px #12100a, 0 0 14px rgba(240,166,58,.4);
}
#screen-title h1 {
  font-size: clamp(34px, 8vw, 68px); line-height: 1.02; color: var(--c-text);
  text-shadow: 0 0 24px rgba(69,216,201,.45), 0 4px 16px #000;
}
#screen-title h1 .accent { color: var(--c-cyan); display: block; }
.title-sub { color: var(--c-amber); font-size: clamp(14px, 2.6vw, 20px); margin: 14px 0 30px;
  letter-spacing: 2px; text-shadow: 0 2px 10px #000; }
.title-actions { display: flex; flex-direction: column; gap: 14px; align-items: center; }

.btn {
  position: relative; border: 1px solid var(--c-line); background: var(--c-panel);
  color: var(--c-text); padding: 13px 26px; font-size: 16px; letter-spacing: 1px;
  transition: transform var(--m-fast) var(--ease), background var(--m-fast), box-shadow var(--m-fast), border-color var(--m-fast);
  min-width: 0; overflow-wrap: break-word;
}
.btn:hover:not(:disabled) { border-color: var(--c-cyan); box-shadow: var(--glow) rgba(69,216,201,.4); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn.primary { background: linear-gradient(180deg, #1b6f68, #0f4a45); border-color: var(--c-cyan);
  color: #eafffb; font-family: var(--font-head); font-size: 18px; padding: 15px 44px; }
.btn.primary:hover { box-shadow: var(--glow) rgba(69,216,201,.7); }
.btn.ghost { background: transparent; font-size: 14px; }
.btn:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.6); }

/* 静音按钮（全局角标） */
#mute-btn {
  position: absolute; top: 12px; right: 12px; z-index: 40; width: 40px; height: 40px;
  border: 1px solid var(--c-line); background: rgba(19,27,38,.8); border-radius: 4px; font-size: 18px;
}
#mute-btn:hover { border-color: var(--c-cyan); }

/* ============================= 主玩法屏 ============================= */
#screen-game { flex-direction: column; }
#game-bg {
  position: absolute; inset: 0; z-index: 0; opacity: .28; filter: blur(2px) brightness(.6);
  background: radial-gradient(70% 60% at 50% 40%, #14202b, #0a0e14 80%);
  background-size: cover; background-position: center;
  transition: background-image var(--m-slow);
}
.game-wrap {
  position: relative; z-index: 2; display: flex; flex-direction: column;
  width: 100%; height: 100%; padding: 10px; gap: 10px;
}

/* HUD：三条资源条 */
.hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 0 0 auto; padding-right: 46px; }
.stat {
  background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 8px 12px; position: relative; overflow: hidden; min-width: 0;
}
.stat-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.stat-name { font-size: 13px; letter-spacing: 1px; color: var(--c-dim); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stat-val { font-family: var(--font-head); font-size: 15px; }
.stat-bar { height: 12px; background: #05080c; border-radius: 3px; overflow: hidden; box-shadow: inset 0 0 6px #000; }
.stat-fill { height: 100%; width: 100%; transform-origin: left; transition: transform var(--m) var(--ease);
  border-radius: 3px; }
.stat.health .stat-fill { background: linear-gradient(90deg, #8f2018, var(--c-red)); }
.stat.sanity .stat-fill { background: linear-gradient(90deg, #4a2f9c, var(--c-sanity)); }
.stat.power  .stat-fill { background: linear-gradient(90deg, #1c7b73, var(--c-cyan)); }
.stat.flash-dmg { animation: dmgflash var(--m) ease; }
.stat.flash-heal { animation: healflash var(--m) ease; }
@keyframes dmgflash { 0%,100%{ box-shadow: inset 0 0 0 rgba(224,72,60,0);} 30%{ box-shadow: inset 0 0 30px rgba(224,72,60,.8), 0 0 14px rgba(224,72,60,.7);} }
@keyframes healflash { 0%,100%{ box-shadow: inset 0 0 0 rgba(127,224,74,0);} 30%{ box-shadow: inset 0 0 26px rgba(127,224,74,.7);} }

/* 主区：左场景视窗 + 右行动菜单 */
.main { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; flex: 1 1 auto; min-height: 0; }
.viewport {
  position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 0;
}
.viewport-scene {
  position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity var(--m-slow);
  background-size: cover; background-position: center;
}
.viewport-scene.show { opacity: .5; }
.viewport-head {
  position: relative; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: linear-gradient(180deg, rgba(19,27,38,.9), rgba(19,27,38,.4));
  border-bottom: 1px solid var(--c-line);
}
.viewport-head .rgn-icon { font-size: 18px; }
.viewport-head .rgn-name { font-family: var(--font-head); font-size: 15px; letter-spacing: 1px;
  color: var(--c-cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.viewport-body { position: relative; z-index: 2; flex: 1 1 auto; display: flex;
  align-items: center; justify-content: center; padding: 12px; min-height: 0; }
.scene-desc {
  position: relative; z-index: 2; max-width: 90%; text-align: center; font-size: 15px; line-height: 1.55;
  color: var(--c-text); text-shadow: 0 2px 8px #000; overflow-wrap: break-word;
}

/* 遭遇怪物立绘弹层 */
.encounter {
  position: absolute; inset: 0; z-index: 5; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(60% 60% at 50% 45%, rgba(224,72,60,.14), rgba(5,8,12,.72));
  backdrop-filter: blur(1px);
}
.encounter.show { display: flex; animation: encIn var(--m) var(--ease); }
@keyframes encIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.enc-art {
  width: min(46%, 180px); aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 84px; filter: drop-shadow(0 0 20px rgba(224,72,60,.6));
}
.enc-art img { width: 100%; height: 100%; object-fit: contain; }
.enc-art.boss { width: min(60%, 230px); filter: drop-shadow(0 0 30px rgba(127,224,74,.7)); }
.enc-name { font-family: var(--font-head); font-size: 18px; color: var(--c-red); letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(224,72,60,.7); }
.enc-name.boss { color: var(--c-bio); text-shadow: 0 0 16px rgba(127,224,74,.8); }
.enc-dmg { display: flex; gap: 10px; font-size: 13px; }
.enc-dmg span { background: rgba(5,8,12,.7); border: 1px solid var(--c-line); padding: 2px 8px; border-radius: 3px; }

/* 行动菜单 */
.actions { display: flex; flex-direction: column; min-height: 0; }
.actions-scroll { overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 12px; }
.act-group-title { font-size: 11px; letter-spacing: 2px; color: var(--c-dim); text-transform: uppercase;
  border-bottom: 1px solid var(--c-line); padding-bottom: 3px; }
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.act-btn {
  display: flex; align-items: center; gap: 7px; text-align: left; padding: 9px 10px;
  border: 1px solid var(--c-line); background: var(--c-panel-2); border-radius: 3px; font-size: 13px;
  transition: transform var(--m-fast), border-color var(--m-fast), box-shadow var(--m-fast), background var(--m-fast);
  min-width: 0;
}
.act-btn .a-icon { font-size: 16px; flex: 0 0 auto; }
.act-btn .a-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-btn:hover:not(:disabled) { border-color: var(--c-cyan); box-shadow: inset 0 0 12px rgba(69,216,201,.15); }
.act-btn:active:not(:disabled) { transform: scale(.95); }
.act-btn:disabled { opacity: .4; cursor: not-allowed; }
.act-btn.done { border-color: var(--c-bio); color: var(--c-bio); }
.act-btn.highlight { border-color: var(--c-amber); box-shadow: 0 0 14px rgba(240,166,58,.5);
  animation: pulseGlow 1.4s infinite; }
@keyframes pulseGlow { 0%,100%{ box-shadow: 0 0 8px rgba(240,166,58,.3);} 50%{ box-shadow: 0 0 20px rgba(240,166,58,.75);} }

/* 底部：日志 + 进度灯 + 物品栏 */
.bottom { display: grid; grid-template-columns: 1fr 300px; gap: 10px; flex: 0 0 auto; height: 150px; }
.log { background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.log-entry { font-size: 13px; line-height: 1.4; padding: 3px 6px; border-left: 2px solid var(--c-line);
  color: var(--c-text); animation: logIn var(--m) var(--ease); overflow-wrap: break-word; }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.log-entry.good { border-color: var(--c-bio); color: #cfeeb8; }
.log-entry.bad { border-color: var(--c-red); color: #f2b6b0; }
.log-entry.warn { border-color: var(--c-amber); color: #f4d59a; }
.log-entry.boss { border-color: var(--c-bio); color: #d6ffb0; background: rgba(127,224,74,.06);
  font-family: var(--font-head); letter-spacing: .5px; }
.log-entry.info { border-color: var(--c-line); color: var(--c-dim); }

.side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.progress-lights { display: flex; gap: 6px; }
.plight { flex: 1; display: flex; align-items: center; gap: 5px; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--c-line); border-radius: 3px; background: var(--c-panel); color: var(--c-dim);
  min-width: 0; }
.plight .pl-dot { width: 9px; height: 9px; border-radius: 50%; background: #2a3644; flex: 0 0 auto;
  box-shadow: inset 0 0 3px #000; }
.plight .pl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plight.on { color: var(--c-bio); border-color: var(--c-bio); }
.plight.on .pl-dot { background: var(--c-bio); box-shadow: 0 0 10px var(--c-bio); }
.plight.ready { color: var(--c-amber); border-color: var(--c-amber); }
.plight.ready .pl-dot { background: var(--c-amber); box-shadow: 0 0 10px var(--c-amber); }
.plight.lit { animation: pulseGlow .8s 2; }

.inventory { flex: 1 1 auto; background: var(--c-panel); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 6px; min-height: 0; overflow-y: auto; }
.inv-title { font-size: 10px; letter-spacing: 2px; color: var(--c-dim); text-transform: uppercase; margin-bottom: 4px; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.inv-slot { aspect-ratio: 1; border: 1px solid var(--c-line); border-radius: 3px; background: var(--c-panel-2);
  display: flex; align-items: center; justify-content: center; font-size: 20px; position: relative; }
.inv-slot.filled { border-color: var(--c-cyan); box-shadow: inset 0 0 10px rgba(69,216,201,.2); }
.inv-slot.filled.pop { animation: invPop 420ms var(--ease); }
@keyframes invPop { 0%{ transform: scale(0); } 60%{ transform: scale(1.25); } 100%{ transform: scale(1); } }
.inv-slot img { width: 82%; height: 82%; object-fit: contain; }
.inv-slot .inv-name { position: absolute; bottom: -1px; left: 0; right: 0; font-size: 8px; text-align: center;
  color: var(--c-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 可点击使用的道具 */
.inv-slot { transition: transform var(--m-fast) var(--ease), box-shadow var(--m-fast); }
.inv-slot.usable.filled { cursor: pointer; border-color: var(--c-cyan); animation: usableGlow 1.8s infinite; }
@keyframes usableGlow { 0%,100%{ box-shadow: inset 0 0 10px rgba(69,216,201,.2);} 50%{ box-shadow: inset 0 0 14px rgba(69,216,201,.45), 0 0 8px rgba(69,216,201,.45);} }
.inv-slot.usable.filled:hover { transform: scale(1.07); border-color: var(--c-bio); }
.inv-slot.usable.filled:active { transform: scale(.96); }
.inv-slot.locked { cursor: not-allowed; filter: grayscale(.55) brightness(.72); animation: none; }
.use-tag { position: absolute; top: 0; right: 0; font-size: 8px; line-height: 1; z-index: 2;
  background: var(--c-cyan); color: #04241f; padding: 2px 3px; border-radius: 0 3px 0 4px; font-weight: 800; }
.inv-slot.locked .use-tag { background: var(--c-dim); color: #10161d; }

/* 飘字 */
.float-num { position: fixed; z-index: 80; font-family: var(--font-head); font-weight: bold; font-size: 22px;
  pointer-events: none; text-shadow: 0 2px 6px #000; animation: floatUp 900ms var(--ease) forwards; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-46px) scale(1.15); } }

/* 屏震 / 全屏闪 */
.shake { animation: shake 260ms; }
@keyframes shake { 0%,100%{ transform: translate(0,0);} 20%{ transform: translate(-6px,3px);} 40%{ transform: translate(5px,-4px);} 60%{ transform: translate(-4px,-3px);} 80%{ transform: translate(4px,3px);} }
#fx-flash { position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0; }
#fx-flash.fire { animation: fxflash 320ms ease; }
@keyframes fxflash { 0%{ opacity: .0;} 15%{ opacity: .7;} 100%{ opacity: 0;} }

/* ============================= 结算屏 ============================= */
#screen-over { align-items: center; justify-content: center; z-index: 70;
  background: rgba(4,6,10,.72); backdrop-filter: blur(4px); }
.over-card {
  position: relative; width: 92%; max-width: 460px; padding: 22px 20px; text-align: center;
  box-shadow: var(--shadow); animation: overIn 420ms var(--ease);
}
@keyframes overIn { from { opacity: 0; transform: scale(.85) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.over-card.win { border-color: var(--c-cyan); box-shadow: 0 0 40px rgba(69,216,201,.35); }
.over-card.lose { border-color: var(--c-red); box-shadow: 0 0 40px rgba(224,72,60,.3); }
.over-tag { font-family: var(--font-head); font-size: 13px; letter-spacing: 4px; text-transform: uppercase; }
.over-card.win .over-tag { color: var(--c-cyan); }
.over-card.lose .over-tag { color: var(--c-red); }
.over-card h2 { font-size: 32px; margin: 8px 0 12px; }
.over-text { font-size: 15px; line-height: 1.6; color: var(--c-text); margin-bottom: 18px; overflow-wrap: break-word; }
.over-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px; }
.over-stat { background: var(--c-panel-2); border: 1px solid var(--c-line); border-radius: 3px; padding: 10px 8px; }
.over-stat .os-val { font-family: var(--font-head); font-size: 22px; color: var(--c-cyan); }
.over-stat .os-label { font-size: 11px; color: var(--c-dim); letter-spacing: 1px; }
.over-best { font-size: 13px; color: var(--c-amber); margin: 10px 0 18px; }
.over-best.record { animation: pulseGlow 1s 3; }

/* ============================= 说明弹窗 ============================= */
#screen-help { align-items: center; justify-content: center; z-index: 75;
  background: rgba(4,6,10,.8); backdrop-filter: blur(4px); }
.help-card { position: relative; width: 92%; max-width: 560px; max-height: 84vh; overflow-y: auto;
  padding: 22px; box-shadow: var(--shadow); animation: overIn 380ms var(--ease); }
.help-card h2 { color: var(--c-cyan); font-size: 24px; margin-bottom: 14px; }
.help-card p, .help-card li { font-size: 14px; line-height: 1.7; color: var(--c-text); }
.help-card ul { padding-left: 18px; margin: 8px 0; }
.help-card .close-x { position: absolute; top: 8px; right: 10px; width: 40px; height: 42px;
  padding: 0; font-size: 0; }

/* ============================= UI Kit（painted-ink）皮肤适配 ============================= */
/* 面板：清空本作底/边，改用 kit 九宫格 border-image 框（win/lose 光晕由 .over-card.win/.lose 提供） */
.over-card[data-ui-component="panel.main"],
.help-card[data-ui-component="panel.main"] { background: transparent; }
/* 主玩法：视窗与行动台套 kit 画框（padding 收紧，避免与 28px 画框叠加过厚） */
.viewport[data-ui-component="panel.main"] { background: transparent; padding: 6px; min-width: 0; min-height: 0; }
.actions[data-ui-component="panel.main"] { background: transparent; padding: 8px; min-width: 0; min-height: 0; }
/* 主 CTA 按钮：套 kit 皮肤 + 本作字体/主色描边呼应 */
.kit-cta { font-family: var(--font-head); font-size: 16px; letter-spacing: 1px; min-height: 50px; }
#screen-title .kit-cta { font-size: 18px; min-height: 58px; padding-left: 40px; padding-right: 40px; }
.kit-secondary { font-family: var(--font-body); font-size: 15px; opacity: .9; min-height: 46px; }
/* kit 关闭按钮悬停高亮 */
.ccg-ui-button-close:hover { filter: brightness(1.15) drop-shadow(0 0 6px rgba(224,72,60,.6)); }

/* ============================= 响应式（竖屏堆叠） ============================= */
@media (max-width: 820px), (orientation: portrait) {
  /* 竖屏：整屏可纵向滚动，各区块自然高度，避免控件被裁到视口外 */
  #screen-game { overflow-y: auto; overflow-x: hidden; align-items: stretch; }
  .game-wrap { height: auto; min-height: 100%; }
  .main { display: flex; flex-direction: column; }
  /* 行动台上移到 HUD 正下方：所有 <button> 控件都落在首屏视口内，场景/日志/物品在下方滚动区 */
  .actions { order: -1; flex: 0 0 auto; }
  .viewport { height: 26vh; min-height: 168px; flex: 0 0 auto; }
  .actions-scroll { overflow: visible; }
  .bottom { display: flex; flex-direction: column; height: auto; }
  .bottom .log { max-height: 110px; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .progress-lights { flex: 1 1 100%; }
  .inventory { flex: 1 1 100%; }
  .act-grid { grid-template-columns: 1fr 1fr; }        /* 双列，压缩按钮列表高度 */
  .hud { grid-template-columns: 1fr; gap: 6px; }
  .stat { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; }
  .stat-top { margin-bottom: 0; flex-direction: column; align-items: flex-start; }
  .stat-bar { grid-column: 2; }
}
@media (max-width: 380px) {
  .act-grid { grid-template-columns: 1fr; }            /* 极窄屏回退单列 */
}
