:root {
  /* 色とフォントの元帳よ。乙女、宇宙、アーケードをここで混ぜてるのよ。 */
  color-scheme: dark;
  --bg: #07090f;
  --panel: #211b2d;
  --panel-2: #342940;
  --ink: #fff7ed;
  --muted: #ffd6ef;
  --accent: #ff9bcf;
  --accent-2: #a8f5e8;
  --electric: #bfefff;
  --gold: #ffe6a7;
  --danger: #ff7b54;
  --display-font: "Bahnschrift Condensed", "Agency FB", "Arial Black", "Yu Gothic", sans-serif;
  --pop-title-font: "HGS創英角ﾎﾟｯﾌﾟ体", "HGP創英角ﾎﾟｯﾌﾟ体", "UD Digi Kyokasho NK-B", "Yu Gothic", sans-serif;
  --readout-font: "Cascadia Mono", "Consolas", "Lucida Console", monospace;
  --ui-font: "Bahnschrift", "Arial Narrow", "Yu Gothic UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  /* ページ全体はゲーム筐体の外側。背景は控えめにして、キャンバスを主役にするのよ。 */
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  background:
    radial-gradient(circle at 20% 12%, rgba(35, 240, 191, 0.2), transparent 25rem),
    radial-gradient(circle at 82% 82%, rgba(255, 63, 127, 0.18), transparent 24rem),
    linear-gradient(145deg, #07090f 0%, #101726 46%, #1d1120 100%);
  color: var(--ink);
  font-family: var(--ui-font);
}

.game-shell {
  width: min(100vw, 980px);
  min-height: 100svh;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 18px;
}

.game-shell:fullscreen {
  /* PC全画面では筐体ごと広げるのよ。ESCで戻るのはブラウザのお仕事なのよ。 */
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  padding: clamp(10px, 1.6vh, 18px);
  background:
    radial-gradient(circle at 18% 10%, rgba(35, 240, 191, 0.18), transparent 28rem),
    radial-gradient(circle at 84% 84%, rgba(255, 63, 127, 0.16), transparent 28rem),
    linear-gradient(145deg, #05070b 0%, #101726 48%, #1d1120 100%);
}

.game-shell:fullscreen .stage-wrap {
  min-height: 0;
  max-height: none;
  height: 100%;
}

.game-shell:fullscreen .overlay {
  /* 全画面では幕の中身だけ妙に詰まらないよう、縦の呼吸を取り直すのよ。 */
  gap: clamp(12px, 1.8vh, 20px);
  padding: clamp(22px, 3.8vh, 46px);
}

.game-shell:fullscreen .overlay.title-screen,
.game-shell:fullscreen .overlay.game-over {
  place-content: center;
}

.game-shell:fullscreen .overlay.title-screen {
  padding-top: clamp(36px, 5.6vh, 74px);
  padding-bottom: clamp(36px, 5.6vh, 74px);
}

.game-shell:fullscreen .overlay.title-screen .title-invader-mesh {
  top: 51%;
  transform: translate(-50%, -43%) scale(0.94);
}

.game-shell:fullscreen .overlay.title-screen h1 {
  font-size: clamp(3rem, 8.8vmin, 6.4rem);
}

.game-shell:fullscreen .overlay.game-over h1 {
  font-size: clamp(2.7rem, 7.8vmin, 5.8rem);
}

.game-shell:fullscreen .overlay.game-over p {
  max-width: min(86vw, 820px);
  font-size: clamp(1.35rem, 3.8vmin, 2.7rem);
}

.topbar {
  /* 上部ステータスは三分割。スコアと残機を広め、レベルは少し控えめにしてるのよ。 */
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(5.6rem, 0.72fr) minmax(0, 1.35fr);
  gap: 10px;
}

.topbar > div {
  /* ステータス枠の花柄。無駄に乙女だけど、数字の視認性は残すのよ。 */
  min-width: 0;
  position: relative;
  overflow: hidden;
  padding: 10px 13px 12px;
  border: 1px solid rgba(255, 229, 247, 0.54);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 8px 8px, rgba(255, 251, 246, 0.95) 0 2px, transparent 3px),
    radial-gradient(ellipse 4px 7px at 8px 1px, rgba(255, 184, 222, 0.82) 0 70%, transparent 72%),
    radial-gradient(ellipse 4px 7px at 8px 15px, rgba(255, 184, 222, 0.74) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at 1px 8px, rgba(255, 212, 235, 0.78) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at 15px 8px, rgba(190, 240, 255, 0.68) 0 70%, transparent 72%),
    radial-gradient(circle at 18px 18px, rgba(255, 236, 181, 0.68) 0 2px, transparent 3px),
    radial-gradient(circle at 4px 20px, rgba(187, 255, 224, 0.44) 0 3px, transparent 4px),
    radial-gradient(ellipse at calc(100% - 8px) 8px, rgba(255, 251, 246, 0.95) 0 2px, transparent 3px),
    radial-gradient(ellipse 4px 7px at calc(100% - 8px) 1px, rgba(255, 184, 222, 0.82) 0 70%, transparent 72%),
    radial-gradient(ellipse 4px 7px at calc(100% - 8px) 15px, rgba(255, 184, 222, 0.74) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at calc(100% - 1px) 8px, rgba(255, 212, 235, 0.78) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at calc(100% - 15px) 8px, rgba(190, 240, 255, 0.68) 0 70%, transparent 72%),
    radial-gradient(circle at calc(100% - 18px) 18px, rgba(255, 236, 181, 0.68) 0 2px, transparent 3px),
    radial-gradient(circle at calc(100% - 4px) 20px, rgba(187, 255, 224, 0.44) 0 3px, transparent 4px),
    radial-gradient(ellipse at 8px calc(100% - 8px), rgba(255, 251, 246, 0.9) 0 2px, transparent 3px),
    radial-gradient(ellipse 4px 7px at 8px calc(100% - 1px), rgba(255, 184, 222, 0.76) 0 70%, transparent 72%),
    radial-gradient(ellipse 4px 7px at 8px calc(100% - 15px), rgba(255, 184, 222, 0.66) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at 1px calc(100% - 8px), rgba(255, 236, 181, 0.62) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at 15px calc(100% - 8px), rgba(190, 240, 255, 0.58) 0 70%, transparent 72%),
    radial-gradient(circle at 19px calc(100% - 19px), rgba(187, 255, 224, 0.4) 0 3px, transparent 4px),
    radial-gradient(ellipse at calc(100% - 8px) calc(100% - 8px), rgba(255, 251, 246, 0.9) 0 2px, transparent 3px),
    radial-gradient(ellipse 4px 7px at calc(100% - 8px) calc(100% - 1px), rgba(255, 184, 222, 0.76) 0 70%, transparent 72%),
    radial-gradient(ellipse 4px 7px at calc(100% - 8px) calc(100% - 15px), rgba(255, 184, 222, 0.66) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at calc(100% - 1px) calc(100% - 8px), rgba(255, 236, 181, 0.62) 0 70%, transparent 72%),
    radial-gradient(ellipse 7px 4px at calc(100% - 15px) calc(100% - 8px), rgba(190, 240, 255, 0.58) 0 70%, transparent 72%),
    radial-gradient(circle at calc(100% - 19px) calc(100% - 19px), rgba(187, 255, 224, 0.4) 0 3px, transparent 4px),
    radial-gradient(circle at 18% 18%, rgba(255, 246, 252, 0.22), transparent 5.5rem),
    linear-gradient(145deg, rgba(86, 61, 92, 0.74), rgba(42, 34, 60, 0.66)),
    linear-gradient(90deg, rgba(255, 192, 224, 0.24), rgba(204, 231, 255, 0.15), rgba(255, 236, 181, 0.12));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 0 22px rgba(255, 196, 226, 0.14),
    inset 0 -2px 0 rgba(255, 236, 181, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.2);
}

.topbar > div::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: min(74%, 9rem);
  height: 5px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.74) 0 18%, transparent 19%),
    linear-gradient(90deg, transparent, rgba(255, 173, 214, 0.88), rgba(255, 236, 181, 0.76), rgba(183, 239, 255, 0.78), transparent);
  opacity: 0.9;
  transform: translateX(-50%);
}

