:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111225;
  color: #f4f1e7;
  --game-width: min(1180px, calc(100vw - 28px));
  --app-height: 100svh;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: var(--app-height);
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 12%, rgba(198, 74, 255, 0.24), transparent 24rem),
    radial-gradient(circle at 82% 22%, rgba(66, 209, 255, 0.17), transparent 23rem),
    linear-gradient(135deg, #111225 0%, #25204a 52%, #0c1023 100%);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #191814;
  font: inherit;
  font-weight: 800;
  background: linear-gradient(180deg, #ffd36a 0%, #ff9e2f 48%, #e46d13 100%);
  box-shadow:
    0 0 12px rgba(255, 158, 47, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.34);
  cursor: pointer;
}

button:hover {
  background: linear-gradient(180deg, #ffe38a 0%, #ffb43f 50%, #f08218 100%);
}

.game-shell {
  width: var(--game-width);
  display: grid;
  gap: 12px;
}

.hud {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(185, 211, 255, 0.18);
  border-radius: 8px;
  background: rgba(10, 12, 28, 0.84);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.hud {
  display: none;
}

.hud strong {
  display: block;
  font-size: 1.02rem;
}

.hud span {
  flex: 1;
  color: #d8d4e7;
  font-size: 0.92rem;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-width: 96px;
  padding: 8px 10px;
  border: 1px solid rgba(185, 211, 255, 0.18);
  border-radius: 8px;
  text-align: center;
  color: #f4f1e7;
  background: rgba(255, 255, 255, 0.06);
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(185, 211, 255, 0.2);
  border-radius: 8px;
  background: #2b3357;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  touch-action: none;
}

.rotate-phone {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  color: #f9f7ff;
  text-align: center;
  background:
    radial-gradient(circle at 50% 24%, rgba(83, 223, 255, 0.16), transparent 16rem),
    radial-gradient(circle at 50% 72%, rgba(255, 178, 62, 0.16), transparent 14rem),
    linear-gradient(145deg, #08091e 0%, #21114b 56%, #050615 100%);
}

.rotate-phone div {
  width: min(340px, 100%);
  display: grid;
  gap: 10px;
  padding: 22px 20px;
  border: 2px solid rgba(255, 178, 62, 0.78);
  border-radius: 8px;
  background: rgba(6, 9, 30, 0.76);
  box-shadow:
    0 0 20px rgba(255, 178, 62, 0.38),
    inset 0 0 24px rgba(83, 223, 255, 0.12);
}

.rotate-phone strong {
  color: #ffd36a;
  font-size: clamp(1.8rem, 10vw, 3rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    0 0 10px rgba(255, 178, 62, 0.88),
    0 2px 0 rgba(42, 19, 4, 0.9);
}

.rotate-phone span {
  color: #dff8ff;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.35;
}

.rotate-phone.is-visible {
  display: grid;
}

.screen,
.message {
  position: absolute;
  left: 50%;
  translate: -50% 0;
}

.message {
  border: 1px solid rgba(80, 219, 255, 0.72);
  border-radius: 8px;
  color: #f9f7ff;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(10, 13, 42, 0.92), rgba(31, 14, 70, 0.88)),
    radial-gradient(circle at 18% 0%, rgba(255, 173, 55, 0.22), transparent 54%);
  box-shadow:
    0 0 18px rgba(67, 223, 255, 0.34),
    0 16px 45px rgba(0, 0, 0, 0.42),
    inset 0 0 22px rgba(126, 76, 255, 0.24);
}

.screen {
  inset: 0;
  left: 0;
  translate: 0 0;
  display: none;
  background-position: center;
  background-size: cover;
  z-index: 3;
}

.screen.is-visible {
  display: block;
}

.title-screen {
  background-image: url("assets/start-screen.webp?v=2");
  isolation: isolate;
  overflow: hidden;
}

.studio-screen {
  background-image: url("assets/studio-screen.webp");
  background-position: center;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  border: 0;
  border-radius: 0;
  background-color: #02030d;
  cursor: pointer;
}

.studio-screen:hover,
.studio-screen:focus-visible {
  background-image: url("assets/studio-screen.webp");
  background-size: contain !important;
  background-color: #02030d;
  outline: 0;
}

.title-screen::before,
.title-screen::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: inherit;
  background-position: inherit;
  background-size: inherit;
  opacity: 0;
  z-index: -1;
}

.title-screen::before {
  mix-blend-mode: screen;
  animation: titleGlitch 7.8s steps(1, end) infinite;
}

.title-screen::after {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 5px
    );
  animation: titleScanFlicker 5.6s steps(1, end) infinite;
}

.select-screen {
  background-image: url("assets/choose-screen.webp?v=2");
}

.story-screen,
.mid-story-screen,
.end-story-screen {
  background-position: center;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  border: 0;
  border-radius: 0;
  background-color: #050313;
  cursor: pointer;
}

.story-screen {
  background-image: url("assets/story-screen.webp");
}

.story-screen:hover,
.story-screen:focus-visible {
  background-image: url("assets/story-screen.webp");
  background-size: contain !important;
  background-color: #050313;
  outline: 0;
}

.mid-story-screen {
  background-image: url("assets/mid-story-screen.webp");
}

.mid-story-screen:hover,
.mid-story-screen:focus-visible {
  background-image: url("assets/mid-story-screen.webp");
  background-size: contain !important;
  background-color: #050313;
  outline: 0;
}

.end-story-screen {
  background-image: url("assets/end-story-screen.webp");
}

.end-story-screen:hover,
.end-story-screen:focus-visible {
  background-image: url("assets/end-story-screen.webp");
  background-size: contain !important;
  background-color: #050313;
  outline: 0;
}

.clear-screen {
  background-image: url("assets/cleared-screen.webp");
  isolation: isolate;
}

.complete-screen {
  background-image: url("assets/complete-screen.webp");
  background-position: center;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  border: 0;
  border-radius: 0;
  background-color: #050313;
  cursor: pointer;
}

.complete-screen:hover,
.complete-screen:focus-visible {
  background-image: url("assets/complete-screen.webp");
  background-size: contain !important;
  background-color: #050313;
  outline: 0;
}

.game-over-screen {
  background-image: url("assets/game-over-screen.webp");
  background-position: center;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-color: #050313;
}

.game-over-actions {
  position: absolute;
  left: 50%;
  bottom: 7%;
  display: flex;
  width: min(760px, calc(100% - 40px));
  justify-content: center;
  gap: clamp(12px, 3vw, 26px);
  translate: -50% 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.game-over-screen.actions-ready .game-over-actions {
  opacity: 1;
  pointer-events: auto;
}

.game-over-screen .menu-action {
  min-width: min(220px, 30vw);
  min-height: 68px;
  padding: 14px 24px;
  border: 2px solid rgba(83, 224, 255, 0.82);
  border-radius: 8px;
  color: #f7fbff;
  background: rgba(3, 12, 34, 0.24);
  box-shadow:
    0 0 12px rgba(67, 223, 255, 0.75),
    0 0 28px rgba(67, 223, 255, 0.42),
    inset 0 0 18px rgba(67, 223, 255, 0.18);
  font-size: clamp(1rem, 2.2vw, 1.8rem);
  font-weight: 950;
  letter-spacing: 0;
  white-space: nowrap;
  text-transform: uppercase;
  text-shadow:
    0 0 8px #43dfff,
    0 0 18px #43dfff,
    0 0 26px #ffffff;
  animation: startFlash 0.78s ease-in-out infinite alternate;
}

.game-over-screen:not(.can-save-score) #game-over-save-score {
  display: none;
}

.game-over-screen .menu-action:hover,
.game-over-screen .menu-action:focus-visible,
.game-over-screen .menu-action.is-selected {
  border-color: rgba(255, 183, 62, 0.98);
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(255, 199, 84, 0.24), rgba(247, 119, 20, 0.18)),
    rgba(4, 16, 42, 0.18);
  box-shadow:
    0 0 16px rgba(255, 164, 45, 0.98),
    0 0 38px rgba(255, 131, 31, 0.62),
    0 0 62px rgba(67, 223, 255, 0.32),
    inset 0 0 22px rgba(255, 183, 62, 0.28);
  text-shadow:
    0 0 8px #ffb23e,
    0 0 18px #ff8a1f,
    0 0 26px #ffffff;
}

.clear-screen::before,
.clear-screen::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.clear-screen::before {
  background: inherit;
  background-position: inherit;
  background-size: inherit;
  mix-blend-mode: screen;
  opacity: 0;
}

.clear-screen::after {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.12) 0,
      rgba(255, 255, 255, 0.12) 1px,
      transparent 1px,
      transparent 5px
    );
  opacity: 0.22;
}

