/* ============================================================
 * styles.css — 互动视频播放器 · 电影式游戏形态（手机优先）
 * 游玩时画面即全部；触屏用轻触与角落按钮，无键盘依赖
 * ============================================================ */

:root {
  --bg: #0a0c10;
  --ink: #f2f4f7;
  --ink-2: #a8b0bd;
  --ink-3: #6b7280;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #4d9be6;
  --accent-deep: #185fa5;
  --gold: #e8b04b;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; touch-action: manipulation; }

.hidden { display: none !important; }

kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 12px;
}

/* ============ 标题画面（游戏主菜单） ============
 * .title-bg-blur     铺底模糊图（填满整屏，避免黑边断层）
 * .title-art         画面盒：菜单层浮在其内部下部 → 按钮永远压在画面上
 *   ├ .title-bg      开屏主美术 / 可选背景视频
 *   ├ .title-scrim   压暗层
 *   └ .title-menu-layer  菜单（按钮 + 标签栏 + 重置）
 * 视口比 11:10 宽 → 画面盒铺满视口（cover 裁切）；更“瘦高”→ 画面盒 2:1 居中完整显示
 * ============================================ */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #05070a;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- 铺底：同一张图的模糊放大版 ---- */
.title-bg-blur {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  filter: blur(34px) brightness(0.42) saturate(1.15);
}

/* ---- 画面盒 ---- */
.title-art {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070a;
}
/* 开屏图（主美术）与可选背景视频，两者共用这套样式 */
.title-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  animation: kenburns 30s ease-in-out infinite alternate;
}
@keyframes kenburns {
  from { transform: scale(1.01); }
  to   { transform: scale(1.06); }
}
/* 压暗层：只做很轻的暗角 + 底部渐变（保证菜单可读，但不吃掉画面） */
.title-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(10, 12, 16, 0) 0%, rgba(10, 12, 16, 0.10) 70%, rgba(10, 12, 16, 0.40) 100%),
    linear-gradient(to bottom,
      rgba(10, 12, 16, 0.20) 0%,
      rgba(10, 12, 16, 0.02) 24%,
      rgba(10, 12, 16, 0.04) 50%,
      rgba(10, 12, 16, 0.40) 72%,
      rgba(10, 12, 16, 0.68) 88%,
      rgba(10, 12, 16, 0.80) 100%);
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 菜单层（浮在画面内部下部，各元素之间留足呼吸） ---- */
.title-menu-layer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  padding-bottom: calc(42px + env(safe-area-inset-bottom));
}

/* ---- 主按钮：描金细边胶囊（呼应标题书法，低调不抢画面） ---- */
.play-wrap {
  display: flex;
  justify-content: center;
  animation: tabIn 0.6s 0.1s ease both;
}
.play-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 13px 34px;
  border-radius: 999px;
  background: rgba(14, 11, 8, 0.40);
  border: 1px solid rgba(232, 176, 75, 0.42);
  backdrop-filter: blur(6px);
  color: #f6ecda;
  font-size: 17px;
  letter-spacing: 0.36em;
  text-indent: 0.36em;                    /* 抵消末字右侧字距，视觉居中 */
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease, transform 0.2s ease;
}
.play-btn:hover {
  background: rgba(22, 16, 9, 0.56);
  border-color: rgba(240, 196, 108, 0.95);
  box-shadow: 0 0 26px rgba(232, 176, 75, 0.22);
}
.play-btn:active { transform: scale(0.98); }
/* 文字两侧的极细金线 */
.play-btn-line {
  width: 26px;
  height: 1px;
  background: linear-gradient(to right, rgba(232, 176, 75, 0), rgba(232, 176, 75, 0.85));
  transition: width 0.24s ease, background 0.24s ease;
}
.play-btn-line:last-child {
  background: linear-gradient(to left, rgba(232, 176, 75, 0), rgba(232, 176, 75, 0.85));
}
.play-btn:hover .play-btn-line {
  width: 40px;
  background: rgba(240, 196, 108, 0.95);
}