.topbar > div::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 246, 253, 0.14), transparent),
    radial-gradient(circle at 88% 24%, rgba(255, 213, 236, 0.16), transparent 2.8rem);
  transform: translateX(-120%);
  animation: scan 4s linear infinite;
}

.label {
  display: block;
  margin-bottom: 4px;
  padding-inline: 4px;
  color: #ffe0f2;
  font-family: "Yu Gothic UI", var(--ui-font);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(255, 155, 207, 0.34),
    0 0 13px rgba(191, 239, 255, 0.18);
}

strong {
  position: relative;
  z-index: 1;
  display: inline-block;
  min-width: 3ch;
  padding-inline: 4px;
  font-family: var(--readout-font);
  font-size: clamp(1.15rem, 4vw, 1.85rem);
  font-weight: 900;
  line-height: 0.95;
  color: #fff8d9;
  font-variant-numeric: tabular-nums;
  text-shadow:
    1px 1px 0 #7a4864,
    -1px 0 0 rgba(196, 240, 255, 0.46),
    0 0 8px rgba(255, 238, 190, 0.78),
    0 0 20px rgba(255, 172, 217, 0.36);
}

#score,
#level {
  font-family: "Yu Mincho", "MS Mincho", "Yu Gothic", var(--ui-font);
  font-size: clamp(0.92rem, 3.1vw, 1.45rem);
  white-space: nowrap;
}

