/* ==========================================================================
   Rhythm Robots - styles. Colours and fonts are CSS variables in :root.
   Everything is sized in em, so the whole interface scales with #app's font-size.
   ========================================================================== */
@font-face {
  font-family: 'RR Display';
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/bungee-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'RR Text';
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-500-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'RR Text';
  font-weight: 600 800;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-600-normal.woff2) format('woff2');
}

:root {
  --bg: #12062e;
  --bg-2: #1f0b4d;
  --ink: #fff;
  --soft: #b9a8f2;
  --line: rgba(255, 255, 255, 0.16);
  --pink: #ff3d9a;
  --pink-d: #b8135f;
  --cyan: #27e0ff;
  --cyan-d: #0a8fb0;
  --lime: #8cff3a;
  --lime-d: #4fa80f;
  --amber: #ffb62e;
  --amber-d: #c97800;
  --violet: #b479ff;
  --violet-d: #7a45d8;
  --font-d: 'RR Display', 'Bungee', Impact, 'Arial Black', sans-serif;
  --font-t: 'RR Text', 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.c-pink {
  --c: var(--pink);
  --cd: var(--pink-d);
}
.c-cyan {
  --c: var(--cyan);
  --cd: var(--cyan-d);
}
.c-lime {
  --c: var(--lime);
  --cd: var(--lime-d);
}
.c-amber {
  --c: var(--amber);
  --cd: var(--amber-d);
}
.c-violet {
  --c: var(--violet);
  --cd: var(--violet-d);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
}
body {
  font-family: var(--font-t);
  font-weight: 500;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
img,
canvas {
  -webkit-user-drag: none;
  user-drag: none;
}
img {
  pointer-events: none;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-size: clamp(14px, calc(9px + 1.5vmin), 21px);
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(123, 77, 255, 0.5), transparent 70%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(255, 61, 154, 0.2), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(39, 224, 255, 0.18), transparent 70%), var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen {
  position: absolute;
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: none;
}
.screen.active {
  display: flex;
  animation: screenin 0.35s ease-out;
}
@keyframes screenin {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------- loading */
.loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1em;
}
.load-bots {
  display: flex;
  gap: 0.3em;
}
.load-bots img {
  width: 4.6em;
  height: 4.6em;
  animation: bop 0.5s ease-in-out infinite alternate;
}
.load-bots img:nth-child(2) {
  animation-delay: 0.12s;
}
.load-bots img:nth-child(3) {
  animation-delay: 0.24s;
}
.load-bots img:nth-child(4) {
  animation-delay: 0.36s;
}
@keyframes bop {
  to {
    transform: translateY(-0.55em) rotate(3deg);
  }
}
.load-title {
  font: 400 2.1em/1 var(--font-d);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 0.25em var(--pink),
    0 0 0.7em var(--pink);
}
.load-bar {
  width: min(70vw, 16em);
  height: 0.8em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  border: 0.12em solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.load-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  transition: width 0.2s;
}

/* ---------------------------------------------------------------- buttons */
.rb {
  /* round icon button */
  position: relative;
  flex: none;
  width: 2.9em;
  height: 2.9em;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  border: 0.12em solid var(--c, var(--cyan));
  box-shadow:
    0 0 0.7em color-mix(in srgb, var(--c, var(--cyan)) 55%, transparent),
    inset 0 0 0.5em rgba(255, 255, 255, 0.08);
  transition: transform 0.1s;
}
.rb img {
  width: 52%;
  height: 52%;
}
.rb:active:not(:disabled) {
  transform: scale(0.92);
}
.rb:disabled {
  opacity: 0.35;
}
.arr {
  flex: none;
  width: 2.4em;
  height: 2.4em;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.1s;
}
.arr img {
  width: 56%;
  height: 56%;
  opacity: 0.9;
}
.arr:active:not(:disabled) {
  transform: scale(0.9);
}
.arr:disabled {
  opacity: 0.22;
}

.nb {
  /* neon pill button */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 2.9em;
  padding: 0.4em 1.1em;
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border: 0.13em solid var(--c);
  color: #fff;
  font: 400 0.95em/1 var(--font-d);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 0 0.5em var(--c);
  box-shadow:
    0 0 0.8em color-mix(in srgb, var(--c) 50%, transparent),
    inset 0 0 0.6em rgba(255, 255, 255, 0.06);
  transition: transform 0.1s;
}
.nb img {
  width: 1.35em;
  height: 1.35em;
  flex: none;
}
.nb.round {
  width: 2.9em;
  padding: 0;
}
.nb.round img {
  width: 1.4em;
  height: 1.4em;
}
.nb:active:not(:disabled) {
  transform: scale(0.95);
}

.tbtn {
  /* solid button used in popups */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 2.8em;
  padding: 0.35em 1.1em;
  border: 0.13em solid #fff;
  border-radius: 0.9em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 40%, var(--cd));
  color: #fff;
  font: 400 0.95em/1 var(--font-d);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 0.08em 0 rgba(0, 0, 0, 0.35);
  box-shadow:
    0 0.28em 0 var(--cd),
    0 0.45em 0.8em rgba(0, 0, 0, 0.35);
  transition: transform 0.1s;
  white-space: nowrap;
}
.tbtn img {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}
.tbtn.small {
  min-height: 2.2em;
  padding: 0.25em 0.8em;
  font-size: 0.8em;
}
.tbtn:active:not(:disabled) {
  transform: translateY(0.14em);
  box-shadow: 0 0.14em 0 var(--cd);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.35em 0.8em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  border: 0.12em solid var(--line);
  font: 400 1em/1 var(--font-d);
}
.star {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}
.star.on {
  fill: #ffd23c;
  filter: drop-shadow(0 0 0.25em rgba(255, 210, 60, 0.8));
}
.star.off {
  fill: rgba(255, 255, 255, 0.16);
}

/* ---------------------------------------------------------------- main menu */
.menu {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.beams {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.beams i {
  position: absolute;
  top: -8%;
  width: 46%;
  height: 88%;
  transform-origin: 50% 0;
  clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);
  opacity: 0.55;
  animation: sweep 7s ease-in-out infinite alternate;
}
.beams i:nth-child(1) {
  left: -6%;
  background: linear-gradient(180deg, rgba(255, 61, 154, 0.55), transparent 85%);
}
.beams i:nth-child(2) {
  left: 27%;
  background: linear-gradient(180deg, rgba(39, 224, 255, 0.5), transparent 85%);
  animation-delay: -2.3s;
  animation-duration: 9s;
}
.beams i:nth-child(3) {
  right: -6%;
  background: linear-gradient(180deg, rgba(255, 182, 46, 0.5), transparent 85%);
  animation-delay: -4.5s;
}
@keyframes sweep {
  from {
    transform: rotate(-9deg);
  }
  to {
    transform: rotate(9deg);
  }
}

.m-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.2em 1em 0;
}
.m-eq {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 14%;
  height: 46%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.25em;
  opacity: 0.55;
}
.m-eq i {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-radius: 0.3em 0.3em 0 0;
  background: linear-gradient(180deg, var(--k), transparent);
  animation: eq 1.2s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}
@keyframes eq {
  from {
    transform: scaleY(0.18);
  }
  to {
    transform: scaleY(1);
  }
}
.m-bots {
  position: relative;
  z-index: 2;
  width: min(100%, 40em);
  height: 100%;
  max-height: 20em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
}
.mb {
  flex: 0 0 31%;
  margin: 0 -2.5%;
  min-width: 0;
  max-height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  transform-origin: 50% 100%;
  animation: groove 0.5s ease-in-out infinite alternate;
  filter: drop-shadow(0 0.4em 0.5em rgba(0, 0, 0, 0.4));
}
.mb.b1 {
  animation-delay: -0.12s;
}
.mb.b2 {
  animation-delay: -0.25s;
}
.mb.b3 {
  animation-delay: -0.37s;
}
.mb.b0,
.mb.b2 {
  margin-bottom: 0;
}
.mb.b1,
.mb.b3 {
  margin-bottom: 1.2em;
}
@keyframes groove {
  from {
    transform: translateY(0) rotate(-2deg) scale(1, 0.96);
  }
  to {
    transform: translateY(-0.7em) rotate(2deg) scale(1, 1.03);
  }
}
.m-floor {
  position: absolute;
  z-index: 1;
  left: 4%;
  right: 4%;
  bottom: 0;
  height: 1.2em;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 0, rgba(255, 61, 154, 0.75), rgba(123, 77, 255, 0.3) 55%, transparent 75%);
  filter: blur(0.1em);
}

