:root {
  --page: #0d0928;
  --page-mid: #171140;
  --hud: #211a59;
  --hud-deep: #151039;
  --stage: #171140;
  --stage-deep: #0c0826;
  --white: #ffffff;
  --ink: #292251;
  --muted: #766ea0;
  --purple: #7657e7;
  --purple-dark: #4c36ae;
  --yellow: #ffd438;
  --yellow-dark: #c98c00;
  --danger: #ff4f70;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(91, 61, 181, .22), transparent 38%),
    linear-gradient(180deg, #110c34 0%, var(--page-mid) 48%, var(--page) 100%);
  color: var(--white);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  user-select: none;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
}

button:focus-visible,
input:focus-visible + .switch {
  outline: 3px solid rgba(255, 212, 56, .65);
  outline-offset: 3px;
}

.app {
  width: 100%;
  min-height: 100dvh;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 50%, rgba(104,72,212,.22) 0%, rgba(73,50,163,.12) 28%, rgba(20,13,60,0) 58%),
    linear-gradient(180deg, #171140 0%, #15103c 46%, #0b0825 100%);
}

.app::before,
.app::after {
  content: none;
}

.game-shell {
  width: min(100vw, 560px);
  height: min(100dvh, 960px);
  min-height: 360px;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.topbar {
  position: relative;
  min-height: calc(78px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: rgba(28, 21, 75, .9);
  border-bottom: 1px solid rgba(139, 110, 239, .28);
  box-shadow: 0 8px 28px rgba(5, 3, 23, .18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.hud-pill {
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 7px;
  background: rgba(20, 15, 58, .9);
  border: 1px solid rgba(151, 125, 255, .12);
  border-radius: 15px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .16);
}

.hud-pill img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
  pointer-events: none;
}

.hud-pill strong {
  min-width: 0;
  color: var(--white);
  font-size: clamp(18px, 4.5vw, 26px);
  font-weight: 1000;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.score-pill {
  justify-self: center;
  min-width: 142px;
  justify-content: center;
}

.currency-pill {
  justify-self: start;
}

.top-actions {
  justify-self: end;
  display: flex;
  gap: 9px;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--hud-deep);
  border-radius: 14px;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
  transition: transform .12s ease, background .12s ease;
}

.icon-button:hover {
  background: #302875;
}

.icon-button:active {
  transform: translateY(2px) scale(.96);
}

.stage-wrap {
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: transparent;
  isolation: isolate;
}

.stage-wrap::before,
.stage-wrap::after {
  content: none;
}

.portrait-wall {
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 26px;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.portrait-wall::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,.52) 0 5px, rgba(255,255,255,0) 5px 14px),
    linear-gradient(180deg, rgba(221,211,255,.42), rgba(146,123,244,.24));
  box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 0 10px rgba(162,137,255,.18);
}

.portrait-wall::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(183,156,255,.08), rgba(183,156,255,.01));
  filter: blur(7px);
}

.wall-left {
  left: calc(var(--portrait-left, 0px) - 11px);
}

.wall-right {
  left: calc(var(--portrait-right, 0px) - 11px);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.rush-meter {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  pointer-events: none;
}

.rush-track {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: rgba(63, 45, 126, .16);
}

.rush-fill {
  width: 0;
  height: 100%;
  background: var(--yellow);
  transform-origin: left center;
  transition: width .18s ease;
}

.rush-meter > span {
  display: none;
}

.rush-meter.is-hot .rush-fill {
  animation: rushPulse .45s ease-in-out infinite alternate;
}

.level-badge,
.shots-panel {
  position: absolute;
  z-index: 7;
  height: 27px;
  display: flex;
  align-items: center;
  background: rgba(62, 48, 132, .72);
  color: var(--white);
  border-radius: 9px;
  box-shadow: 0 3px 0 rgba(60, 43, 132, .24);
  pointer-events: none;
}

.level-badge {
  display: none;
  left: 12px;
  gap: 4px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.shots-panel {
  right: 12px;
  bottom: calc(16px + var(--safe-bottom));
  padding: 0 8px;
}

.shot-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .16);
  transition: opacity .16s ease, transform .16s ease;
}