.life-icons {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 22px;
  padding-top: 1px;
}

.life-icon {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 20px;
  filter:
    drop-shadow(1px 1px 0 #7a4864)
    drop-shadow(0 0 5px rgba(255, 179, 221, 0.54));
}

.life-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 1px;
  width: 10px;
  height: 17px;
  border-radius: 50% 50% 44% 44%;
  background:
    radial-gradient(ellipse at 50% 35%, #101722 0 24%, transparent 26%),
    linear-gradient(180deg, #fff8ee 0 22%, #ffb6db 23% 68%, #bff3ff 69% 100%);
  transform: translateX(-50%);
}

.life-icon::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 3px;
  height: 8px;
  clip-path: polygon(50% 0, 100% 72%, 72% 100%, 55% 52%, 45% 52%, 28% 100%, 0 72%);
  background: #ffb6db;
  box-shadow: inset 0 -2px 0 rgba(255, 236, 181, 0.62);
}

.life-count {
  color: #fff7c9;
  font-family: var(--readout-font);
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    1px 1px 0 #704060,
    0 0 8px rgba(255, 230, 167, 0.76),
    0 0 16px rgba(168, 245, 232, 0.24);
}

.stage-wrap {
  /* ここが実際のゲーム画面。比率を固定して、ブラウザ差で盤面が暴れないようにするのよ。 */
  position: relative;
  width: 100%;
  aspect-ratio: 45 / 31;
  min-height: 320px;
  max-height: calc(100svh - 190px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  background: #05070b;
  box-shadow:
    0 0 0 1px rgba(35, 240, 191, 0.08),
    0 0 42px rgba(255, 63, 127, 0.16),
    0 18px 60px rgba(0, 0, 0, 0.4);
}

.stage-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 56%, rgba(0, 0, 0, 0.28));
  mix-blend-mode: screen;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  touch-action: none;
}

