/* game-stage.css — 小游戏沉浸式外壳（2026-11-12）
 * 只做“标题页 + 游玩态 + 设置/排行榜面板”，游戏自身 UI 仍由各页负责。
 * 依赖 styles.css 的 --bg-color/--text-color/--card-color 等变量。
 */

.gj-stage {
  --gj-stage-accent: #4d6bfe;
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  color: var(--text-color, #1b2a4a);
  background:
    radial-gradient(ellipse 70% 60% at 76% 20%, color-mix(in srgb, var(--gj-stage-accent) 18%, transparent), transparent 66%),
    radial-gradient(ellipse 60% 50% at 18% 84%, color-mix(in srgb, var(--gj-stage-accent) 12%, transparent), transparent 68%),
    var(--bg-color, #f2f6fb);
}

.gj-stage::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(color-mix(in srgb, var(--text-color, #1b2a4a) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text-color, #1b2a4a) 5%, transparent) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 75% 75% at 50% 45%, #000 20%, transparent 78%);
}

.gj-stage-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: clamp(20px, 4vw, 54px);
  width: min(980px, 100%);
  padding: clamp(26px, 4vw, 46px);
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 10%, transparent);
  border-radius: 28px;
  background: color-mix(in srgb, var(--card-color, #fff) 82%, transparent);
  box-shadow: 0 30px 90px color-mix(in srgb, #153052 18%, transparent);
  backdrop-filter: blur(18px);
}

.gj-stage-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(260px, 34vw, 380px);
  isolation: isolate;
}

.gj-stage-halo {
  position: absolute;
  width: min(88%, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--gj-stage-accent) 30%, #fff) 0%, transparent 68%);
  filter: blur(4px);
  animation: gj-stage-breathe 5.6s ease-in-out infinite;
}

.gj-stage-grid {
  position: absolute;
  width: min(76%, 300px);
  aspect-ratio: 1;
  border: 1px dashed color-mix(in srgb, var(--gj-stage-accent) 36%, transparent);
  border-radius: 50%;
  transform: rotate(-12deg);
}

.gj-stage-hero {
  position: relative;
  z-index: 2;
  width: min(82%, 330px);
  height: auto;
  filter: drop-shadow(0 22px 24px rgba(18, 50, 86, 0.22));
  animation: gj-stage-float 4.8s ease-in-out infinite;
  user-select: none;
}

.gj-stage-sticker {
  position: absolute;
  z-index: 3;
  right: 4%;
  bottom: 8%;
  padding: 5px 11px;
  border: 1px solid color-mix(in srgb, var(--gj-stage-accent) 36%, transparent);
  border-radius: 999px;
  color: var(--gj-stage-accent);
  background: color-mix(in srgb, var(--card-color, #fff) 86%, transparent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transform: rotate(3deg);
}

.gj-stage-copy { position: relative; z-index: 2; }
.gj-stage-kicker {
  margin: 0 0 10px;
  color: var(--gj-stage-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.gj-stage-title {
  margin: 0 0 12px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.gj-stage-tagline {
  margin: 0 0 16px;
  max-width: 34em;
  color: color-mix(in srgb, var(--text-color, #1b2a4a) 68%, transparent);
  font-size: clamp(13px, 1.3vw, 15px);
  line-height: 1.8;
}
.gj-stage-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 22px; }
.gj-stage-chip {
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 12%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--text-color, #1b2a4a) 72%, transparent);
  background: color-mix(in srgb, var(--card-color, #fff) 65%, transparent);
  font-size: 11px;
}
.gj-stage-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.gj-stage-actions .g-btn { min-width: 118px; }
.gj-stage-start {
  min-width: 158px !important;
  border-color: var(--gj-stage-accent) !important;
  background: var(--gj-stage-accent) !important;
  color: #fff !important;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--gj-stage-accent) 30%, transparent);
}
.gj-stage-note {
  margin: 18px 0 0;
  color: color-mix(in srgb, var(--text-color, #1b2a4a) 48%, transparent);
  font-size: 11.5px;
  line-height: 1.7;
}

.gj-stage-sound {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 18px;
  z-index: 2;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 14%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--text-color, #1b2a4a) 70%, transparent);
  background: color-mix(in srgb, var(--card-color, #fff) 74%, transparent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.gj-stage-sound.is-on { color: var(--gj-stage-accent); border-color: color-mix(in srgb, var(--gj-stage-accent) 40%, transparent); }

/* 游玩态：标题页退场，只留顶栏；根节点不拦截画布事件 */
.gj-stage.is-playing { pointer-events: none; background: none; padding: 0; }
.gj-stage.is-playing::before { display: none; }
.gj-stage.is-playing .gj-stage-card,
.gj-stage.is-playing .gj-stage-sound { display: none; }
.gj-stage.is-playing .gj-stage-bar { pointer-events: auto; }

.gj-stage-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: max(6px, env(safe-area-inset-top)) 14px 6px;
  color: var(--text-color, #1b2a4a);
  background: color-mix(in srgb, var(--bg-color, #f2f6fb) 82%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 9%, transparent);
  backdrop-filter: blur(14px);
}
.gj-stage-bar[hidden] { display: none; }
.gj-stage-back,
.gj-stage-bar button {
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 13%, transparent);
  border-radius: 8px;
  color: inherit;
  background: color-mix(in srgb, var(--card-color, #fff) 62%, transparent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.gj-stage-back:hover,
.gj-stage-bar button:hover { color: var(--gj-stage-accent); border-color: var(--gj-stage-accent); }
.gj-stage-bar-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.gj-stage-bar-actions { display: flex; gap: 7px; align-items: center; }

/* 面板：说明 / 设置 / 排行榜 */
.gj-stage-panel {
  position: fixed;
  inset: 0;
  z-index: 1700;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 20, 38, 0.52);
  backdrop-filter: blur(4px);
}
.gj-stage-panel[hidden] { display: none; }
.gj-stage-panel-card {
  position: relative;
  width: min(430px, 100%);
  max-height: min(82dvh, 640px);
  overflow: auto;
  padding: 26px 28px 22px;
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 10%, transparent);
  border-radius: 18px;
  background: var(--card-color, #fff);
  color: var(--text-color, #1b2a4a);
  box-shadow: 0 22px 60px rgba(8, 26, 48, 0.28);
}
.gj-stage-panel-card h3 { margin: 0 0 14px; font-size: 20px; }
.gj-stage-panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.6;
}
.gj-stage-panel-close:hover { opacity: 1; }
.gj-stage-help { margin: 0; padding-left: 1.2em; font-size: 13.5px; line-height: 1.85; }
.gj-stage-help li { margin: 4px 0; }
.gj-stage-panel-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.gj-stage-panel-note { margin: 14px 0 0; color: color-mix(in srgb, var(--text-color, #1b2a4a) 52%, transparent); font-size: 11.5px; line-height: 1.7; }
.gj-stage-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--text-color, #1b2a4a) 12%, transparent);
  font-size: 13.5px;
}
.gj-stage-toggle input { width: 40px; height: 22px; accent-color: var(--gj-stage-accent); }
.gj-stage-rank-card { width: min(480px, 100%); }
.gj-stage-rank-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.gj-stage-rank-tabs { display: flex; gap: 4px; }
.gj-stage-rank-tabs button {
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--text-color, #1b2a4a) 12%, transparent);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.gj-stage-rank-tabs button.is-on { color: var(--gj-stage-accent); border-color: var(--gj-stage-accent); background: color-mix(in srgb, var(--gj-stage-accent) 9%, transparent); }
.gj-stage-rank-list { min-height: 120px; }
.gj-stage-rank-empty { margin: 26px 0; color: color-mix(in srgb, var(--text-color, #1b2a4a) 56%, transparent); font-size: 12.5px; line-height: 1.8; text-align: center; }
.gj-stage-rank-rows { margin: 0; padding: 0; list-style: none; }
.gj-stage-rank-rows li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  border-bottom: 1px dashed color-mix(in srgb, var(--text-color, #1b2a4a) 9%, transparent);
  font-size: 12.5px;
}
.gj-stage-rank-no { color: color-mix(in srgb, var(--text-color, #1b2a4a) 42%, transparent); font-variant-numeric: tabular-nums; }
.gj-stage-rank-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gj-stage-rank-score { color: var(--gj-stage-accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.gj-stage-rank-level { color: color-mix(in srgb, var(--text-color, #1b2a4a) 40%, transparent); font-size: 10.5px; }

/* 游玩态：隐藏站内壳，但不从源码里删正文 */
body.gj-game-active { padding: 0 !important; overflow: hidden; }
body.gj-game-active header,
body.gj-game-active .nav-pod,
body.gj-game-active .game-footer,
body.gj-game-active #ad-banner-top,
body.gj-game-active .game-desc,
body.gj-game-active .game-controls,
body.gj-game-active .game-main > h1,
body.gj-game-active .game-main > p,
body.gj-game-active .zm-hint,
body.gj-game-active .rc-hint { display: none !important; }
body.gj-game-active .game-main {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  box-sizing: border-box;
  padding-left: 12px;
  padding-right: 12px;
  padding-top: 66px;
  padding-bottom: 14px;
}
body.gj-game-active .game-hud { margin-top: 0; }
body.gj-game-active .g-board-wrap { margin-left: auto; margin-right: auto; }
body.gj-game-active-mergefish .g-board-wrap { width: min(100%, 560px); }
body.gj-game-active-mergefish canvas { width: 100%; height: auto; }

body.gj-reduce-motion .gj-stage-hero,
body.gj-reduce-motion .gj-stage-halo { animation: none !important; }

@keyframes gj-stage-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}
@keyframes gj-stage-breathe {
  0%, 100% { opacity: 0.72; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

body.dark .gj-stage {
  background:
    radial-gradient(ellipse 70% 60% at 76% 20%, color-mix(in srgb, var(--gj-stage-accent) 22%, transparent), transparent 66%),
    radial-gradient(ellipse 60% 50% at 18% 84%, color-mix(in srgb, var(--gj-stage-accent) 14%, transparent), transparent 68%),
    #0d1720;
}
body.dark .gj-stage-card { border-color: rgba(150, 180, 210, 0.16); background: rgba(18, 32, 46, 0.86); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4); }
body.dark .gj-stage-sticker { background: rgba(18, 32, 46, 0.9); }
body.dark .gj-stage-panel-card { border-color: rgba(150, 180, 210, 0.18); background: #152433; color: #e6eef6; }
body.dark .gj-stage-bar { background: rgba(13, 23, 32, 0.82); border-bottom-color: rgba(150, 180, 210, 0.14); }

@media (max-width: 820px) {
  .gj-stage { padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
  .gj-stage-card { grid-template-columns: 1fr; gap: 10px; padding: 18px 16px 20px; border-radius: 20px; }
  .gj-stage-art { min-height: 150px; }
  .gj-stage-hero { width: min(46%, 176px); }
  .gj-stage-halo { width: min(52%, 200px); }
  .gj-stage-grid { width: min(48%, 190px); }
  .gj-stage-sticker { right: 14%; bottom: 0; }
  .gj-stage-copy { text-align: center; }
  .gj-stage-kicker { margin-bottom: 6px; font-size: 11px; }
  .gj-stage-title { font-size: clamp(26px, 7.6vw, 32px); margin-bottom: 8px; }
  .gj-stage-tagline { margin-bottom: 12px; font-size: 12.5px; line-height: 1.7; }
  .gj-stage-chips { margin-bottom: 14px; }
  .gj-stage-actions { gap: 7px; }
  .gj-stage-actions .g-btn { flex: 1 1 40%; min-width: 0; padding: 9px 10px; }
  .gj-stage-start { flex-basis: 100% !important; }
  .gj-stage-note { margin-top: 12px; font-size: 11px; }
  .gj-stage-sound { top: max(8px, env(safe-area-inset-top)); right: 8px; padding: 6px 10px; }
  .gj-stage-bar-title { font-size: 11px; }
  .gj-stage-bar-actions #gj-stage-fullscreen { display: none; }
  body.gj-game-active .game-main { padding-top: 60px; }
}