.m-info {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65em;
  padding: 1.1em 1em 1em;
  text-align: center;
}
.logo {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font: 400 3em/0.95 var(--font-d);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.logo span {
  display: block;
}
.logo .l1 {
  color: #fff;
  text-shadow:
    0 0 0.15em #fff,
    0 0 0.4em var(--pink),
    0 0 0.9em var(--pink),
    0 0.06em 0 var(--pink-d);
}
.logo .l2 {
  color: #fff;
  text-shadow:
    0 0 0.15em #fff,
    0 0 0.4em var(--cyan),
    0 0 0.9em var(--cyan),
    0 0.06em 0 var(--cyan-d);
  animation: flick 5s steps(1) infinite;
}
@keyframes flick {
  0%,
  92%,
  96%,
  100% {
    opacity: 1;
  }
  94%,
  98% {
    opacity: 0.62;
  }
}
.tagline {
  margin: 0;
  font-size: 1.02em;
  color: var(--soft);
  font-weight: 600;
}

.playb {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9em;
  width: min(100%, 20em);
  margin-top: 0.35em;
  padding: 0.7em 1.1em;
  border: 0.16em solid #ffd0e8;
  border-radius: 1.3em;
  text-align: left;
  background: linear-gradient(180deg, #ff6bb5, var(--pink) 45%, #d81d78);
  color: #fff;
  box-shadow:
    0 0.38em 0 var(--pink-d),
    0 0 1.6em rgba(255, 61, 154, 0.65);
  transition: transform 0.1s;
  animation: throb 1s ease-in-out infinite alternate;
}
@keyframes throb {
  to {
    box-shadow:
      0 0.38em 0 var(--pink-d),
      0 0 2.4em rgba(255, 61, 154, 0.95);
  }
}
.playb:active {
  transform: translateY(0.2em);
  box-shadow:
    0 0.18em 0 var(--pink-d),
    0 0 1.4em rgba(255, 61, 154, 0.6);
  animation: none;
}
.playb > img {
  width: 2.1em;
  height: 2.1em;
  flex: none;
  margin-left: auto;
  filter: drop-shadow(0 0.08em 0 rgba(0, 0, 0, 0.25));
}
.eqi {
  display: flex;
  align-items: flex-end;
  gap: 0.16em;
  height: 2.2em;
  flex: none;
}
.eqi b {
  display: block;
  width: 0.34em;
  height: 100%;
  border-radius: 0.14em;
  background: #fff;
  transform-origin: 50% 100%;
  animation: eq 0.6s ease-in-out infinite alternate;
  opacity: 0.92;
}
.eqi b:nth-child(2) {
  animation-delay: -0.2s;
}
.eqi b:nth-child(3) {
  animation-delay: -0.4s;
  animation-duration: 0.45s;
}
.eqi b:nth-child(4) {
  animation-delay: -0.1s;
}
.pl-t {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  min-width: 0;
}
.pl-t b {
  font: 400 1.7em/1 var(--font-d);
  text-transform: uppercase;
  text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.pl-t small {
  font: 600 0.82em/1.15 var(--font-t);
  color: #ffe3f1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  flex-wrap: wrap;
}
.m-prog {
  width: min(100%, 20em);
  display: grid;
  gap: 0.35em;
  font-size: 0.82em;
  color: var(--soft);
  font-weight: 600;
}
.m-prog .bar {
  height: 0.55em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.m-prog .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  transition: width 0.4s;
}
.m-prog .star {
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.18em;
}

/* wide screens: the band fills the left, title and buttons on the right */
@media (min-aspect-ratio: 5/4) {
  .menu {
    flex-direction: row;
    font-size: clamp(14px, 2.7vmin + 4px, 36px);
  }
  .m-stage {
    flex: 1.15 1 0;
    padding: 1.4em 1em 0 1.4em;
  }
  .m-bots {
    max-height: min(100%, 26em);
  }
  .m-info {
    flex: 1 1 0;
    min-width: 0;
    align-self: center;
    justify-content: center;
    padding: 1em 1.4em;
    gap: 0.8em;
  }
  .logo {
    font-size: 3.1em;
  }
}
@media (min-aspect-ratio: 5/4) and (max-height: 460px) {
  .m-info {
    gap: 0.45em;
    padding: 0.6em 1em;
  }
  .logo {
    font-size: 2.3em;
  }
  .tagline {
    display: none;
  }
  .m-prog {
    display: none;
  }
  .playb {
    padding: 0.5em 0.9em;
    margin-top: 0;
  }
  .m-stage {
    padding-top: 0.6em;
  }
  .m-row {
    flex-wrap: nowrap;
    gap: 0.4em;
  }
  .nb {
    padding: 0.3em 0.8em;
    font-size: 0.85em;
    min-height: 2.6em;
  }
  .nb.round {
    width: 2.6em;
    padding: 0;
  }
}
@media (max-aspect-ratio: 5/4) and (max-height: 640px) {
  .logo {
    font-size: 2.3em;
  }
  .m-info {
    gap: 0.45em;
    padding-top: 0.6em;
  }
  .m-prog {
    display: none;
  }
  .m-bots {
    max-height: 12em;
  }
}
@media (max-aspect-ratio: 5/4) and (max-height: 520px) {
  .tagline {
    display: none;
  }
  .logo {
    font-size: 1.9em;
  }
}
@media (max-width: 350px) {
  .logo {
    font-size: 2.4em;
  }
  .v-t h2 {
    font-size: 0.8em;
    letter-spacing: 0;
    white-space: normal;
  }
  .pill {
    padding: 0.3em 0.55em;
  }
  .lv-head .rb {
    width: 2.4em;
    height: 2.4em;
  }
  .arr {
    width: 1.7em;
    height: 1.7em;
  }
  .lv-head {
    gap: 0.4em;
    padding-left: 0.5em;
    padding-right: 0.5em;
  }
}

/* ---------------------------------------------------------------- song select */
.levels {
  flex-direction: column;
  padding-top: 0.2em;
}
.lv-head {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.7em 0.9em 0.2em;
  flex: none;
}
.venue {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
}
.v-t {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.1;
}
.v-t h2 {
  margin: 0;
  font: 400 1.35em/1.05 var(--font-d);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow:
    0 0 0.5em var(--wc, var(--pink)),
    0 0 0.15em var(--wc, var(--pink));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v-t small {
  display: block;
  margin-top: 0.2em;
  font-size: 0.82em;
  color: var(--soft);
  font-weight: 600;
}
.v-dots {
  display: flex;
  justify-content: center;
  gap: 0.55em;
  padding: 0.35em 0 0.15em;
  flex: none;
}
.v-dots button {
  width: 0.7em;
  height: 0.7em;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: transform 0.15s;
}
.v-dots button.on {
  background: var(--wc, var(--pink));
  transform: scale(1.5);
  box-shadow: 0 0 0.6em var(--wc, var(--pink));
}
.crate {
  flex: 1;
  min-height: 0;
  margin: 0.45em 0.9em 0.3em;
  padding: 0.8em 0.6em;
  border-radius: 1.3em;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 0.13em solid var(--line);
  box-shadow: inset 0 0.3em 1em rgba(0, 0, 0, 0.35);
}
.lv-grid {
  width: 100%;
  max-width: 62em;
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 5), minmax(0, 1fr));
}
.disc {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  padding: 0;
  border: 0;
  background: none;
  transition: transform 0.1s;
}
.disc:active {
  transform: scale(0.93);
}
.vinyl {
  position: relative;
  flex: none;
  width: var(--s, 3.4em);
  height: var(--s, 3.4em);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0.2em 0.3em rgba(0, 0, 0, 0.5));
}
.rec {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 0.08em solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle, var(--wc) 0 26%, #0b0418 27% 30%, transparent 31%),
    conic-gradient(
      from 20deg,
      rgba(255, 255, 255, 0),
      rgba(255, 255, 255, 0.22) 8%,
      rgba(255, 255, 255, 0) 22%,
      rgba(255, 255, 255, 0) 50%,
      rgba(255, 255, 255, 0.22) 58%,
      rgba(255, 255, 255, 0) 72%
    ),
    repeating-radial-gradient(circle, #1a0f33 0 0.12em, #261845 0.12em 0.24em);
}
.vinyl b {
  grid-area: 1 / 1;
  z-index: 1;
  font: 400 calc(var(--s, 3.4em) * 0.3)/1 var(--font-d);
  color: #fff;
  text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.45);
}
.vinyl b .lk {
  width: 1em;
  height: 1em;
}
.disc .st {
  display: flex;
  gap: 0.06em;
  height: 0.95em;
}
.disc .st .star {
  width: 0.85em;
  height: 0.85em;
}
.disc.current .rec {
  animation: spin 2.4s linear infinite;
}
.disc.current .vinyl {
  filter: drop-shadow(0 0 0.7em var(--wc));
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.disc.locked .rec {
  filter: grayscale(1) brightness(0.6);
}
.disc.locked .vinyl b {
  opacity: 0.75;
}
.lv-sub {
  margin: 0;
  padding: 0 1em 0.8em;
  text-align: center;
  font-size: 0.85em;
  color: var(--soft);
  font-weight: 600;
  flex: none;
}

/* ---------------------------------------------------------------- game */
.game {
  flex-direction: column;
}
.hud {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.6em 0.8em 0.15em;
  flex: none;
}
.song {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.1;
}
.song b {
  display: block;
  font: 400 1.05em/1.1 var(--font-d);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 0.5em var(--wc, var(--pink));
}
.song span {
  display: block;
  font-size: 0.78em;
  color: var(--soft);
  font-weight: 600;
}
.stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3em 1em;
  padding: 0.1em 1em 0.35em;
  flex: none;
}
.st-b {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.st-b small {
  font-size: 0.62em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 700;
}
.st-b b {
  font: 400 1.5em/1.1 var(--font-d);
  min-width: 3.4em;
}
.st-b.combo {
  align-items: center;
  margin-left: auto;
  margin-right: auto;
}
.st-b.combo b {
  min-width: 2.2em;
  text-align: center;
  color: var(--amber);
  text-shadow: 0 0 0.4em rgba(255, 182, 46, 0.6);
  transition: transform 0.1s;
}
.st-b.combo.hot b {
  color: #fff;
  text-shadow:
    0 0 0.25em #fff,
    0 0 0.7em var(--pink);
}
.st-b.combo b.pop {
  transform: scale(1.35);
}
.meter {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.meter small {
  font-size: 0.62em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 700;
}
.m-bar {
  flex: 1;
  height: 0.75em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  border: 0.1em solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.m-bar i {
  display: block;
  height: 100%;
  width: 60%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--amber), var(--lime));
  background-size: 100vw 100%;
  transition: width 0.25s;
}
.meter.low .m-bar i {
  background: #ff4466;
  animation: lowp 0.5s ease-in-out infinite alternate;
}
@keyframes lowp {
  to {
    opacity: 0.45;
  }
}

.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: var(--sw, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, var(--bh, 4.5em)) minmax(0, 1fr);
}
.road {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  min-height: 0;
  touch-action: none;
}
.road canvas {
  position: absolute;
  left: 0;
  top: 0;
  touch-action: none;
}
.rbt {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding-bottom: 0.1em;
}
.rbt img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 0.5em color-mix(in srgb, var(--rc) 55%, transparent));
}
.rbt.r0 {
  grid-column: 1;
  grid-row: 1;
  --rc: var(--pink);
}
.rbt.r1 {
  grid-column: 2;
  grid-row: 1;
  --rc: var(--cyan);
}
.rbt.r2 {
  grid-column: 3;
  grid-row: 1;
  --rc: var(--lime);
}
.rbt.r3 {
  grid-column: 4;
  grid-row: 1;
  --rc: var(--amber);
}
.rbt.hit img {
  animation: rhit 0.22s ease-out;
}
.rbt.oops img {
  animation: roops 0.3s ease-in-out;
}
.rbt.dance img {
  animation: groove 0.5s ease-in-out infinite alternate;
}
@keyframes rhit {
  0% {
    transform: scale(1.1, 0.9);
  }
  40% {
    transform: translateY(-0.5em) scale(0.95, 1.08);
    filter: drop-shadow(0 0 1em var(--rc)) brightness(1.3);
  }
  100% {
    transform: none;
  }
}
@keyframes roops {
  0%,
  100% {
    transform: none;
  }
  25% {
    transform: translateX(-0.25em) rotate(-4deg);
  }
  75% {
    transform: translateX(0.25em) rotate(4deg);
  }
}