.shot-dot.is-empty {
  opacity: .25;
  transform: scale(.76);
  background: var(--white);
}

.danger-label {
  position: absolute;
  z-index: 8;
  left: 50%;
  transform: translate(-50%, -8px);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--white);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .09em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.danger-label.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.next-card {
  position: absolute;
  z-index: 8;
  left: calc(50% + 54px);
  bottom: calc(76px + var(--safe-bottom));
  width: 74px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.mini-bubble {
  width: 49px;
  height: 49px;
  position: relative;
  display: block;
  border-radius: 50%;
  background-image: url("assets/bubble-sprites.webp");
  background-size: 600% 100%;
  background-position: 100% center;
  background-repeat: no-repeat;
  box-shadow: 0 4px 0 rgba(54, 39, 126, .25);
  transition: transform .16s ease, background-color .16s ease;
}

.swap-icon {
  position: absolute;
  left: -8px;
  top: 50%;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--white);
  color: var(--purple);
  font-size: 13px;
  box-shadow: 0 3px 0 rgba(54, 39, 126, .18);
}

.next-card:hover .mini-bubble {
  transform: scale(1.06);
}

.next-card:active .mini-bubble {
  transform: scale(.92);
}

.power-dock {
  position: absolute;
  z-index: 9;
  left: 14px;
  bottom: calc(13px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.power-button {
  width: 58px;
  height: 58px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: #8d72ed;
  color: var(--white);
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(76, 54, 174, .35);
  transition: transform .12s ease, opacity .12s ease;
}

.power-button img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  pointer-events: none;
}

.power-button > i {
  font-size: 26px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .17);
}

.color-power {
  background: #ed5ac8;
}

.power-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid var(--white);
  border-radius: 13px;
  background: #6546d3;
  color: var(--white);
  font-size: 12px;
  font-weight: 1000;
  box-shadow: 0 2px 0 rgba(52, 35, 124, .26);
}

.power-button:hover {
  transform: translateY(-2px);
}

.power-button:active {
  transform: translateY(2px) scale(.94);
}

.power-button:disabled {
  opacity: .4;
  filter: grayscale(.5);
  cursor: default;
}

.combo-pill,
.toast {
  position: absolute;
  z-index: 12;
  left: 50%;
  transform: translate(-50%, -10px) scale(.9);
  border-radius: 10px;
  background: var(--hud);
  color: var(--white);
  font-weight: 1000;
  letter-spacing: .05em;
  pointer-events: none;
  opacity: 0;
}

.combo-pill {
  top: 42%;
  padding: 8px 13px;
  font-size: 13px;
}

.toast {
  top: 14%;
  padding: 9px 14px;
  font-size: 14px;
}

.combo-pill.is-visible,
.toast.is-visible {
  animation: toastPop 1.2s ease both;
}

.overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 5, 29, .78);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel {
  width: min(100%, 390px);
  position: relative;
  padding: 28px;
  color: var(--ink);
  text-align: center;
  background: #f3efff;
  border: 3px solid var(--white);
  border-radius: 22px;
  box-shadow: 0 10px 0 #5c45bd, 0 24px 55px rgba(20, 14, 62, .36);
  transform: translateY(14px) scale(.96);
  transition: transform .2s ease;
}

.overlay.is-open .panel {
  transform: translateY(0) scale(1);
}

.menu-panel {
  width: min(100%, 430px);
  padding: 10px 26px 24px;
  color: var(--white);
  text-align: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.brand-logo {
  width: min(290px, 78%);
  display: block;
  margin: 0 auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(22, 12, 70, .18));
}

.menu-brand {
  margin-bottom: 8px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#menuOverlay {
  align-items: center;
  justify-items: center;
  background: radial-gradient(circle at 50% 38%, rgba(120, 90, 235, .18), rgba(8, 5, 29, .7) 42%, rgba(8, 5, 29, .84));
}

#menuOverlay .menu-copy {
  color: rgba(255,255,255,.78);
}

#menuOverlay h1,
#menuOverlay h2,
#menuOverlay p,
#menuOverlay .eyebrow {
  color: var(--white);
}