.overlay {
  /* タイトル、ロード、ゲームオーバーを重ねる幕。ゲーム画面とは別の芝居小屋なのよ。 */
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 22px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 63, 127, 0.2), transparent 16rem),
    rgba(5, 7, 11, 0.68);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.overlay.loading {
  cursor: wait;
}

.overlay.title-screen {
  /* タイトル画面だけは漫画背景と3D風ベーダー隊列を見せる特別仕様なのよ。 */
  perspective: 820px;
  place-content: start center;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 63, 127, 0.28), transparent 15rem),
    linear-gradient(180deg, rgba(5, 7, 11, 0.22) 0%, rgba(5, 7, 11, 0.32) 44%, rgba(5, 7, 11, 0.52) 100%),
    url("assets/title-manga-otome-lip-invaders.png") center / cover no-repeat;
  backdrop-filter: none;
  box-shadow: inset 0 0 120px rgba(5, 7, 11, 0.58);
  padding-top: clamp(32px, 6.8vw, 72px);
}

.overlay.title-screen > :not(.title-invader-mesh) {
  position: relative;
  z-index: 1;
}

.title-invader-mesh {
  /* タイトルのぐりんぐりん隊列。通常時は隠して、タイトル画面だけ出すのよ。 */
  display: none;
}

.overlay.title-screen .title-invader-mesh {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
  transform: translate(-50%, -45%);
}

.title-invader-mesh__piece {
  position: absolute;
  left: 50%;
  top: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: url("assets/okusan-invader.jpg") center / 100% 100% no-repeat;
  overflow: hidden;
  transform-origin: 50% 50%;
  will-change: transform;
}

.title-invader-mesh__piece--color {
  background-image: url("assets/color-okusan-invader.png");
}