/* tall screens: more room for the band; wide screens: two robots on each side of the highway */
@media (min-aspect-ratio: 11/10) {
  .game.active {
    display: grid;
  }
  .game {
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.5fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'back song stats pause' 'stage stage stage stage';
    align-items: center;
  }
  .hud {
    display: contents;
  }
  #btnGameLevels {
    grid-area: back;
    margin: 0.6em 0 0 0.8em;
  }
  .song {
    grid-area: song;
    padding: 0.6em 0.5em 0;
  }
  #btnPause {
    grid-area: pause;
    margin: 0.6em 0.8em 0 0;
  }
  .stats {
    grid-area: stats;
    flex-wrap: nowrap;
    padding: 0.6em 0.5em 0;
    gap: 0.8em;
  }
  .meter {
    flex: 1 1 0;
    min-width: 6em;
  }
  .stage {
    grid-area: stage;
    width: 100%;
    height: 100%;
    grid-template-columns: minmax(0, 1fr) var(--rw, 22em) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .road {
    grid-column: 2;
    grid-row: 1 / 3;
  }
  .rbt {
    padding: 0.3em 0.6em;
  }
  .rbt.r0 {
    grid-column: 1;
    grid-row: 1;
  }
  .rbt.r1 {
    grid-column: 1;
    grid-row: 2;
  }
  .rbt.r2 {
    grid-column: 3;
    grid-row: 1;
  }
  .rbt.r3 {
    grid-column: 3;
    grid-row: 2;
  }
  .rbt img {
    max-height: min(100%, 15em);
  }
}