#menuOverlay h1 span {
  color: #d7b3ff;
}

#menuOverlay .eyebrow {
  color: #c3b5ff;
}

#menuOverlay .best-chip {
  background: rgba(237, 231, 255, .16);
  color: #f1edff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#menuOverlay .best-chip strong {
  color: #ffffff;
}

#menuOverlay .primary-button,
#menuOverlay .secondary-button,
#menuOverlay .text-button {
  max-width: 320px;
  margin-inline: auto;
}

#menuOverlay .text-button {
  color: rgba(255,255,255,.76);
}

#menuOverlay .secondary-button {
  background: rgba(221, 212, 255, .94);
}

.loading-panel {
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.loading-panel .brand-logo {
  width: min(290px, 82vw);
  margin-bottom: 0;
  filter: drop-shadow(0 14px 26px rgba(18, 8, 68, .26));
}

.menu-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.level-chip {
  padding: 0 14px;
}

.splash-overlay {
  background:
    radial-gradient(circle at 50% 44%, rgba(117, 87, 231, .28), rgba(10, 7, 33, .88) 52%),
    rgba(8, 5, 29, .94);
}

#loadingOverlay {
  background: transparent;
}

.splash-card {
  width: min(100%, 420px);
  text-align: center;
  transform: translateY(0) scale(1);
}

.splash-logo {
  width: min(92vw, 460px);
  display: block;
  margin: 0 auto 14px;
  object-fit: contain;
  filter: drop-shadow(0 16px 34px rgba(18, 8, 68, .34));
  animation: floatLogo 1.9s ease-in-out infinite alternate;
}

.splash-copy,
.loading-copy {
  margin: 0;
  color: rgba(255,255,255,.82);
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.loading-panel {
  padding-top: 0;
}

.loading-bar {
  width: min(100%, 280px);
  height: 18px;
  overflow: hidden;
  margin: 8px 0 12px;
  padding: 3px;
  border-radius: 999px;
  background: #ddd4ff;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.44);
}

.loading-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7657e7, #c78dff);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.14);
  transition: width .18s ease;
}

.endless-button {
  margin-top: 12px;
}


.levels-panel {
  width: min(94vw, 330px);
  padding: 16px;
  overflow: hidden;
  border-radius: 22px;
  background: #f4f0ff;
  border: 2px solid rgba(255,255,255,.98);
  box-shadow: 0 7px 0 #5c45bd, 0 22px 52px rgba(20,14,62,.38);
}

.levels-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.levels-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.levels-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -.04em;
}

.levels-range {
  min-width: 64px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  padding: 0 9px;
  border-radius: 9px;
  background: #ded5ff;
  color: var(--purple-dark);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .07em;
  font-variant-numeric: tabular-nums;
}

.levels-close {
  position: static;
  flex: 0 0 auto;
}

.levels-summary {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 12px;
  border-radius: 12px;
  background: #e7e0ff;
  color: var(--purple-dark);
  box-shadow: inset 0 -2px 0 rgba(91,67,176,.1);
}

.levels-summary span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .09em;
}

.levels-summary i {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #7657e7;
  color: #fff;
  font-size: 9px;
}

.levels-summary strong {
  font-size: 13px;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 322px;
}

.level-tile {
  min-width: 0;
  min-height: 57px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 0;
  border-radius: 13px;
  background: #ded5ff;
  color: var(--purple-dark);
  font-size: 18px;
  font-weight: 1000;
  box-shadow: 0 3px 0 #b8a8ed;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}

.level-tile:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.level-tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b8a8ed;
}

.level-tile .level-number {
  line-height: 1;
}

.level-tile .level-status {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.68);
  font-size: 7px;
}

.level-tile.is-current {
  background: #7657e7;
  color: #fff;
  box-shadow: 0 3px 0 #4c36ae;
}

.level-tile.is-current .level-status {
  background: #ffd438;
  color: #765000;
}

.level-tile.is-complete .level-status {
  background: #ffffff;
  color: #684bcf;
}

.level-tile.is-locked {
  background: #eae5f8;
  color: #aaa2c2;
  box-shadow: 0 3px 0 #d2cae7;
  cursor: default;
}