.overlay.title-screen h1 {
  background:
    linear-gradient(180deg, #fffdf8 0%, #ffe4f3 26%, #ff8bc4 55%, #8eeaff 100%);
  background-clip: text;
  font-family: var(--pop-title-font);
  font-size: clamp(2.35rem, 8.4vw, 5rem);
  line-height: 0.98;
  text-shadow:
    2px 2px 0 rgba(83, 38, 104, 0.98),
    4px 4px 0 rgba(255, 104, 183, 0.62),
    -2px 0 0 rgba(118, 235, 255, 0.38),
    0 0 18px rgba(255, 139, 196, 0.94),
    0 0 38px rgba(142, 234, 255, 0.48);
  transform: rotate(-2deg);
}

.overlay.title-screen h1::after {
  -webkit-text-stroke: 1px rgba(255, 247, 253, 0.82);
}

.overlay.title-screen.coming-soon h1 {
  background:
    linear-gradient(180deg, #fffdf8 0%, #ffeaf7 30%, #f28fc8 62%, #b9f4ff 100%);
  background-clip: text;
  font-family: var(--pop-title-font);
  font-size: clamp(2.15rem, 7.4vw, 4.45rem);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    2px 2px 0 rgba(102, 46, 96, 0.86),
    4px 4px 0 rgba(255, 184, 218, 0.48),
    -2px 0 0 rgba(184, 244, 255, 0.42),
    0 0 20px rgba(255, 170, 213, 0.86),
    0 0 38px rgba(184, 244, 255, 0.42);
  transform: rotate(-1.4deg);
}

.overlay.title-screen.coming-soon h1::after {
  -webkit-text-stroke: 1px rgba(255, 249, 253, 0.86);
}

.overlay h1 {
  margin: 0;
  position: relative;
  color: transparent;
  background:
    linear-gradient(180deg, #fffdf5 0%, #ffd166 28%, #ff3f7f 58%, #62d5ff 100%);
  background-clip: text;
  font-family: var(--display-font);
  font-size: clamp(2.2rem, 9vw, 5.2rem);
  font-stretch: condensed;
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    2px 2px 0 rgba(7, 9, 15, 0.96),
    5px 5px 0 rgba(255, 63, 127, 0.52),
    -3px 0 0 rgba(98, 213, 255, 0.32),
    0 0 22px rgba(255, 63, 127, 0.86),
    0 0 46px rgba(98, 213, 255, 0.55);
  transform: skewX(-6deg);
}

.overlay h1::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 247, 237, 0.6);
  text-shadow: none;
  transform: translate(0, 0);
  pointer-events: none;
}

.overlay.game-over h1 {
  font-family: var(--pop-title-font);
  font-size: clamp(2rem, 7vw, 4.25rem);
  font-weight: 800;
  line-height: 1;
  transform: rotate(-0.6deg);
  text-shadow:
    1px 1px 0 rgba(83, 38, 104, 0.86),
    3px 3px 0 rgba(255, 104, 183, 0.42),
    -1px 0 0 rgba(118, 235, 255, 0.28),
    0 0 16px rgba(255, 139, 196, 0.76),
    0 0 30px rgba(142, 234, 255, 0.34);
}

.overlay.game-over h1::after {
  -webkit-text-stroke: 0.7px rgba(255, 247, 253, 0.66);
}

.version-badge {
  display: none;
  margin-top: -8px;
  color: #ffd166;
  font-family: var(--readout-font);
  font-size: clamp(0.78rem, 2vw, 0.96rem);
  font-weight: 800;
  letter-spacing: 0;
  text-shadow:
    0 0 10px rgba(255, 209, 102, 0.72),
    0 0 24px rgba(255, 63, 127, 0.38);
}

.overlay.title-screen .version-badge {
  display: inline-block;
  margin-top: clamp(22px, 4.5vw, 46px);
  color: #a72f68;
  font-family: var(--pop-title-font);
  font-size: clamp(0.86rem, 2.1vw, 1.05rem);
  text-shadow:
    1px 1px 0 rgba(255, 250, 253, 0.9),
    0 0 12px rgba(255, 184, 214, 0.62);
}

.develop-credit {
  display: none;
}

.overlay.title-screen .develop-credit {
  display: block;
  position: absolute;
  right: clamp(12px, 2.8vw, 24px);
  bottom: clamp(10px, 2.2vw, 18px);
  color: rgba(255, 247, 253, 0.86);
  font-family: var(--readout-font);
  font-size: clamp(0.58rem, 1.45vw, 0.78rem);
  font-weight: 800;
  line-height: 1;
  text-shadow:
    1px 1px 0 rgba(37, 17, 54, 0.88),
    0 0 8px rgba(255, 139, 196, 0.44);
}

.overlay p {
  margin: 0;
  color: #d9e7f1;
  font-family: var(--readout-font);
  font-size: clamp(0.78rem, 2.4vw, 0.98rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.55;
  text-shadow: 0 0 11px rgba(98, 213, 255, 0.44);
}

.overlay.title-screen p {
  color: #9c2b68;
  font-family: var(--pop-title-font);
  font-size: clamp(0.9rem, 2.5vw, 1.08rem);
  text-shadow:
    1px 1px 0 rgba(255, 250, 253, 0.88),
    0 0 12px rgba(255, 181, 216, 0.52);
}

.overlay.device-blocked p {
  color: #fff2b2;
  font-family: var(--pop-title-font);
  font-size: clamp(0.96rem, 3vw, 1.24rem);
  white-space: pre-line;
  text-align: center;
  text-shadow:
    1px 1px 0 rgba(94, 28, 70, 0.9),
    0 0 14px rgba(255, 139, 196, 0.64);
}

.safari-note {
  display: none;
}

.is-safari .overlay.title-screen .safari-note {
  display: inline-block;
  padding: 7px 14px 8px;
  border: 2px solid rgba(119, 76, 162, 0.68);
  border-radius: 8px;
  color: #6d3b91;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), transparent 48%),
    linear-gradient(145deg, rgba(244, 237, 255, 0.95), rgba(209, 187, 255, 0.9));
  font-family: var(--pop-title-font);
  font-size: clamp(0.82rem, 2.2vw, 1rem);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    1px 1px 0 rgba(255, 250, 253, 0.9),
    0 0 12px rgba(226, 204, 255, 0.66);
  box-shadow:
    inset 0 -3px 0 rgba(62, 31, 84, 0.24),
    0 0 20px rgba(201, 167, 255, 0.34);
  transform: rotate(1.2deg);
}

.overlay.game-over p {
  color: #fff2b2;
  font-family: var(--pop-title-font);
  font-size: clamp(1.08rem, 4.2vw, 2.35rem);
  font-weight: 800;
  line-height: 1.08;
  white-space: pre-line;
  text-shadow:
    1px 1px 0 #5f1b2f,
    -1px 0 0 rgba(98, 213, 255, 0.44),
    0 0 12px rgba(255, 209, 102, 0.84),
    0 0 24px rgba(255, 63, 127, 0.34);
}

.overlay.game-over #startButton {
  font-family: var(--pop-title-font);
}

.fullscreen-toggle {
  display: none;
}

.fullscreen-help {
  display: none;
}

button {
  border: 0;
  border-radius: 8px;
  color: #07110f;
  background: var(--accent-2);
  font-family: var(--display-font);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.35);
}

button:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 22px rgba(35, 240, 191, 0.32);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

#startButton {
  min-width: 156px;
  padding: 13px 22px;
  color: #08100e;
  font-size: 1.15rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 35%),
    linear-gradient(145deg, #ffd166 0%, #23f0bf 52%, #62d5ff 100%);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 0 24px rgba(35, 240, 191, 0.28);
}

.overlay.title-screen #startButton {
  color: #7f2359;
  font-family: var(--pop-title-font);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), transparent 42%),
    linear-gradient(145deg, #fff2b2 0%, #ff9bd0 48%, #8eeaff 100%);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.62);
  box-shadow:
    inset 0 -3px 0 rgba(66, 16, 55, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 0 22px rgba(255, 139, 196, 0.42);
}

.overlay.title-screen .fullscreen-toggle {
  /* タイトル専用の全画面ボタン。STARTとは別物に見えるよう、少し水色へ振るのよ。 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 156px;
  margin-top: -4px;
  padding: 10px 18px 11px;
  color: #23456a;
  border: 1px solid rgba(130, 218, 255, 0.62);
  font-family: var(--pop-title-font);
  font-size: 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), transparent 46%),
    linear-gradient(145deg, #e9fbff 0%, #b6edff 52%, #ffc8e7 100%);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 -2px 0 rgba(39, 83, 115, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 18px rgba(142, 234, 255, 0.34);
}

.overlay.title-screen .fullscreen-toggle[hidden] {
  display: none;
}

.game-shell:fullscreen .overlay.title-screen .fullscreen-help {
  /* 全画面に入った後だけ、逃げ道をそっと出しておくの。親切は小さくでいいのよ。 */
  display: inline-block;
  margin-top: -8px;
  padding: 4px 12px 5px;
  color: #fff5fb;
  border: 1px solid rgba(255, 196, 226, 0.5);
  border-radius: 999px;
  background: rgba(86, 33, 72, 0.46);
  font-family: var(--pop-title-font);
  font-size: clamp(0.72rem, 1.4vw, 0.9rem);
  text-shadow:
    1px 1px 0 rgba(70, 20, 56, 0.82),
    0 0 10px rgba(255, 155, 207, 0.42);
}

.overlay.title-screen.coming-soon #startButton {
  color: #8f245f;
  cursor: default;
  filter: saturate(0.82);
  opacity: 0.88;
}

