:root {
  --y: #ffd800;
  --y2: #e8c300;
  --k: #1e1e1e;
  --k2: #2a2c31;
  --ink: #f5f6f8;
  --mute: #a9afb8;
  --glass: rgba(22, 24, 29, 0.84);
  --glass2: rgba(36, 39, 46, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --good: #34b37a;
  --bad: #e2364b;
  --blue: #3fa9f5;
  --r: 18px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  --slab: 'Roboto Slab', Georgia, serif;
}

[hidden] {
  display: none !important;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #101114;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

input {
  user-select: text;
  -webkit-user-select: text;
}

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

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

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

#shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(10, 11, 14, 0.78) 0%, rgba(10, 11, 14, 0.45) 38%, rgba(10, 11, 14, 0) 70%);
  opacity: 0;
  transition: opacity 0.5s;
}

#shade.on {
  opacity: 1;
}

#shade.full {
  opacity: 1;
  background: rgba(10, 11, 14, 0.55);
}

#layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#layer > * {
  pointer-events: auto;
}

/* ---------------------------------------------------------------- boot */
#boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 28px;
  background: radial-gradient(circle at 50% 40%, #2a2c31, #111215 70%);
  z-index: 50;
  transition: opacity 0.5s;
}

#boot.gone {
  opacity: 0;
  pointer-events: none;
}

.boot-logo {
  width: min(280px, 60vw);
}

.boot-bar {
  width: 180px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.boot-bar i {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--y);
  border-radius: 4px;
  animation: boot 1.1s ease-in-out infinite;
}

@keyframes boot {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

/* ---------------------------------------------------------------- common */
.panel {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 14px;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--glass2);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: transform 0.08s, background 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(2px) scale(0.98);
}

.btn:focus-visible,
.chip:focus-visible,
.tab:focus-visible {
  outline: 3px solid var(--y);
  outline-offset: 2px;
}