/* ---------------------------------------------------------------- popups, toast, confetti */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(8, 2, 22, 0.72);
  animation: fadein 0.2s;
}
@keyframes fadein {
  from {
    opacity: 0;
  }
}
.modal {
  width: min(94vw, 27em);
  max-height: 94%;
  overflow: auto;
  padding: 1.2em 1.3em 1.15em;
  border-radius: 1.5em;
  text-align: center;
  background: linear-gradient(180deg, #2c1066, #1a0845);
  border: 0.16em solid var(--cyan);
  box-shadow:
    0 0 1.6em rgba(39, 224, 255, 0.45),
    0 0.6em 2em rgba(0, 0, 0, 0.55);
  animation: modalin 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes modalin {
  from {
    transform: scale(0.85) translateY(10px);
    opacity: 0;
  }
}
.modal h2 {
  margin: 0 0 0.5em;
  font: 400 1.6em/1.05 var(--font-d);
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 0.4em var(--pink),
    0 0 0.15em var(--pink);
}
.modal-body {
  text-align: left;
}
.modal-btns {
  display: flex;
  gap: 0.55em;
  justify-content: center;
  margin-top: 1em;
  flex-wrap: wrap;
}
.modal-btns .tbtn {
  padding: 0.35em 0.9em;
  font-size: 0.9em;
}
.about {
  margin: 0.9em 0 0;
  font-size: 0.75em;
  color: var(--soft);
}
.row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  padding: 0.55em 0;
  border-bottom: 0.08em solid var(--line);
  font-weight: 600;
}
.row-toggle:last-child {
  border-bottom: 0;
}
.row-toggle > span {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}
.row-toggle > span img {
  width: 1.5em;
  height: 1.5em;
}
.switch {
  position: relative;
  width: 3.1em;
  height: 1.75em;
  padding: 0;
  border: 0.1em solid rgba(255, 255, 255, 0.35);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  left: 0.15em;
  top: 0.15em;
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch[aria-checked='true'] {
  background: var(--lime);
  border-color: #fff;
}
.switch[aria-checked='true']::after {
  transform: translateX(1.35em);
}
.sync {
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.sync .rb {
  --d: 2.2em;
  width: 2.2em;
  height: 2.2em;
}
.sync b {
  min-width: 4.4em;
  text-align: center;
  font: 400 0.95em/1 var(--font-d);
}
.hint-t {
  margin: 0.1em 0 0;
  font-size: 0.78em;
  color: var(--soft);
  font-weight: 500;
  line-height: 1.3;
}

.how {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55em;
}
.how li {
  display: flex;
  align-items: center;
  gap: 0.75em;
  font-weight: 600;
  font-size: 0.95em;
  line-height: 1.25;
}
.how .chip {
  flex: none;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 0.1em solid var(--line);
}
.how .chip img {
  width: 76%;
  height: 76%;
}
.how .chip svg {
  width: 70%;
  height: 70%;
}

.win {
  position: relative;
}
.win-bot {
  width: 5.4em;
  height: 5.4em;
  margin: -0.4em auto 0;
  display: block;
  animation: groove 0.5s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 0.8em rgba(255, 61, 154, 0.7));
}
.win-sub {
  margin: -0.2em 0 0.4em;
  color: var(--soft);
  font-weight: 600;
}
.win-stars {
  display: flex;
  justify-content: center;
  gap: 0.3em;
  margin: 0.2em 0 0.5em;
}
.win-stars .star {
  width: 3em;
  height: 3em;
  transform: scale(0);
  animation: starin 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) forwards;
}
.win-stars .star:nth-child(1) {
  animation-delay: 0.2s;
}
.win-stars .star:nth-child(2) {
  animation-delay: 0.45s;
  margin-top: -0.5em;
}
.win-stars .star:nth-child(3) {
  animation-delay: 0.7s;
}
@keyframes starin {
  to {
    transform: scale(1);
  }
}
.res {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5em;
  margin: 0.5em 0 0.2em;
}
.res div {
  padding: 0.45em 0.2em;
  border-radius: 0.8em;
  background: rgba(255, 255, 255, 0.07);
  border: 0.08em solid var(--line);
  line-height: 1.1;
}
.res small {
  display: block;
  font-size: 0.62em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 700;
}
.res b {
  font: 400 1.15em/1.25 var(--font-d);
}
.res .wide {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.res .wide span {
  display: block;
}
.res .p {
  color: #ffe45c;
}
.res .g {
  color: #9ff0ff;
}
.res .m {
  color: #ff6b8a;
}
.newbest {
  display: inline-block;
  margin: 0.1em 0 0.3em;
  padding: 0.25em 0.8em;
  border-radius: 99px;
  background: var(--amber);
  color: #3a1d00;
  font: 400 0.72em/1 var(--font-d);
  text-transform: uppercase;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 12%;
  z-index: 60;
  max-width: 86vw;
  padding: 0.6em 1.1em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.95);
  color: #2a0f5e;
  font-weight: 700;
  font-size: 0.95em;
  text-align: center;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  box-shadow: 0 0.3em 1em rgba(0, 0, 0, 0.4);
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.confetti {
  position: fixed;
  top: -20px;
  z-index: 55;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to {
    transform: translateY(110vh) rotate(var(--rot));
    opacity: 0.9;
  }
}

@media (min-aspect-ratio: 5/4) and (max-height: 460px) {
  .modal {
    max-height: 94vh;
    padding: 0.8em 1em;
  }
  .win-bot {
    width: 3.4em;
    height: 3.4em;
    margin-top: -0.3em;
  }
  .win-stars .star {
    width: 2.2em;
    height: 2.2em;
  }
  .res {
    margin: 0.3em 0 0;
  }
  .modal h2 {
    font-size: 1.25em;
    margin-bottom: 0.3em;
  }
  .modal-btns {
    margin-top: 0.6em;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
  }
}