.clear-screen.is-visible {
  animation: clearGlitch 760ms steps(2, end) both;
}

.clear-screen.is-visible::before {
  animation: colorGlitch 640ms steps(2, end) 3;
}

.clear-panel {
  position: absolute;
  left: 50%;
  bottom: 8.5%;
  translate: -50% 0;
  width: min(520px, calc(100% - 40px));
  display: grid;
  gap: 5px;
  padding: 12px 18px;
  z-index: 2;
  border: 1px solid rgba(83, 224, 255, 0.8);
  border-radius: 8px;
  background: rgba(5, 8, 28, 0.76);
  box-shadow:
    0 0 18px rgba(67, 223, 255, 0.62),
    inset 0 0 18px rgba(255, 156, 45, 0.2);
  text-align: center;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
}

.clear-panel strong {
  color: #f7fbff;
  font-size: clamp(1.1rem, 3vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 0 8px #43dfff,
    0 0 18px #9f50ff,
    0 0 30px #ff9c2d;
  animation: loadingPulse 0.9s ease-in-out infinite alternate;
}

.boss-warning {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  gap: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 50%, rgba(255, 60, 55, 0.16), rgba(2, 4, 20, 0.82) 58%);
  text-align: center;
}

.boss-warning.is-visible {
  display: grid;
  animation: warningFlash 0.34s steps(2, end) infinite;
}

