:root {
  --black: #05050a;
  --panel: rgba(8, 8, 14, 0.82);
  --red: #f0303d;
  --red-dark: #8f111d;
  --white: #fff8ef;
  --muted: #d6c8c8;
  --gold: #ffd966;
  --cyan: #76f7ff;
  --line: rgba(255, 255, 255, 0.18);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--black);
  color: var(--white);
  font-family: "Arial Black", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  letter-spacing: 0;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 16% 22%, rgba(240, 48, 61, 0.34), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(255, 217, 102, 0.16), transparent 24%),
    linear-gradient(180deg, #171724 0%, #05050a 100%);
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  height: clamp(560px, calc(100svh - 16px), 860px);
  overflow: hidden;
  border: 4px solid #1f1f2b;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    #07070d;
  background-size: 18px 18px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), 0 0 34px rgba(240, 48, 61, 0.3);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100%;
  padding: 24px;
}

.screen.is-active {
  display: flex;
}

.screen-title,
.screen-result {
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 248, 239, 0.16), transparent 24%),
    linear-gradient(120deg, rgba(240, 48, 61, 0.24), transparent 40%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), #08080f 74%);
}

.screen-title::before,
.screen-result::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 2px solid var(--line);
  pointer-events: none;
}

.brand {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 3px;
  text-shadow: 2px 2px 0 #000;
}

h1,
h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--white);
  font-size: clamp(44px, 14vw, 68px);
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 5px 5px 0 #000, 8px 8px 0 var(--red-dark);
}

h2 {
  font-size: clamp(42px, 13vw, 64px);
}

.lead,
.howto {
  position: relative;
  z-index: 1;
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.8;
}

.howto {
  color: #fff;
  font-size: 12px;
}

.primary-button,
.ghost-button,
.control-button {
  border-radius: 0;
  cursor: pointer;
  text-transform: uppercase;
}

.primary-button,
.ghost-button {
  position: relative;
  z-index: 1;
  min-width: 168px;
  min-height: 52px;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 5px 5px 0 #000;
}

.primary-button {
  background: linear-gradient(180deg, #ff4b57, #c91423);
}

.ghost-button {
  margin-top: -6px;
  background: #111;
  border-color: var(--line);
}

.title-high {
  position: relative;
  z-index: 1;
  min-width: 180px;
  padding: 10px 12px;
  border: 3px solid #fff;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 4px 4px 0 #000;
}

.title-high span,
.result-grid span {
  display: block;
  color: var(--gold);
  font-size: 10px;
}

.title-high strong,
.result-grid strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.screen-game {
  padding: 0;
  background: #050509;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #08080d;
}

.hud {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 10px;
  right: 10px;
  pointer-events: none;
}

.hud-row {
  display: grid;
  grid-template-columns: 1.35fr 0.78fr 0.78fr;
  gap: 6px;
}

.hud-box {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 9px 10px 8px;
  border: 1px solid rgba(118, 247, 255, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 45, 127, 0.28), transparent 28%),
    linear-gradient(225deg, rgba(118, 247, 255, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(8, 16, 34, 0.92), rgba(3, 3, 12, 0.88));
  box-shadow:
    0 0 18px rgba(118, 247, 255, 0.26),
    0 0 16px rgba(255, 45, 127, 0.18),
    inset 0 0 18px rgba(118, 247, 255, 0.12),
    3px 3px 0 #000;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 13px, 100% 100%, 13px 100%, 0 calc(100% - 13px));
}

.hud-box::before,
.hud-box::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.hud-box::before {
  inset: 3px;
  border: 1px solid rgba(255, 248, 239, 0.22);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.hud-box::after {
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 3px;
  background: linear-gradient(90deg, var(--red), #ff4ed0, var(--cyan));
  box-shadow: 0 0 12px rgba(118, 247, 255, 0.8);
}

.hud-box.is-bouncing {
  animation: hudBounce 180ms steps(2, end);
}

.hud-box span,
.meter span,
.control-button small,
.skill-status small {
  display: block;
  color: var(--gold);
  font-size: 8px;
  line-height: 1.1;
  letter-spacing: 0.7px;
}

.hud-box strong {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  color: var(--cyan);
  font-size: clamp(16px, 4.8vw, 24px);
  line-height: 1;
  text-overflow: ellipsis;
  text-shadow: 0 0 10px rgba(118, 247, 255, 0.72), 2px 2px 0 #000;
}

.meter {
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(118, 247, 255, 0.8);
  background:
    linear-gradient(90deg, rgba(118, 247, 255, 0.22), rgba(255, 45, 127, 0.16), rgba(255, 217, 102, 0.08)),
    rgba(0, 0, 0, 0.74);
  box-shadow: 0 0 18px rgba(118, 247, 255, 0.26), inset 0 0 18px rgba(255, 45, 127, 0.12), 3px 3px 0 #000;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 10px 50%);
}

.meter div {
  height: 10px;
  margin-top: 4px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 6px, transparent 6px 12px),
    #101321;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.72);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), #ff4ed0, var(--cyan));
  box-shadow: 0 0 18px rgba(255, 45, 127, 0.8);
}

.meter.small {
  margin-top: 6px;
  padding: 6px;
}

.meter.small div {
  height: 8px;
}

.controls {
  position: absolute;
  z-index: 6;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.control-button {
  min-height: 62px;
  border: 4px solid #fff;
  color: #fff;
  background: #101017;
  box-shadow: 5px 5px 0 #000;
}

.skill-status {
  position: relative;
  overflow: hidden;
  align-self: end;
  min-height: 54px;
  padding: 10px 12px;
  border: 2px solid rgba(118, 247, 255, 0.58);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(118, 247, 255, 0.16), rgba(255, 45, 127, 0.1)),
    rgba(0, 0, 0, 0.56);
  box-shadow: 0 0 12px rgba(118, 247, 255, 0.18), 4px 4px 0 #000;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.skill-status::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 5px;
  width: var(--skill-progress, 100%);
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  box-shadow: 0 0 16px rgba(118, 247, 255, 0.75);
  transition: width 120ms linear;
}

.auto-skill {
  cursor: default;
  user-select: none;
}

.skill-status.is-ready {
  border-color: rgba(118, 247, 255, 0.9);
  box-shadow: 0 0 18px rgba(118, 247, 255, 0.58), 4px 4px 0 #000;
}

.skill-status.is-pending {
  animation: autoSkillPending 420ms steps(2, end) infinite;
}

.skill-status.is-fired {
  animation: autoSkillFire 180ms steps(2, end);
}

.skill-status small {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  color: var(--cyan);
}

.skill-status span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--white);
  font-size: 10px;
  line-height: 1;
}