.level-tile.is-locked .level-status {
  background: transparent;
  color: #aaa2c2;
  font-size: 9px;
}

.levels-pagination {
  height: 46px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}

.page-button {
  width: 42px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
  background: #ded5ff;
  color: var(--purple-dark);
  font-size: 19px;
  box-shadow: 0 3px 0 #b8a8ed;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, filter .12s ease;
}

.page-button:hover:not(:disabled) {
  filter: brightness(1.04);
}

.page-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b8a8ed;
}

.page-button:disabled {
  opacity: .32;
  cursor: default;
}

.page-center {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.page-indicator {
  color: var(--purple-dark);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .09em;
  font-variant-numeric: tabular-nums;
}

.page-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.page-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c5b9e9;
  transition: width .15s ease, background .15s ease;
}

.page-dots span.is-active {
  width: 17px;
  background: #7657e7;
}

.menu-orbs {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.menu-orbs span {
  width: 62px;
  height: 62px;
  margin: 0 -8px;
  border-radius: 50%;
  background-image: url("assets/bubble-sprites.webp");
  background-size: 600% 100%;
  background-repeat: no-repeat;
  box-shadow: 0 5px 0 rgba(55, 38, 119, .22);
}


.menu-orbs span:nth-child(1) { background-position: 0% center; }
.menu-orbs span:nth-child(2) { background-position: 40% center; }
.menu-orbs span:nth-child(3) { background-position: 20% center; }
.menu-orbs span:nth-child(2) {
  transform: translateY(-15px) scale(1.08);
  z-index: 2;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--purple);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(40px, 12vw, 58px);
  line-height: .92;
  letter-spacing: -.055em;
  font-weight: 1000;
}

h1 span {
  color: var(--purple);
}

h2 {
  margin-bottom: 20px;
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
  font-weight: 1000;
}

.menu-copy {
  max-width: 270px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.best-chip {
  width: max-content;
  height: 40px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 5px;
  border-radius: 12px;
  background: #ded5ff;
  color: var(--purple-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.best-chip img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.best-chip strong {
  font-size: 16px;
  letter-spacing: 0;
}

.primary-button,
.secondary-button,
.text-button {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 1000;
  letter-spacing: .045em;
  transition: transform .12s ease, filter .12s ease;
}

.primary-button {
  border-radius: 14px;
  background: var(--purple);
  color: var(--white);
  box-shadow: 0 5px 0 var(--purple-dark);
}

.secondary-button {
  margin-top: 12px;
  border-radius: 14px;
  background: #ddd4ff;
  color: var(--purple-dark);
  box-shadow: 0 4px 0 #b8a8ed;
}

.text-button {
  min-height: 44px;
  margin-top: 12px;
  background: transparent;
  color: var(--muted);
}

.primary-button:hover,
.secondary-button:hover,
.text-button:hover {
  filter: brightness(1.04);
}

.primary-button:active,
.secondary-button:active,
.text-button:active {
  transform: translateY(3px);
}

.modal-icon {
  width: 64px;
  height: 64px;
  margin: -2px auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--purple);
  color: var(--white);
  font-size: 27px;
  box-shadow: 0 5px 0 var(--purple-dark);
}

.close-button {
  width: 38px;
  height: 38px;
  position: absolute;
  right: 14px;
  top: 14px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #dfd7ff;
  color: var(--purple-dark);
  cursor: pointer;
}

.settings-panel {
  width: min(100%, 390px);
  padding: 24px 26px 22px;
  text-align: left;
}

.settings-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 42px;
  margin-bottom: 22px;
}

.settings-heading h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1;
}

.settings-heading-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #e0d8ff;
  color: var(--purple);
  font-size: 21px;
  box-shadow: inset 0 -3px 0 rgba(76, 54, 174, .12);
}

.volume-setting {
  padding: 14px 0 16px;
  border-bottom: 1px solid #d8cff4;
}

.volume-setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-label i,
.settings-heading-icon i,
.vibration-setting > span:first-child i {
  color: var(--purple);
}

