:root {
  color-scheme: dark;
  --ink: #f6f7ff;
  --muted: #9ea8cf;
  --panel: rgba(11, 14, 35, 0.88);
  --panel-light: rgba(25, 31, 70, 0.72);
  --line: rgba(154, 169, 255, 0.18);
  --blue: #087dff;
  --cyan: #27dcff;
  --violet: #754dff;
  --purple: #aa58ff;
  --pink: #ff3b9d;
  --danger: #ff315a;
  --good: #44f4bb;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #050711;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(45, 74, 255, 0.2), transparent 26rem),
    radial-gradient(circle at 90% 86%, rgba(142, 49, 255, 0.14), transparent 24rem),
    #050711;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.game-shell {
  width: min(1420px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px clamp(14px, 2vw, 30px) 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  border: 1px solid rgba(88, 189, 255, 0.65);
  border-radius: 14px;
  color: white;
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
  background: linear-gradient(145deg, #086ef8, #633af0 62%, #ac42ff);
  box-shadow: 0 0 28px rgba(42, 125, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand-kicker {
  color: #7fdfff;
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.21em;
}

.brand h1 {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.5rem, 3.2vw, 2.35rem);
  letter-spacing: 0.045em;
  line-height: 1;
}

.brand h1 span {
  color: #8da0cc;
  font-size: 0.69em;
  font-weight: 700;
}

.sound-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 13px 8px 9px;
  border: 1px solid rgba(123, 158, 255, 0.25);
  border-radius: 999px;
  color: #dfe6ff;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: rgba(18, 23, 52, 0.78);
  cursor: pointer;
  transition: 180ms ease;
}

.sound-button:hover,
.sound-button:focus-visible {
  border-color: rgba(80, 189, 255, 0.7);
  transform: translateY(-1px);
  outline: none;
}

.sound-icon {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  color: #061127;
  font-size: 1rem;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(39, 220, 255, 0.45);
}

.sound-button[aria-pressed="false"] .sound-icon {
  color: #8790b4;
  background: #282d49;
  box-shadow: none;
}

.hud {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.hud-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 16px;
  border: 1px solid rgba(129, 150, 243, 0.16);
  background: linear-gradient(135deg, rgba(19, 24, 57, 0.94), rgba(10, 13, 33, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.hud-card:first-child {
  border-radius: 14px 5px 5px 14px;
}

.hud-card:last-child {
  border-radius: 5px 14px 14px 5px;
}

.hud-label {
  color: #7180ad;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.hud-card strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  letter-spacing: 0.04em;
  line-height: 1;
}

.score-card strong {
  color: #6fe9ff;
  text-shadow: 0 0 18px rgba(39, 220, 255, 0.35);
}

.combo-card strong {
  color: #c18aff;
}

.hud-card small {
  margin-left: 2px;
  color: #7580a6;
  font-size: 0.6em;
}

.arena {
  --danger-progress: 0;
  position: relative;
  min-height: clamp(560px, calc(100vh - 180px), 760px);
  overflow: hidden;
  border: 1px solid rgba(113, 150, 255, 0.3);
  border-radius: 22px;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(10, 12, 34, 0.32), rgba(5, 7, 20, 0.94)),
    radial-gradient(circle at 50% 40%, rgba(34, 76, 195, 0.22), transparent 42%),
    #080b1b;
  box-shadow: var(--shadow), inset 0 0 80px rgba(31, 86, 217, 0.08);
}

.arena::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background-image:
    linear-gradient(rgba(79, 116, 210, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 116, 210, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, black 30%, black);
  perspective: 500px;
}

.arena::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: -42%;
  height: 68%;
  background:
    linear-gradient(rgba(45, 104, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 104, 255, 0.16) 1px, transparent 1px);
  background-size: 54px 34px;
  transform: perspective(460px) rotateX(64deg) scale(1.3);
  transform-origin: center top;
  box-shadow: inset 0 40px 80px rgba(0, 94, 255, 0.08);
}

.market-canvas,
.scanlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.market-canvas {
  z-index: -1;
  opacity: 0.72;
}

.scanlines {
  z-index: 15;
  opacity: 0.1;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255, 255, 255, 0.055) 4px);
  mix-blend-mode: overlay;
}

.arena-flare {
  position: absolute;
  z-index: -1;
  width: 390px;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.16;
}

.flare-one {
  left: -130px;
  bottom: -150px;
  background: #0c78ff;
}

.flare-two {
  right: -170px;
  top: 90px;
  background: #b313ff;
}

.wave-indicator {
  position: absolute;
  top: 20px;
  left: 22px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-left: 3px solid var(--cyan);
  color: #8190be;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  background: linear-gradient(90deg, rgba(19, 42, 88, 0.7), transparent);
}

.wave-indicator strong {
  color: white;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.player-zone,
.enemy-zone {
  position: absolute;
  z-index: 3;
  bottom: 26px;
}

.player-zone {
  left: clamp(18px, 4vw, 66px);
  width: clamp(235px, 32vw, 410px);
  height: min(67%, 560px);
}

.fang-sprite {
  position: absolute;
  z-index: 2;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  filter: drop-shadow(0 22px 17px rgba(0, 0, 0, 0.42)) drop-shadow(0 0 22px rgba(41, 133, 255, 0.28));
  animation: heroFloat 2.8s ease-in-out infinite;
  transform-origin: center bottom;
}

.player-zone.attacking .fang-sprite {
  animation: heroAttack 210ms ease-out;
}

.player-zone.hit .fang-sprite {
  animation: heroHit 360ms ease;
  filter: drop-shadow(0 0 28px rgba(255, 42, 101, 0.8));
}

.player-aura,
.enemy-aura {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 74%;
  aspect-ratio: 1;
  border: 2px solid rgba(39, 203, 255, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 134, 255, 0.2), transparent 63%);
  box-shadow: 0 0 45px rgba(28, 131, 255, 0.24), inset 0 0 34px rgba(47, 150, 255, 0.14);
  transform: translate(-50%, 18%) rotateX(72deg);
}

.player-aura::before,
.enemy-aura::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px dashed rgba(97, 211, 255, 0.52);
  border-radius: 50%;
  animation: spin 9s linear infinite;
}