.boss-warning strong {
  color: #ff463d;
  font-size: clamp(2.2rem, 8vw, 6.5rem);
  font-weight: 950;
  line-height: 1;
  text-shadow:
    0 0 14px rgba(255, 70, 61, 0.95),
    0 0 36px rgba(255, 184, 47, 0.72);
}

.boss-warning span {
  color: #ffd36a;
  font-size: clamp(1.2rem, 4vw, 3rem);
  font-weight: 950;
  text-shadow: 0 0 18px rgba(255, 184, 47, 0.86);
}

.press-start,
.select-start {
  position: absolute;
  color: transparent;
  border: 0;
  background: transparent;
  font-size: 0;
  cursor: pointer;
}

.press-start {
  left: 50%;
  bottom: 7%;
  width: min(330px, 30%);
  min-height: 74px;
  translate: -50% 0;
  border: 2px solid rgba(83, 224, 255, 0.78);
  border-radius: 8px;
  color: #f7fbff;
  background: rgba(3, 12, 34, 0.18);
  box-shadow:
    0 0 12px rgba(67, 223, 255, 0.75),
    0 0 28px rgba(67, 223, 255, 0.42),
    inset 0 0 18px rgba(67, 223, 255, 0.18);
  font-size: clamp(1.1rem, 2.4vw, 2rem);
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 0 8px #43dfff,
    0 0 18px #43dfff,
    0 0 26px #ffffff;
  animation: startFlash 0.78s ease-in-out infinite alternate;
}