.control-button:disabled {
  opacity: 0.44;
  filter: grayscale(1);
}

.ult-button.is-active:disabled,
.ult-button.is-ready:disabled {
  opacity: 1;
  filter: none;
}

.ult-button {
  --ult-fill: 0%;
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  min-height: 116px;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid rgba(255, 248, 239, 0.86);
  background:
    conic-gradient(from -40deg, rgba(255,45,127,0.78), rgba(118,247,255,0.82), rgba(255,217,102,0.7), rgba(255,45,127,0.78)),
    radial-gradient(circle at 50% 48%, rgba(5,5,10,0.96) 0 54%, transparent 55%),
    #05050a;
  box-shadow:
    0 0 26px rgba(255, 45, 127, 0.46),
    0 0 18px rgba(118, 247, 255, 0.24),
    inset 0 0 24px rgba(0, 0, 0, 0.95),
    5px 5px 0 #000;
}

.ult-button::before,
.ult-button::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.ult-button::before {
  inset: 7px;
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,0.26), transparent 14%),
    radial-gradient(circle at 52% 58%, rgba(118,247,255,0.16), transparent 36%),
    rgba(3, 5, 14, 0.92);
  border: 2px solid rgba(118, 247, 255, 0.42);
  box-shadow: inset 0 0 20px rgba(255, 45, 127, 0.18), inset 0 0 34px rgba(0,0,0,0.92);
}

.ult-button::after {
  inset: 0;
  background:
    radial-gradient(circle at 20% 78%, rgba(255,217,102,0.64) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 28%, rgba(118,247,255,0.72) 0 2px, transparent 3px),
    radial-gradient(circle at 74% 76%, rgba(255,78,208,0.6) 0 2px, transparent 3px);
  opacity: 0.66;
}

.ult-button.is-ready {
  color: #fff;
  border-color: var(--cyan);
  box-shadow:
    0 0 34px rgba(118, 247, 255, 0.95),
    0 0 28px rgba(255, 45, 127, 0.86),
    inset 0 0 20px rgba(255, 217, 102, 0.3),
    5px 5px 0 #000;
  animation: ultPulse 920ms steps(2, end) infinite;
}

.ult-button.is-active {
  border-color: var(--gold);
  box-shadow:
    0 0 38px rgba(255, 217, 102, 0.94),
    0 0 28px rgba(118, 247, 255, 0.76),
    inset 0 0 28px rgba(255, 217, 102, 0.2),
    5px 5px 0 #000;
}

.ult-liquid {
  position: absolute;
  z-index: 1;
  left: 13px;
  right: 13px;
  bottom: 13px;
  height: var(--ult-fill, 0%);
  max-height: calc(100% - 26px);
  border-radius: 0 0 999px 999px;
  background:
    radial-gradient(circle at 32% 14%, rgba(255, 255, 255, 0.55), transparent 16%),
    repeating-radial-gradient(circle at 54% 34%, rgba(255,255,255,0.2) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, rgba(255, 217, 102, 0.9), rgba(255, 45, 127, 0.94) 42%, rgba(118, 247, 255, 0.92));
  box-shadow: 0 0 24px rgba(255, 45, 127, 0.8), inset 0 0 18px rgba(255,255,255,0.18);
  transition: height 120ms linear;
}