.shield-readout {
  position: absolute;
  z-index: 4;
  top: 16%;
  left: 1%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shield-unit {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(89, 148, 255, 0.3);
  border-radius: 8px;
  color: #48506c;
  font-weight: 950;
  background: rgba(8, 11, 28, 0.8);
  transition: 240ms ease;
}

.shield-unit.active {
  color: white;
  border-color: rgba(65, 205, 255, 0.82);
  background: linear-gradient(145deg, #0877ef, #582ae2);
  box-shadow: 0 0 14px rgba(31, 153, 255, 0.45);
}

.nameplate {
  position: absolute;
  z-index: 5;
  bottom: 4px;
  left: 50%;
  min-width: 128px;
  padding: 8px 16px;
  border: 1px solid rgba(98, 186, 255, 0.48);
  border-radius: 6px;
  color: white;
  font-weight: 950;
  text-align: center;
  letter-spacing: 0.07em;
  background: linear-gradient(90deg, rgba(4, 29, 83, 0.95), rgba(24, 20, 84, 0.95));
  transform: translateX(-50%) skewX(-10deg);
  box-shadow: 0 0 18px rgba(23, 121, 255, 0.24);
}

.nameplate span {
  margin-right: 7px;
  color: #75dfff;
  font-size: 0.64rem;
}

.enemy-zone {
  --enemy-color: #ff467e;
  --enemy-rgb: 255, 51, 108;
  right: clamp(26px, 7vw, 110px);
  width: clamp(190px, 25vw, 330px);
  height: min(57%, 440px);
  transform: translateX(calc(var(--danger-progress) * -58px));
  transition: transform 140ms linear;
}

.enemy-zone.enemy-dragon {
  --enemy-color: #ffab48;
  --enemy-rgb: 255, 159, 49;
}

.enemy-zone.enemy-golem {
  --enemy-color: #97f46d;
  --enemy-rgb: 130, 241, 100;
}

.enemy-zone.entering {
  animation: enemyEnter 420ms cubic-bezier(0.2, 0.8, 0.25, 1);
}

.enemy-zone.damaged .enemy-sprite {
  animation: enemyDamage 170ms ease-out;
}

.enemy-zone.defeated .enemy-sprite {
  animation: enemyDefeat 470ms ease-in forwards;
}

.enemy-header {
  position: absolute;
  z-index: 5;
  top: -20px;
  left: 50%;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  width: min(310px, 92vw);
  padding: 9px 12px 8px;
  border-left: 3px solid var(--enemy-color);
  background: linear-gradient(90deg, rgba(var(--enemy-rgb), 0.15), rgba(16, 8, 27, 0.85));
  transform: translateX(-50%);
}

.enemy-header div {
  display: grid;
}

.enemy-class {
  color: var(--enemy-color);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.enemy-header strong {
  font-size: 0.98rem;
}

.danger-label {
  color: #ffadb8;
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.enemy-hp-track {
  position: absolute;
  z-index: 5;
  top: 37px;
  left: 50%;
  width: 84%;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(var(--enemy-rgb), 0.32);
  background: rgba(29, 5, 14, 0.8);
  transform: translateX(-50%) skewX(-12deg);
}

.enemy-hp {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ffd575, var(--enemy-color));
  box-shadow: 0 0 12px rgba(var(--enemy-rgb), 0.7);
  transform-origin: left center;
  transition: width 100ms ease;
}

.enemy-sprite {
  position: absolute;
  z-index: 2;
  top: 48px;
  left: 50%;
  width: 94%;
  height: calc(100% - 48px);
  object-fit: contain;
  user-select: none;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.46)) drop-shadow(0 0 25px rgba(var(--enemy-rgb), 0.34));
  transform: translateX(-50%);
  transform-origin: center;
  animation: enemyHover 2.2s ease-in-out infinite;
}

.enemy-aura {
  z-index: 0;
  bottom: 10%;
  width: 84%;
  border-color: rgba(var(--enemy-rgb), 0.27);
  background: radial-gradient(circle, rgba(var(--enemy-rgb), 0.18), transparent 63%);
  box-shadow: 0 0 45px rgba(var(--enemy-rgb), 0.22), inset 0 0 34px rgba(var(--enemy-rgb), 0.13);
}

.enemy-aura::before {
  border-color: rgba(var(--enemy-rgb), 0.44);
  animation-direction: reverse;
}

.prompt-card {
  position: absolute;
  z-index: 8;
  top: clamp(84px, 17%, 132px);
  left: 50%;
  width: min(630px, 54vw);
  padding: 16px clamp(18px, 2vw, 27px) 14px;
  border: 1px solid rgba(118, 166, 255, 0.38);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(27, 35, 78, 0.92), rgba(8, 12, 31, 0.94)),
    rgba(8, 12, 31, 0.94);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.prompt-card::before,
.prompt-card::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 13px;
  border-top: 2px solid var(--cyan);
}

