:root {
  color-scheme: dark;
  --royal: #0629c7;
  --gray: #808080;
  --ink: #07031a;
  --ink2: #120733;
  --cyan: #29f3ff;
  --magenta: #ff2bd6;
  --violet: #8a3dff;
  --orange: #ff8a3d;
  --red: #ff3355;
  --fg: #f5f3ff;
  --dim: #b7a9d9;
  --title: "Aldrich", "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --body: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--fg);
  font: 16px/1.4 var(--body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: fixed; inset: 0; touch-action: none; display: none; }
body.playing #touch { display: block; }

#flash {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 40, 90, 0.55));
  transition: opacity 0.35s ease;
}
#flash.on { opacity: 1; transition: none; }

.screen {
  position: fixed; inset: 0;
  display: none;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
}
.screen.show { display: flex; }

button { font: inherit; color: inherit; }

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
  min-height: 52px;
  padding: 0.7em 1.6em;
  border: 0;
  cursor: pointer;
  font: 1.05rem/1 var(--title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  background: linear-gradient(90deg, rgba(41, 243, 255, 0.14), rgba(255, 43, 214, 0.14));
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: transform 0.12s ease, filter 0.12s ease, background 0.2s ease;
}
.btn::before {
  content: "";
  position: absolute; inset: 0;
  padding: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  clip-path: inherit;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.btn:hover, .btn:focus-visible { transform: translateX(4px); filter: brightness(1.25); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(90deg, var(--royal), #5a1bd6 60%, #b3179c);
  box-shadow: 0 0 24px rgba(6, 41, 199, 0.65);
}
.btn.small { min-height: 42px; padding: 0.5em 1.1em; font-size: 0.85rem; }
.btn em { font-style: normal; font-family: var(--body); font-size: 0.72rem; letter-spacing: 0.04em; color: var(--cyan); text-transform: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* LOADING */
#loading { flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: radial-gradient(circle at 50% 40%, #2a0b52, var(--ink) 70%); }
.load-logo { width: min(150px, 38vw); filter: drop-shadow(0 0 18px var(--cyan)) drop-shadow(0 0 40px var(--magenta)); animation: pulse 1.6s ease-in-out infinite; }
.load-bar { width: min(320px, 70vw); height: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 12px var(--magenta); transition: width 0.2s ease; }
.load-text { margin: 0; font: 0.9rem var(--title); letter-spacing: 0.3em; color: var(--dim); text-transform: uppercase; }
@keyframes pulse { 50% { transform: scale(1.06); filter: drop-shadow(0 0 28px var(--cyan)) drop-shadow(0 0 60px var(--magenta)); } }

/* MENU */
#menu { flex-direction: column; justify-content: center; background: linear-gradient(90deg, rgba(7, 3, 26, 0.88) 0%, rgba(7, 3, 26, 0.55) 38%, transparent 62%); }
.menu-col { display: flex; flex-direction: column; gap: 18px; width: min(420px, 100%); margin-left: clamp(0px, 5vw, 80px); }
.brand { display: flex; align-items: center; gap: 12px; font: 1.1rem var(--title); letter-spacing: 0.35em; }
.brand img { width: 46px; filter: drop-shadow(0 0 8px var(--cyan)); }
.title { margin: 0; line-height: 0.9; }
.chrome {
  display: block;
  font: clamp(3rem, min(8.4vw, 12vh), 6.2rem)/0.9 var(--title);
  white-space: nowrap;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 0%, #9ee9ff 38%, #1b1446 50%, #ff5bd8 56%, #ffd1f2 78%, #ffffff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 43, 214, 0.75)) drop-shadow(0 4px 0 #2a0b52);
}
.title small { display: block; margin-top: 8px; font: 1rem var(--title); letter-spacing: 0.55em; color: var(--orange); text-shadow: 0 0 10px var(--orange); }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-buttons .btn { justify-content: space-between; }
.menu-buttons .row .btn { flex: 1; justify-content: center; }
.menu-stats { display: flex; gap: 22px; margin: 6px 0 0; }
.menu-stats div { display: flex; flex-direction: column; }
.menu-stats dt { font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.menu-stats dd { margin: 0; font: 1.3rem var(--title); color: var(--cyan); text-shadow: 0 0 8px rgba(41, 243, 255, 0.6); }
.menu-hint { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); margin: 0; text-align: center; font-size: 0.8rem; color: var(--dim); letter-spacing: 0.05em; }

/* HUD */
#hud { flex-direction: column; pointer-events: none; padding-top: calc(12px + var(--safe-t)); }
#hud button { pointer-events: auto; }
.hud-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.hud-left { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.icon-btn { width: 44px; height: 44px; border: 1px solid rgba(41, 243, 255, 0.5); background: rgba(7, 3, 26, 0.5); font-size: 0.9rem; cursor: pointer; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.tech { display: flex; gap: 4px; }
.tech b { width: 28px; height: 30px; display: grid; place-items: center; font: 1rem var(--title); color: rgba(255, 255, 255, 0.28); border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(7, 3, 26, 0.45); }
.tech b.on { color: #fff; border-color: var(--cyan); background: rgba(41, 243, 255, 0.25); text-shadow: 0 0 8px var(--cyan); box-shadow: 0 0 12px rgba(41, 243, 255, 0.55); }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mult { font: 1.9rem/1 var(--title); color: var(--orange); text-shadow: 0 0 12px var(--orange); transition: transform 0.15s ease; }
.mult.bump { transform: scale(1.35); }
.combo { position: relative; width: min(180px, 36vw); height: 8px; background: rgba(255, 255, 255, 0.12); }
.combo i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--magenta), var(--orange)); box-shadow: 0 0 10px var(--magenta); }
.combo span { position: absolute; top: 12px; left: 0; right: 0; text-align: center; font: 0.72rem var(--title); letter-spacing: 0.2em; color: var(--fg); white-space: nowrap; }
.hud-right { text-align: right; }
.score { font: clamp(1.8rem, 6vw, 2.6rem)/1 var(--title); font-variant-numeric: tabular-nums; text-shadow: 0 0 12px rgba(41, 243, 255, 0.8), 0 2px 0 #2a0b52; }
.sub { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; font: 0.95rem var(--title); color: var(--dim); }
.coin-count { color: var(--orange); display: inline-flex; align-items: center; gap: 5px; }
.coin-dot { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle, #fff3c4, var(--orange) 60%); box-shadow: 0 0 8px var(--orange); }
.ghost-tag { margin-top: 6px; font-size: 0.75rem; color: var(--cyan); letter-spacing: 0.06em; min-height: 1em; }

.powers { position: absolute; left: 16px; top: 38%; display: flex; flex-direction: column; gap: 10px; }
.power { position: relative; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--cyan) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0); }
.power::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: rgba(7, 3, 26, 0.85); }
.power img { position: relative; z-index: 1; width: 40px; height: 40px; }

.popups { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop { font: 1.2rem var(--title); letter-spacing: 0.14em; color: var(--cyan); text-shadow: 0 0 10px currentColor; animation: pop 1s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 2rem; color: var(--orange); }
.pop.warn { color: var(--red); }
@keyframes pop { 0% { opacity: 0; transform: translateY(12px) scale(0.8); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

.hint { position: absolute; left: 0; right: 0; bottom: calc(18% + var(--safe-b)); text-align: center; font: clamp(1.1rem, 4vw, 1.6rem) var(--title); letter-spacing: 0.18em; color: #fff; text-shadow: 0 0 12px var(--magenta); opacity: 0; transition: opacity 0.25s ease; }
.hint.show { opacity: 1; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font: clamp(5rem, 22vw, 9rem) var(--title); color: #fff; text-shadow: 0 0 30px var(--magenta), 0 0 60px var(--cyan); pointer-events: none; }
.countdown:empty { display: none; }
.countdown b { animation: count 0.7s ease-out forwards; }
@keyframes count { from { transform: scale(1.8); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); opacity: 0.9; } }

/* MODALS */
.modal { align-items: center; justify-content: center; background: rgba(7, 3, 26, 0.62); backdrop-filter: blur(3px); overflow-y: auto; }
.panel {
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  width: min(380px, 100%);
  margin: auto;
  padding: 26px 24px;
  background: linear-gradient(160deg, rgba(18, 7, 51, 0.96), rgba(7, 3, 26, 0.96));
  border: 1px solid rgba(41, 243, 255, 0.35);
  box-shadow: 0 0 40px rgba(138, 61, 255, 0.35), inset 0 0 60px rgba(6, 41, 199, 0.18);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.panel.wide { width: min(560px, 100%); }
.panel h2 { margin: 0 0 6px; text-align: center; font: 1.8rem var(--title); letter-spacing: 0.16em; text-transform: uppercase; color: #fff; text-shadow: 0 0 14px var(--magenta); }
.panel h3 { margin: 0 0 8px; font: 0.95rem var(--title); letter-spacing: 0.2em; color: var(--cyan); text-transform: uppercase; }

.glitch { position: relative; color: #fff; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; mix-blend-mode: screen; }
.glitch::before { color: var(--cyan); animation: glitch 1.2s infinite steps(2); clip-path: inset(0 0 55% 0); }
.glitch::after { color: var(--magenta); animation: glitch 0.9s infinite reverse steps(2); clip-path: inset(50% 0 0 0); }
@keyframes glitch { 0% { transform: translate(0); } 25% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 75% { transform: translate(-1px, 2px); } }

.newbest { display: none; text-align: center; font: 1rem var(--title); letter-spacing: 0.3em; color: var(--orange); text-shadow: 0 0 10px var(--orange); animation: blink 0.7s steps(2) infinite; }
.newbest.show { display: block; }
.over-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.over-grid div { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; background: rgba(255, 255, 255, 0.05); }
.over-grid .big { grid-column: 1 / -1; }
.over-grid span { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.over-grid b { font: 1.2rem var(--title); color: #fff; }
.over-grid .big b { font-size: 2.6rem; color: var(--cyan); text-shadow: 0 0 14px var(--cyan); }

.submit { display: flex; gap: 8px; }
.submit input {
  flex: 1; min-width: 0; min-height: 42px; padding: 0 12px;
  font: 1rem var(--title); letter-spacing: 0.08em; color: #fff;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(41, 243, 255, 0.45); outline: none;
  user-select: text; -webkit-user-select: text;
}
.submit input:focus { border-color: var(--magenta); box-shadow: 0 0 12px rgba(255, 43, 214, 0.4); }
.submit.done { display: none; }
.net-status { margin: 0; min-height: 1.2em; text-align: center; font-size: 0.8rem; color: var(--dim); }

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 38vh; overflow-y: auto; }
.board li { display: grid; grid-template-columns: 2.2em 1fr auto auto; gap: 10px; align-items: center; padding: 6px 10px; background: rgba(255, 255, 255, 0.04); font-size: 0.92rem; }
.board li b { font-family: var(--title); color: var(--dim); }
.board li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .s { font-family: var(--title); color: var(--cyan); }
.board li .d { font-size: 0.75rem; color: var(--dim); }
.board li:nth-child(1) b { color: var(--orange); }
.board li.me { background: rgba(6, 41, 199, 0.4); outline: 1px solid var(--cyan); }
.board .empty { display: block; text-align: center; color: var(--dim); }

.tabs { display: flex; gap: 6px; }
.tab { flex: 1; min-height: 40px; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.2); background: transparent; font: 0.85rem var(--title); letter-spacing: 0.14em; text-transform: uppercase; }
.tab.on { border-color: var(--cyan); background: rgba(41, 243, 255, 0.15); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--dim); }
.field.check { flex-direction: row; align-items: center; gap: 10px; color: var(--fg); }
.field select, .field input[type="range"] { width: 100%; accent-color: var(--magenta); }
.field select { min-height: 40px; padding: 0 10px; color: #fff; background: #1a0c40; border: 1px solid rgba(41, 243, 255, 0.4); font: 0.95rem var(--body); }
.field input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--cyan); }

.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; font-size: 0.88rem; }
.howto p { margin: 0 0 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--fg); }
.legend p { flex-wrap: nowrap; }
.legend p span { flex: 1; }
.howto img { flex: none; }
.howto p.small { color: var(--dim); font-size: 0.8rem; }
.howto img { width: 34px; height: 34px; }
kbd { display: inline-block; min-width: 26px; padding: 2px 6px; text-align: center; font: 0.75rem var(--title); border: 1px solid rgba(41, 243, 255, 0.5); background: rgba(41, 243, 255, 0.08); }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px); padding: 10px 18px; background: rgba(18, 7, 51, 0.95); border: 1px solid var(--cyan); font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  #menu { justify-content: flex-end; padding-bottom: calc(46px + var(--safe-b)); background: linear-gradient(0deg, rgba(7, 3, 26, 0.92) 0%, rgba(7, 3, 26, 0.6) 55%, transparent 80%); }
  .menu-col { margin: 0 auto; gap: 12px; }
  .brand { justify-content: center; }
  .title { text-align: center; }
  .menu-stats { justify-content: center; }
  .menu-hint { display: none; }
  .howto { grid-template-columns: 1fr; }
  .over-grid { grid-template-columns: repeat(2, 1fr); }
  .powers { left: 10px; top: 30%; }
  .power { width: 46px; height: 46px; }
  .power img { width: 34px; height: 34px; }
  .tech b { width: 24px; height: 26px; font-size: 0.85rem; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #menu { justify-content: center; }
  .chrome { font-size: 3rem; }
  .menu-buttons { gap: 6px; }
  .btn { min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .load-logo, .hint.show, .newbest, .glitch::before, .glitch::after { animation: none; }
}

/* ── v2: mobile-first menu, profile, shop, missions, revive, ranks ─────── */
[hidden] { display: none !important; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn.big { min-height: 64px; font-size: 1.35rem; letter-spacing: 0.2em; }
.small { margin: 0; font-size: 0.82rem; color: var(--dim); text-align: center; }

.topbar { position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; justify-content: flex-end; z-index: 2; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; font: 0.9rem var(--title); color: #fff; background: rgba(7, 3, 26, 0.7); border: 1px solid rgba(41, 243, 255, 0.35); border-radius: 999px; cursor: pointer; backdrop-filter: blur(4px); }
.chip.player { margin-right: auto; max-width: 48vw; overflow: hidden; }
.chip.player #menuNick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .flag { font-size: 1.15rem; }
.chip.coins { color: var(--orange); }
.chip.mult-chip b { color: var(--orange); }

.menu-now { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.now-card { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px; text-align: left; cursor: pointer; background: rgba(7, 3, 26, 0.6); border: 1px solid rgba(255, 43, 214, 0.35); }
.now-card img { width: 44px; height: 44px; object-fit: cover; flex: none; }
.now-card span { display: flex; flex-direction: column; min-width: 0; }
.now-card em { font: normal 0.65rem var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.now-card b { font: 0.9rem var(--title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row.two .btn { flex-direction: column; gap: 3px; padding: 0.5em 0.6em; font-size: 0.9rem; letter-spacing: 0.08em; }
.row.icons { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; }
.icon-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; cursor: pointer; background: rgba(7, 3, 26, 0.6); border: 1px solid rgba(41, 243, 255, 0.25); }
.icon-tile span { font-size: 1.3rem; line-height: 1; }
.icon-tile em { font: normal 0.66rem var(--title); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.icon-tile .badge { position: absolute; top: 6px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

.profile-form .field input, .profile-form select, .row-fields input, .row-fields select {
  width: 100%; min-height: 46px; padding: 0 12px; font: 1rem var(--body); color: #fff;
  background: #140a35; border: 1px solid rgba(41, 243, 255, 0.45); outline: none; border-radius: 0;
  user-select: text; -webkit-user-select: text;
}
.profile-form input:focus, .profile-form select:focus { border-color: var(--magenta); }
.profile-form.inline { display: flex; flex-direction: column; gap: 8px; }
.row-fields { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; }

.ranks { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.ranks:empty { display: none; }
.rank-pill { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 6px 10px; background: rgba(6, 41, 199, 0.35); border: 1px solid rgba(41, 243, 255, 0.4); }
.rank-pill span { font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.rank-pill b { font: 1.2rem var(--title); color: var(--cyan); }
.unlock-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.unlock-list li { padding: 6px 10px; font-size: 0.85rem; background: rgba(255, 138, 61, 0.12); border-left: 3px solid var(--orange); }

.tabs { flex-wrap: wrap; }
.tab { min-width: 70px; }
.board li { grid-template-columns: 2.2em 1.6em 1fr auto; }
.board li .f { font-size: 1.1rem; }
.board-me { text-align: center; font: 0.9rem var(--title); color: var(--cyan); min-height: 1.2em; }
.live { display: inline-flex; align-items: center; gap: 6px; color: #ff4d7a; font: 0.75rem var(--title); letter-spacing: 0.2em; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff4d7a; box-shadow: 0 0 8px #ff4d7a; animation: blink 1s steps(2) infinite; }

.balance { margin: -4px 0 0; display: flex; justify-content: center; align-items: center; gap: 6px; font: 1.2rem var(--title); color: var(--orange); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 58vh; overflow-y: auto; padding: 2px; }
.card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.12); }
.card.on { border-color: var(--cyan); box-shadow: 0 0 16px rgba(41, 243, 255, 0.35); }
.card.locked img { filter: grayscale(0.85) brightness(0.6); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; max-width: 100%; }
.cards.scenes img, .cards.scenes .ph { aspect-ratio: 16 / 9; }
.card .ph { display: grid; place-items: center; width: 100%; font: 0.8rem var(--title); letter-spacing: 0.2em; color: var(--dim); background: linear-gradient(135deg, #2a0b52, #0b0430); }
.card b { font: 0.95rem var(--title); }
.card p { margin: 0; font-size: 0.75rem; color: var(--dim); }
.card .btn { min-height: 40px; padding: 0.4em 0.6em; font-size: 0.8rem; letter-spacing: 0.06em; }
.card .tag { position: absolute; top: 12px; left: 12px; padding: 2px 8px; font: 0.65rem var(--title); letter-spacing: 0.14em; background: var(--magenta); color: #fff; }

.missions, .achievements, .mini-missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.missions li, .mini-missions li { display: grid; gap: 6px; padding: 10px 12px; background: rgba(255, 255, 255, 0.05); border-left: 3px solid var(--magenta); }
.missions li.done, .mini-missions li.done { border-left-color: var(--cyan); opacity: 0.85; }
.missions .bar, .mini-missions .bar { height: 6px; background: rgba(255, 255, 255, 0.12); }
.missions .bar i, .mini-missions .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--magenta), var(--orange)); }
.missions span, .mini-missions span { font-size: 0.9rem; }
.missions em { font-style: normal; font-size: 0.75rem; color: var(--dim); }
.mini-missions li { padding: 6px 10px; }
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.achievements li { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); font-size: 0.82rem; }
.achievements li.got { border-color: var(--orange); background: rgba(255, 138, 61, 0.1); }
.achievements li b { font-family: var(--title); }
.achievements li em { font-style: normal; color: var(--orange); font-size: 0.75rem; }

.revive-panel { align-items: center; }
.revive-ring { position: relative; width: 120px; height: 120px; }
.revive-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.revive-ring circle { fill: none; stroke-width: 7; stroke: rgba(255, 255, 255, 0.12); }
.revive-ring #reviveArc { stroke: var(--cyan); stroke-dasharray: 276.5; stroke-dashoffset: 0; filter: drop-shadow(0 0 6px var(--cyan)); transition: stroke-dashoffset 0.1s linear; }
.revive-ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 2.6rem var(--title); }
.revive-panel .btn { width: 100%; }
.revive-panel .btn.big { flex-direction: column; gap: 4px; }

.touch-only { display: none !important; }
body.touch .touch-only { display: flex !important; }
body.touch .menu-hint { display: none; }
body.touch .howto kbd { display: none; }

/* Phones: menu as a bottom sheet under the 3D hero. */
@media (max-width: 720px), (pointer: coarse) and (orientation: portrait) {
  #menu { justify-content: flex-end; padding-bottom: calc(14px + var(--safe-b)); background: linear-gradient(0deg, rgba(7, 3, 26, 0.95) 0%, rgba(7, 3, 26, 0.75) 48%, transparent 72%); }
  .menu-col { width: 100%; max-width: 460px; margin: 0 auto; gap: 10px; }
  .brand { justify-content: center; font-size: 0.85rem; }
  .brand img { width: 30px; }
  .title { text-align: center; }
  .chrome { font-size: clamp(2.6rem, 14vw, 3.6rem); }
  .title small { font-size: 0.8rem; margin-top: 4px; }
  .btn { min-height: 50px; }
  .panel { padding: 20px 16px; }
  .panel h2 { font-size: 1.45rem; }
  .cards { grid-template-columns: 1fr 1fr; max-height: 62vh; }
  .achievements { grid-template-columns: 1fr 1fr; }
  .row-fields { grid-template-columns: 1fr; }
  .icon-btn { width: 48px; height: 48px; }
  .hud-top { gap: 4px; }
  .score { font-size: 1.7rem; }
  .mult { font-size: 1.5rem; }
  .hint { bottom: calc(24% + var(--safe-b)); }
}
@media (max-height: 640px) and (max-width: 720px) {
  .brand, .title small { display: none; }
  .chrome { font-size: 2.3rem; }
  .menu-now img { width: 34px; height: 34px; }
  .icon-tile { min-height: 48px; }
}

/* ── round 2: abilities, trails, race ─────────────────────────────────── */
.card .perk { font-size: 0.7rem; line-height: 1.25; }
.card .perk.plus { color: #7dffc8; }
.card .perk.minus { color: #ff8fb1; }
.card .swatch { width: 100%; aspect-ratio: 16 / 9; border-radius: 2px; background: radial-gradient(circle at 20% 50%, var(--a) 0 6%, transparent 7%), linear-gradient(90deg, transparent, var(--a) 45%, var(--b) 80%, transparent); background-color: #07031a; }
.card .swatch.smoke { background: radial-gradient(ellipse at 30% 60%, var(--a), transparent 55%), radial-gradient(ellipse at 70% 40%, var(--b), transparent 50%), #07031a; filter: blur(0.5px); }
.card .swatch.pixels { background: repeating-linear-gradient(90deg, var(--a) 0 10px, transparent 10px 20px), repeating-linear-gradient(0deg, var(--b) 0 10px, transparent 10px 20px), #07031a; background-blend-mode: screen; }
.card .swatch.rainbow { background: linear-gradient(180deg, transparent 25%, var(--a) 25% 42%, var(--b) 42% 58%, var(--c) 58% 75%, transparent 75%), #07031a; }
.card .swatch.fireflies, .card .swatch.coins { background: radial-gradient(circle at 20% 30%, var(--a) 0 3%, transparent 4%), radial-gradient(circle at 55% 65%, var(--a) 0 3%, transparent 4%), radial-gradient(circle at 80% 35%, var(--b) 0 3%, transparent 4%), radial-gradient(circle at 40% 45%, var(--b) 0 2%, transparent 3%), #07031a; }
#shopTabs { margin-bottom: 8px; }

.ability { position: absolute; left: 16px; bottom: calc(16px + var(--safe-b)); width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--magenta) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0); }
.ability::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: rgba(7, 3, 26, 0.85); }
.ability span, .ability em { position: relative; z-index: 1; }
.ability span { font-size: 1.4rem; line-height: 1; }
.ability em { position: absolute; right: -4px; bottom: -4px; min-width: 22px; padding: 1px 5px; font: 0.7rem var(--title); font-style: normal; color: #fff; background: #1a0c40; border: 1px solid var(--magenta); border-radius: 10px; text-align: center; }
.ability.ready { box-shadow: 0 0 18px rgba(255, 43, 214, 0.7); }

.race-btn { display: flex; align-items: center; justify-content: center; gap: 10px; border-color: var(--orange, #ffb347); }
.race-btn em { font-style: normal; font-size: 0.7rem; opacity: 0.75; }
.race-map { position: absolute; right: 8px; top: calc(96px + var(--safe-t)); width: 124px; height: min(48vh, 360px); pointer-events: none; }
.race-map canvas { width: 100%; height: 100%; display: block; }
.item-slot { position: absolute; right: 14px; bottom: calc(18px + var(--safe-b)); width: 76px; height: 76px; border-radius: 18px; display: grid; place-items: center; z-index: 5; cursor: pointer; background: rgba(7, 3, 26, 0.7); border: 2px solid rgba(255, 255, 255, 0.25); color: #fff; touch-action: manipulation; }
.item-slot span { font-size: 2.3rem; line-height: 1; filter: grayscale(1) opacity(0.4); }
.item-slot em { position: absolute; bottom: 3px; right: 7px; font: 0.62rem var(--title); font-style: normal; color: var(--dim); }
.item-slot.full { border-color: #ffe14d; box-shadow: 0 0 18px rgba(255, 225, 77, 0.6), inset 0 0 14px rgba(255, 43, 214, 0.4); animation: itemPulse 0.9s ease-in-out infinite; }
.item-slot.full span { filter: none; }
@keyframes itemPulse { 50% { transform: scale(1.06); } }
.incoming { position: absolute; left: 50%; top: calc(128px + var(--safe-t)); transform: translateX(-50%); padding: 6px 14px; font: 0.95rem var(--title); letter-spacing: 0.1em; color: #fff; background: rgba(255, 42, 85, 0.85); box-shadow: 0 0 20px rgba(255, 42, 85, 0.7); animation: incomingBlink 0.35s steps(2) infinite; pointer-events: none; white-space: nowrap; }
@keyframes incomingBlink { 50% { opacity: 0.55; } }
#raceModeTabs { margin: 6px 0 2px; }
.panel .center { text-align: center; }
.race-pos { position: absolute; left: 0; right: 0; top: calc(78px + var(--safe-t, 0px)); text-align: center; font: 0.9rem var(--title); letter-spacing: 0.12em; color: #fff; text-shadow: 0 0 10px var(--magenta); pointer-events: none; }
.room-code { display: flex; align-items: center; justify-content: center; gap: 10px; font: 1rem var(--title); letter-spacing: 0.1em; }
.room-code b { font-size: 1.6rem; color: var(--cyan); letter-spacing: 0.3em; }
.race-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.race-players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); }
.race-players li i { width: 14px; height: 14px; border-radius: 50%; }
.race-players li em { margin-left: auto; font-size: 0.7rem; color: var(--dim); font-style: normal; }
#raceJoinForm input { min-height: 44px; padding: 0 12px; color: #fff; background: #1a0c40; border: 1px solid rgba(41, 243, 255, 0.4); font: 1.1rem var(--title); letter-spacing: 0.3em; text-transform: uppercase; width: 100%; }
.panel .dim { margin: 0; font-size: 0.8rem; color: var(--dim); }

body.autopilot #hud::after { content: "AUTO"; position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); padding: 2px 10px; font: 0.7rem var(--title); letter-spacing: 0.3em; color: #07031a; background: var(--orange); }

/* ── account ─────────────────────────────────────────────────────────── */
.google-btn { display: flex; justify-content: center; min-height: 44px; margin: 6px 0; }
.or { margin: 4px 0; text-align: center; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
#accountOut, #accountIn { display: flex; flex-direction: column; gap: 8px; }
#accountOut[hidden], #accountIn[hidden], .google-btn[hidden], .or[hidden] { display: none; }
.account-who { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 4px 0; }
.account-who b { font: 1rem var(--title); color: #fff; word-break: break-all; }
.account-who em { font-style: normal; font-size: 0.75rem; color: var(--cyan); }
.btn.danger { border-color: #ff4d6d; color: #ffb3c1; }
body.signed-in .chip.player::after { content: "✓"; margin-left: 6px; color: var(--cyan); font-weight: 700; }

/* ── first visit ─────────────────────────────────────────────────────── */
.first-hint { display: none; margin: -2px 0 0; text-align: center; font-size: 0.78rem; color: var(--cyan); letter-spacing: 0.04em; }
body.first-run .first-hint { display: block; }
body.first-run .btn.primary.big[data-act="play"] { animation: playPulse 1.1s ease-in-out infinite; box-shadow: 0 0 28px rgba(255, 43, 214, 0.75); }
@keyframes playPulse { 50% { transform: scale(1.04); box-shadow: 0 0 44px rgba(41, 243, 255, 0.85); } }

/* ── ads ─────────────────────────────────────────────────────────────── */
.gift-chip { cursor: pointer; border-color: #ffe14d; color: #fff; animation: playPulse 1.6s ease-in-out infinite; }
.ad-sim { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: repeating-linear-gradient(45deg, #1a0c40 0 20px, #07031a 20px 40px); }
.ad-sim b { font: 2.4rem var(--title); color: #ffe14d; letter-spacing: 0.2em; }
.ad-sim button { position: absolute; top: calc(16px + var(--safe-t)); right: 16px; }