.ult-liquid::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  top: -8px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(90deg, rgba(118,247,255,0.4), rgba(255,248,239,0.72), rgba(255,78,208,0.42));
  box-shadow: 0 0 16px rgba(255, 248, 239, 0.58);
  animation: ultWave 1.45s ease-in-out infinite;
}

.ult-shine {
  position: absolute;
  z-index: 2;
  inset: 11px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.22), transparent 28%),
    linear-gradient(315deg, rgba(118,247,255,0.16), transparent 34%);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.18), 0 0 10px rgba(118,247,255,0.28);
}

.ult-button strong,
.ult-button small {
  position: relative;
  z-index: 3;
  display: block;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
}

.ult-button strong {
  font-size: 24px;
  line-height: 1;
}

.ult-button small {
  max-width: 72px;
  margin-top: 4px;
  color: #fff;
  font-size: 7px;
  line-height: 1.1;
}

.center-callout {
  position: absolute;
  z-index: 7;
  top: 42%;
  left: 50%;
  width: min(86%, 340px);
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: clamp(28px, 10vw, 44px);
  line-height: 0.95;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #000, 0 0 18px rgba(240, 48, 61, 0.9);
  pointer-events: none;
  opacity: 0;
}

.center-callout.is-visible {
  animation: callout 850ms steps(2, end);
}

.choice-status {
  position: absolute;
  z-index: 6;
  top: 18%;
  right: 8px;
  max-width: 108px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 217, 102, 0.82);
  background:
    linear-gradient(135deg, rgba(255,45,127,0.22), transparent 38%),
    linear-gradient(225deg, rgba(118,247,255,0.18), transparent 42%),
    rgba(0, 0, 0, 0.68);
  box-shadow: 0 0 18px rgba(255,217,102,0.24), 3px 3px 0 #000;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  pointer-events: none;
}

.choice-status span,
.choice-status strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-status span {
  margin-top: 4px;
  color: var(--gold);
  font-size: 7px;
  line-height: 1;
}

.choice-status span:first-child {
  margin-top: 0;
}

.choice-status strong {
  color: var(--white);
  font-size: 10px;
  line-height: 1.05;
}

.lane-badge {
  position: absolute;
  z-index: 6;
  top: 18%;
  left: 9px;
  padding: 6px 8px;
  border: 2px solid rgba(118, 247, 255, 0.62);
  background: rgba(0, 0, 0, 0.52);
  color: var(--cyan);
  font-size: 9px;
  line-height: 1;
  text-shadow: 2px 2px 0 #000;
  box-shadow: 3px 3px 0 #000;
  pointer-events: none;
}

.lane-badge.is-flashing {
  animation: laneBadgeFlash 900ms steps(2, end);
}

.shift-badge {
  position: absolute;
  z-index: 6;
  top: calc(18% + 36px);
  left: 9px;
  min-width: 70px;
  padding: 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  background: rgba(0, 0, 0, 0.46);
  box-shadow: 3px 3px 0 #000;
  pointer-events: none;
}

.shift-badge span,
.shift-badge strong {
  display: block;
  line-height: 1;
}

.shift-badge span {
  color: var(--cyan);
  font-size: 7px;
}

.shift-badge strong {
  margin-top: 3px;
  color: var(--white);
  font-size: 14px;
}

.result-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 330px);
}

.result-grid div {
  padding: 10px 12px;
  border: 3px solid #fff;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 4px 4px 0 #000;
}

@keyframes callout {
  0%,
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.94);
  }
  12%,
  76% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes hudBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-3px) scale(1.08);
  }
  70% {
    transform: translateY(1px) scale(0.98);
  }
}

@keyframes ultPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 18px rgba(255, 217, 102, 0.9), 5px 5px 0 #000;
  }
  50% {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 30px rgba(255, 217, 102, 1), 0 0 18px rgba(240, 48, 61, 0.7), 5px 5px 0 #000;
  }
}

@keyframes ultWave {
  0%,
  100% {
    transform: translateX(-4%) rotate(-2deg);
  }
  50% {
    transform: translateX(4%) rotate(2deg);
  }
}

@keyframes autoSkillPending {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 18px rgba(118, 247, 255, 0.75), 4px 4px 0 #000;
  }
  50% {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 26px rgba(255, 217, 102, 0.95), 0 0 18px rgba(118, 247, 255, 0.8), 4px 4px 0 #000;
  }
}

@keyframes autoSkillFire {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

@keyframes laneBadgeFlash {
  0%,
  100% {
    transform: scale(1);
    color: var(--cyan);
    border-color: rgba(118, 247, 255, 0.62);
  }
  18%,
  74% {
    transform: scale(1.08);
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 22px rgba(255, 217, 102, 0.82), 3px 3px 0 #000;
  }
}

@media (min-width: 720px) {
  body {
    padding: 24px;
  }

  .app-shell {
    height: min(92vh, 860px);
  }
}