.prompt-card::before {
  top: -1px;
  left: 14px;
  border-left: 2px solid var(--cyan);
}

.prompt-card::after {
  right: 14px;
  bottom: -1px;
  border-right: 2px solid var(--purple);
  border-top: 0;
  border-bottom: 2px solid var(--purple);
}

.prompt-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.topic-chip {
  padding: 4px 9px;
  border: 1px solid rgba(89, 214, 255, 0.42);
  border-radius: 999px;
  color: #8be8ff;
  font-size: 0.72rem;
  font-weight: 900;
  background: rgba(0, 128, 255, 0.11);
}

.prompt-number {
  color: #68759f;
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.prompt-number b {
  color: #b8c4ee;
}

.japanese-prompt {
  margin: 0;
  color: white;
  font-size: clamp(1.12rem, 2.3vw, 1.62rem);
  font-weight: 850;
  line-height: 1.5;
  text-align: center;
  letter-spacing: 0.035em;
}

.roman-prompt {
  min-height: 2.4rem;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  color: #9ba6cc;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.97rem, 2vw, 1.28rem);
  font-weight: 750;
  line-height: 1.55;
  text-align: center;
  white-space: pre-wrap;
}

.roman-prompt .typed {
  color: #52e9ff;
  text-shadow: 0 0 12px rgba(54, 228, 255, 0.55);
}

.roman-prompt .cursor-char {
  display: inline-block;
  min-width: 0.65em;
  color: #071025;
  background: #79eaff;
  box-shadow: 0 0 14px rgba(60, 229, 255, 0.45);
  animation: cursorBlink 720ms steps(1) infinite;
}

.roman-prompt .remaining {
  color: #9aa4ca;
}

.typing-hint {
  margin: 7px 0 0;
  color: #59668e;
  font-size: 0.67rem;
  font-weight: 700;
  text-align: center;
}

kbd {
  padding: 2px 5px;
  border: 1px solid rgba(142, 157, 202, 0.28);
  border-radius: 4px;
  color: #9aa8d4;
  font: inherit;
  font-size: 0.93em;
  background: rgba(255, 255, 255, 0.045);
}

.typing-capture {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
}

.battle-effects {
  position: absolute;
  z-index: 7;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.laser {
  position: absolute;
  left: 27%;
  top: 58%;
  width: 0;
  height: 4px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 0 8px white, 0 0 18px var(--cyan), 0 0 35px var(--blue);
  transform: rotate(-6deg);
  transform-origin: left center;
  animation: laserShot 240ms ease-out forwards;
}

.laser.big {
  height: 9px;
  box-shadow: 0 0 12px white, 0 0 28px var(--cyan), 0 0 55px var(--violet);
  animation-duration: 380ms;
}

.hit-spark {
  position: absolute;
  top: 48%;
  right: 20%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 18px 6px var(--pink);
  animation: sparkPop 320ms ease-out forwards;
}

.particle {
  position: absolute;
  top: 53%;
  right: 23%;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--particle-color, #ff3b9d);
  box-shadow: 0 0 12px var(--particle-color, #ff3b9d);
  animation: particleBurst 560ms ease-out forwards;
}

.combo-pop {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 43%;
  color: white;
  font-family: Impact, sans-serif;
  font-size: clamp(1.4rem, 4vw, 2.7rem);
  font-style: italic;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px var(--cyan), 4px 4px 0 rgba(74, 49, 223, 0.7);
  transform: translate(-50%, -50%);
  animation: comboPop 560ms ease-out forwards;
}

.overlay-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  align-items: center;
  gap: clamp(18px, 4vw, 72px);
  padding: clamp(28px, 5vw, 74px);
  background:
    linear-gradient(90deg, rgba(5, 8, 23, 0.98) 0%, rgba(5, 8, 23, 0.92) 48%, rgba(5, 8, 23, 0.35) 100%),
    radial-gradient(circle at 75% 45%, rgba(60, 82, 232, 0.26), transparent 34%);
  backdrop-filter: blur(6px);
}

.overlay-screen.hidden {
  display: none;
}

.intro-copy {
  position: relative;
  z-index: 2;
  max-width: 650px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
  color: #71e1ff;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.eyebrow span {
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 10px var(--cyan);
}

.intro-copy h2 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 4.85rem);
  font-weight: 950;
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.intro-copy h2 em {
  color: transparent;
  font-style: normal;
  background: linear-gradient(90deg, #55e9ff, #8a78ff 54%, #e855ff);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(81, 133, 255, 0.34));
}

.intro-text {
  max-width: 520px;
  margin: 16px 0 20px;
  color: #adb8df;
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  font-weight: 650;
  line-height: 1.7;
}

.game-rules {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  max-width: 510px;
  margin: 0 0 18px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid rgba(49, 203, 255, 0.5);
  border-radius: 8px;
  color: #b2bce0;
  font-size: 0.85rem;
  background: linear-gradient(135deg, rgba(10, 110, 231, 0.28), rgba(94, 48, 214, 0.32));
}

.game-rules strong {
  color: white;
  font-weight: 850;
}

.game-rules span {
  font-size: 0.75rem;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: 180ms ease;
}

.primary-button {
  gap: 32px;
  min-width: 250px;
  min-height: 58px;
  padding: 12px 16px 12px 26px;
  border: 1px solid rgba(90, 218, 255, 0.72);
  border-radius: 10px;
  color: white;
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  background: linear-gradient(115deg, #087cf8, #5140dd 65%, #8539f2);
  box-shadow: 0 10px 30px rgba(37, 84, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.primary-button b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #0b2a59;
  background: #8cecff;
  box-shadow: 0 0 14px rgba(133, 235, 255, 0.64);
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(37, 84, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.36);
  outline: none;
}

.primary-button:active {
  transform: translateY(0) scale(0.985);
}

.how-to {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 22px;
  color: #717da6;
  font-size: 0.72rem;
  font-weight: 700;
}

.how-to span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.how-to b {
  color: #5ddcff;
  font-family: monospace;
}

.intro-character {
  position: relative;
  align-self: stretch;
  min-height: 430px;
}

.intro-character img {
  position: absolute;
  z-index: 2;
  right: 4%;
  bottom: -13%;
  width: min(100%, 430px);
  height: 114%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 28px 28px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 25px rgba(46, 123, 255, 0.28));
  animation: heroFloat 2.8s ease-in-out infinite;
}

.intro-ring {
  position: absolute;
  right: 3%;
  bottom: 2%;
  width: min(90%, 420px);
  aspect-ratio: 1;
  border: 1px solid rgba(84, 158, 255, 0.2);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 32px, rgba(74, 122, 255, 0.11) 33px 34px),
    radial-gradient(circle, rgba(53, 79, 230, 0.22), transparent 65%);
  box-shadow: 0 0 70px rgba(64, 74, 255, 0.15);
  animation: pulseRing 2.6s ease-in-out infinite;
}

.speech-bubble {
  position: absolute;
  z-index: 4;
  top: 18%;
  right: 3%;
  padding: 10px 15px;
  border: 1px solid rgba(130, 226, 255, 0.62);
  border-radius: 14px 14px 4px 14px;
  color: #092045;
  font-size: 0.86rem;
  font-weight: 900;
  background: #a7f0ff;
  box-shadow: 0 0 22px rgba(77, 214, 255, 0.25);
  transform: rotate(3deg);
}

.result-screen {
  grid-template-columns: minmax(430px, 1fr) minmax(220px, 0.55fr);
  background:
    linear-gradient(90deg, rgba(5, 8, 23, 0.98), rgba(7, 10, 27, 0.84)),
    radial-gradient(circle at 70% 30%, rgba(99, 61, 236, 0.24), transparent 40%);
}

.result-panel {
  position: relative;
  z-index: 4;
  max-width: 650px;
}

.result-kicker {
  margin: 0 0 7px;
  color: #76e3ff;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.2em;
}

.rank-lockup {
  position: absolute;
  top: -15px;
  right: 0;
  display: grid;
  place-items: center;
  width: 118px;
  aspect-ratio: 1;
  border: 1px solid rgba(118, 231, 255, 0.38);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(17, 64, 139, 0.76), rgba(91, 35, 170, 0.76));
  box-shadow: 0 0 36px rgba(51, 114, 255, 0.24), inset 0 0 24px rgba(76, 230, 255, 0.12);
  transform: rotate(5deg);
}

.rank-lockup span {
  align-self: end;
  color: #80e8ff;
  font-size: 0.61rem;
  font-weight: 950;
  letter-spacing: 0.18em;
}

.rank-lockup strong {
  align-self: start;
  color: white;
  font-family: Impact, sans-serif;
  font-size: 4.2rem;
  line-height: 0.95;
  text-shadow: 0 0 18px rgba(89, 225, 255, 0.65);
}

.result-panel h2 {
  margin: 0;
  font-size: clamp(3rem, 7vw, 6rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.06em;
}

.result-panel h2 small {
  color: #7784ac;
  font-size: 0.2em;
  letter-spacing: 0.02em;
}

.result-message {
  margin: 12px 0 22px;
  color: #b7c2e7;
  font-weight: 700;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 0 0 24px;
}

.result-stats div {
  padding: 12px;
  border: 1px solid rgba(126, 151, 232, 0.16);
  border-radius: 9px;
  background: rgba(22, 28, 60, 0.68);
}

.result-stats dt {
  margin-bottom: 5px;
  color: #7783aa;
  font-size: 0.68rem;
  font-weight: 800;
}

.result-stats dd {
  margin: 0;
  color: white;
  font-size: 1.24rem;
  font-weight: 950;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.best-readout { margin: 12px 0 8px; color: #73e5ff; font-size: 1rem; font-weight: 800; }
.best-readout.new-record { color: #ffdf82; }
.record-note { max-width: 520px; margin: 8px 0 14px; color: #a4b0d3; font-size: 0.8rem; line-height: 1.65; }
.share-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.secondary-button:disabled { opacity: .6; cursor: wait; }
.result-screen { overflow-y: auto; }

.result-actions .primary-button {
  min-width: 205px;
  min-height: 52px;
}

.secondary-button {
  min-width: 145px;
  min-height: 52px;
  padding: 10px 18px;
  border: 1px solid rgba(135, 157, 229, 0.3);
  border-radius: 10px;
  color: #bdc8e9;
  font-size: 0.82rem;
  font-weight: 850;
  background: rgba(24, 29, 57, 0.78);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: rgba(93, 215, 255, 0.55);
  color: white;
  outline: none;
}

.result-fang {
  align-self: end;
  justify-self: center;
  width: min(100%, 370px);
  max-height: 93%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 22px 24px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 22px rgba(49, 137, 255, 0.28));
  animation: resultBounce 1.8s ease-in-out infinite;
}

.result-burst {
  position: absolute;
  z-index: 0;
  right: 1%;
  bottom: -34%;
  width: 720px;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.5;
  background: repeating-conic-gradient(from 0deg, rgba(39, 220, 255, 0.12) 0 4deg, transparent 4deg 14deg);
  mask-image: radial-gradient(circle, transparent 0 24%, black 25% 67%, transparent 68%);
  animation: spin 18s linear infinite;
}

.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  bottom: 22px;
  padding: 11px 18px;
  border: 1px solid rgba(90, 231, 255, 0.45);
  border-radius: 999px;
  color: #06213d;
  font-size: 0.82rem;
  font-weight: 900;
  background: #9deeff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: 220ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 40px;
  padding: 0 4px;
  color: #4f5b7f;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.game-footer p {
  margin: 0;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
}

.arena.miss-flash {
  animation: arenaShake 220ms ease-out;
}

.arena.miss-flash::before {
  background-color: rgba(255, 19, 78, 0.09);
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.006); }
}

@keyframes heroAttack {
  0% { transform: translateX(0) rotate(0); }
  45% { transform: translateX(13px) rotate(1deg) scale(1.025); }
  100% { transform: translateX(0) rotate(0); }
}

@keyframes heroHit {
  0%, 100% { transform: translateX(0); opacity: 1; }
  25% { transform: translateX(-10px); opacity: 0.55; }
  50% { transform: translateX(8px); opacity: 0.85; }
  75% { transform: translateX(-4px); opacity: 0.65; }
}

@keyframes enemyHover {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); }
  50% { transform: translateX(-50%) translateY(-10px) rotate(1deg); }
}

