/* 焰境游戏 — 游戏平台样式（game.whizzzest.com，docs/游戏方案.md）
   品牌：延续主站焰色 #d64524 与万载TV「影院模式」深色基调（--bg-theater 同源） */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --c-text: #f4f1ec;
  --c-text-2: #b9b0a6;
  --c-text-3: #857c73;
  --c-bg: #150a05;
  --c-panel: rgba(255, 244, 230, 0.05);
  --c-panel-strong: rgba(255, 244, 230, 0.09);
  --c-hairline: rgba(255, 244, 230, 0.12);
  --c-accent: #d64524;         /* 焰色（主站同款） */
  --c-accent-bright: #f0572f;
  --c-gold: #f4d31f;           /* 火花金（点缀） */
  --c-danger: #e5484d;
  --bg-theater: linear-gradient(180deg, #2b1208, #1c0d06 45%, #150a05);
  --radius: 20px;
  --radius-s: 12px;
  --nav-h: 52px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--bg-theater) fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--c-hairline);
  background: var(--c-panel-strong);
  color: var(--c-text);
  font-size: 15px;
  transition: transform 0.15s var(--ease), background 0.15s;
}
.btn:hover { background: rgba(255, 244, 230, 0.14); }
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: var(--c-accent);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: var(--c-accent-bright); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ---------------- 运行页 chrome ---------------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px calc(0px + env(safe-area-inset-top)) 12px;
  padding-top: env(safe-area-inset-top);
  background: rgba(21, 10, 5, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-hairline);
  z-index: 30;
  user-select: none;
}
.back {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c-panel-strong);
  font-size: 17px;
}
.tb-title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--c-hairline);
  background: var(--c-panel-strong);
  color: var(--c-text);
  font-size: 13px;
  white-space: nowrap;
}
.tb-btn[aria-pressed="true"], .tb-btn[disabled] { opacity: 0.45; }

.persist-banner {
  position: fixed;
  top: calc(var(--nav-h) + env(safe-area-inset-top));
  left: 12px; right: 12px;
  z-index: 29;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: rgba(244, 211, 31, 0.12);
  border: 1px solid rgba(244, 211, 31, 0.35);
  color: #f6e8a8;
  font-size: 13px;
}
.persist-banner button {
  margin-left: auto;
  background: none; border: 0;
  color: inherit; font-size: 16px;
}
/* display:flex 会压过 hidden 属性的 UA 样式（同 .boot/.save-drawer 的配套规则），缺失它 = 横幅永远关不掉 */
.persist-banner[hidden] { display: none; }

.stage-wrap {
  position: fixed;
  inset: 0;
  padding-top: calc(var(--nav-h) + env(safe-area-inset-top));
  touch-action: none;           /* 游玩区禁手势滚动/缩放 */
}
#stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#stage > * { max-width: 100%; }
/* iframe 运行模式（第三方游戏包，docs/游戏整合方案.md §1.3） */
#stage > iframe.game-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* 伪全屏（iOS Safari 无元素全屏 API 时的兜底） */
body.pseudo-full .topbar, body.pseudo-full .persist-banner { display: none; }
body.pseudo-full .stage-wrap { padding-top: 0; }
/* 元素全屏：游玩区铺满，去掉顶栏预留位（顶栏在容器外自动隐藏） */
.stage-wrap:fullscreen { padding-top: 0; }
.stage-wrap:-webkit-full-screen { padding-top: 0; }