.setting-label i {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

.volume-setting output {
  min-width: 46px;
  padding: 4px 7px;
  border-radius: 8px;
  background: #e5defc;
  color: var(--purple-dark);
  text-align: center;
  font-size: 12px;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.volume-slider {
  --value: 65%;
  width: 100%;
  height: 22px;
  display: block;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: pan-x;
}

.volume-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple) 0 var(--value), #c9c0e4 var(--value) 100%);
  box-shadow: inset 0 2px 2px rgba(45, 32, 100, .14);
}

.volume-slider::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -6px;
  appearance: none;
  -webkit-appearance: none;
  border: 4px solid var(--white);
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 2px 0 var(--purple-dark), 0 4px 10px rgba(46, 32, 103, .22);
}

.volume-slider::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: #c9c0e4;
  box-shadow: inset 0 2px 2px rgba(45, 32, 100, .14);
}

.volume-slider::-moz-range-progress {
  height: 10px;
  border-radius: 999px;
  background: var(--purple);
}

.volume-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 4px solid var(--white);
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 2px 0 var(--purple-dark), 0 4px 10px rgba(46, 32, 103, .22);
}

.volume-slider:focus-visible {
  outline: none;
}

.volume-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(118, 87, 231, .22), 0 2px 0 var(--purple-dark);
}

.setting-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #d8cff4;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.setting-row > span:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-row > span:first-child i {
  width: 22px;
  color: var(--purple);
}

.setting-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 48px;
  height: 28px;
  position: relative;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #bfb7d9;
  transition: background .16s ease;
}

.switch::after {
  content: "";
  width: 22px;
  height: 22px;
  position: absolute;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 4px rgba(48, 36, 94, .22);
  transition: transform .16s ease;
}

.setting-row input:checked + .switch {
  background: var(--purple);
}

.setting-row input:checked + .switch::after {
  transform: translateX(20px);
}

.vibration-setting {
  min-height: 58px;
  padding-bottom: 0;
  border-bottom: 0;
}

.result-score {
  min-height: 64px;
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: 46px auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: 15px;
  background: #ded5ff;
  color: var(--purple-dark);
}

.result-score img {
  width: 46px;
  height: 46px;
}

.result-score span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
}

.result-score strong {
  justify-self: end;
  font-size: 28px;
  font-weight: 1000;
}

@keyframes toastPop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.82); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  24%, 72% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(.94); }
}

@keyframes rushPulse {
  from { opacity: .72; }
  to { opacity: 1; }
}

@keyframes floatLogo {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

@keyframes splashFadeInOut {
  0% { opacity: 0; transform: scale(.96); }
  22% { opacity: 1; transform: scale(1); }
  72% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}


@media (orientation: landscape) and (min-width: 700px) {
  .portrait-wall {
    opacity: .72;
  }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    grid-template-rows: auto 1fr;
  }

  .topbar {
    width: min(100vw, 560px);
    justify-self: center;
    min-height: calc(78px + var(--safe-top));
    padding: calc(10px + var(--safe-top)) 14px 10px;
    background: rgba(28, 21, 75, .9);
    border-bottom: 1px solid rgba(139, 110, 239, .28);
    box-shadow: 0 8px 28px rgba(5, 3, 23, .18);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
  }

  .stage-wrap {
    width: 100%;
  }

  .power-dock {
    left: calc(50% - 280px + 14px);
    bottom: calc(13px + var(--safe-bottom));
    gap: 9px;
  }

  .power-button {
    width: 58px;
    height: 58px;
    background: #8d72ed;
    box-shadow: 0 5px 0 rgba(76, 54, 174, .35);
  }

  .color-power {
    background: #ed5ac8;
  }

  .shots-panel {
    right: calc(50% - 280px + 12px);
    bottom: calc(16px + var(--safe-bottom));
  }

  .next-card {
    left: calc(50% + 54px);
    bottom: calc(76px + var(--safe-bottom));
  }
}


