/* Gravity Drift - bright "sky glass" UI floating over the live 3D scene. Sizes are in rem; js/game.js sets the root size. */

@font-face {
  font-family: "Righteous";
  src: url(../assets/fonts/righteous-latin-400-normal.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url(../assets/fonts/outfit-latin-600-normal.woff2) format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url(../assets/fonts/outfit-latin-700-normal.woff2) format("woff2");
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --ink: #2a2468;
  --soft: #6a64a8;
  --paper: rgba(255, 255, 255, .92);
  --coral: #ff5d73;
  --orange: #ff9f1c;
  --aqua: #20c9e8;
  --violet: #7a52f5;
  --lime: #8be04e;
  --display: "Righteous", "Trebuchet MS", sans-serif;
  --ui: "Outfit", "Segoe UI", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-size: 16px;
  background: #ffd6ec;
}

body {
  font-family: var(--ui);
  font-weight: 600;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

img {
  display: block;
  -webkit-user-drag: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: var(--safe-t) 0 var(--safe-b);
  pointer-events: none;
}

.screen.active {
  display: flex;
  animation: rise .45s cubic-bezier(.2, .9, .3, 1) both;
}

.screen button,
.screen .world-card,
.modal {
  pointer-events: auto;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(1.2rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-height: 3.3rem;
  padding: .5rem 1.5rem;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 1.3rem;
  line-height: 1;
  color: #fff;
  letter-spacing: .03em;
  border: .2rem solid rgba(255, 255, 255, .95);
  box-shadow: 0 .45rem 1.1rem rgba(42, 36, 104, .28), inset 0 .15rem 0 rgba(255, 255, 255, .5);
  text-shadow: 0 .1rem .2rem rgba(42, 36, 104, .3);
  transition: transform .1s, filter .15s;
}

.btn:active {
  transform: scale(.95);
  filter: brightness(1.05);
}

.btn img {
  width: 1.55rem;
  height: 1.55rem;
}

.btn small {
  display: block;
  font-family: var(--ui);
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: .2rem;
  opacity: .95;
}

.btn-main {
  background: linear-gradient(180deg, #ff8a7a, var(--coral) 55%, #f23a72);
}

.btn-aqua {
  background: linear-gradient(180deg, #5fe3f5, var(--aqua));
}

.btn-violet {
  background: linear-gradient(180deg, #a387ff, var(--violet));
}

.btn-glass {
  background: rgba(255, 255, 255, .3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  text-shadow: none;
}

.btn-glass img {
  filter: invert(1) brightness(.18) sepia(1) hue-rotate(205deg) saturate(5);
}

.btn-glassdark {
  background: rgba(42, 36, 104, .55);
}

.btn.wide {
  width: 100%;
}

.btn.round {
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
  min-height: 0;
  font-size: 2rem;
}

.btn.round.arrow {
  padding-bottom: .3rem;
}

.btn.round img {
  width: 1.5rem;
  height: 1.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem 1rem .35rem .7rem;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 .3rem .9rem rgba(42, 36, 104, .22);
  font-weight: 800;
  font-size: 1.05rem;
}

.chip img {
  width: 1.35rem;
  height: 1.35rem;
}

.chip.small {
  font-size: .95rem;
  padding: .28rem .85rem .28rem .6rem;
}

/* ---------- loader ---------- */

#loader {
  justify-content: center;
  gap: 1rem;
  background: linear-gradient(180deg, #ffd6f2, #ffb3d9 55%, #fff1c9);
  pointer-events: auto;
}

.load-logo {
  width: 9rem;
  height: 9rem;
  animation: roll 1.4s ease-in-out infinite;
}

.load-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  line-height: .95;
  text-align: center;
}

.load-title span {
  font-size: 2.6rem;
  color: #fff;
  text-shadow: 0 .25rem 0 var(--coral);
}

.load-title b {
  font-weight: 400;
  font-size: 3.6rem;
  color: var(--coral);
  text-shadow: 0 .25rem 0 #fff;
}

.load-bar {
  width: min(70vw, 16rem);
  height: 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  overflow: hidden;
  box-shadow: 0 .2rem .6rem rgba(42, 36, 104, .2);
}

.load-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--coral), var(--orange));
  transition: width .25s;
}

@keyframes roll {
  50% {
    transform: translateY(-.8rem) rotate(8deg);
  }
}

/* ---------- menu (the 3D scene plays in the free area, the buttons sit on a glass panel) ---------- */

#menu {
  justify-content: flex-end;
}

.m-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.m-top {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 400;
  line-height: .9;
  transform: rotate(-3deg);
}

.title span {
  font-size: 3.6rem;
  color: #fff;
  letter-spacing: .06em;
  -webkit-text-stroke: .5rem var(--violet);
  paint-order: stroke fill;
  text-shadow: 0 .4rem 0 rgba(42, 36, 104, .35);
}

.title b {
  font-weight: 400;
  font-size: 6.2rem;
  color: #fff;
  background: linear-gradient(180deg, #ffb35c, var(--coral));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 .4rem 0 #fff) drop-shadow(0 .6rem .4rem rgba(42, 36, 104, .35));
  margin-top: -.5rem;
}

.tagline {
  margin: 1.1rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
  padding: .3rem 1.1rem;
  border-radius: 999px;
  background: rgba(42, 36, 104, .4);
}

.m-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
  width: min(100%, 32rem);
  padding: 1.1rem 1.3rem calc(1.4rem + var(--safe-b));
  border-radius: 2.2rem 2.2rem 0 0;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -.5rem 2rem rgba(42, 36, 104, .22), inset 0 .2rem 0 rgba(255, 255, 255, .9);
  pointer-events: auto;
}

#playBtn {
  width: 100%;
  min-height: 4.6rem;
  font-size: 2rem;
  gap: 1rem;
}

#playBtn img {
  width: 2rem;
  height: 2rem;
}

