:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #abc5db;
  --night: #07152f;
  --night-2: #0d2550;
  --cyan: #58ecff;
  --blue: #2678ff;
  --yellow: #ffe05c;
  --pink: #ff4f91;
  --orange: #ff8a3d;
  --lime: #83f28f;
  --line: rgba(88, 236, 255, .34);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #030a19; }
body {
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", Meiryo, sans-serif;
  font-weight: 750;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, a { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.game-shell {
  position: relative;
  width: min(100%, 600px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background-color: var(--night);
  background-image:
    linear-gradient(rgba(88,236,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88,236,255,.035) 1px, transparent 1px);
  background-size: 24px 24px;
  border-inline: 1px solid rgba(255,255,255,.1);
  isolation: isolate;
}
.game-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #030a19;
}
.topbar {
  position: relative;
  z-index: 2100;
  min-height: 52px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) 9px 6px;
  background: rgba(4, 13, 35, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.mini-brand { min-width: 0; text-align: center; }
.mini-brand span { display: block; color: var(--cyan); font: 900 9px Consolas, monospace; }
.mini-brand strong { display: block; margin-top: 1px; font-size: 16px; line-height: 1.1; }
.top-actions { display: flex; gap: 5px; }
.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: #122b58;
  border: 1px solid #3773a8;
  border-radius: 5px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 950;
}
.icon-button:active { transform: translateY(1px); }

.screen { display: none; min-height: calc(100dvh - 52px); }
.screen.is-active { display: block; }
.title-screen { position: relative; overflow: hidden; }
.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(45,127,255,.36), transparent 34%),
    radial-gradient(circle at 15% 20%, rgba(255,79,145,.18), transparent 25%),
    radial-gradient(circle at 82% 76%, rgba(88,236,255,.16), transparent 28%);
  pointer-events: none;
}
.title-grid {
  position: absolute;
  left: 50%;
  top: 12%;
  width: min(92%, 520px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
  transform: translateX(-50%) perspective(600px) rotateX(8deg);
}
.title-grid i {
  aspect-ratio: 1.85;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 4px;
  background: #2878ff;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 7px 0 #0e3b88, 0 11px 15px rgba(0,0,0,.28);
}
.title-grid i:nth-child(4n+1) { background: #ff4f91; box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 7px 0 #98244e, 0 11px 15px rgba(0,0,0,.28); }
.title-grid i:nth-child(4n+2) { background: #58dced; box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 7px 0 #15708d, 0 11px 15px rgba(0,0,0,.28); }
.title-grid i:nth-child(4n+3) { background: #ffb23e; box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 7px 0 #9a5b13, 0 11px 15px rgba(0,0,0,.28); }
.title-burst {
  position: absolute;
  left: 50%;
  top: 35%;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%);
}
.title-burst::before, .title-burst::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 3px solid rgba(88,236,255,.45);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(88,236,255,.28);
}
.title-burst::after { inset: 28%; border-color: rgba(255,224,92,.65); }
.title-burst b {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 130px;
  background: linear-gradient(transparent, rgba(255,255,255,.7), transparent);
  transform-origin: center;
}
.title-burst b:nth-child(2) { transform: translate(-50%,-50%) rotate(60deg); }
.title-burst b:nth-child(3) { transform: translate(-50%,-50%) rotate(120deg); }
.title-burst span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 9px rgba(88,236,255,.25), 0 0 32px #fff;
  transform: translate(-50%,-50%);
  animation: titleBall 1.8s ease-in-out infinite;
}
@keyframes titleBall { 50% { transform: translate(-50%,-58%) scale(1.12); } }

.title-copy {
  position: relative;
  z-index: 2;
  min-height: calc(100dvh - 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(280px, 49vh, 430px) 22px max(30px, env(safe-area-inset-bottom));
  text-align: center;
}
.overline { margin: 0; color: var(--cyan); font: 900 10px Consolas, monospace; }
.title-copy h1 {
  margin: 7px 0 0;
  font-family: "Arial Black", "Yu Gothic UI", sans-serif;
  font-size: clamp(35px, 10.4vw, 57px);
  line-height: .98;
  text-shadow: 0 4px 0 #102b62, 0 0 22px rgba(88,236,255,.24);
}
.title-copy h1 span { display: block; color: var(--yellow); font-size: .74em; }
.title-lead { max-width: 480px; margin: 13px auto 15px; color: #d6e7f7; font-size: 13px; line-height: 1.7; }
.title-features {
  width: min(100%, 400px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 13px;
  border-block: 1px solid var(--line);
}
.title-features span { padding: 7px 4px; color: #b7cce1; font: 800 9px Consolas, monospace; border-right: 1px solid rgba(255,255,255,.1); }
.title-features span:last-child { border: 0; }
.title-features b { color: var(--yellow); font-size: 18px; }
.best-record { width: min(100%, 330px); display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; color: var(--muted); font: 900 10px Consolas, monospace; }
.best-record strong { color: #fff; font-size: 22px; }
.primary-command {
  width: min(100%, 350px);
  min-height: 62px;
  color: #09162c;
  background: linear-gradient(#ffe985, #ffc43e);
  border: 2px solid #fff4b6;
  border-radius: 5px;
  box-shadow: 0 6px 0 #9e5d12, 0 10px 25px rgba(0,0,0,.32);
  font-weight: 950;
}
.primary-command span { display: block; font-size: 20px; }
.primary-command small { display: block; margin-top: 2px; font: 900 9px Consolas, monospace; }
.primary-command:active { transform: translateY(4px); box-shadow: 0 2px 0 #9e5d12; }
.guide-link { margin-top: 15px; color: #d7edff; font-size: 12px; font-weight: 900; text-underline-offset: 4px; }

.play-screen.is-active { display: flex; flex-direction: column; min-height: calc(100dvh - 52px); background: #07152f; }
.hud {
  min-height: 68px;
  display: grid;
  grid-template-columns: .8fr 1.3fr 1fr .8fr;
  background: #07142d;
  border-bottom: 1px solid var(--line);
}
.hud > div { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 6px 8px; border-right: 1px solid rgba(255,255,255,.1); }
.hud > div:last-child { border: 0; }
.hud span { color: #9fc2dc; font: 900 9px Consolas, monospace; }
.hud strong { margin-top: 2px; overflow: hidden; color: #fff; font: 950 clamp(18px, 4.8vw, 25px) "Arial Black", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 3px 0 #102b62; }
.score-box strong { color: var(--cyan); }
.combo-box strong { color: var(--yellow); }
.combo-box strong small { margin-left: 4px; color: #fff; font-size: 11px; }
#lifeValue { color: #ff668f; letter-spacing: 1px; }
.rush-meter { height: 6px; background: #030a19; }
.rush-meter i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--yellow), var(--pink)); box-shadow: 0 0 14px var(--cyan); transition: width .08s linear; }

.stage-wrap {
  position: relative;
  width: 100%;
  flex: 1 0 auto;
  aspect-ratio: 720 / 1000;
  min-height: 0;
  overflow: hidden;
  background: #06132d;
}
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#gameCanvas canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.boss-hud {
  position: absolute;
  z-index: 170;
  left: 50%;
  top: 14px;
  width: min(92%, 510px);
  padding: 8px 10px 10px;
  color: #fff;
  background: rgba(24, 4, 42, .94);
  border: 2px solid #ff5ab8;
  box-shadow: 0 0 0 2px rgba(255,255,255,.72), 0 0 24px rgba(255,47,139,.55);
  transform: translateX(-50%);
  pointer-events: none;
}
.boss-hud[hidden] { display: none; }
.boss-hud > div { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 1px 10px; }
.boss-hud span { grid-column: 1 / 3; color: #ffb8dc; font: 900 8px Consolas, monospace; }
.boss-hud strong { min-width: 0; overflow: hidden; font: 950 15px "Arial Black", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.boss-hud div > b { color: #ffe05c; font: 900 11px Consolas, monospace; }
.boss-hud > i { display: block; height: 9px; margin-top: 6px; overflow: hidden; background: #12051e; border: 1px solid rgba(255,255,255,.58); }
.boss-hud > i > b { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #ff2f8b, #ff8a3d, #ffe05c); box-shadow: 0 0 12px #ff4f91; transition: width .12s linear; }
.effect-toast {
  position: absolute;
  z-index: 180;
  left: 50%;
  top: 20%;
  min-width: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  color: #fff;
  background: rgba(6,19,45,.92);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 18px rgba(88,236,255,.45);
  transform: translateX(-50%);
  pointer-events: none;
  animation: effectPop .18s ease-out;
}
.effect-toast[hidden] { display: none; }
.effect-toast span { color: var(--yellow); font: 950 10px Consolas, monospace; }
.effect-toast strong { font: 950 13px "Arial Black", sans-serif; }
.effect-toast[data-type="yellow"] { border-color: #ffe05c; box-shadow: 0 0 18px rgba(255,224,92,.48); }
.effect-toast[data-type="pink"] { border-color: #ff4f91; box-shadow: 0 0 18px rgba(255,79,145,.5); }
.effect-toast[data-type="green"] { border-color: #83f28f; box-shadow: 0 0 18px rgba(131,242,143,.48); }
.effect-toast[data-type="purple"] { border-color: #b36cff; box-shadow: 0 0 18px rgba(179,108,255,.5); }
.effect-toast[data-type="split"] { border-color: #ff8a62; box-shadow: 0 0 18px rgba(255,104,79,.52); }
.effect-toast[data-type="obstacle"] { border-color: #aab8cb; box-shadow: 0 0 18px rgba(170,184,203,.38); }
@keyframes effectPop { from { opacity: 0; transform: translateX(-50%) scale(.78); } }
.round-banner {
  position: absolute;
  z-index: 200;
  left: 50%;
  top: 46%;
  width: min(78%, 390px);
  padding: 12px 18px;
  color: #fff;
  background: rgba(6, 19, 45, .92);
  border: 3px solid var(--cyan);
  box-shadow: 0 0 0 5px rgba(255,255,255,.85), 0 16px 42px rgba(0,0,0,.45);
  text-align: center;
  transform: translate(-50%,-50%);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.round-banner[hidden] { display: block; opacity: 0; transform: translate(-50%,-45%) scale(.88); }
.round-banner small { display: block; color: var(--yellow); font: 900 9px Consolas, monospace; }
.round-banner strong { display: block; margin: 3px 0; font: 950 29px "Arial Black", sans-serif; }
.round-banner span { color: #c8dcee; font-size: 11px; }
.control-strip {
  min-height: 47px;
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  align-items: center;
  gap: 5px;
  padding: 6px 9px max(7px, env(safe-area-inset-bottom));
  color: #86a8c4;
  background: #050e22;
  border-top: 1px solid var(--line);
  font-size: 9px;
  text-align: center;
}
.control-strip strong { color: #fff; font-size: 11px; }
kbd { padding: 1px 4px; color: #07152f; background: #dcecff; border-radius: 3px; font: 900 9px Consolas, monospace; }

.choice-backdrop, .pause-backdrop {
  position: fixed;
  z-index: 5000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(2, 8, 24, .9);
  backdrop-filter: blur(8px);
}
.choice-backdrop[hidden], .pause-backdrop[hidden] { display: none; }
.choice-modal, .pause-modal {
  width: min(100%, 560px);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  padding: 24px 18px;
  color: #10213d;
  background: #f3f8ff;
  border: 4px solid var(--cyan);
  box-shadow: 0 0 0 6px #142d65, 0 24px 70px rgba(0,0,0,.58);
}
.choice-modal > .overline, .pause-modal > .overline { color: #1b61aa; text-align: center; }
.choice-modal h2, .pause-modal h2 { margin: 5px 0 3px; color: #0d2951; font-size: 28px; line-height: 1.2; text-align: center; }
.choice-progress { margin: 0 0 14px; color: #54708e; font-size: 12px; text-align: center; }
.choice-grid { display: grid; gap: 9px; }
.choice-card {
  position: relative;
  width: 100%;
  min-height: 104px;
  display: grid;
  grid-template-columns: 38px 62px 1fr;
  grid-template-rows: auto 1fr;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 12px;
  color: #10213d;
  background: #fff;
  border: 2px solid #a9cbe4;
  border-radius: 5px;
  box-shadow: 0 5px 0 #6b8ca5;
  text-align: left;
}
.choice-card:hover { border-color: #287dce; transform: translateY(-1px); }
.choice-card:active { transform: translateY(4px); box-shadow: 0 1px 0 #6b8ca5; }
.choice-card em {
  grid-row: 1 / 3;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  align-self: start;
  color: #fff;
  background: #173f7d;
  border-radius: 3px;
  font: normal 950 15px Consolas, monospace;
}
.choice-icon {
  grid-row: 1 / 3;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #2375dd;
  border: 3px solid #0c315f;
  border-radius: 8px;
  box-shadow: inset 0 5px 0 rgba(255,255,255,.25);
  font-size: 28px;
}
.choice-card strong { align-self: end; color: #0d2951; font-size: 17px; line-height: 1.25; }
.choice-card span:last-child { align-self: start; color: #486580; font-size: 12px; line-height: 1.45; }
.reroll-button {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  color: #fff;
  background: #173f7d;
  border: 2px solid #0b2850;
  border-radius: 4px;
  font-weight: 900;
}
.reroll-button:disabled { opacity: .45; cursor: default; }
.key-hint { margin: 10px 0 0; color: #69839b; font-size: 10px; text-align: center; }
.pause-modal { max-width: 400px; text-align: center; }
.pause-modal .primary-command { margin-top: 14px; }
.secondary-command {
  width: min(100%, 350px);
  min-height: 48px;
  margin-top: 11px;
  color: #173457;
  background: #e8f0f8;
  border: 1px solid #a8bed3;
  border-radius: 4px;
  font-weight: 900;
}

.result-screen { position: relative; overflow: hidden; }
.result-screen.is-active { display: grid; place-items: center; }
.result-burst { position: absolute; inset: 0; background: radial-gradient(circle at 50% 28%, rgba(88,236,255,.25), transparent 38%); }
.result-burst span { position: absolute; left: 50%; top: 27%; width: 120px; height: 120px; border: 15px solid rgba(255,224,92,.18); border-radius: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 30px rgba(88,236,255,.08), 0 0 0 60px rgba(255,79,145,.05); }
.result-copy { position: relative; z-index: 1; width: 100%; padding: 28px 20px max(28px, env(safe-area-inset-bottom)); text-align: center; }
.result-copy h2 { margin: 4px 0 18px; color: var(--yellow); font: 950 clamp(33px, 9vw, 50px)/1.1 "Arial Black", sans-serif; }
.final-score {
  width: min(100%, 390px);
  margin: 0 auto 15px;
  padding: 13px;
  display: block;
  color: #0c1f42;
  background: #fff;
  border: 4px solid var(--cyan);
  box-shadow: 0 7px 0 #176095;
}
.final-score span { display: block; color: #31719b; font: 900 10px Consolas, monospace; }
.final-score strong { display: block; font: 950 clamp(38px, 12vw, 58px) Consolas, monospace; }
.final-score em { display: none; width: max-content; margin: 3px auto 0; padding: 3px 8px; color: #fff; background: var(--pink); font: normal 900 10px Consolas, monospace; }
.final-score em.is-visible { display: block; }
.result-grid {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 auto 18px;
  border: 1px solid var(--line);
}
.result-grid div { min-height: 64px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-grid div:nth-child(even) { border-right: 0; }
.result-grid div:nth-child(n+3) { border-bottom: 0; }
.result-grid span { color: #86a8c4; font-size: 10px; }
.result-grid strong { margin-top: 3px; font: 900 18px Consolas, monospace; }
.result-copy .secondary-command { display: block; margin-inline: auto; }

@media (min-width: 720px) {
  body { padding-block: 14px; }
  .game-shell { min-height: calc(100dvh - 28px); border: 1px solid rgba(88,236,255,.24); box-shadow: 0 20px 80px rgba(0,0,0,.5); }
  .screen { min-height: calc(100dvh - 80px); }
  .play-screen.is-active { min-height: calc(100dvh - 80px); }
}
@media (max-width: 420px) {
  .title-copy { padding-inline: 16px; }
  .title-lead { font-size: 12px; }
  .hud > div { padding-inline: 5px; }
  .control-strip { padding-inline: 5px; }
  .choice-modal { padding: 18px 11px; }
  .choice-card { min-height: 94px; grid-template-columns: 31px 52px 1fr; padding: 8px; gap: 2px 7px; }
  .choice-icon { width: 49px; height: 49px; font-size: 24px; }
  .choice-card strong { font-size: 15px; }
  .choice-card span:last-child { font-size: 11px; }
}
@media (max-height: 760px) {
  .title-copy { padding-top: 245px; padding-bottom: 18px; }
  .title-grid { top: 7%; }
  .title-burst { top: 31%; transform: translate(-50%,-50%) scale(.82); }
  .title-lead { margin-block: 8px; line-height: 1.45; }
  .title-features { margin-bottom: 8px; }
  .best-record { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