@media (max-width: 460px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    padding-inline: 9px;
  }

  .hud-pill {
    height: 44px;
    padding-right: 10px;
    border-radius: 13px;
  }

  .hud-pill img {
    width: 38px;
    height: 38px;
  }

  .score-pill {
    min-width: 112px;
  }

  .brand-logo {
    width: min(250px, 84%);
  }

  .icon-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 19px;
  }

  .top-actions {
    gap: 6px;
  }

  .power-button {
    width: 53px;
    height: 53px;
  }

  .power-button img {
    width: 42px;
    height: 42px;
  }

  .next-card {
    left: calc(50% + 44px);
    bottom: calc(70px + var(--safe-bottom));
  }
}

@media (max-height: 620px) {
  .topbar {
    min-height: calc(64px + var(--safe-top));
    padding-top: calc(6px + var(--safe-top));
    padding-bottom: 6px;
  }

  .hud-pill,
  .icon-button {
    height: 40px;
  }

  .hud-pill img,
  .icon-button {
    width: 40px;
  }

  .power-button {
    width: 48px;
    height: 48px;
  }

  .power-button img {
    width: 38px;
    height: 38px;
  }

  .next-card {
    bottom: calc(58px + var(--safe-bottom));
  }

  .levels-panel {
    width: min(96vw, 316px);
    padding: 13px;
  }

  .levels-summary {
    margin-bottom: 10px;
  }

  .level-grid {
    min-height: 280px;
    gap: 6px;
  }

  .level-tile {
    min-height: 50px;
    font-size: 16px;
  }

  .levels-pagination {
    margin-top: 10px;
  }

  .mini-bubble {
    width: 43px;
    height: 43px;
  }
}

@media (max-height: 620px) and (min-width: 500px) {
  .overlay {
    padding: 6px;
  }

  .panel {
    width: min(94vw, 430px);
    max-height: calc(100dvh - 12px);
    padding: 14px 20px;
    border-radius: 16px;
    box-shadow: 0 6px 0 #5c45bd, 0 14px 30px rgba(20, 14, 62, .3);
  }

  .menu-panel {
    width: min(100%, 400px);
    padding: 0 18px 20px;
  }

  .menu-orbs {
    height: 44px;
    margin-bottom: 0;
  }

  .menu-orbs span {
    width: 42px;
    height: 42px;
    margin: 0 -5px;
  }

  .menu-orbs span:nth-child(2) {
    transform: translateY(-7px) scale(1.05);
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 9px;
  }

  h1 {
    margin-bottom: 7px;
    font-size: 36px;
    line-height: .95;
  }

  h2 {
    margin-bottom: 10px;
    font-size: 25px;
  }

  .menu-copy {
    display: none;
  }

  .best-chip {
    height: 31px;
    margin-bottom: 9px;
  }

  .best-chip img {
    width: 25px;
    height: 25px;
  }

  .primary-button,
  .secondary-button {
    min-height: 40px;
  }

  .secondary-button,
  .text-button {
    margin-top: 7px;
  }

  .text-button {
    min-height: 32px;
  }

  .modal-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 20px;
  }

  .settings-panel {
    padding: 16px 20px 14px;
  }

  .settings-heading {
    margin-bottom: 10px;
  }

  .settings-heading-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .settings-heading h2 {
    font-size: 25px;
  }

  .volume-setting {
    padding: 8px 0 10px;
  }

  .volume-setting-head {
    margin-bottom: 7px;
  }

  .setting-row {
    min-height: 45px;
    padding: 5px 0;
  }

  .result-score {
    min-height: 48px;
    margin-bottom: 10px;
  }

  .result-score img {
    width: 36px;
    height: 36px;
  }
}

/* Smooth scene handoff */
.scene-transition {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 52%, rgba(89, 61, 184, .16), transparent 42%),
    #0b0825;
  transition: opacity .22s cubic-bezier(.4, 0, .2, 1);
  will-change: opacity;
}

.scene-transition.is-covering {
  opacity: 1;
}

