:root {
  --ink: #080b16;
  --panel: rgba(12, 18, 35, 0.88);
  --line: rgba(160, 225, 255, 0.24);
  --text: #eef7ff;
  --muted: #9eb1c9;
  --cyan: #7ee7ff;
  --pink: #ff9fbc;
  --gold: #ffd76a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(47, 89, 125, 0.22), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(44, 82, 58, 0.16), transparent 48%),
    #05070d;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* 兜底：老 WebView 不认识 dvh / env()，先给一套 vh 版本；支持时再用更精确的那套覆盖。 */
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 0.5625));
  height: min(100vh, calc(100vw * 1.7778));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--ink);
  box-shadow:
    0 0 0 1px rgba(136, 210, 255, 0.08),
    0 24px 90px rgba(0, 0, 0, 0.6);
}

@supports (height: 100dvh) {
  #stage {
    width: min(100vw, calc(100dvh * 0.5625));
    height: min(
      calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)),
      calc(100vw * 1.7778)
    );
    margin-top: env(safe-area-inset-top, 0px);
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }
}

#game {
  display: block;
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  /* 不用 inset 简写：老 WebView 内核不认，会退回静态位置从而被裁掉 */
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  display: grid;
  place-items: center;
  padding: 22px;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 22px calc(22px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(circle at 50% 30%, rgba(41, 74, 98, 0.34), transparent 48%),
    rgba(4, 7, 14, 0.72);
  /* WebView 合成层保险：强制独立图层，避免被硬件加速的 canvas 盖住 */
  transform: translateZ(0);
  isolation: isolate;
  transition: opacity 180ms ease;
}

/* backdrop-filter 在部分 WebView 内核上会把整层画没，只在支持时启用 */
@supports (backdrop-filter: blur(1px)) {
  .overlay {
    background:
      radial-gradient(circle at 50% 30%, rgba(41, 74, 98, 0.34), transparent 48%),
      rgba(4, 7, 14, 0.58);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(100%, 320px);
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(24, 38, 62, 0.94), rgba(9, 14, 26, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 20px 55px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 10vw, 42px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 24px rgba(126, 231, 255, 0.2),
    0 3px 0 rgba(0, 0, 0, 0.35);
}

h1 span {
  color: var(--pink);
}

h2 {
  margin: 0 0 8px;
  font-size: 25px;
  line-height: 1.15;
}

.lead {
  margin: 13px auto 15px;
  color: #c7d8ea;
  font-size: 13px;
  line-height: 1.7;
}

.tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.tips span {
  padding: 5px 8px;
  border: 1px solid rgba(126, 231, 255, 0.14);
  border-radius: 999px;
  background: rgba(126, 231, 255, 0.05);
  color: #a9c6db;
  font-size: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 14px;
  color: #b7cadd;
  font-size: 11px;
  cursor: pointer;
}

.toggle input {
  width: 14px;
  height: 14px;
  accent-color: #7ee7ff;
}

button {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(126, 231, 255, 0.44);
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(126, 231, 255, 0.2), rgba(58, 151, 185, 0.15));
  color: #f2fbff;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 24px rgba(126, 231, 255, 0.08);
}

button:active {
  transform: translateY(1px);
  filter: brightness(0.92);
}

button.ghost {
  min-height: 40px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(126, 231, 255, 0.06);
  border-color: rgba(126, 231, 255, 0.22);
  color: #a8c3d6;
}

.foot {
  margin-top: 12px;
  color: #6f829a;
  font-size: 10px;
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.stat {
  padding: 9px 5px;
  border: 1px solid rgba(160, 225, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.stat strong {
  display: block;
  margin-bottom: 2px;
  color: #f4fbff;
  font-size: 18px;
}

.stat span {
  color: #8499b0;
  font-size: 9px;
}

.hint {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(6, 10, 18, 0.68);
  color: #d6e8f7;
  font-size: 11px;
  letter-spacing: 0.08em;
  pointer-events: none;
  animation: hint-pulse 1.2s ease-in-out infinite;
  transition: opacity 220ms ease;
}

.hint.hidden {
  opacity: 0;
  visibility: hidden;
  animation: none;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.48; }
  50% { opacity: 1; }
}

@media (max-height: 700px) {
  .panel {
    padding: 16px 16px 14px;
  }

  .lead {
    margin: 9px auto 10px;
    font-size: 12px;
  }

  .tips {
    margin-bottom: 10px;
  }

  .toggle {
    margin-bottom: 10px;
  }
}
