/* ============================================================
   跳一跳 · Jump Jump — 页面外壳 + 主题变量
   ============================================================ */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #00d4ff;
  --gradient: linear-gradient(135deg, #00d4ff, #7c4dff);
  --radius: 14px;
}

/* 全局重置，别删：少了 box-sizing，.panel 的 width 会变成内容宽度、
   加 padding 后撑破容器（实测 312px 的卡片会撑到 358px）；
   少了 ul/p/h1 的归零，列表还会捡回浏览器默认的 40px 缩进。 */
* { margin: 0; padding: 0; box-sizing: border-box; }

.game-page {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  outline: none;
  touch-action: none;
  cursor: pointer;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------- 顶部计分 ---------- */
#hud {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
}

/* 首页演示时藏起来：那时分数没有意义（不累计），
   而且挪下来之后会跟标题卡叠在一起 */
#hud[hidden] { display: none; }

/* 竖屏窄屏：计分和右上角按钮会撞上。实测 360px 宽 + 3 位分数时
   分数右边缘在 217、按钮左边缘在 200，最后一位被按钮压住；
   390px 宽也还差 3px。分数居中就必须给右侧 144px 宽的按钮组让位，
   而把字号压到塞得下需要缩到 18px —— 不划算，所以整块计分挪到按钮行下方。
   46px = 按钮高 38 + 间距 8，与 #game-tools 的 top 保持同一基准。 */
@media (max-width: 430px) {
  #hud {
    top: calc(max(16px, env(safe-area-inset-top)) + 46px);
  }
}

#score {
  font-size: clamp(2.6rem, 11vw, 4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #fdf7f0;
  /* 黄昏底是雾紫蓝，用暖色暗影托一下，不要用原来的青色辉光 */
  text-shadow: 0 2px 20px rgba(28, 20, 44, 0.6);
  transition: transform 0.18s cubic-bezier(0.34, 1.6, 0.64, 1);
}

#score.pop { transform: scale(1.22); }

.hud-best,
.panel-best {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hud-best strong,
.panel-best strong { color: var(--accent); font-weight: 700; }

.combo {
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0d1117;
  background: linear-gradient(135deg, #ffd86b, #ff9a3c);
  box-shadow: 0 0 20px rgba(255, 190, 80, 0.45);
  animation: combo-in 0.25s cubic-bezier(0.34, 1.6, 0.64, 1);
}

@keyframes combo-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ---------- 右上角工具 ---------- */
#game-tools {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  /* 必须高于遮罩层，否则开始/结束面板会挡住音效与语言按钮 */
  z-index: 5;
}

.tool-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

/* 角色样式按钮：上面写的是当前的样式名，所以要能自适应宽度 */
.tool-btn--wide {
  width: auto;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.tool-btn:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.tool-btn[aria-pressed="true"] { color: var(--text-muted); opacity: 0.55; }

/* ---------- 底部提示 ---------- */
.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(38px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.86rem;
  letter-spacing: 0.1em;
  /* 画面下方是暖玫瑰底，浅灰会糊掉，改用深暖色 */
  color: rgba(58, 40, 48, 0.82);
  text-shadow: 0 1px 10px rgba(255, 236, 220, 0.35);
  pointer-events: none;
  animation: hint-pulse 2.4s ease-in-out infinite;
  transition: opacity 0.5s;
}

.hint[hidden] { display: none; }
/* animation 会盖过普通声明，淡出时必须一并停掉 */
.hint.fade { opacity: 0; animation: none; }

@keyframes hint-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.95; }
}

/* ---------- 遮罩面板 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 45%, rgba(13, 17, 23, 0.62), rgba(13, 17, 23, 0.92));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.28s;
}

.overlay[hidden] { display: none; }

/* 首页是「角色自己在跳」的实景，遮罩得让路：只压上下两条，
   中间留透，面板也挪到上方，别盖住 70% 高度处的角色 */
.overlay.is-attract {
  place-items: start center;
  padding-top: max(56px, 8vh);
  background: linear-gradient(
    to bottom,
    rgba(13, 17, 23, 0.42) 0%,
    rgba(13, 17, 23, 0.10) 42%,
    rgba(13, 17, 23, 0.46) 100%
  );
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* 权重特意写成 .panel.panel--attract：这组规则排在 .panel 之前，
   同权重会被后者盖掉（首页那张卡就一直是实心的深色底）。 */
.panel.panel--attract {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  gap: 8px;
}

/* 标题是在实景上，得自己带一层阴影才读得清 */
.panel--attract .panel-title {
  filter: drop-shadow(0 4px 18px rgba(8, 6, 18, 0.75));
}

.panel--attract .panel-sub,
.panel--attract .rules li,
.panel--attract .panel-best {
  text-shadow: 0 1px 12px rgba(8, 6, 18, 0.8);
}

.cta {
  margin-top: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ffe6a8;
  text-shadow: 0 1px 14px rgba(8, 6, 18, 0.85);
  animation: hint-pulse 1.9s ease-in-out infinite;
}

.panel {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 34px 28px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: panel-in 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel[hidden] { display: none; }

@keyframes panel-in {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.panel-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.panel-title--sm { font-size: 1.3rem; letter-spacing: 0.14em; }

.panel-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: -6px;
}

.rules {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0;
  text-align: left;
}

.rules li {
  position: relative;
  padding-left: 20px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.rules li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gradient);
}

.panel .btn { width: 100%; padding: 13px 28px; }

.panel-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record {
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #0d1117;
  background: linear-gradient(135deg, #ffd86b, #ff9a3c);
  box-shadow: 0 0 24px rgba(255, 190, 80, 0.5);
  animation: combo-in 0.3s cubic-bezier(0.34, 1.6, 0.64, 1);
}

.final-score {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 4px 34px rgba(0, 212, 255, 0.4);
}

/* ---------- 响应式 ---------- */
@media (max-height: 520px) {
  .panel { padding: 22px 22px 20px; gap: 10px; }
  .panel-title { font-size: 1.7rem; }
  .rules { display: none; }
  .final-score { font-size: 2.4rem; }
  #score { font-size: 2.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .combo,
  .record { animation: none; }
  .hint { animation: none; opacity: 0.7; }
  #score { transition: none; }
}