#playBtn span {
  text-align: left;
}

.m-row {
  display: flex;
  gap: .8rem;
  width: 100%;
  justify-content: center;
}

.m-row .btn:first-child {
  flex: 1;
}

.m-bottom .chip {
  box-shadow: 0 .2rem .6rem rgba(42, 36, 104, .18);
  background: #fff;
}

.ver {
  position: absolute;
  top: calc(.5rem + var(--safe-t));
  right: .9rem;
  font-size: .75rem;
  opacity: .7;
  color: #fff;
  text-shadow: 0 0 .3rem rgba(0, 0, 0, .4);
}

/* ---------- levels ---------- */

#levels {
  justify-content: flex-start;
  gap: .9rem;
  padding-left: 1rem;
  padding-right: 1rem;
  pointer-events: auto;
  background: linear-gradient(180deg, var(--w1, #ffd6f2), var(--w2, #fff1c9));
  transition: background .4s;
}

.bar {
  width: min(100%, 34rem);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding-top: .8rem;
}

.bar h2 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.7rem;
  text-align: center;
  color: var(--ink);
}

.world-card {
  width: min(100%, 34rem);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .9rem;
  border-radius: 1.8rem;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 .6rem 1.6rem rgba(42, 36, 104, .18), inset 0 0 0 .2rem rgba(255, 255, 255, .9);
}

.world-info {
  flex: 1;
  text-align: center;
}