/* 覆盖层：加载中 / 未找到 / 崩溃 */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 40;
  background: rgba(21, 10, 5, 0.7);
}
.boot-card {
  max-width: 420px;
  width: 100%;
  padding: 34px 28px;
  border-radius: var(--radius);
  background: #20100a;
  border: 1px solid var(--c-hairline);
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}
.boot-card h2 { font-size: 20px; }
.boot-card p { font-size: 14px; color: var(--c-text-2); line-height: 1.7; }
.boot[hidden] { display: none; }
.boot-loading .boot-card h2::after {
  content: '';
  display: block;
  width: 34px; height: 34px;
  margin: 10px auto 0;
  border-radius: 50%;
  border: 3px solid var(--c-hairline);
  border-top-color: var(--c-accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 存档面板（右侧抽屉） ---------------- */

.save-drawer {
  position: fixed;
  top: calc(var(--nav-h) + env(safe-area-inset-top));
  right: 0;
  bottom: 0;
  width: min(430px, 100vw);
  z-index: 35;
  background: rgba(26, 13, 7, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--c-hairline);
  padding: 18px;
  overflow-y: auto;
}
.save-drawer[hidden] { display: none; }
.save-drawer h3 { font-size: 16px; margin-bottom: 12px; }
.save-drawer h3 small { color: var(--c-text-3); font-weight: 400; margin-left: 8px; font-size: 12px; }

.slot-card {
  border: 1px solid var(--c-hairline);
  border-radius: var(--radius-s);
  background: var(--c-panel);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.slot-empty { opacity: 0.65; }
.slot-head { display: flex; justify-content: space-between; align-items: baseline; }
.slot-head b { font-size: 14px; }
.slot-head span { font-size: 12px; color: var(--c-text-3); }
.slot-ops { display: flex; gap: 8px; margin-top: 10px; }
.btn-mini {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--c-hairline);
  background: var(--c-panel-strong);
  color: var(--c-text);
  font-size: 12px;
}
.btn-danger { color: #ffb3b5; border-color: rgba(229, 72, 77, 0.4); }

.drawer-io { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.storage-line {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--c-text-2);
}
.storage-line.warn { color: #f6e8a8; }

/* ---------------- 虚拟手柄 ---------------- */

#padHost { position: absolute; inset: 0; display: none; pointer-events: none; z-index: 20; }
#padHost.pad-on.ready { display: block; }
#padHost.pad-on.ready .gp-hidden { display: none; }

.gp {
  position: absolute;
  inset: auto 0 calc(10px + env(safe-area-inset-bottom)) 0;
  display: grid;
  gap: 6px;
  padding: 0 18px;
}
.gp-shoulders { display: flex; justify-content: space-between; }
.gp-main { display: flex; justify-content: space-between; align-items: flex-end; }
.gp-system { display: flex; justify-content: center; gap: 26px; }

.gp-btn {
  pointer-events: auto;
  border: 1px solid var(--c-hairline);
  background: rgba(255, 244, 230, 0.08);
  color: var(--c-text-2);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.06s, background 0.06s;
}
.gp-on { background: var(--c-accent); color: #fff; transform: scale(0.9); border-color: transparent; }
.gp-face { position: relative; width: 150px; height: 120px; }
.gp-face .gp-btn { position: absolute; width: 62px; height: 62px; }
.gp-face .gp-a { right: 0; bottom: 0; width: 70px; height: 70px; }
.gp-face .gp-b { left: 0; top: 0; }
.gp-shoulder { border-radius: 999px; width: 84px; height: 34px; }
.gp-sys { border-radius: 999px; width: 64px; height: 24px; font-size: 10px; }

.gp-dpad {
  pointer-events: auto;
  position: relative;
  width: 138px; height: 138px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.gp-arm {
  position: absolute;
  background: rgba(255, 244, 230, 0.08);
  border: 1px solid var(--c-hairline);
  transition: background 0.06s;
}
.gp-arm.gp-on { background: var(--c-accent); border-color: transparent; }
.gp-up    { left: 34%; bottom: 50%; width: 32%; height: 50%; border-radius: 10px 10px 0 0; }
.gp-down  { left: 34%; top: 50%;    width: 32%; height: 50%; border-radius: 0 0 10px 10px; }
.gp-left  { top: 34%; right: 50%;  height: 32%; width: 50%; border-radius: 10px 0 0 10px; }
.gp-right { top: 34%; left: 50%;   height: 32%; width: 50%; border-radius: 0 10px 10px 0; }
.gp-pivot {
  position: absolute;
  left: 50%; top: 50%;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 244, 230, 0.12);
  border: 1px solid var(--c-hairline);
}

/* ---------------- toast / dialog ---------------- */

#toastBox {
  position: fixed;
  top: calc(var(--nav-h) + env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(32, 16, 10, 0.95);
  border: 1px solid var(--c-hairline);
  font-size: 13px;
  animation: toast-in 0.25s var(--ease);
}
.toast-warn { border-color: rgba(244, 211, 31, 0.5); color: #f6e8a8; }
.toast-err { border-color: rgba(229, 72, 77, 0.6); color: #ffc2c4; }
.toast-out { opacity: 0; transition: opacity 0.4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

dialog {
  border: 1px solid var(--c-hairline);
  border-radius: var(--radius);
  background: #20100a;
  color: var(--c-text);
  padding: 24px;
  width: min(400px, 92vw);
}
dialog::backdrop { background: rgba(10, 5, 3, 0.6); backdrop-filter: blur(4px); }
#dlgTitle { font-size: 17px; margin-bottom: 10px; }
#dlgBody { font-size: 14px; color: var(--c-text-2); line-height: 1.7; margin-bottom: 20px; }
.dlg-ops { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------- 横竖屏提示 ---------------- */

#orientHint {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--c-bg);
  font-size: 15px;
  color: var(--c-text-2);
  text-align: center;
  line-height: 2;
}
#orientHint[hidden] { display: none; }

/* ---------------- 游戏库列表页 ---------------- */

.site-head {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px;
}
.site-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.site-brand img { width: 26px; height: 26px; }
.site-head .spacer { flex: 1; }
.site-head a.link { font-size: 13px; color: var(--c-text-2); }
.site-head a.link:hover { color: var(--c-text); }

.hero {
  max-width: 1080px;
  margin: 26px auto 30px;
  padding: 0 20px;
}
.hero .kicker {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--c-gold);
  margin-bottom: 10px;
}
.hero h1 { font-size: clamp(26px, 5vw, 40px); line-height: 1.25; }
.hero h1 em { font-style: normal; color: var(--c-accent-bright); }
.hero p {
  margin-top: 12px;
  color: var(--c-text-2);
  font-size: 15px;
  line-height: 1.8;
  max-width: 640px;
}

.games-grid {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.game-card {
  border: 1px solid var(--c-hairline);
  border-radius: var(--radius);
  background: var(--c-panel);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.game-card:hover { transform: translateY(-3px); border-color: rgba(214, 69, 36, 0.55); }
.game-card .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--c-hairline);
  color: var(--c-text-2);
}
.chip-accent { color: var(--c-gold); border-color: rgba(244, 211, 31, 0.4); }
.game-card h3 { font-size: 18px; }
.game-card .tagline { font-size: 13px; color: var(--c-text-2); line-height: 1.7; flex: 1; }
.game-card .meta { font-size: 12px; color: var(--c-text-3); }
.game-card .btn { align-self: flex-start; margin-top: 6px; }

.game-card.ghost {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--c-text-3);
  border-style: dashed;
  min-height: 180px;
}
.game-card.ghost b { color: var(--c-text-2); font-weight: 600; }

/* 云端畅玩 · 第三方平台入口（docs/游戏整合方案.md §8，决策⑭）
   外链指路牌，与游戏卡刻意区分：无实底、金色悬停、描边按钮 */
.cloud {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 54px;
}
.cloud h2 { font-size: 20px; }
.cloud .cloud-sub { margin-top: 6px; font-size: 13px; color: var(--c-text-2); }
.cloud-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.platform-card {
  border: 1px solid var(--c-hairline);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.platform-card:hover { transform: translateY(-3px); border-color: rgba(244, 211, 31, 0.45); }
.platform-card .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.platform-card h3 { font-size: 16px; }
.platform-card .tagline { font-size: 13px; color: var(--c-text-2); line-height: 1.7; flex: 1; }
.platform-card .meta { font-size: 12px; color: var(--c-text-3); }
.platform-card .btn { align-self: flex-start; margin-top: 6px; padding: 8px 18px; font-size: 13px; }
.cloud-note { margin-top: 16px; font-size: 12px; color: var(--c-text-3); }

/* 正版平台 · 第三方商店入口（docs/游戏整合方案.md §8.6，决策⑰）
   紧凑链接网格：一行一条「名称 — 一句话」，视觉轻于云区大卡，金色悬停与云区一致 */
.store-list {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.store-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--c-hairline);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.2s;
}
.store-item:hover { border-color: rgba(244, 211, 31, 0.45); }
.store-item b { flex-shrink: 0; font-size: 14px; font-weight: 600; }
.store-item b::after { content: " ↗"; font-size: 11px; color: var(--c-text-3); }
.store-item span { flex: 1; min-width: 0; font-size: 12px; color: var(--c-text-2); line-height: 1.6; }

.site-foot {
  border-top: 1px solid var(--c-hairline);
  padding: 26px 20px calc(30px + env(safe-area-inset-bottom));
  max-width: 1080px;
  margin: 0 auto;
  color: var(--c-text-3);
  font-size: 12px;
  line-height: 2;
}
.site-foot a { color: var(--c-text-2); }
.site-foot a:hover { color: var(--c-text); }

/* 窄屏：运行页顶栏按钮收敛为图标级 */
@media (max-width: 520px) {
  .tb-btn { padding: 7px 11px; font-size: 12px; }
  .gp { padding: 0 12px; }
}
