/* =========================================================
   Subway Run — style.css
   ========================================================= */
:root {
  --blue: #1f6feb;
  --blue-dark: #12408f;
  --navy: #0d2557;
  --yellow: #ffc81f;
  --yellow-dark: #c88400;
  --green: #2fd36b;
  --green-dark: #128a3d;
  --red: #ff4d5e;
  --red-dark: #b3122a;
  --panel: rgba(13, 37, 87, 0.92);
  --glass: rgba(10, 25, 60, 0.55);
  --text: #fff;
  --dim: rgba(255, 255, 255, 0.72);
  --font: 'Baloo 2', 'Arial Rounded MT Bold', 'Nunito', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0d2557;
}

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  margin-right: 3px;
  border-radius: 6px;
  font-family: inherit;
  font-size: .85em;
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, .18);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}

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

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: .82;
  font-weight: 900;
  letter-spacing: 1px;
  transform: rotate(-4deg);
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, .25));
}
.logo span {
  display: block;
  -webkit-text-stroke: 6px var(--navy);
  paint-order: stroke fill;
}
.logo-rail {
  color: #fff;
  font-size: .78em;
  letter-spacing: 3px;
}
.logo-dash {
  font-size: 1.5em;
  background: linear-gradient(180deg, #fff27a 0%, #ffc81f 45%, #ff8a00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0;
  text-shadow: none;
  position: relative;
}
.logo-dash::after {
  content: 'RUN';
  position: absolute;
  inset: 0;
  z-index: -1;
  color: var(--navy);
  -webkit-text-stroke: 12px var(--navy);
}
.logo-lg { font-size: 54px; }
.logo-xl { font-size: clamp(48px, 13vw, 86px); }

/* ---------- Coin icon ---------- */
.coin-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8c4 0 12%, #ffd23a 35%, #f5a300 75%, #c47a00 100%);
  box-shadow: inset 0 0 0 .12em #e08f00, 0 2px 0 rgba(0, 0, 0, .3);
  flex: 0 0 auto;
}
.coin-icon.bump { animation: coinBump .25s ease; }
@keyframes coinBump { 50% { transform: scale(1.35) rotate(20deg); } }

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .35s ease, visibility .35s ease;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.screen-top { z-index: 40; }