.controls {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  padding: 10px 12px 12px;
  border: 1px solid rgba(255, 229, 247, 0.54);
  border-radius: 16px;
  background:
    radial-gradient(circle at 13px 13px, rgba(255, 249, 226, 0.74) 0 2px, rgba(91, 39, 67, 0.56) 2.5px 4px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 13px) 13px, rgba(255, 249, 226, 0.74) 0 2px, rgba(91, 39, 67, 0.56) 2.5px 4px, transparent 4.5px),
    radial-gradient(circle at 13px calc(100% - 13px), rgba(255, 249, 226, 0.74) 0 2px, rgba(91, 39, 67, 0.56) 2.5px 4px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 13px) calc(100% - 13px), rgba(255, 249, 226, 0.74) 0 2px, rgba(91, 39, 67, 0.56) 2.5px 4px, transparent 4.5px),
    linear-gradient(90deg, rgba(255, 192, 224, 0.24), rgba(204, 231, 255, 0.15), rgba(255, 236, 181, 0.12)),
    repeating-linear-gradient(135deg, rgba(255, 230, 243, 0.035) 0 1px, transparent 1px 9px),
    linear-gradient(145deg, rgba(86, 61, 92, 0.74), rgba(42, 34, 60, 0.66)),
    repeating-linear-gradient(90deg, rgba(255, 236, 247, 0.045) 0 1px, transparent 1px 7px);
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 247, 0.34),
    inset 0 0 22px rgba(255, 196, 226, 0.14),
    inset 0 -2px 0 rgba(255, 236, 181, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.2);
  touch-action: none;
}