@keyframes enemyEnter {
  from { opacity: 0; transform: translateX(130px) scale(0.66); }
  to { opacity: 1; transform: translateX(calc(var(--danger-progress) * -58px)) scale(1); }
}

@keyframes enemyDamage {
  0%, 100% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-55%) scale(0.96); filter: brightness(2.2) saturate(0); }
}

@keyframes enemyDefeat {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  35% { transform: translateX(-50%) scale(1.14) rotate(-4deg); filter: brightness(2.4); }
  100% { transform: translateX(-50%) scale(0.12) rotate(22deg); opacity: 0; }
}

@keyframes cursorBlink {
  0%, 54% { opacity: 1; }
  55%, 100% { opacity: 0.42; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseRing {
  0%, 100% { transform: scale(0.98); opacity: 0.72; }
  50% { transform: scale(1.035); opacity: 1; }
}

@keyframes laserShot {
  0% { width: 0; opacity: 0; }
  24% { opacity: 1; }
  68% { width: 53%; opacity: 1; }
  100% { width: 58%; opacity: 0; }
}

@keyframes sparkPop {
  0% { transform: scale(0); opacity: 0; }
  35% { transform: scale(2.1); opacity: 1; }
  100% { transform: scale(5.2); opacity: 0; }
}

@keyframes particleBurst {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(270deg) scale(0); opacity: 0; }
}

@keyframes comboPop {
  0% { transform: translate(-50%, -40%) scale(0.5); opacity: 0; }
  30% { transform: translate(-50%, -55%) scale(1.12); opacity: 1; }
  100% { transform: translate(-50%, -105%) scale(0.96); opacity: 0; }
}

@keyframes arenaShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  55% { transform: translateX(4px); }
  78% { transform: translateX(-2px); }
}