.screen-loading {
  z-index: 50;
  gap: 36px;
  background:
    radial-gradient(ellipse at 50% 0%, #4fa3ff 0%, transparent 60%),
    linear-gradient(180deg, #1f6feb 0%, #0d2557 100%);
}
.loader { width: min(320px, 80vw); text-align: center; }
.loader-track {
  height: 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.loader-fill {
  width: 0%;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff27a, #ffb300);
  transition: width .25s ease;
}
.loader-text { margin-top: 10px; font-weight: 700; color: var(--dim); }
.loader-tip { position: absolute; bottom: calc(28px + var(--sb)); color: var(--dim); font-size: 14px; }

.screen-error { z-index: 60; background: linear-gradient(180deg, #3a1a5a, #0d2557); }

.screen-overlay {
  z-index: 30;
  background: rgba(8, 20, 50, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* ---------- Panels ---------- */
.panel {
  width: min(92vw, 380px);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 22px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(180deg, #2a7bf5 0%, #1546a8 100%);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .18), inset 0 -6px 0 rgba(0, 0, 0, .18), 0 24px 60px rgba(0, 0, 0, .45);
  transform: translateY(20px) scale(.9);
  transition: transform .4s cubic-bezier(.2, 1.4, .4, 1);
  touch-action: pan-y;
}
.screen.active .panel { transform: none; }
.panel-sm { width: min(90vw, 330px); }
.panel h2 {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .3);
}
.panel p { color: var(--dim); margin-bottom: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 18px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .3px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  transition: transform .1s ease, box-shadow .1s ease, filter .2s;
}
.btn svg { width: 22px; height: 22px; fill: currentColor; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); }
.btn:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }
.btn-green  { background: linear-gradient(180deg, #74f7a3, #2fd36b 50%, #19b155); box-shadow: 0 6px 0 var(--green-dark), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.5); }
.btn-blue   { background: linear-gradient(180deg, #7ab4ff, #3d8bff 50%, #2569e0); box-shadow: 0 6px 0 var(--blue-dark), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-yellow { color: #5a2f00; text-shadow: 0 1px 0 rgba(255,255,255,.5); background: linear-gradient(180deg, #fff27a, #ffc81f 50%, #ffa200); box-shadow: 0 6px 0 var(--yellow-dark), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.6); }
.btn-red    { background: linear-gradient(180deg, #ff9aa5, #ff4d5e 50%, #e02a40); box-shadow: 0 6px 0 var(--red-dark), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-green:active  { box-shadow: 0 2px 0 var(--green-dark), inset 0 2px 0 rgba(255,255,255,.5); }
.btn-blue:active   { box-shadow: 0 2px 0 var(--blue-dark), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-yellow:active { box-shadow: 0 2px 0 var(--yellow-dark), inset 0 2px 0 rgba(255,255,255,.6); }
.btn-red:active    { box-shadow: 0 2px 0 var(--red-dark), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-sm { min-height: 42px; font-size: 15px; padding: 0 14px; border-radius: 14px; }
.btn-col { display: flex; flex-direction: column; gap: 14px; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* ---------- Menu ---------- */
.screen-menu {
  justify-content: space-between;
  background:
    linear-gradient(180deg, rgba(10, 30, 80, .55) 0%, rgba(10, 30, 80, 0) 30%, rgba(10, 30, 80, 0) 55%, rgba(8, 20, 55, .8) 100%);
}
.menu-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--glass);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15);
  font-size: 18px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.chip-label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; }
.coin-chip b { color: var(--yellow); }
.menu-logo { text-align: center; margin-top: 2vh; animation: logoIn .8s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes logoIn { from { transform: scale(.4); opacity: 0; } }
.menu-tag { margin-top: 10px; font-weight: 700; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.menu-mult {
  margin-top: auto;
  margin-bottom: 14px;
  padding: 4px 14px;
  border-radius: 14px;
  background: var(--glass);
  font-size: 14px;
  color: var(--dim);
}
.menu-mult b { color: var(--yellow); font-size: 18px; margin-left: 6px; }
.btn-play {
  min-width: 220px;
  min-height: 70px;
  border-radius: 24px;
  font-size: 30px;
  font-weight: 900;
  color: #5a2f00;
  text-shadow: 0 2px 0 rgba(255,255,255,.5);
  background: linear-gradient(180deg, #fff27a, #ffc81f 50%, #ffa200);
  box-shadow: 0 8px 0 var(--yellow-dark), 0 14px 26px rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.6);
  animation: playPulse 1.6s ease-in-out infinite;
}
.btn-play svg { width: 30px; height: 30px; }
.btn-play:active { box-shadow: 0 2px 0 var(--yellow-dark), inset 0 3px 0 rgba(255,255,255,.6); }
@keyframes playPulse { 50% { transform: scale(1.05); } }
.tap-hint { margin: 12px 0 16px; font-size: 14px; color: var(--dim); }
.menu-nav {
  display: flex;
  gap: 12px;
  width: min(100%, 460px);
}
.nav-btn {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(180deg, #4d97ff, #1f6feb);
  box-shadow: 0 5px 0 var(--blue-dark), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.35);
  transition: transform .1s;
}
.nav-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-dark); }
.nav-ico { font-size: 26px; line-height: 1.1; }
.badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--red);
  font-style: normal;
  font-size: 14px;
  line-height: 24px;
  box-shadow: 0 2px 0 var(--red-dark);
}
.badge:empty { display: none; }

/* ---------- Sheets (shop / missions / settings) ---------- */
.screen-sheet {
  justify-content: flex-end;
  padding-bottom: 0;
  background: linear-gradient(180deg, rgba(10,30,80,.35), rgba(10,30,80,0) 40%);
}
.sheet-top {
  position: absolute;
  top: calc(12px + var(--st));
  left: calc(12px + var(--sl));
  right: calc(12px + var(--sr));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.sheet-top h2 {
  font-size: 28px;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.back-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 34px;
  font-weight: 900;
  line-height: 44px;
  background: linear-gradient(180deg, #4d97ff, #1f6feb);
  box-shadow: 0 4px 0 var(--blue-dark), inset 0 2px 0 rgba(255,255,255,.35);
}
.back-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
.sheet {
  width: min(100%, 560px);
  max-height: 62%;
  overflow-y: auto;
  padding: 18px 16px calc(20px + var(--sb));
  border-radius: 28px 28px 0 0;
  background: var(--panel);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.12), 0 -10px 40px rgba(0,0,0,.35);
  transform: translateY(40px);
  transition: transform .4s cubic-bezier(.2, 1.2, .4, 1);
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.screen.active .sheet { transform: none; }
#screenSettings .sheet, #screenMissions .sheet { max-height: 78%; }

.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 16px; background: rgba(0,0,0,.25); margin-bottom: 14px; }
.tab { flex: 1; min-height: 40px; border-radius: 12px; font-weight: 800; color: var(--dim); }
.tab.active { color: #5a2f00; background: linear-gradient(180deg, #fff27a, #ffb300); box-shadow: 0 3px 0 var(--yellow-dark); }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.shop-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.1);
  font-size: 14px;
  font-weight: 700;
  transition: transform .15s, box-shadow .15s;
}
.shop-item:active { transform: scale(.96); }
.shop-item.preview { box-shadow: inset 0 0 0 3px var(--yellow); background: rgba(255,200,31,.14); }
.shop-swatch {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.2), 0 3px 6px rgba(0,0,0,.3);
}
.shop-swatch.board { border-radius: 26px / 12px; height: 26px; width: 64px; margin: 13px 0; }
.shop-price { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--yellow); }
.shop-price.owned { color: var(--green); }
.shop-tag { position: absolute; top: 6px; right: 8px; font-size: 14px; }
.shop-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(0,0,0,.22);
}
.shop-sel { display: flex; flex-direction: column; min-width: 0; }
.shop-sel b { font-size: 20px; }
.shop-sel span { font-size: 13px; color: var(--dim); }
.shop-extra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
}
.shop-extra > div { display: flex; flex-direction: column; font-size: 13px; color: var(--dim); }
.shop-extra > div > b { font-size: 16px; color: #fff; }

.mission-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.mission-head p { font-size: 14px; color: var(--dim); }
.mult-big {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 22px;
  font-size: 22px;
  font-weight: 900;
  color: #5a2f00;
  background: linear-gradient(180deg, #fff27a, #ffb300);
  box-shadow: 0 5px 0 var(--yellow-dark), inset 0 2px 0 rgba(255,255,255,.6);
}
.mult-big b { font-size: 34px; }
.mission-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.mission {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
}
.mission.done { background: rgba(47, 211, 107, .18); box-shadow: inset 0 0 0 2px rgba(47,211,107,.5); }
.mission-title { font-weight: 800; font-size: 16px; }
.mission-reward { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--yellow); }
.mission-bar { grid-column: 1 / -1; height: 10px; border-radius: 6px; background: rgba(0,0,0,.35); overflow: hidden; }
.mission-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #36e07e, #b6ff6a); transition: width .4s; }
.mission-count { grid-column: 1 / -1; font-size: 12px; color: var(--dim); }
.mission-reset { margin-top: 14px; text-align: center; color: var(--dim); font-size: 14px; }

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
}
.toggle-row, .slider-row, .seg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  font-weight: 700;
}
.settings-mini { margin-bottom: 16px; padding: 6px 12px; border-radius: 16px; background: rgba(0,0,0,.18); text-align: left; }
.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 54px;
  height: 30px;
  border-radius: 16px;
  background: rgba(0,0,0,.4);
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
  transition: transform .2s;
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(24px); }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 52%;
  height: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,.4);
  touch-action: pan-x;
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--yellow); box-shadow: 0 2px 0 var(--yellow-dark); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--yellow); cursor: pointer; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0,0,0,.35); }
.segmented button { min-height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--dim); }
.segmented button.active { color: #5a2f00; background: linear-gradient(180deg, #fff27a, #ffb300); }
.controls-help h3 { margin: 6px 0; }
.ctrl-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; align-items: center; }
.ctrl-grid > div:nth-child(even) { color: var(--dim); }
.help-note { margin: 10px 0 6px; font-size: 13px; color: var(--dim); }
#btnReset { width: 100%; }
.version { margin-top: 12px; text-align: center; font-size: 12px; color: rgba(255,255,255,.45); }