.controls::before {
  content: "乙女Control™︎  ·  OKUSAN SYSTEM";
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 1;
  color: rgba(255, 228, 242, 0.68);
  font: 700 0.56rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.controls::after {
  content: "✿  ·  ◆  ·  ✿  ·  ◆  ·  ✿";
  position: absolute;
  right: 13px;
  bottom: 7px;
  z-index: 1;
  color: rgba(255, 192, 220, 0.38);
  font: 700 0.6rem/1 ui-rounded, "Hiragino Maru Gothic ProN", sans-serif;
  letter-spacing: 0.18em;
  text-shadow: 0 0 8px rgba(255, 116, 176, 0.22);
  pointer-events: none;
}

.controls [data-touch-controls] {
  display: none;
}

.controls[data-touch-control-scheme="puni"] [data-touch-controls="puni"],
.controls[data-touch-control-scheme="buttons"] [data-touch-controls="buttons"] {
  display: grid;
}

.controls[data-touch-control-scheme="puni"] {
  /* 盤面の下に残る余白も、ぷにコンを出せる操作エリアにする。 */
  min-height: clamp(10.5rem, 30svh, 16rem);
}

.puni-controls {
  position: relative;
  z-index: 0;
  min-height: inherit;
  grid-template-columns: minmax(0, 1.4fr) minmax(7.6rem, 0.8fr);
  align-items: center;
  gap: 16px;
}

.puni-controls::after {
  content: "◈  P1  ◈";
  position: absolute;
  top: 8px;
  right: 14px;
  color: rgba(133, 255, 230, 0.48);
  font: 700 0.55rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.16em;
  pointer-events: none;
}

.puni-stick {
  --puni-knob-x: 0px;
  --puni-knob-y: 0px;
  position: relative;
  width: min(11rem, 42vw);
  aspect-ratio: 1;
  justify-self: center;
  touch-action: none;
}

.puni-controls .puni-stick {
  position: absolute;
  left: 25%;
  top: 50%;
  width: min(6.6rem, 27vw);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.puni-stick__knob {
  position: absolute;
  inset: 50%;
  border-radius: 50%;
}

.puni-stick__knob {
  width: 68%;
  height: 68%;
  transform: translate(calc(-50% + var(--puni-knob-x)), calc(-50% + var(--puni-knob-y))) scale(1);
  border: 2px solid rgba(255, 235, 246, 0.72);
  background: radial-gradient(circle at 36% 30%, #fff8fc, #ffb9d6 38%, #5cded1 72%, #168980 100%);
  box-shadow: 0 0 20px rgba(255, 105, 170, 0.28), 0 0 14px rgba(35, 240, 191, 0.28), inset 0 -5px 9px rgba(2, 65, 70, 0.44);
  transition: transform 110ms cubic-bezier(0.18, 0.9, 0.28, 1.24), filter 120ms ease;
}

.puni-stick.is-active .puni-stick__knob {
  filter: brightness(1.18);
  transform: translate(calc(-50% + var(--puni-knob-x)), calc(-50% + var(--puni-knob-y))) scale(1.08, 0.92);
}

.puni-shot {
  --puni-shot-size: clamp(8.3rem, 32vw, 11.8rem);
  grid-column: 2;
  inline-size: var(--puni-shot-size);
  block-size: var(--puni-shot-size);
  min-height: 0;
  justify-self: center;
  border-radius: 50%;
  border: 3px double rgba(255, 246, 214, 0.86);
  color: #2b0710;
  font-size: clamp(1.15rem, 5.8vw, 1.7rem);
  letter-spacing: 0.08em;
  background: radial-gradient(circle at 35% 28%, #fff4b2, #ff7598 40%, #b52e60 100%);
  box-shadow: 0 0 24px rgba(255, 63, 127, 0.44), inset 0 -8px 12px rgba(102, 13, 47, 0.36), inset 0 0 0 5px rgba(255, 238, 246, 0.16);
}

.puni-shot.shot-hold {
  color: #06130f;
  background: radial-gradient(circle at 35% 28%, #f5fff9, #7dffd9 42%, #27bfb4 100%);
  box-shadow: 0 0 30px rgba(35, 240, 191, 0.7), inset 0 -8px 12px rgba(1, 83, 79, 0.38);
}

.button-controls {
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 10px;
}

.device-blocked .controls {
  display: none;
}

.controls button {
  min-height: 56px;
  color: var(--ink);
  font-size: 1.18rem;
  background: linear-gradient(145deg, #202637, #161b28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-shadow:
    1px 1px 0 #05070b,
    0 0 12px rgba(98, 213, 255, 0.42);
}

.controls [data-action="shoot"] {
  color: #170408;
  background: linear-gradient(145deg, #ff6e91, var(--accent));
}

.controls [data-action="shoot"].shot-hold {
  color: #04110e;
  background: linear-gradient(145deg, #7dffd9, var(--accent-2));
  box-shadow: 0 0 22px rgba(35, 240, 191, 0.34);
}

@keyframes scan {
  0% {
    transform: translateX(-120%);
  }

  45%,
  100% {
    transform: translateX(120%);
  }
}

@media (hover: hover) and (pointer: fine) {
  .controls {
    display: none;
  }

  .touch-controls-preview .controls {
    display: block;
  }

  .game-shell {
    min-height: 100vh;
  }
}

@media (hover: none) and (pointer: coarse) {
  .overlay.title-screen #startButton,
  #fullscreenButton,
  .fullscreen-help {
    display: none !important;
  }
}

@media (max-width: 560px) {
  .game-shell {
    padding: 10px;
    gap: 10px;
    align-content: start;
  }

  .topbar {
    grid-template-columns: minmax(0, 1.25fr) minmax(4.8rem, 0.7fr) minmax(0, 1.35fr);
    gap: 7px;
  }

  .topbar > div {
    padding: 8px;
  }

  .stage-wrap {
    min-height: 0;
    aspect-ratio: 45 / 31;
    max-height: calc(100svh - 150px);
  }

  .controls button {
    min-height: 64px;
  }

  .is-safari .overlay.title-screen .safari-note {
    position: absolute;
    left: 50%;
    top: 54%;
    z-index: 4;
    padding: 9px 16px 10px;
    font-size: clamp(1rem, 5.1vw, 1.34rem);
    white-space: nowrap;
    transform: translate(-50%, -50%) rotate(1.2deg);
  }

}