.btn.primary {
  background: linear-gradient(180deg, #ffe34a, var(--y) 55%, var(--y2));
  color: var(--k);
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 6px 0 #b39500, 0 14px 30px rgba(255, 216, 0, 0.28);
}

.btn.primary:active {
  box-shadow: 0 3px 0 #b39500, 0 8px 18px rgba(255, 216, 0, 0.2);
}

.btn.big {
  min-height: 72px;
  font-size: 34px;
  padding: 0 44px;
  border-radius: 18px;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn.small {
  min-height: 38px;
  font-size: 16px;
  padding: 0 14px;
  border-radius: 11px;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn svg,
.chip svg {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

.link {
  color: var(--y);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  font-size: 15px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}

.chip .bolt {
  color: var(--y);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn.off {
  opacity: 0.5;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--mute);
}

.field {
  width: 100%;
  height: 56px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: 600 20px var(--font);
  padding: 0 18px;
  outline: none;
  transition: border-color 0.2s;
}

.field:focus {
  border-color: var(--y);
}

.error {
  color: #ff8a96;
  min-height: 22px;
  font-size: 15px;
  font-weight: 600;
}

.yellow {
  color: var(--y);
}

/* ---------------------------------------------------------------- screens */
.screen {
  position: absolute;
  inset: 0;
  padding: calc(16px + var(--safe-t)) calc(20px + var(--safe-r)) calc(16px + var(--safe-b)) calc(20px + var(--safe-l));
  animation: fadein 0.35s ease both;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* ---- home */
.home {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar .right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar .logo {
  height: 40px;
}

.home-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  max-width: 560px;
}

.title {
  font-family: var(--slab);
  font-weight: 800;
  font-size: clamp(46px, 8.5vw, 96px);
  line-height: 0.92;
  letter-spacing: -0.01em;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

.title span {
  color: var(--y);
}

.title small {
  display: block;
  font-family: var(--cond);
  font-size: 0.26em;
  letter-spacing: 0.32em;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.85;
  margin-bottom: 8px;
}

.tagline {
  font-size: clamp(15px, 1.8vw, 19px);
  color: #dfe3e8;
  max-width: 440px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.play-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  flex-wrap: wrap;
  margin-top: 6px;
}

.daily-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 72px;
  padding: 8px 18px;
  border-radius: 18px;
  text-align: left;
  background: rgba(20, 22, 26, 0.75);
  border: 1px solid rgba(255, 216, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.daily-btn b {
  font-family: var(--cond);
  font-weight: 800;
  font-size: 21px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.daily-btn b svg {
  width: 20px;
  height: 20px;
  color: var(--y);
}

.daily-btn span {
  font-size: 13px;
  color: var(--mute);
}

.nav-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.home-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  font-size: 13px;
  color: #c9ced6;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.home-foot .ver {
  opacity: 0.6;
}

.best-card {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(20, 22, 26, 0.62);
  border: 1px solid var(--line);
  width: fit-content;
}

.best-card div {
  display: flex;
  flex-direction: column;
}

.best-card small {
  font-size: 12px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.best-card b {
  font-family: var(--cond);
  font-size: 24px;
  font-weight: 800;
}

/* ---- modal-ish full panels */
.sheet {
  position: absolute;
  inset: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  display: grid;
  grid-template-rows: auto 1fr;
  max-width: 980px;
  margin: 0 auto;
  overflow: hidden;
  animation: fadein 0.3s ease both;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 28px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-head h2 svg {
  width: 26px;
  height: 26px;
  color: var(--y);
}

.sheet-body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 12px;
}

.tab {
  padding: 8px 14px;
  border-radius: 9px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 17px;
  color: var(--mute);
  white-space: nowrap;
}

.tab.on {
  background: var(--y);
  color: var(--k);
}

/* ---- onboarding */
.onboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  align-items: center;
  gap: 24px;
  max-width: 1050px;
  margin: 0 auto;
}

.onboard .hero-wrap {
  display: grid;
  place-items: center;
}

.onboard canvas.portrait {
  width: min(420px, 38vw);
  height: min(420px, 38vw);
}

.onboard .panel {
  padding: 26px;
  display: grid;
  gap: 14px;
}

.onboard h1 {
  font-size: 34px;
  line-height: 1.05;
}

.onboard .logo {
  height: 42px;
  justify-self: start;
}

.code-box {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(32px, 6vw, 46px);
  letter-spacing: 0.08em;
  text-align: center;
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 216, 0, 0.1);
  border: 2px dashed var(--y);
  color: var(--y);
  user-select: all;
  -webkit-user-select: all;
}

/* ---- HUD */
/* ---- touch controls (icons only; taps go to the canvas zones) */
.touch-ctl {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.touch-ctl .split {
  position: absolute;
  top: 22%;
  bottom: 10%;
  left: 35%;
  border-left: 2px dashed rgba(255, 255, 255, 0.2);
}

.touch-ctl .ctl {
  position: absolute;
  bottom: calc(16px + var(--safe-b));
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.touch-ctl .ctl svg {
  width: 54px;
  height: 54px;
  overflow: visible;
}

.touch-ctl .ctl small {
  position: absolute;
  top: -19px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.touch-ctl .ctl.left {
  left: calc(18px + var(--safe-l));
}

.touch-ctl .ctl.right {
  right: calc(18px + var(--safe-r));
}

.touch-ctl .ctl.on {
  animation: ctlPress 0.28s ease-out;
}

@keyframes ctlPress {
  0% {
    transform: scale(0.88);
    background: rgba(255, 216, 0, 0.45);
    border-color: #ffd800;
  }
  100% {
    transform: scale(1);
  }
}

.touch-ctl.faint .ctl {
  opacity: 0.45;
}

.touch-ctl.faint .split,
.touch-ctl.faint small {
  display: none;
}

@media (max-height: 380px) {
  .touch-ctl .ctl {
    width: 62px;
    height: 62px;
  }
  .touch-ctl .ctl svg {
    width: 46px;
    height: 46px;
  }
}

/* ---- ability buttons (shield above slide, jetpack above jump) */
.abilities .ab {
  position: absolute;
  bottom: calc(16px + var(--safe-b));
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.4);
  opacity: 0.75;
  transition: opacity 0.25s ease;
}

.abilities.touch .ab {
  bottom: calc(132px + var(--safe-b));
}

.abilities .ab.shield {
  left: calc(24px + var(--safe-l));
}

.abilities .ab.jet {
  right: calc(24px + var(--safe-r));
}

.abilities .ab .ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.abilities .ab > svg:not(.ring) {
  width: 34px;
  height: 34px;
  opacity: 0.55;
}

.abilities .ab small {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.abilities .ab kbd {
  position: absolute;
  bottom: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font: 700 12px/18px var(--cond);
  text-align: center;
}

.abilities .ab.ready {
  opacity: 1;
  background: rgba(255, 216, 0, 0.28);
  box-shadow: 0 0 18px rgba(255, 216, 0, 0.75);
  animation: abReady 1.2s ease-in-out infinite;
}

.abilities .ab.ready > svg:not(.ring) {
  opacity: 1;
}

.abilities .ab.active {
  opacity: 1;
  background: rgba(159, 227, 255, 0.35);
  box-shadow: 0 0 18px rgba(159, 227, 255, 0.8);
}

.abilities .ab.on {
  animation: ctlPress 0.28s ease-out;
}

@keyframes abReady {
  50% {
    transform: scale(1.08);
  }
}

@media (max-height: 380px) {
  .abilities .ab {
    width: 54px;
    height: 54px;
  }
  .abilities.touch .ab {
    bottom: calc(108px + var(--safe-b));
  }
  .abilities .ab > svg:not(.ring) {
    width: 28px;
    height: 28px;
  }
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px;
}

.hud-score {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-score .num {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}

.mult {
  font-family: var(--cond);
  font-weight: 800;
  font-size: 22px;
  min-width: 46px;
  height: 34px;
  padding: 0 9px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--y);
  color: var(--k);
  box-shadow: 0 3px 0 #b39500;
}

.mult.bump {
  animation: pop 0.4s ease;
}

.mult.double {
  background: var(--good);
  color: #fff;
  box-shadow: 0 3px 0 #1f7a52;
}

.hud-route {
  min-width: min(420px, 42vw);
  padding: 7px 14px 9px;
  border-radius: 14px;
  background: rgba(20, 22, 26, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud-route .names {
  display: flex;
  justify-content: space-between;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 16px;
  gap: 10px;
}

.hud-route .names .next {
  color: var(--mute);
}

.hud-route .bar {
  position: relative;
  height: 6px;
  margin-top: 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
}

.hud-route .bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 6px;
  background: var(--y);
}

.hud-route .bar b {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--y);
}

.hud-route .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  font-size: 13px;
  color: var(--mute);
}

.stars {
  display: inline-flex;
  gap: 3px;
}

.stars svg {
  width: 15px;
  height: 15px;
  color: rgba(255, 255, 255, 0.25);
}

.stars svg.on {
  color: var(--y);
  filter: drop-shadow(0 0 4px rgba(255, 216, 0, 0.6));
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.hud-right .icon-btn {
  pointer-events: auto;
}

.powers {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.power {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: rgba(20, 22, 26, 0.7);
}

.power canvas {
  width: 30px;
  height: 30px;
}

.power svg.ring {
  position: absolute;
  inset: 0;
  width: 46px;
  height: 46px;
  transform: rotate(-90deg);
}

.banner {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  animation: banner 2.6s ease both;
  white-space: nowrap;
}

.banner .k {
  font-family: var(--cond);
  font-weight: 700;
  font-size: clamp(14px, 2vw, 18px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #eef0f3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.banner .v {
  font-family: var(--slab);
  font-weight: 800;
  font-size: clamp(40px, 7vw, 78px);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), 0 8px 34px rgba(0, 0, 0, 0.55);
}

.banner .s {
  margin-top: 6px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: clamp(15px, 2vw, 20px);
  color: var(--y);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.banner .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--y);
  color: var(--k);
  font-family: var(--cond);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.banner .badge img {
  height: 14px;
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: translate(-50%, 18px) scale(0.92);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
}

.hint {
  position: absolute;
  bottom: 22%;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: 92vw;
  text-align: center;
  padding: 12px 20px;
  border-radius: 16px;
  background: rgba(20, 22, 26, 0.85);
  border: 2px solid var(--y);
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(18px, 2.6vw, 26px);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  animation: pop 0.35s ease both;
  white-space: normal;
}

.zone {
  position: absolute;
  top: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: zonePulse 1s ease-in-out infinite;
}

.zone.left {
  left: 0;
  width: 35%;
  background: linear-gradient(90deg, rgba(63, 169, 245, 0.28), rgba(63, 169, 245, 0));
}

.zone.right {
  right: 0;
  width: 65%;
  background: linear-gradient(270deg, rgba(255, 216, 0, 0.26), rgba(255, 216, 0, 0));
}

.zone svg {
  width: 70px;
  height: 70px;
  color: #fff;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

@keyframes zonePulse {
  50% {
    opacity: 0.55;
  }
}

/* ---- overlays (pause, game over, task) */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  background: rgba(8, 9, 12, 0.5);
  animation: fadein 0.25s ease both;
}

.dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 24px - var(--safe-t) - var(--safe-b));
  max-height: calc(100dvh - 24px - var(--safe-t) - var(--safe-b));
  overflow-y: auto;
  padding: 22px;
  display: grid;
  gap: 14px;
  text-align: center;
}

.dialog h2 {
  font-size: 34px;
}

.dialog .row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.over {
  width: min(760px, 100%);
  grid-template-columns: 1fr;
}

.over-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-direction: column;
}

.over-head .cause {
  color: var(--mute);
  font-size: 15px;
}

.score-big {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(56px, 10vw, 92px);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.record {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--y);
  color: var(--k);
  font-family: var(--cond);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.08em;
  animation: pop 0.5s ease both, glow 1.6s ease-in-out infinite;
}

@keyframes glow {
  50% {
    box-shadow: 0 0 30px rgba(255, 216, 0, 0.7);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  padding: 10px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.stat small {
  display: block;
  font-size: 12px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat b {
  display: block;
  margin-top: 2px;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 22px;
}

.ranks {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.rank-pill {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 216, 0, 0.1);
  border: 1px solid rgba(255, 216, 0, 0.35);
  font-size: 14px;
}

.rank-pill b {
  font-family: var(--cond);
  font-size: 22px;
  color: var(--y);
  margin-left: 6px;
}

.notice {
  font-size: 14px;
  color: #ffc2c9;
}

.over-head .tip {
  max-width: 34ch;
  color: #cfd5dc;
  font-size: 14px;
  line-height: 1.35;
}

.goals {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  text-align: left;
}

.goals:empty {
  display: none;
}

.goals small {
  display: block;
  font-size: 12px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.goals ul {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
  font-size: 15px;
}

.goals li::before {
  content: '›';
  margin-right: 8px;
  color: var(--y);
  font-weight: 800;
}

/* ---- 3-2-1 after a pause */
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.countdown b {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(90px, 22vh, 180px);
  color: var(--y);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 40px rgba(0, 0, 0, 0.4);
  animation: countPop 0.7s ease both;
}

@keyframes countPop {
  0% {
    transform: scale(1.6);
    opacity: 0;
  }
  25% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.85);
    opacity: 0.2;
  }
}

/* ---- leaderboard */
.board-list {
  display: grid;
  gap: 6px;
}

.board-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}

.board-row.me {
  background: rgba(255, 216, 0, 0.12);
  border-color: rgba(255, 216, 0, 0.5);
}

.board-row .pos {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 19px;
  background: rgba(255, 255, 255, 0.08);
}

.board-row .pos.g1 {
  background: linear-gradient(180deg, #ffe46b, #e3b51f);
  color: #3a2c00;
}

.board-row .pos.g2 {
  background: linear-gradient(180deg, #eef1f4, #a9b2bc);
  color: #222;
}

.board-row .pos.g3 {
  background: linear-gradient(180deg, #f0b47e, #b96f35);
  color: #2a1500;
}

.board-row .who b {
  display: block;
  font-weight: 700;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-row .who small {
  color: var(--mute);
  font-size: 13px;
}

.board-row .pts {
  font-family: var(--cond);
  font-weight: 800;
  font-size: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board-row .pts small {
  display: block;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--mute);
}

.board-me {
  margin-top: 10px;
}

.empty {
  text-align: center;
  padding: 40px 10px;
  color: var(--mute);
}

/* ---- shop */
.shop-hint {
  margin: 0 0 12px;
  color: var(--mute);
  font-size: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
  align-content: start;
}

.card .top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.card .ico {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 14px;
  background: rgba(255, 216, 0, 0.12);
  display: grid;
  place-items: center;
}

.card .ico canvas {
  width: 40px;
  height: 40px;
}

.card h3 {
  font-size: 21px;
  line-height: 1.05;
}

.card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--mute);
}

.pips {
  display: flex;
  gap: 4px;
}

.pips i {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.pips i.on {
  background: var(--y);
}

.card .btn {
  width: 100%;
}

.card.outfit canvas {
  width: 100%;
  height: 170px;
  border-radius: 12px;
  background: linear-gradient(180deg, #9ccbe9, #d9ecf7);
}

.card.equipped {
  border-color: var(--y);
}

/* ---- map */
.map-wrap {
  position: relative;
}

.map-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

@media (min-height: 600px) {
  .map-wrap svg {
    max-height: 62vh;
  }
}

.map-info {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  min-height: 64px;
}

.map-info h3 {
  font-size: 22px;
}

/* ---- profile */
.prof-grid {
  display: grid;
  gap: 14px;
}

.prof-sec {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.prof-sec h3 {
  font-size: 20px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline .field {
  flex: 1;
  min-width: 160px;
  height: 48px;
  font-size: 18px;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.ach {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  opacity: 0.5;
}

.ach.on {
  opacity: 1;
  background: rgba(255, 216, 0, 0.1);
}

.ach .medal {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
}

.ach.on .medal {
  background: var(--y);
  color: var(--k);
}

.ach .medal svg {
  width: 20px;
  height: 20px;
}

.ach b {
  display: block;
  font-size: 14px;
}

.ach small {
  display: block;
  font-size: 12px;
  color: var(--mute);
}

.toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- tasks (mini games) */
.task {
  width: min(520px, 100%);
  padding: 16px 18px 18px;
  display: grid;
  gap: 12px;
  text-align: center;
  border: 2px solid #ff8a1f;
  animation: pop 0.3s ease both;
}

.task-head {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.task-head h2 {
  font-size: 26px;
  color: #ffb066;
}

.task-sub {
  font-size: 16px;
  color: #e6e8ec;
  min-height: 20px;
}

.timer {
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.timer i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff8a1f, var(--y));
  transform-origin: left;
}

.task-area {
  position: relative;
  height: 210px;
  border-radius: 14px;
  background: #23262c;
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
}

.task-area canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.task-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 40px;
  background: rgba(20, 22, 26, 0.6);
  animation: pop 0.3s ease both;
}

.task-result.ok {
  color: #7cf0b0;
}

.task-result.fail {
  color: #ff8a96;
}

/* ---- toasts */
#toasts {
  position: absolute;
  right: calc(14px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
  display: grid;
  gap: 8px;
  pointer-events: none;
  z-index: 40;
}

.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(20, 22, 26, 0.92);
  border: 1px solid rgba(255, 216, 0, 0.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toast 4s ease both;
  max-width: 320px;
}

.toast .medal {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--y);
  color: var(--k);
}

.toast .medal svg {
  width: 19px;
  height: 19px;
}

.toast small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--y);
}

.toast b {
  display: block;
  font-size: 15px;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }
  8%,
  88% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateX(30px);
  }
}

/* ---- rotate prompt */
#rotate {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: #15171b;
  text-align: center;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 24px;
  padding: 30px;
}

#rotate[hidden] {
  display: none;
}

.rotate-icon {
  width: 70px;
  height: 110px;
  border: 5px solid var(--y);
  border-radius: 14px;
  animation: rot 1.8s ease-in-out infinite;
}

@keyframes rot {
  0%,
  20% {
    transform: rotate(0);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}

/* ---- birthday */
.bday {
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  width: min(640px, 100%);
  padding: 22px;
}

.bday h1 {
  font-family: var(--slab);
  font-size: clamp(32px, 6vw, 56px);
  line-height: 1;
  color: var(--y);
}

.bday canvas {
  width: min(300px, 50vh);
  height: min(300px, 50vh);
}

/* ---------------------------------------------------------------- responsive */
@media (max-height: 520px) and (min-width: 520px) {
  .over {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    align-items: center;
    column-gap: 18px;
  }
  .over > .over-head {
    grid-row: 1 / span 6;
  }
  .over .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .over .stat {
    padding: 6px 4px;
  }
  .over .stat small {
    font-size: 10px;
  }
  .over .stat b {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .over .rank-pill {
    padding: 4px 10px;
    font-size: 13px;
  }
  .over .rank-pill b {
    font-size: 18px;
  }
  .over .goals {
    padding: 6px 12px;
  }
  .over .goals ul {
    font-size: 13px;
    gap: 1px;
  }
  .over .btn.big {
    min-height: 46px;
    font-size: 22px;
  }
  .over .btn.small {
    min-height: 38px;
    font-size: 16px;
  }
  .over-head {
    gap: 6px;
  }
  .over-head h2 {
    font-size: 28px;
  }
  .over .score-big {
    font-size: 48px;
  }
  .over-head .record {
    font-size: 15px;
  }
  .over-head .tip {
    font-size: 13px;
  }
}

/* small phones in landscape (e.g. iPhone SE): keep the whole game-over card on screen */
@media (max-height: 380px) and (min-width: 520px) {
  .dialog.over {
    gap: 7px;
    padding: 12px;
  }
  .over .stat small {
    font-size: 9px;
  }
  .over .stat b {
    font-size: 15px;
  }
  .over .ranks {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .over .rank-pill {
    padding: 3px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
  .over .rank-pill b {
    font-size: 15px;
  }
  .over .goals ul {
    font-size: 12px;
  }
  .over .row {
    gap: 6px;
    flex-wrap: nowrap;
  }
  .over .btn.big {
    min-height: 40px;
    font-size: 19px;
  }
  .over .btn.small {
    min-height: 34px;
    font-size: 14px;
    padding: 0 10px;
    gap: 6px;
  }
  .over .score-big {
    font-size: 40px;
  }
}

@media (max-height: 520px) {
  .btn {
    min-height: 42px;
    font-size: 18px;
  }
  .btn.big {
    min-height: 58px;
    font-size: 28px;
    padding: 0 32px;
  }
  .daily-btn {
    min-height: 58px;
  }
  .title {
    font-size: clamp(38px, 7vw, 64px);
  }
  .home-main {
    gap: 9px;
  }
  .topbar .logo {
    height: 30px;
  }
  .chip {
    height: 34px;
    font-size: 16px;
  }
  .icon-btn {
    width: 38px;
    height: 38px;
  }
  .tagline {
    display: none;
  }
  .task-area {
    height: 150px;
  }
  .dialog {
    padding: 14px;
    gap: 10px;
  }
  .score-big {
    font-size: 54px;
  }
  .stat b {
    font-size: 19px;
  }
  .onboard canvas.portrait {
    width: min(280px, 32vw);
    height: min(280px, 32vw);
  }
  .onboard .panel {
    padding: 18px;
    gap: 10px;
  }
  .onboard h1 {
    font-size: 26px;
  }
  .home-foot .controls {
    display: none;
  }
  .hud-route .names {
    font-size: 14px;
  }
}

@media (max-width: 760px) {
  .onboard {
    grid-template-columns: 1fr;
    align-content: center;
  }
  .onboard canvas.portrait {
    width: 200px;
    height: 200px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-route {
    min-width: 0;
  }
  .home-main {
    justify-content: flex-end;
    padding-bottom: 10px;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  #shade.on {
    background: linear-gradient(0deg, rgba(10, 11, 14, 0.88) 0%, rgba(10, 11, 14, 0.5) 50%, rgba(10, 11, 14, 0.1) 100%);
  }
  .btn.big {
    flex: 1;
  }
  .daily-btn {
    flex: 1;
  }
  .nav-row .btn {
    flex: 1;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- email protection */
.email-dialog {
  z-index: 30;
  background: rgba(4, 10, 24, 0.72);
}
.email-dialog .dialog {
  max-width: 420px;
}
.code-input {
  font-size: 30px;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.protect-tip {
  color: #e8eefc;
  background: rgba(255, 210, 0, 0.1);
  border: 1px solid rgba(255, 210, 0, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
}
.protect-tip b {
  color: var(--y);
}
.protect-tip .inline {
  margin-top: 8px;
}