.w-num {
  display: inline-block;
  padding: .12rem .9rem;
  border-radius: 999px;
  background: var(--acc, var(--coral));
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.world-info h3 {
  margin: .35rem 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1;
  color: var(--ink);
}

.world-info p {
  margin: .25rem 0 0;
  font-size: 1rem;
  color: var(--soft);
  font-weight: 700;
}

.dots {
  display: flex;
  gap: .5rem;
}

.dots i {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
}

.dots i.on {
  background: var(--acc, var(--coral));
  transform: scale(1.35);
}

.lv-grid {
  width: min(100%, 34rem);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(0, 6.6rem);
  gap: .9rem;
  padding-bottom: 1.2rem;
  align-content: center;
}

.lv {
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 .45rem 1rem rgba(42, 36, 104, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-family: var(--display);
  font-size: 2.3rem;
  color: var(--ink);
  transition: transform .1s;
}

.lv:active:not(.locked) {
  transform: scale(.95);
}

.lv .st {
  display: flex;
  gap: .1rem;
}

.lv .st img {
  width: 1.3rem;
  height: 1.3rem;
}

.lv.done {
  background: linear-gradient(180deg, #fff, #fff4cf);
}

.lv.next {
  background: linear-gradient(180deg, #ff8a7a, var(--coral));
  color: #fff;
  text-shadow: 0 .1rem .2rem rgba(42, 36, 104, .3);
  animation: pulse 1.5s ease-in-out infinite;
}

.lv.locked {
  background: rgba(255, 255, 255, .5);
  color: #aab;
  box-shadow: none;
  cursor: default;
}

.lv.locked img {
  width: 1.6rem;
  height: 1.6rem;
  filter: invert(.6) sepia(.3) hue-rotate(190deg);
}

@keyframes pulse {
  50% {
    transform: scale(1.05);
  }
}

/* ---------- game HUD ---------- */

#game {
  justify-content: flex-start;
  padding-left: .9rem;
  padding-right: .9rem;
}

.hud {
  width: min(100%, 40rem);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding-top: .7rem;
}

.hud-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
}

.hud-mid span {
  font-family: var(--display);
  font-size: 1.3rem;
  color: #fff;
  text-shadow: 0 .12rem .4rem rgba(42, 36, 104, .6);
}

.track-bar {
  position: relative;
  width: 100%;
  height: .85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 .15rem rgba(255, 255, 255, .9), 0 .2rem .6rem rgba(42, 36, 104, .2);
}

.track-bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--coral));
}

.track-bar em {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin: -.75rem 0 0 -.75rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #ffd9e0 60%, #ff9aa8);
  box-shadow: 0 .15rem .4rem rgba(42, 36, 104, .45);
}

.chip.gems b,
.chip.gems span {
  font-variant-numeric: tabular-nums;
}

.count {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 9rem;
  color: #fff;
  text-shadow: 0 .5rem 0 var(--coral), 0 .8rem 1.2rem rgba(42, 36, 104, .4);
  opacity: 0;
  transform: scale(.4);
  pointer-events: none;
}

.count.pop {
  animation: countPop .8s ease-out both;
}

@keyframes countPop {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  25% {
    opacity: 1;
    transform: scale(1.1);
  }
  80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

.toast {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, 0);
  padding: .5rem 1.3rem;
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--display);
  font-size: 1.4rem;
  box-shadow: 0 .4rem 1rem rgba(42, 36, 104, .25);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  animation: toast 1.4s ease both;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 1rem) scale(.8);
  }
  15%,
  75% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -1rem);
  }
}

