:root {
  color-scheme: dark;
  --ink: #ecf8ff;
  --muted: #9bb9cb;
  --cyan: #6de6ff;
  --amber: #ffc66d;
  --panel: rgba(9, 25, 48, 0.9);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(71, 161, 199, .25), transparent 38%),
    radial-gradient(circle at 85% 85%, rgba(113, 92, 190, .2), transparent 36%),
    #071426;
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Microsoft YaHei", sans-serif;
}

.game-shell { width: min(100%, 1440px); padding: 24px; }
.topbar, footer { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 4px; color: var(--cyan); font-size: 11px; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 42px); }
.status { display: flex; gap: 18px; color: var(--muted); }
.status strong { color: var(--ink); }
.music-toggle {
  padding: 7px 12px;
  border: 1px solid rgba(109, 230, 255, .3);
  background: rgba(20, 55, 83, .72);
  color: var(--cyan);
  box-shadow: none;
  font-size: 12px;
}
.music-toggle[aria-pressed="false"] { color: var(--muted); opacity: .8; }

.home-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  border: 1px solid rgba(109, 230, 255, .3);
  border-radius: 999px;
  background: rgba(20, 55, 83, .72);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease;
}
.home-btn:hover { background: rgba(34, 82, 116, .92); border-color: rgba(109, 230, 255, .55); }

.home-link {
  display: inline-block;
  margin-top: 14px;
  padding: 9px 18px;
  border: 1px solid rgba(141, 224, 255, .32);
  border-radius: 999px;
  background: rgba(20, 55, 83, .72);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease;
}
.home-link:hover { background: rgba(34, 82, 116, .92); border-color: rgba(109, 230, 255, .55); }
.home-btn:focus-visible, .home-link:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.stage-wrap {
  position: relative;
  margin: 16px 0 12px;
  overflow: hidden;
  border: 1px solid rgba(145, 220, 255, .22);
  border-radius: 26px;
  background: #a9dcf5;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .36), inset 0 0 0 1px rgba(255,255,255,.12);
  touch-action: pan-x pan-y pinch-zoom;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  touch-action: pan-x pan-y pinch-zoom;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(110deg, rgba(4, 17, 37, .82), rgba(10, 32, 57, .38));
  transition: opacity .25s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  width: min(520px, 92%);
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid rgba(141, 224, 255, .32);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 25px 80px rgba(0,0,0,.28);
  backdrop-filter: blur(16px);
}
.badge { color: var(--amber); font-size: 12px; letter-spacing: .12em; }
.panel h2 { margin: 10px 0 12px; font-size: clamp(28px, 5vw, 48px); line-height: 1.05; }
.panel p { color: var(--muted); line-height: 1.7; }
button {
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  background: linear-gradient(135deg, #79edff, #73a8ff);
  color: #07203a;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(71, 190, 255, .24);
}
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.controls { margin-bottom: 0; font-size: 12px; }

.touch-controls { position: absolute; inset: auto 16px 14px; display: none; gap: 10px; pointer-events: none; }
.touch-controls button { width: 58px; height: 58px; padding: 0; opacity: .82; pointer-events: auto; }
.touch-controls .jump { margin-left: auto; }

footer { align-items: center; color: var(--muted); font-size: 12px; }

@media (hover: none), (max-width: 1100px) {
  .touch-controls {
    position: static;
    display: flex;
    padding: 10px 14px;
    background: rgba(7, 24, 45, .92);
    border-top: 1px solid rgba(145, 220, 255, .18);
    pointer-events: auto;
  }
}

@media (max-width: 760px) {
  .game-shell { padding: 10px; }
  .topbar { align-items: start; flex-direction: column; gap: 8px; }
  .eyebrow { display: none; }
  h1 { font-size: 25px; }
  .status { width: 100%; justify-content: space-between; gap: 7px; font-size: 12px; flex-wrap: wrap; }
  .music-toggle, .home-btn { padding: 5px 9px; }
  .stage-wrap { margin-top: 9px; border-radius: 18px; }

  /* 竖屏下画面很矮，弹窗内容装不下会被 overflow:hidden 裁掉（开始按钮看不见）。
     允许弹窗溢出显示，并让面板自身可滚动。 */
  .stage-wrap:has(.overlay:not(.hidden)) { overflow: visible; }
  .overlay { align-items: start; overflow-y: auto; padding: 14px 12px; }
  .panel { padding: 20px 18px; border-radius: 20px; }
  .panel h2 { font-size: 22px; margin: 8px 0 10px; }
  .panel p { font-size: 14px; line-height: 1.55; }
  button { padding: 11px 20px; }
  .home-link { margin-top: 10px; padding: 8px 16px; font-size: 12px; }

  /* 弹窗打开时隐藏触控按钮，否则会压住底部的操作说明和返回主页链接 */
  .stage-wrap:has(.overlay:not(.hidden)) .touch-controls { display: none !important; }

  footer { display: none; }
}

@media (orientation: portrait) and (max-width: 1100px) {
  .game-shell { padding-top: 6px; }
  .topbar { gap: 5px; }
  .touch-controls button { width: 52px; height: 52px; }

  /* 平板竖屏同样会裁掉弹窗底部（760px 断点覆盖不到这里） */
  .stage-wrap:has(.overlay:not(.hidden)) { overflow: visible; }
  .overlay { align-items: start; overflow-y: auto; padding: 14px 12px; }
  .stage-wrap:has(.overlay:not(.hidden)) .touch-controls { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay { transition: none; }
}