.scene.scene-enter .game-shell,
.scene.scene-enter .menu-scene-content {
  animation: sceneContentIn .34s cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes sceneContentIn {
  from { opacity: 0; transform: translateY(8px) scale(.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .scene-transition { transition-duration: .01ms; }
  .scene.scene-enter .game-shell,
  .scene.scene-enter .menu-scene-content { animation: none; }
}

/* Distinct application scenes */
.scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.scene.is-active {
  display: grid;
}

.splash-scene,
.loading-scene,
.menu-scene,
.game-scene {
  place-items: center;
}

.splash-scene {
  background: #000000;
}

.splash-scene .splash-logo {
  width: min(88vw, 470px);
  margin: 0;
  animation: splashFadeInOut 1.05s ease-in-out both;
  filter: none;
}

.loading-scene,
.menu-scene {
  background: #0b0825 center / cover no-repeat;
}

.loading-scene::before,
.loading-scene::after,
.menu-scene::before,
.menu-scene::after {
  content: none;
}

.loading-content {
  width: min(86vw, 360px);
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 14px;
}

.loading-title-logo {
  width: min(74vw, 270px);
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(8, 4, 32, .22));
}

.loading-content .loading-bar {
  width: min(76vw, 285px);
  margin: 0;
}

.menu-scene {
  overflow: hidden;
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
}

.menu-scene-content {
  width: min(100%, 360px);
  height: calc(100dvh - (36px + var(--safe-top) + var(--safe-bottom)));
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0;
  padding-top: 0;
  padding-bottom: 88px;
}

.menu-studio-logo {
  width: min(24vw, 92px);
  display: block;
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 2px);
  transform: translateX(-50%);
  margin: 0;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(7, 3, 28, .22));
  opacity: .95;
}

.menu-title-block {
  width: min(100%, 340px);
  min-height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.game-title-logo {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(4, 2, 22, .24));
}

.menu-scene .menu-stats {
  width: min(100%, 330px);
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-scene .best-chip {
  width: 100%;
  height: 52px;
  margin: 0;
  justify-content: flex-start;
  padding: 4px 12px 4px 8px;
  background: rgba(237, 231, 255, .12);
  color: #f0ebff;
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-sizing: border-box;
}

.menu-scene .best-chip strong {
  margin-left: auto;
  color: #ffffff;
}

.main-menu-actions {
  width: min(100%, 330px);
  display: grid;
  gap: 11px;
}

.main-menu-actions .primary-button,
.main-menu-actions .secondary-button,
.menu-settings-button {
  width: 100%;
  min-height: 52px;
  margin: 0;
  border-radius: 15px;
}

.main-menu-actions .secondary-button {
  background: rgba(225, 216, 255, .96);
  color: var(--purple-dark);
}

.menu-settings-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.game-scene {
  background: transparent;
}

.game-scene .game-shell {
  align-self: center;
  justify-self: center;
}

@media (orientation: landscape) and (min-width: 700px) {
  .game-scene .game-shell {
    width: 100vw;
    height: 100dvh;
  }

  .menu-scene-content {
    width: min(100%, 360px);
    height: calc(100dvh - (36px + var(--safe-top) + var(--safe-bottom)));
    padding-bottom: 76px;
  }

  .menu-studio-logo {
    width: min(10vw, 80px);
    bottom: calc(var(--safe-bottom) + 2px);
  }

  .main-menu-actions,
  .menu-scene .menu-stats {
    width: min(100%, 330px);
  }
}

@media (max-height: 650px) {
  .menu-scene {
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: calc(8px + var(--safe-bottom));
  }

  .menu-scene-content {
    height: calc(100dvh - (16px + var(--safe-top) + var(--safe-bottom)));
    padding-bottom: 60px;
  }

  .menu-studio-logo {
    width: min(18vw, 64px);
  }

  .menu-title-block {
    width: min(100%, 285px);
    min-height: 72px;
    margin-bottom: 7px;
  }

  .menu-scene .menu-stats {
    margin: 6px 0 10px;
    gap: 8px;
  }

  .main-menu-actions {
    gap: 8px;
  }

  .main-menu-actions .primary-button,
  .main-menu-actions .secondary-button,
  .menu-settings-button,
  .menu-scene .best-chip {
    min-height: 42px;
    height: 42px;
  }
}

@media (max-height: 650px) {
  .loading-content {
    gap: 14px;
  }

    .loading-title-logo {
    width: min(58vw, 200px);
  }
}