.press-start:hover,
.press-start:focus-visible {
  color: #ffffff;
  border-color: rgba(116, 235, 255, 0.95);
  background: rgba(4, 16, 42, 0.14);
  box-shadow:
    0 0 16px rgba(67, 223, 255, 0.9),
    0 0 36px rgba(67, 223, 255, 0.5),
    inset 0 0 20px rgba(67, 223, 255, 0.2);
}

.settings-cog,
.leaderboard-open {
  position: absolute;
  bottom: 4%;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid rgba(255, 202, 91, 0.82);
  border-radius: 50%;
  color: #fff5d0;
  background: rgba(10, 9, 28, 0.54);
  box-shadow:
    0 0 14px rgba(255, 178, 62, 0.58),
    inset 0 0 16px rgba(255, 178, 62, 0.2);
  font-size: 1.45rem;
  line-height: 1;
  text-align: center;
}

.settings-cog {
  right: 3%;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols", system-ui, sans-serif;
  font-size: 1.72rem;
  font-weight: 900;
  line-height: 0;
  text-indent: 0;
}

.settings-cog::before {
  content: "⚙";
  display: block;
  color: #fff5d0;
  translate: 0 2px;
}

.leaderboard-open {
  left: 3%;
}

.settings-cog:hover,
.settings-cog:focus-visible,
.leaderboard-open:hover,
.leaderboard-open:focus-visible {
  color: #ffffff;
  background: rgba(20, 13, 36, 0.7);
  box-shadow:
    0 0 20px rgba(255, 178, 62, 0.86),
    0 0 34px rgba(83, 223, 255, 0.28),
    inset 0 0 18px rgba(255, 178, 62, 0.28);
}

.settings-cog:hover::before,
.settings-cog:focus-visible::before {
  color: #ffffff;
}

.reset-home {
  position: absolute;
  left: 2.4%;
  bottom: 3.2%;
  z-index: 7;
  display: none;
  width: 42px;
  min-height: 42px;
  border: 1px solid rgba(255, 202, 91, 0.48);
  border-radius: 50%;
  color: rgba(255, 245, 208, 0.78);
  background:
    linear-gradient(180deg, rgba(255, 211, 106, 0.16), rgba(247, 147, 30, 0.12)),
    rgba(10, 9, 28, 0.32);
  box-shadow:
    0 0 10px rgba(255, 178, 62, 0.24),
    inset 0 0 12px rgba(255, 178, 62, 0.1);
  font-size: 1.45rem;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 178, 62, 0.36);
  opacity: 0.76;
}

.reset-home.is-visible {
  display: grid;
  place-items: center;
}

.reset-home:hover,
.reset-home:focus-visible {
  color: #ffffff;
  outline: 0;
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(255, 211, 106, 0.28), rgba(247, 147, 30, 0.18)),
    rgba(10, 9, 28, 0.48);
  box-shadow:
    0 0 14px rgba(255, 178, 62, 0.48),
    0 0 24px rgba(83, 223, 255, 0.18),
    inset 0 0 14px rgba(255, 178, 62, 0.18);
  transform: translateY(-1px);
}

.touch-controls {
  position: absolute;
  inset: auto max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 5;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-move {
  display: flex;
  gap: 12px;
}

.touch-button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: clamp(58px, 9vw, 84px);
  height: clamp(58px, 9vw, 84px);
  min-height: 0;
  border: 2px solid rgba(255, 211, 106, 0.78);
  border-radius: 50%;
  color: #fff5d4;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
  text-shadow: 0 0 10px rgba(255, 185, 61, 0.78);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 213, 122, 0.28), transparent 44%),
    linear-gradient(180deg, rgba(30, 24, 62, 0.74), rgba(9, 12, 31, 0.7));
  box-shadow:
    0 0 18px rgba(255, 156, 38, 0.34),
    inset 0 0 18px rgba(74, 216, 255, 0.16);
  backdrop-filter: blur(8px);
}

.touch-jump {
  width: clamp(74px, 11vw, 104px);
  height: clamp(74px, 11vw, 104px);
  font-size: clamp(0.82rem, 1.8vw, 1.05rem);
  letter-spacing: 0;
  text-transform: uppercase;
}