@keyframes resultBounce {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

@media (max-width: 900px) {
  .game-shell { padding-inline: 10px; }
  .arena { min-height: 690px; }
  .prompt-card { top: 82px; width: min(640px, calc(100% - 28px)); }
  .player-zone { width: clamp(180px, 43vw, 280px); height: 47%; left: 8px; }
  .enemy-zone { width: clamp(165px, 39vw, 250px); height: 39%; right: 8px; }
  .enemy-header { width: min(265px, 44vw); }
  .overlay-screen { padding: 34px; }
  .intro-character { opacity: 0.66; }
  .intro-copy { z-index: 5; }
  .result-screen { grid-template-columns: minmax(0, 1fr) 220px; }
  .result-fang { opacity: 0.56; }
}

@media (max-width: 680px) {
  .game-shell { padding-top: 10px; }
  .topbar { min-height: 50px; margin-bottom: 7px; }
  .brand-mark { width: 38px; border-radius: 11px; font-size: 1.55rem; }
  .brand-kicker { display: none; }
  .brand h1 { font-size: 1.33rem; }
  .brand h1 span { display: block; margin-top: 2px; font-size: 0.55em; }
  .sound-button { min-height: 38px; padding-right: 9px; }
  #soundLabel { display: none; }
  .hud { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .hud-card { display: grid; min-height: 54px; padding: 8px 7px; text-align: center; }
  .hud-card:first-child { border-radius: 10px 4px 4px 10px; }
  .hud-card:last-child { border-radius: 4px 10px 10px 4px; }
  .hud-label { font-size: 0.54rem; }
  .hud-card strong { font-size: 1.02rem; }
  .arena { min-height: 650px; border-radius: 15px; }
  .wave-indicator { top: 12px; left: 12px; }
  .prompt-card { top: 60px; padding: 13px 13px 11px; }
  .japanese-prompt { font-size: 1.05rem; }
  .roman-prompt { font-size: 0.92rem; }
  .player-zone { bottom: 12px; width: 48vw; height: 42%; }
  .enemy-zone { bottom: 40px; width: 42vw; height: 34%; right: -4px; }
  .enemy-header { top: -42px; width: 43vw; padding: 7px 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px 5px; }
  .enemy-header div { display: contents; }
  .enemy-header strong { grid-column: 1 / -1; grid-row: 2; font-size: 0.78rem; }
  .enemy-class { grid-column: 1; grid-row: 1; letter-spacing: 0.07em; }
  .danger-label { grid-column: 2; grid-row: 1; }
  .enemy-class, .danger-label { font-size: 0.49rem; }
  .enemy-hp-track { top: 27px; }
  .enemy-sprite { top: 38px; height: calc(100% - 38px); }
  .shield-readout { top: 23%; }
  .shield-unit { width: 23px; height: 23px; }
  .nameplate { min-width: 100px; padding: 6px 10px; font-size: 0.72rem; }
  .overlay-screen { grid-template-columns: 1fr; align-items: start; padding: 33px 20px; overflow-y: auto; }
  .intro-copy { max-width: none; }
  .intro-copy h2 { font-size: clamp(2.25rem, 11vw, 3.45rem); }
  .intro-text { font-size: 0.88rem; }
  .primary-button { width: 100%; min-width: 0; }
  .how-to { gap: 8px 15px; }
  .intro-character { position: absolute; inset: 0; min-height: 0; pointer-events: none; opacity: 0.18; }
  .intro-character img { right: -20%; bottom: -9%; width: 78%; height: 78%; }
  .speech-bubble { display: none; }
  .result-screen { display: flex; align-items: flex-start; padding-top: 70px; }
  .result-screen.hidden { display: none; }
  .result-panel { width: 100%; }
  .rank-lockup { width: 82px; top: -30px; }
  .rank-lockup strong { font-size: 2.8rem; }
  .result-panel h2 { font-size: clamp(2.7rem, 15vw, 4.5rem); }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-fang { position: absolute; right: -11%; bottom: -8%; z-index: -1; width: 58%; opacity: 0.16; }
  .result-actions { width: 100%; }
  .secondary-button { width: 100%; }
  .game-footer { justify-content: center; min-height: 32px; }
  .game-footer p:not(:nth-child(2)) { display: none; }
  .game-footer p { font-size: 0.6rem; }
}

@media (max-height: 740px) and (min-width: 681px) {
  .arena { min-height: 560px; }
  .overlay-screen { padding-block: 25px; }
  .intro-character { min-height: 360px; }
  .intro-copy h2 { font-size: clamp(2.2rem, 4.4vw, 3.8rem); }
  .how-to { margin-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Phone layout: reserve separate space for the prompt and the battle. */
@media (max-width: 680px), (max-height: 500px) and (pointer: coarse) {
  .game-shell {
    min-height: 100svh;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .topbar { min-height: 44px; }
  .sound-button { min-width: 44px; min-height: 44px; }
  .hud { position: sticky; top: 0; z-index: 30; gap: 4px; padding-block: 4px; background: #080c20; }
  .hud-card { min-width: 0; min-height: 58px; padding: 7px 3px; }
  .hud-label { font-size: .75rem; letter-spacing: 0; }
  .hud-card strong { font-size: 1.125rem; }
  .arena { min-height: max(540px, calc(var(--visible-height, 100svh) - 145px)); border-radius: 15px; }
  .arena.is-playing { min-height: max(380px, calc(var(--visible-height, 100svh) - 145px)); padding: 42px 10px 195px; }
  .wave-indicator { top: 12px; left: 12px; font-size: .75rem; }
  .prompt-card { position: relative; top: auto; left: auto; transform: none; width: 100%; margin: 0; padding: 12px; }
  .prompt-topline { gap: 8px; flex-wrap: wrap; }
  .topic-chip, .prompt-number { font-size: .75rem; }
  .japanese-prompt { font-size: 1.125rem; line-height: 1.55; overflow-wrap: anywhere; }
  .roman-prompt { font-size: 1.0625rem; line-height: 1.6; min-height: 0; }
  .typing-hint { color: #a0add1; font-size: .75rem; line-height: 1.5; }
  .player-zone { left: 4px; bottom: 8px; width: 45%; height: 172px; }
  .enemy-zone { right: 4px; bottom: 20px; width: 44%; height: 118px; }
  .enemy-header { top: -43px; width: 100%; padding: 5px; }
  .enemy-header strong { font-size: .875rem; }
  .enemy-class, .danger-label { font-size: .75rem; letter-spacing: 0; }
  .enemy-hp-track { top: 12px; }
  .enemy-sprite { top: 23px; height: calc(100% - 23px); }
  .shield-readout { top: 15%; }
  .nameplate { font-size: .75rem; }
  .typing-capture { top: 44px; bottom: auto; font-size: 16px; }
  .overlay-screen { padding: 24px 18px; }
  .intro-copy h2 { font-size: clamp(2rem, 9vw, 3rem); }
  .intro-text { font-size: 1rem; }
  .eyebrow, .game-rules, .how-to, .record-note { font-size: .75rem; line-height: 1.6; }
  .best-readout { font-size: .875rem; }
  .result-screen { display: flex; padding: 52px 16px 24px; }
  .result-screen.hidden { display: none; }
  .result-panel { min-width: 0; width: 100%; }
  .result-message { font-size: 1rem; }
  .result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-stats dt { font-size: .875rem; }
  .result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .result-actions .primary-button { grid-column: 1 / -1; }
  .result-actions button, .result-actions a { min-width: 0; min-height: 48px; width: 100%; padding: 12px 8px; font-size: .875rem; }
  .game-footer p { font-size: .75rem; }
}
