/* ============================================================
   森林冰火人 · 神庙机台沉浸样式
   一体化机顶状态条 + 双翼火/冰牌匾 + 中央神庙舞台
   ============================================================ */

:root {
  --forest-0: #0b2e22;
  --forest-1: #0d2530;
  --forest-2: #081a24;
  --fire: #ff7043;
  --fire-deep: #d84315;
  --ice: #4fc3f7;
  --ice-deep: #0277bd;
  --gold: #ffd54f;
  --stone: #23352f;
  --stone-hi: #3a554a;
  --text: #e8f3ec;
  --text-dim: #9fc3b4;
  --font: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(255, 150, 60, 0.1), transparent 60%),
    radial-gradient(1200px 600px at 82% -10%, rgba(80, 180, 255, 0.1), transparent 60%),
    linear-gradient(160deg, var(--forest-0) 0%, var(--forest-1) 45%, var(--forest-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景萤火/水汽粒子 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 32%, rgba(255, 190, 90, 0.5), transparent 60%),
    radial-gradient(2px 2px at 38% 18%, rgba(255, 190, 90, 0.35), transparent 60%),
    radial-gradient(2px 2px at 62% 26%, rgba(140, 210, 255, 0.4), transparent 60%),
    radial-gradient(2px 2px at 84% 14%, rgba(140, 210, 255, 0.35), transparent 60%),
    radial-gradient(1.6px 1.6px at 26% 58%, rgba(255, 190, 90, 0.3), transparent 60%),
    radial-gradient(1.6px 1.6px at 72% 64%, rgba(140, 210, 255, 0.3), transparent 60%);
  animation: ambient-drift 22s ease-in-out infinite alternate;
  opacity: 0.9;
}

@keyframes ambient-drift {
  from { transform: translateY(0); }
  to { transform: translateY(-18px); }
}

/* ---------------- 机顶状态条 ---------------- */
.arcade-topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 40px);
  background: linear-gradient(180deg, rgba(10, 26, 22, 0.92), rgba(10, 26, 22, 0.72));
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.topbar-brand {
  display: flex;
  justify-content: flex-start;
}

.topbar-home {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.topbar-home:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
}

.topbar-title {
  text-align: center;
}

.topbar-title h1 {
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  background: linear-gradient(90deg, #ffb98a 0%, #ffd9c0 35%, #bdeaff 65%, #8ed4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-sub {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 胶囊小按钮 */
.chip-btn {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--stone-hi), var(--stone));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.chip-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chip-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ---------------- 主容器：双翼 + 中央 ---------------- */
.arcade-container {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr) minmax(190px, 260px);
  gap: clamp(10px, 1.6vw, 22px);
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px) clamp(14px, 3vw, 40px) 24px;
}

/* ---------------- 双翼牌匾 ---------------- */
.side-plaque {
  border-radius: 14px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    linear-gradient(160deg, var(--stone), #182520);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -8px 20px rgba(0, 0, 0, 0.3);
}

.plaque-fire {
  border-top: 3px solid rgba(255, 112, 67, 0.7);
}

.plaque-ice {
  border-top: 3px solid rgba(79, 195, 247, 0.7);
}

.plaque-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.gem-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.gem-dot.fire {
  background: radial-gradient(circle at 35% 30%, #ffb199, var(--fire) 70%);
  box-shadow: 0 0 10px rgba(255, 112, 67, 0.8);
}

.gem-dot.ice {
  background: radial-gradient(circle at 35% 30%, #d6f6ff, var(--ice) 70%);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.8);
}

.plaque-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}

.plaque-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 12px;
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #1a2b26;
  background: linear-gradient(180deg, #f2f8f4, #c3d6cc);
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-bottom-width: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.key-label {
  width: 100%;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.plaque-collect {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}

.collect-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.collect-row span:last-child {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.plaque-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
}

.stat-row span:last-child {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.plaque-total {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding-top: 2px;
}

.star-total {
  color: var(--gold);
  font-weight: 800;
  font-size: 17px;
}

.plaque-solo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
}

.plaque-advice {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* 焦点徽章（呼吸脉动） */
.focus-badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  animation: focus-pulse 1.6s ease-in-out infinite;
}

.focus-fire {
  color: #ffe0d2;
  background: radial-gradient(circle at 30% 30%, rgba(255, 112, 67, 0.85), rgba(216, 67, 21, 0.65));
  box-shadow: 0 0 12px rgba(255, 112, 67, 0.55);
}

.focus-ice {
  color: #e3f6ff;
  background: radial-gradient(circle at 30% 30%, rgba(79, 195, 247, 0.85), rgba(2, 119, 189, 0.65));
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.55);
}

@keyframes focus-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* ---------------- 中央舞台 ---------------- */
.stage-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.level-badge {
  font-weight: 800;
  color: var(--gold);
  font-size: 15px;
  letter-spacing: 0.05em;
}

.level-name {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: var(--text);
  opacity: 0.92;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.5),
    inset 0 0 60px rgba(0, 0, 0, 0.35);
  background: var(--forest-1);
}

#stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.status-banner {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px;
  letter-spacing: 0.06em;
}

/* 石质实体按钮 */
.stone-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 11px;
  background: linear-gradient(180deg, var(--stone-hi) 0%, var(--stone) 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.32);
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.stone-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  filter: brightness(1.12);
}