/* ---- 底部标签栏 ---- */
.tab-bar {
  display: flex;
  justify-content: center;
  gap: 46px;
  animation: tabIn 0.6s 0.28s ease both;
}
@keyframes tabIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab {
  position: relative;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 14px;
  letter-spacing: 4px;
  padding: 10px 2px;
  cursor: pointer;
  transition: color 0.18s ease;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}
.tab:hover { color: rgba(255, 255, 255, 0.85); }
.tab.active { color: #fff; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}
.tab em {
  font-style: normal;
  font-size: 11px;
  color: var(--gold);
  margin-left: 5px;
  letter-spacing: 1px;
}

/* ---- 瘦高视口（窄窗口 / 手机竖屏）：画面完整显示并居中，四周由铺底模糊图填满 ----
 * 触发条件：视口比 11:10 更“瘦高”；此时若继续 cover 会把两侧标题裁掉 */
@media (max-aspect-ratio: 11/10) {
  .title-art {
    height: auto;
    aspect-ratio: 2 / 1;   /* 与开屏图同比例 → 完整显示，绝不裁标题 */
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
  }
}

/* ---- 小屏：菜单更紧凑，别吃掉太多画面 ---- */
@media (max-width: 720px) {
  .title-menu-layer { gap: 10px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .play-btn { gap: 12px; padding: 9px 20px; font-size: 13px; letter-spacing: 0.3em; text-indent: 0.3em; }
  .play-btn-line { width: 14px; }
  .tab-bar { gap: 14px; }
  .tab { font-size: 11px; letter-spacing: 1px; padding: 4px 2px; }
}

/* ============ 游戏画面 ============ */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}
.video-frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  overflow: hidden;
  transition: opacity 0.22s ease;
}
@supports (height: 100dvh) {
  .video-frame {
    width: min(100vw, calc(100dvh * 16 / 9));
    height: min(100dvh, calc(100vw * 9 / 16));
  }
}
.stage.fading .video-frame { opacity: 0; }

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  touch-action: manipulation;
}

/* 空闲时隐藏光标（纯沉浸） */
.stage.idle { cursor: none; }

/* ---- 无素材演示占位层 ---- */
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16202e 0%, #0b0e14 100%);
  text-align: center;
}
.placeholder-inner { padding: 20px; }
.placeholder-node {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 4px;
  margin-bottom: 10px;
}
.placeholder-line { font-size: 14px; color: var(--ink-2); margin-bottom: 26px; }
.count-ring { position: relative; width: 84px; height: 84px; margin: 0 auto 16px; }
.count-ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.14); stroke-width: 5; }
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 0;
}
.count-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.placeholder-tip { font-size: 12px; color: var(--ink-3); }