/* ---------- Game over ---------- */
.new-best {
  display: none;
  width: max-content;
  margin: -4px auto 10px;
  padding: 4px 14px;
  border-radius: 14px;
  font-weight: 800;
  color: #5a2f00;
  background: linear-gradient(180deg, #fff27a, #ffb300);
  animation: playPulse 1s ease-in-out infinite;
}
.new-best.show { display: block; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.result { padding: 8px 6px; border-radius: 16px; background: rgba(0,0,0,.22); display: flex; flex-direction: column; }
.result span { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }
.result b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.result-wide { grid-column: 1 / -1; }
.result-wide b { font-size: 38px; color: var(--yellow); }
.go-missions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; }
.go-missions:empty { display: none; }
.go-mission { font-size: 13px; padding: 6px 10px; border-radius: 12px; background: rgba(0,0,0,.2); display: flex; justify-content: space-between; gap: 8px; }
.go-mission.done { color: #8dffb8; }

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s;
  padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(10px + var(--sb)) calc(10px + var(--sl));
}
.hud.active { opacity: 1; visibility: visible; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hud-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(180deg, #6fb0ff, #2a7bf5);
  box-shadow: 0 4px 0 var(--blue-dark), 0 6px 12px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.4);
}
.hud-btn svg { width: 24px; height: 24px; fill: #fff; }
.hud-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.distance-pill {
  padding: 2px 14px;
  border-radius: 14px;
  background: var(--glass);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.distance-pill small { font-size: 13px; margin-left: 2px; color: var(--dim); }
.mission-pill {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: min(60vw, 260px);
  padding: 5px 12px 6px;
  border-radius: 14px;
  background: var(--glass);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .4s, transform .4s;
}
.mission-pill.show { opacity: 1; transform: none; }
.mission-pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mission-pill-bar { height: 6px; border-radius: 4px; background: rgba(0,0,0,.4); overflow: hidden; }
.mission-pill-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #36e07e, #b6ff6a); transition: width .3s; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.score-pill, .coin-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 4px;
  border-radius: 16px;
  background: rgba(10, 25, 60, .7);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.score-value { font-size: 24px; letter-spacing: 1px; }
.mult-badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 16px;
  color: #5a2f00;
  background: linear-gradient(180deg, #fff27a, #ffb300);
}
.mult-badge.bump { animation: multBump .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes multBump { 30% { transform: scale(1.6) rotate(-8deg); } }
.coin-pill { padding: 3px 8px 3px 12px; font-size: 20px; }
.coin-pill .coin-icon { font-size: 20px; }
.hi-pill { font-size: 12px; font-weight: 800; color: var(--dim); padding: 0 6px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }

.powerups {
  position: absolute;
  left: calc(10px + var(--sl));
  top: calc(74px + var(--st));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 26px;
  background: rgba(10, 25, 60, .7);
  font-weight: 800;
  font-size: 14px;
  animation: puIn .35s cubic-bezier(.2, 1.5, .4, 1);
}
.pu.ending { animation: puBlink .3s steps(2) infinite; }
@keyframes puIn { from { transform: translateX(-40px) scale(.6); opacity: 0; } }
@keyframes puBlink { 50% { opacity: .45; } }
.pu-ring {
  --p: 100;
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255,255,255,.12) 0);
  display: grid;
  place-items: center;
}
.pu-ring span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: #13306e;
}
.pu-time { font-variant-numeric: tabular-nums; min-width: 30px; }

.stumble-warn {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  padding: 6px 18px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 20px;
  background: rgba(255, 77, 94, .85);
  opacity: 0;
  transition: opacity .2s;
}
.stumble-warn.show { opacity: 1; animation: shakeX .4s ease; }
@keyframes shakeX { 25% { transform: translateX(-56%); } 75% { transform: translateX(-44%); } }

.hover-btn {
  pointer-events: auto;
  position: absolute;
  right: calc(14px + var(--sr));
  bottom: calc(18px + var(--sb));
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ff9b6b, #ff5a36);
  box-shadow: 0 5px 0 #b3301a, 0 8px 16px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.4);
  display: grid;
  place-items: center;
}
.hover-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3301a; }
.hover-btn.empty { filter: grayscale(1) brightness(.7); }
.hover-btn.hidden { display: none; }
.hover-ico {
  width: 40px;
  height: 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #ffe0d2);
  transform: rotate(-20deg);
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.hover-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 900;
  line-height: 24px;
  background: var(--navy);
  box-shadow: inset 0 0 0 2px #fff;
}