.stone-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.45), inset 0 3px 6px rgba(0, 0, 0, 0.55);
}

.stone-btn.primary {
  background: linear-gradient(180deg, #4d8f7a, #2c6a55);
}

.stone-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.stage-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.mode-btn {
  font-size: 12.5px;
  opacity: 0.9;
  border-style: dashed;
}

/* ---------------- 移动端掌机操作台 ---------------- */
.touch-pad {
  display: none;
}

/* ---------------- 选关弹层 ---------------- */
.level-card {
  width: min(880px, 94vw);
}

.level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.level-head h2 {
  margin-bottom: 0;
  flex: 1;
}

.modal-x {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.1s ease, color 0.1s ease, background 0.1s ease;
}

.modal-x:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.modal-x:active {
  transform: translateY(1px);
}

.level-select {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.chapter-block {
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  margin-bottom: 9px;
  color: var(--text-dim);
}

.chapter-name {
  font-weight: 700;
  color: var(--text);
}

.chapter-stars {
  color: var(--gold);
  font-weight: 700;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(38px, 1fr));
  gap: 7px;
}

.level-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 52px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(180deg, var(--stone-hi), var(--stone));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.level-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4);
}

.level-cell:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.4);
}

.level-cell.locked {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.level-cell.active {
  outline: none;
  box-shadow: 0 0 0 2px var(--gold), 0 4px 0 rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, #6a5a24, #4a3f1a);
}

.cell-stars {
  font-size: 9.5px;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 0.02em;
}

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 14, 18, 0.72);
  backdrop-filter: blur(4px);
  padding: 18px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 26px 28px;
  background:
    radial-gradient(600px 200px at 50% -10%, rgba(255, 180, 90, 0.1), transparent 60%),
    linear-gradient(165deg, #1c322c, #12201e);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.modal-card h2 {
  font-size: 21px;
  text-align: center;
  margin-bottom: 14px;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.modal-card p {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-card .stone-btn {
  display: block;
  margin: 16px auto 0;
}

.result-card {
  text-align: center;
}

.result-stars {
  font-size: 40px;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 213, 79, 0.55);
  margin-bottom: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  text-align: left;
  margin-bottom: 8px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 14px;
}

.result-row span:last-child {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-record {
  color: var(--gold);
  font-weight: 800;
  font-size: 15px;
  margin: 8px 0 4px;
  min-height: 20px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ---------------- 响应式 ---------------- */
/* 桌面窄屏：双翼收窄 */
@media (max-width: 1099px) {
  .arcade-container {
    grid-template-columns: minmax(160px, 200px) minmax(0, 1fr) minmax(160px, 200px);
  }
  .level-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 移动端：双翼折叠为舞台上缘细长挂件，底部预留在广告安全区 */
@media (max-width: 768px) {
  .arcade-topbar {
    grid-template-columns: auto 1fr auto;
    padding: 8px 10px;
  }
  .topbar-title h1 {
    font-size: 17px;
  }
  .topbar-sub,
  .topbar-home {
    display: none;
  }

  .arcade-container {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 10px 0;
  }

  .side-plaque {
    display: none;
  }

  .level-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .level-cell {
    height: 44px;
    font-size: 13px;
  }

  .stage-shell {
    gap: 8px;
  }

  .stage-controls .stone-btn {
    font-size: 12.5px;
    padding: 8px 12px;
  }

  /* 移动端掌机操作台：屏幕下半区左右分控 */
  .touch-pad {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 4px;
  }

  .touch-group {
    display: flex;
    gap: 6px;
  }

  .touch-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 19px;
    font-weight: 800;
    color: var(--text);
    background: linear-gradient(180deg, var(--stone-hi), var(--stone));
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-top-color: rgba(255, 255, 255, 0.32);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .touch-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.45);
  }

  .touch-jump {
    background: linear-gradient(180deg, #4d8f7a, #2c6a55);
  }

  .touch-hint {
    font-size: 11px;
    color: var(--text-dim);
    writing-mode: vertical-rl;
  }

  /* 底部安全留白：Banner 广告绝不遮挡操作区 */
  body {
    padding-bottom: max(68px, calc(16px + env(safe-area-inset-bottom)));
  }
}

/* ---------------- 动效降级 ---------------- */
@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
  .focus-badge,
  .chip-btn,
  .stone-btn,
  .level-cell,
  .topbar-home {
    animation: none;
    transition: none;
  }
  .focus-badge:hover,
  .chip-btn:hover,
  .stone-btn:hover,
  .level-cell:hover {
    transform: none;
  }
}