.hint {
  position: absolute;
  bottom: calc(2rem + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.6rem;
  padding: .7rem 1.3rem;
  border-radius: 1.4rem;
  background: var(--paper);
  box-shadow: 0 .4rem 1rem rgba(42, 36, 104, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
  white-space: nowrap;
  font-weight: 800;
}

.hint.show {
  opacity: 1;
}

.hint span {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.hint img {
  width: 1.6rem;
  height: 1.6rem;
  filter: invert(1) brightness(.2) sepia(1) hue-rotate(205deg) saturate(5);
}

/* ---------- modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 36, 104, .35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  animation: fade .2s both;
}

.modal.show .card {
  animation: pop .42s cubic-bezier(.2, 1.3, .4, 1) both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    transform: scale(.7) translateY(1rem);
    opacity: 0;
  }
}

.card {
  width: min(24rem, 100%);
  max-height: calc(100% - 1rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
  padding: 1.3rem 1.2rem;
  border-radius: 2rem;
  background: #fff;
  box-shadow: 0 1.2rem 3rem rgba(42, 36, 104, .4);
  text-align: center;
}

.card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.05;
}

.card p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--soft);
  font-weight: 700;
}

.badge {
  padding: .28rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--coral));
  color: #fff;
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.badge.bad {
  background: var(--violet);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
  width: 100%;
}

.row2 .btn {
  padding: .5rem .6rem;
  font-size: 1.15rem;
}

.stars {
  display: flex;
  gap: .3rem;
  align-items: flex-end;
}

.stars img {
  width: 4rem;
  height: 4rem;
}

.stars img:nth-child(2) {
  margin-bottom: .8rem;
}

.stars img.new {
  animation: starIn .6s cubic-bezier(.2, 1.6, .4, 1) both;
}

@keyframes starIn {
  from {
    transform: scale(0) rotate(-90deg);
  }
}

.facts {
  display: flex;
  gap: .6rem;
  width: 100%;
}

.facts div {
  flex: 1;
  padding: .5rem .2rem;
  border-radius: 1rem;
  background: #f2f0ff;
}

.facts small {
  display: block;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--soft);
  font-weight: 800;
}

.facts b {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.5rem;
}

.how {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  text-align: left;
}

.how li {
  display: flex;
  gap: .8rem;
  align-items: center;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
}

.how b {
  font-weight: 800;
}

.how .n {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-style: normal;
  font-family: var(--display);
  font-size: 1.2rem;
  color: #fff;
  background: var(--coral);
}

.how li:nth-child(2) .n {
  background: var(--aqua);
}

.how li:nth-child(3) .n {
  background: var(--orange);
}

.how li:nth-child(4) .n {
  background: var(--violet);
}

.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 1.2rem;
  text-align: left;
  font-weight: 700;
}

.set-row small {
  display: block;
  font-size: .8rem;
  color: var(--soft);
  font-weight: 600;
}

.switch {
  flex: none;
  width: 3.6rem;
  height: 2rem;
  border-radius: 999px;
  background: #d8d6ee;
  position: relative;
  transition: background .15s;
}

.switch i {
  position: absolute;
  top: .2rem;
  left: .2rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 .1rem .3rem rgba(0, 0, 0, .25);
  transition: transform .15s;
}

.switch.on {
  background: var(--aqua);
}

.switch.on i {
  transform: translateX(1.6rem);
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 11;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -1rem;
  width: .7rem;
  height: 1.1rem;
  border-radius: .15rem;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

/* ---------- landscape / short screens ---------- */

@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  #menu {
    align-items: flex-start;
    justify-content: center;
    padding-left: 4vw;
  }
  .m-wrap {
    width: min(25rem, 44vw);
    height: auto;
    max-height: calc(100% - 1.6rem);
    justify-content: center;
    gap: 1.1rem;
    padding: 1.4rem 1.3rem;
    border-radius: 2.2rem;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 1rem 2.6rem rgba(42, 36, 104, .3), inset 0 .2rem 0 rgba(255, 255, 255, .9);
    pointer-events: auto;
  }
  .m-top {
    margin: 0;
  }
  .title b {
    font-size: 5rem;
    filter: drop-shadow(0 .3rem 0 var(--violet)) drop-shadow(0 .5rem .3rem rgba(42, 36, 104, .3));
  }
  .title span {
    font-size: 2.8rem;
  }
  .m-bottom {
    width: 100%;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-radius: 0;
  }
  .lv-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(0, 6rem);
    max-width: 60rem;
  }
  .bar,
  .world-card {
    max-width: 60rem;
  }
}

@media (max-height: 500px) {
  .title b {
    font-size: 4rem !important;
  }
  .title span {
    font-size: 2.2rem !important;
  }
  .tagline {
    margin-top: .5rem;
    font-size: 1rem;
  }
  .btn {
    min-height: 2.8rem;
  }
  #playBtn {
    min-height: 3.6rem;
    font-size: 1.6rem;
  }
  .lv {
    font-size: 1.4rem;
  }
  .lv .st img {
    width: 1rem;
    height: 1rem;
  }
  .world-card {
    padding: .4rem .8rem;
  }
  .card {
    padding: .9rem 1rem;
    gap: .6rem;
  }
  .stars img {
    width: 3rem;
    height: 3rem;
  }
  .count {
    font-size: 6rem;
  }
  .how {
    gap: .4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}