.toasts {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 90%;
}
.toast {
  padding: 8px 18px;
  border-radius: 18px;
  font-weight: 900;
  font-size: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(47, 211, 107, .95), rgba(18, 138, 61, .95));
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  animation: toast 2.6s ease forwards;
}
.toast.gold { color: #5a2f00; background: linear-gradient(180deg, #fff27a, #ffb300); }
.toast.blue { background: linear-gradient(180deg, #6fb0ff, #2a7bf5); }
.toast.big { font-size: 26px; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(16px) scale(.7); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--glass);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .5s;
}
.hint.show { opacity: 1; }

.noscript { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--navy); font-size: 20px; }

/* Wide screens: sheets sit on the right so the 3D character stays visible */
@media (min-aspect-ratio: 1/1) {
  .screen-sheet {
    align-items: flex-end;
    justify-content: center;
    padding: calc(74px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) 16px;
    background: linear-gradient(90deg, rgba(10,30,80,0) 35%, rgba(10,30,80,.35));
  }
  .screen-sheet .sheet {
    width: min(50vw, 540px);
    max-height: 100%;
    border-radius: 28px;
    padding-bottom: 18px;
    transform: translateX(40px);
  }
  #screenSettings .sheet, #screenMissions .sheet { max-height: 100%; }
}
@media (max-aspect-ratio: 1/1) {
  #screenShop .sheet { max-height: 54%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .score-value { font-size: 20px; }
  .hud-btn { width: 44px; height: 44px; border-radius: 14px; }
  .distance-pill { font-size: 17px; }
  .coin-pill { font-size: 17px; }
  .nav-btn { font-size: 13px; }
  .pu-ring { width: 38px; height: 38px; }
  .pu-ring span { width: 31px; height: 31px; font-size: 17px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .screen-menu { flex-direction: row; flex-wrap: wrap; align-content: space-between; justify-content: center; }
  .menu-top { order: 0; }
  .menu-logo { width: 100%; margin-top: 0; }
  .logo-xl { font-size: 50px; }
  .menu-tag, .tap-hint { display: none; }
  .menu-mult { margin: 0 12px 0 0; align-self: center; }
  .btn-play { min-height: 56px; font-size: 24px; min-width: 170px; }
  .menu-nav { width: auto; margin-left: 14px; }
  .nav-btn { padding: 6px 12px; }
  .nav-ico { font-size: 20px; }
  .panel { padding: 14px 18px; }
  .panel h2 { font-size: 26px; margin-bottom: 6px; }
  .result-grid { grid-template-columns: repeat(3, 1fr); }
  .result-wide { grid-column: auto; }
  .result-wide b { font-size: 24px; }
  .btn-col { flex-direction: row; }
  .btn-col .btn { flex: 1; }
  .powerups { top: calc(64px + var(--st)); }
  .loader-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-play, .new-best { animation: none; }
}