/* ---- 播放前点击层 ---- */
.play-gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}
.play-gate-btn {
  width: 76px;
  height: 76px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.play-gate-btn:hover { transform: scale(1.08); }

/* ---- 触屏角落按钮 ---- */
.touch-ui {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 5;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.stage.idle .touch-ui { opacity: 0; pointer-events: none; }
.touch-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.touch-btn:active { transform: scale(0.9); }

/* ---- 跳过（右上角，播放数秒后浮现；永久可见直到被使用） ---- */
.skip-btn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(12, 14, 19, 0.5);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  animation: fadeIn 0.35s ease;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.skip-btn:hover {
  border-color: rgba(240, 196, 108, 0.9);
  background: rgba(22, 16, 9, 0.62);
  color: #f6ecda;
}
.skip-btn:active { transform: scale(0.97); }
/* 触屏：静音/全屏挪到左上角，给跳过让位 */
@media (pointer: coarse) {
  .touch-ui {
    left: calc(12px + env(safe-area-inset-left));
    right: auto;
  }
}

/* ---- A/B 选择浮层（播完浮现） ---- */
.choice-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 130px 24px calc(44px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 55%, transparent 100%);
  animation: choiceIn 0.35s ease;
}
@keyframes choiceIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.choice-btns { display: flex; gap: 18px; }
.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 15px 32px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  background: rgba(16, 20, 28, 0.8);
  backdrop-filter: blur(10px);
  color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  animation: btnIn 0.4s backwards ease;
}
.choice-btn:nth-child(2) { animation-delay: 0.08s; }
@keyframes btnIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.choice-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 36px rgba(77, 155, 230, 0.25);
}
.choice-btn:active { transform: scale(0.97); }
.choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.choice-btn:hover .choice-key { background: var(--accent-deep); color: #fff; }

/* ---- 结局卡 ---- */
.ending-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(8px);
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  animation: fadeIn 0.5s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.ending-kicker {
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 12px;
}
.ending-name {
  font-size: 46px;
  font-weight: 600;
  letter-spacing: 12px;
  text-indent: 12px;
  margin-bottom: 14px;
  text-shadow: 0 4px 40px rgba(232, 176, 75, 0.25);
}
.ending-desc { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; letter-spacing: 1px; }
.ending-progress { font-size: 13px; color: var(--gold); margin-bottom: 30px; }
.ending-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---- 按钮 ---- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-deep); color: #fff; }
.btn-primary:hover { background: #1e74c4; }
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

/* ---- 横屏建议 ---- */
.rotate-hint {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 1px;
  white-space: nowrap;
  touch-action: manipulation;
  animation: fadeIn 0.4s ease;
}
.rotate-icon { display: inline-block; font-size: 15px; animation: rot 2.6s ease-in-out infinite; }
@keyframes rot {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
/* 选项或结局出现时让位 */
.choice-overlay:not(.hidden) ~ .rotate-hint,
.ending-card:not(.hidden) ~ .rotate-hint { display: none; }

/* ============ 结局册抽屉 ============ */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  z-index: 60;
  animation: fadeIn 0.2s ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(400px, 92vw);
  background: #10131a;
  border-left: 1px solid var(--line);
  z-index: 70;
  display: flex;
  flex-direction: column;
  padding: 26px;
  padding-top: calc(26px + env(safe-area-inset-top));
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  animation: slideIn 0.28s ease;
  overflow-y: auto;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.drawer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.drawer-head h3 { font-size: 18px; font-weight: 600; letter-spacing: 3px; }
.drawer-count { font-size: 13px; color: var(--gold); font-weight: 600; }
.drawer-close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
}
.drawer-close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.ending-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ending-cell {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  background: rgba(255,255,255,0.03);
}
.ending-cell.unlocked {
  background: rgba(232, 176, 75, 0.08);
  border-color: rgba(232, 176, 75, 0.35);
}
.ending-cell .ec-icon { font-size: 22px; margin-bottom: 8px; color: var(--gold); }
.ending-cell.locked .ec-icon { color: var(--ink-3); }
.ending-cell .ec-name { font-size: 14px; font-weight: 600; letter-spacing: 2px; }
.ending-cell .ec-desc { font-size: 11px; color: var(--ink-2); margin-top: 5px; line-height: 1.5; }
.ending-cell.locked .ec-name,
.ending-cell.locked .ec-desc { color: var(--ink-3); }
.drawer-foot { margin-top: auto; padding-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ============ 成就弹窗 ============ */
.achieve {
  position: fixed;
  top: calc(22px + env(safe-area-inset-top));
  right: calc(22px + env(safe-area-inset-right));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(16, 20, 28, 0.92);
  border: 1px solid rgba(232, 176, 75, 0.4);
  border-radius: 12px;
  padding: 12px 20px 12px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: achieveIn 0.35s ease;
}
@keyframes achieveIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.achieve-star {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(232, 176, 75, 0.15);
  color: var(--gold);
  font-size: 17px;
}
.achieve-kicker { font-size: 11px; color: var(--gold); letter-spacing: 2px; margin-bottom: 2px; }
.achieve-name { font-size: 15px; font-weight: 600; letter-spacing: 2px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(16, 20, 28, 0.95);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 999px;
  z-index: 90;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 触屏适配 ============ */
@media (pointer: coarse) {
  .choice-key { display: none; }          /* 触屏没有键盘，隐藏按键徽标 */
  .touch-btn { width: 44px; height: 44px; }
}

/* ============ 小屏适配（玩法界面；标题画面见上方 720px 规则） ============ */
@media (max-width: 640px) {
  .choice-btns { flex-direction: column; width: 100%; max-width: 320px; }
  .choice-btn { justify-content: center; padding: 14px 20px; font-size: 16px; }
  .ending-name { font-size: 32px; letter-spacing: 6px; }
  .choice-overlay { padding-top: 100px; }
}