.touch-button.is-pressed,
.touch-button:active {
  transform: translateY(2px) scale(0.96);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 230, 154, 0.46), transparent 48%),
    linear-gradient(180deg, rgba(255, 158, 47, 0.68), rgba(80, 44, 100, 0.72));
  box-shadow:
    0 0 26px rgba(255, 178, 62, 0.58),
    inset 0 0 18px rgba(255, 255, 255, 0.22);
}

@media (pointer: coarse) {
  .touch-controls.is-visible {
    display: flex;
  }

  body {
    padding:
      max(4px, env(safe-area-inset-top))
      max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(4px, env(safe-area-inset-left));
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .rotate-phone {
    display: grid;
  }

  .game-shell {
    filter: blur(2px) brightness(0.58);
    pointer-events: none;
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  body {
    place-items: center;
  }

  .game-shell {
    gap: 0;
  }

  .stage-wrap {
    border-radius: 6px;
  }

  .touch-controls {
    inset:
      auto
      max(10px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .touch-move {
    gap: clamp(8px, 1.8vw, 12px);
  }

  .touch-button {
    width: clamp(54px, 11.5svh, 76px);
    height: clamp(54px, 11.5svh, 76px);
    font-size: clamp(1.65rem, 7svh, 2.6rem);
  }

  .touch-jump {
    width: clamp(70px, 14svh, 96px);
    height: clamp(70px, 14svh, 96px);
    font-size: clamp(0.78rem, 2.1svh, 1rem);
  }
}

.settings-menu {
  position: absolute;
  right: 3%;
  bottom: 14%;
  z-index: 8;
  width: min(390px, 44%);
  max-height: 84%;
  overflow: auto;
  padding: 18px 18px 0;
  border: 2px solid rgba(255, 178, 62, 0.84);
  border-radius: 8px;
  color: #f9f7ff;
  background:
    linear-gradient(135deg, rgba(10, 13, 42, 0.96), rgba(30, 13, 60, 0.94)),
    radial-gradient(circle at 10% 0%, rgba(255, 178, 62, 0.18), transparent 48%);
  box-shadow:
    0 0 24px rgba(255, 178, 62, 0.42),
    0 24px 80px rgba(0, 0, 0, 0.62),
    inset 0 0 26px rgba(83, 223, 255, 0.12);
  overscroll-behavior: contain;
}

.settings-menu h2,
.settings-menu h3 {
  margin: 0;
  color: #ffd36a;
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow: 0 0 10px rgba(255, 178, 62, 0.55);
}

.settings-menu h2 {
  margin-bottom: 12px;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
}

.settings-menu h3 {
  margin-bottom: 8px;
  font-size: clamp(0.78rem, 2vw, 0.9rem);
}

.settings-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.settings-menu label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(185, 211, 255, 0.15);
  border-radius: 8px;
  color: #f9f7ff;
  background: rgba(255, 255, 255, 0.045);
  font-size: clamp(0.78rem, 2vw, 0.95rem);
}

.settings-menu label:focus-within,
.settings-apply:focus-visible {
  outline: 2px solid #ffb23e;
  box-shadow: 0 0 18px rgba(255, 178, 62, 0.62);
}

.settings-menu input {
  accent-color: #ffb23e;
}

.settings-menu label span {
  margin-left: auto;
  color: #cfd8ff;
  font-size: 0.78rem;
  text-align: right;
}

.settings-apply {
  width: 100%;
  margin-top: 2px;
}

.settings-footer {
  position: sticky;
  bottom: 0;
  margin: 10px -18px 0;
  padding: 12px 18px 14px;
  border-top: 1px solid rgba(255, 178, 62, 0.28);
  background:
    linear-gradient(180deg, rgba(16, 10, 38, 0.86), rgba(10, 13, 42, 0.98));
  box-shadow: 0 -14px 26px rgba(5, 3, 18, 0.56);
}

.settings-footer small {
  display: block;
  margin-top: 9px;
  color: rgba(249, 247, 255, 0.72);
  font-size: 0.72rem;
  text-align: center;
}

.score-entry-screen,
.leaderboard-screen {
  display: none;
  place-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(83, 223, 255, 0.16), transparent 22rem),
    linear-gradient(135deg, rgba(5, 3, 19, 0.96), rgba(23, 11, 55, 0.96));
}

.score-entry-screen.is-visible,
.leaderboard-screen.is-visible {
  display: grid;
}

.arcade-panel {
  width: min(520px, calc(100% - 48px));
  max-height: calc(100% - 48px);
  padding: 28px;
  border: 2px solid rgba(255, 178, 62, 0.9);
  border-radius: 8px;
  text-align: center;
  color: #f9f7ff;
  background:
    linear-gradient(135deg, rgba(10, 13, 42, 0.96), rgba(30, 13, 60, 0.94)),
    radial-gradient(circle at 50% 0%, rgba(255, 178, 62, 0.18), transparent 48%);
  box-shadow:
    0 0 24px rgba(255, 178, 62, 0.42),
    0 24px 80px rgba(0, 0, 0, 0.62),
    inset 0 0 26px rgba(83, 223, 255, 0.14);
}

.leaderboard-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(580px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: clamp(16px, 3vw, 28px);
  overflow: hidden;
}

.arcade-panel h2 {
  margin: 0 0 14px;
  color: #ffd36a;
  font-size: clamp(1.35rem, 4vw, 2.35rem);
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow: 0 0 14px rgba(255, 178, 62, 0.72);
}

.arcade-panel p {
  margin: 0 0 18px;
  color: #53dfff;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 950;
  text-shadow: 0 0 12px rgba(83, 223, 255, 0.72);
}

.arcade-panel label {
  display: block;
  margin-bottom: 8px;
  color: #f9f7ff;
  font-weight: 900;
  text-transform: uppercase;
}

.arcade-panel input {
  width: 150px;
  min-height: 58px;
  margin-bottom: 18px;
  border: 2px solid rgba(83, 223, 255, 0.86);
  border-radius: 8px;
  color: #ffd36a;
  background: rgba(4, 8, 24, 0.78);
  font: 950 2rem Inter, system-ui, sans-serif;
  text-align: center;
  text-transform: uppercase;
  box-shadow: inset 0 0 18px rgba(83, 223, 255, 0.16);
}

.arcade-action {
  min-width: 180px;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: minmax(58px, 0.7fr) minmax(72px, 1fr) minmax(86px, 1fr);
  gap: 8px;
  margin: 0 6px 8px 0;
  padding: 0 10px;
  color: #ffd36a;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 178, 62, 0.62);
}

.leaderboard-header span:first-child {
  text-align: left;
}

.leaderboard-header span:nth-child(2) {
  text-align: center;
}

.leaderboard-header span:last-child {
  text-align: right;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding-left: 0;
  padding-right: 6px;
  list-style: none;
  overflow: auto;
  text-align: left;
  scrollbar-color: rgba(255, 178, 62, 0.7) rgba(255, 255, 255, 0.08);
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: minmax(58px, 0.7fr) minmax(72px, 1fr) minmax(86px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(185, 211, 255, 0.15);
  border-radius: 8px;
  color: #f9f7ff;
  background: rgba(255, 255, 255, 0.045);
  font-weight: 900;
}

.leaderboard-name {
  text-align: left;
}

.leaderboard-score {
  color: #ffd36a;
  text-align: center;
}

.leaderboard-result {
  color: #53dfff;
  text-align: right;
}

.select-start {
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.character-hotspot {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 36%;
  width: 20.5%;
  height: 47%;
  --go-x: 50%;
  --go-y: 45%;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  outline: 0;
  -webkit-tap-highlight-color: transparent;
}

.character-hotspot::after {
  position: absolute;
  left: var(--go-x);
  top: var(--go-y);
  min-width: 72px;
  padding: 8px 14px;
  translate: -50% -50%;
  content: "GO";
  color: #fff8e8;
  border: 2px solid rgba(255, 183, 62, 0.92);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 210, 102, 0.96), rgba(240, 112, 18, 0.96));
  box-shadow:
    0 0 16px rgba(255, 164, 45, 0.86),
    0 0 30px rgba(69, 218, 255, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.42);
  font-size: 1.05rem;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 2px 0 rgba(80, 38, 4, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, translate 140ms ease, filter 140ms ease;
}

.character-hotspot:hover,
.character-hotspot:focus,
.character-hotspot:focus-visible,
.character-hotspot.is-selected {
  outline: 0;
  background: transparent;
  box-shadow: none;
}

.character-hotspot:hover::after,
.character-hotspot:focus-visible::after,
.character-hotspot.is-selected::after {
  translate: -50% -50%;
  opacity: 1;
  filter: brightness(1.08);
}

.character-hotspot.eliah {
  left: 16%;
  --go-x: 51%;
  --go-y: 45%;
}

.character-hotspot.renee {
  left: 39.9%;
  --go-x: 50%;
  --go-y: 45%;
}

.character-hotspot.daddy {
  left: 63%;
  --go-x: 54%;
  --go-y: 45%;
}

@keyframes neonPulse {
  from {
    opacity: 0.62;
    filter: brightness(0.88);
  }
  to {
    opacity: 1;
    filter: brightness(1.2);
  }
}

@keyframes titleGlitch {
  0%,
  76%,
  100% {
    opacity: 0;
    translate: 0 0;
    filter: none;
    clip-path: inset(0 0 0 0);
  }
  77% {
    opacity: 0.34;
    translate: -8px 0;
    filter: hue-rotate(95deg) saturate(1.35);
    clip-path: inset(12% 0 67% 0);
  }
  78% {
    opacity: 0.28;
    translate: 7px 0;
    filter: hue-rotate(-65deg) contrast(1.25);
    clip-path: inset(58% 0 16% 0);
  }
  79% {
    opacity: 0.18;
    translate: -3px 0;
    filter: brightness(1.35);
    clip-path: inset(31% 0 43% 0);
  }
}

@keyframes titleScanFlicker {
  0%,
  81%,
  100% {
    opacity: 0.08;
    translate: 0 0;
  }
  82% {
    opacity: 0.22;
    translate: 0 -2px;
  }
  83% {
    opacity: 0.04;
    translate: 0 1px;
  }
}

@keyframes clearGlitch {
  0% {
    filter: hue-rotate(0deg) contrast(1.1);
    clip-path: inset(0 0 0 0);
  }
  16% {
    filter: hue-rotate(44deg) contrast(1.5);
    translate: -9px 0;
    clip-path: inset(7% 0 4% 0);
  }
  33% {
    translate: 8px 0;
    clip-path: inset(0 0 62% 0);
  }
  48% {
    filter: hue-rotate(-28deg) contrast(1.35);
    translate: -5px 0;
    clip-path: inset(58% 0 10% 0);
  }
  66% {
    translate: 4px 0;
    clip-path: inset(21% 0 31% 0);
  }
  100% {
    filter: none;
    translate: 0 0;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes colorGlitch {
  0%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }
  35% {
    opacity: 0.55;
    transform: translateX(-12px);
    filter: hue-rotate(110deg);
  }
  62% {
    opacity: 0.45;
    transform: translateX(14px);
    filter: hue-rotate(-80deg);
  }
}

@keyframes loadingPulse {
  from {
    opacity: 0.58;
    filter: brightness(0.85);
  }
  to {
    opacity: 1;
    filter: brightness(1.3);
  }
}

@keyframes startFlash {
  from {
    opacity: 0.52;
    filter: brightness(0.86);
  }
  to {
    opacity: 1;
    filter: brightness(1.25);
  }
}

@keyframes warningFlash {
  from {
    filter: brightness(0.78) saturate(1.1);
  }
  to {
    filter: brightness(1.35) saturate(1.8);
  }
}

.message {
  top: 24px;
  width: min(560px, calc(100% - 32px));
  display: none;
  padding: 13px 18px 14px;
}

.message.is-visible {
  display: grid;
  gap: 3px;
  animation: hudNoticeIn 180ms ease-out both;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(83, 223, 255, 0.14), transparent 18rem),
    rgba(4, 5, 19, 0.48);
  backdrop-filter: blur(2px);
}

.pause-overlay.is-visible {
  display: grid;
}

.resume-game {
  min-width: min(300px, 58%);
  min-height: 76px;
  padding: 16px 32px;
  border: 2px solid rgba(83, 224, 255, 0.86);
  border-radius: 8px;
  color: #f7fbff;
  background: rgba(3, 12, 34, 0.32);
  box-shadow:
    0 0 14px rgba(67, 223, 255, 0.82),
    0 0 34px rgba(67, 223, 255, 0.46),
    inset 0 0 20px rgba(67, 223, 255, 0.2);
  font-size: clamp(1.2rem, 3vw, 2.1rem);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 0 8px #43dfff,
    0 0 18px #43dfff,
    0 0 26px #ffffff;
  animation: startFlash 0.78s ease-in-out infinite alternate;
}

.resume-game:hover,
.resume-game:focus-visible {
  border-color: rgba(255, 183, 62, 0.98);
  outline: 0;
  box-shadow:
    0 0 18px rgba(255, 164, 45, 0.98),
    0 0 42px rgba(255, 131, 31, 0.62),
    inset 0 0 22px rgba(255, 183, 62, 0.28);
}

.message strong {
  color: #ffd36a;
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(255, 162, 45, 0.85),
    0 2px 0 rgba(47, 21, 5, 0.88);
}

.message span {
  color: #dff8ff;
  font-size: 0.9rem;
  font-weight: 750;
  text-shadow: 0 0 8px rgba(67, 223, 255, 0.48);
}

@keyframes hudNoticeIn {
  from {
    opacity: 0;
    translate: -50% -10px;
    filter: brightness(1.35);
  }
  to {
    opacity: 1;
    translate: -50% 0;
    filter: brightness(1);
  }
}

@media (hover: none), (max-width: 760px) {
  body {
    place-items: start center;
    padding-top: 10px;
  }

  .hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    width: 100%;
    justify-content: stretch;
  }

  .stats span {
    flex: 1;
    min-width: 0;
  }

  .choice-row {
    grid-template-columns: 1fr;
  }

  .game-over-actions {
    bottom: 5%;
  }

  .game-over-screen .menu-action {
    min-width: 0;
    min-height: 52px;
    padding: 10px 14px;
  }

}

@media (max-width: 760px) {
  .settings-cog,
  .leaderboard-open {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .settings-cog {
    right: max(10px, env(safe-area-inset-right));
  }

  .leaderboard-open {
    left: max(10px, env(safe-area-inset-left));
  }

  .settings-cog {
    font-size: 1.45rem;
  }

  .settings-menu {
    inset: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(58px, calc(env(safe-area-inset-bottom) + 52px)) max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: none;
    padding: 12px 12px 0;
  }

  .settings-menu h2 {
    margin-bottom: 8px;
  }

  .settings-menu h3 {
    margin-bottom: 5px;
  }

  .settings-group {
    gap: 6px;
    margin-bottom: 10px;
  }

  .settings-menu label {
    min-height: 30px;
    gap: 7px;
    padding: 5px 7px;
  }

  .settings-menu label span {
    max-width: 42%;
    font-size: 0.68rem;
    line-height: 1.05;
  }

  .settings-footer {
    margin: 8px -12px 0;
    padding: 10px 12px 12px;
  }

  .settings-footer small {
    margin-top: 6px;
    font-size: 0.64rem;
  }
}
