:root {
  --bg: #0d0f1f;
  --bg-2: #161a33;
  --panel: #1b2042;
  --panel-2: #232a5c;
  --line: rgba(255, 255, 255, .08);
  --text: #eef0ff;
  --muted: #8b90b8;
  --accent: #6c7bff;
  --accent-2: #a35cff;
  --gold: #ffcf4d;
  --green: #3ee08a;
  --pink: #ff5fcf;
  --danger: #ff5c7a;
  --app-h: var(--tg-viewport-stable-height, 100dvh);
  --ease-pop: cubic-bezier(.2, 1.4, .4, 1);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body {
  background:
    radial-gradient(120% 60% at 50% 0%, #1d2250 0%, transparent 60%),
    radial-gradient(80% 50% at 50% 110%, #1a1440 0%, transparent 60%),
    var(--bg);
}

button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; display: block; }
.hidden { display: none !important; }

/* ================= JUEGO ================= */
#app {
  height: var(--app-h);
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 0 2px;
}
.hud__left { display: flex; align-items: center; gap: 10px; }
.hud__stat { display: flex; flex-direction: column; gap: 2px; }
.hud__stat--right { align-items: flex-end; }
.hud__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hud__value { font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.hud__center { text-align: center; }
.hud__score { font-size: 42px; font-weight: 700; line-height: 1.05; text-shadow: 0 3px 14px rgba(108, 123, 255, .45); }
.hud__level {
  display: inline-block; margin-top: 2px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  padding: 2px 10px; border-radius: 10px;
  background: rgba(108, 123, 255, .18); color: #b9c0ff;
}
.hud__level.up { animation: levelup .6s ease; }
@keyframes levelup { 0% { transform: scale(1); } 40% { transform: scale(1.35); background: var(--gold); color: #3a2600; } 100% { transform: scale(1); } }

.coin {
  display: inline-block;
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c9 0 18%, var(--gold) 40%, #c98a12 100%);
  box-shadow: 0 0 6px rgba(255, 207, 77, .6);
  vertical-align: -1px;
}

.gem {
  display: inline-block; flex: none;
  width: 14px; height: 14px;
  background: linear-gradient(135deg, #e6fbff 0%, #6fe7ff 30%, #2fa8ff 60%, #7b5cff 100%);
  clip-path: polygon(50% 0, 100% 38%, 50% 100%, 0 38%);
  filter: drop-shadow(0 0 4px rgba(111, 231, 255, .7));
  vertical-align: -1px;
}
.gem--xl { width: 44px; height: 44px; }

/* Objetivos de gemas durante la partida */
.goals { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; min-height: 0; }
.goal {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 10px;
  background: rgba(111, 231, 255, .1);
  box-shadow: inset 0 0 0 1px rgba(111, 231, 255, .25);
  color: #bdf3ff;
  position: relative; overflow: hidden;
}
.goal i { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(111, 231, 255, .18); z-index: 0; transition: width .3s ease; }
.goal > *:not(i) { position: relative; z-index: 1; }
.goal--off { opacity: .45; text-decoration: line-through; }
.goal--done { background: rgba(62, 224, 138, .18); color: var(--green); box-shadow: inset 0 0 0 1px rgba(62, 224, 138, .4); }

#stage { flex: 1; position: relative; min-height: 0; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.bar { display: flex; justify-content: center; padding-top: 6px; }

/* ================= BOTONES ================= */
.btn {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .08s ease, filter .15s ease, opacity .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn--primary { background: linear-gradient(180deg, #7f8cff, #5563f0); box-shadow: 0 4px 0 #3a45b8, 0 8px 20px rgba(85, 99, 240, .35); }
.btn--gold { background: linear-gradient(180deg, #ffd96b, #f0aa22); color: #3a2600; box-shadow: 0 4px 0 #b37700, 0 8px 20px rgba(240, 170, 34, .3); }
.btn--ghost { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.btn--grow { flex: 1; }
.btn__svg { width: 20px; height: 20px; }
.btn__ad {
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 5px; border-radius: 6px;
  background: rgba(0, 0, 0, .28);
}
.btn__count {
  min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--accent); font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 13px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .08s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--flat { background: transparent; box-shadow: none; }

.link-btn {
  background: none; border: 0; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 10px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  box-shadow: inset 0 0 0 1px rgba(255, 207, 77, .25);
  font-size: 17px;
}
.pill .coin { width: 18px; height: 18px; }
.pill--sm { font-size: 15px; padding: 5px 12px 5px 8px; margin-left: auto; }
.pill--sm .coin { width: 15px; height: 15px; }
.pill.bump { animation: bump .45s var(--ease-pop); }
.wallet { display: flex; gap: 8px; }
.pill--gem { border: 0; cursor: pointer; color: var(--text); box-shadow: inset 0 0 0 1px rgba(111, 231, 255, .35); }
.pill--gem .gem { width: 17px; height: 17px; }
.btn--gem { background: linear-gradient(180deg, #6fe7ff, #3f7bff); color: #041a3a; box-shadow: 0 4px 0 #2a4fb8, 0 8px 20px rgba(63, 123, 255, .35); }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ================= MENÚ ================= */
.menu {
  position: fixed; inset: 0; z-index: 5;
  background:
    radial-gradient(90% 50% at 50% 0%, #2a2f78 0%, transparent 70%),
    radial-gradient(70% 45% at 100% 100%, #3a1d6e 0%, transparent 70%),
    radial-gradient(60% 40% at 0% 80%, #13306b 0%, transparent 70%),
    var(--bg);
  overflow: hidden;
  overflow: clip; /* los bloques que caen no deben hacer scroll */
  animation: fade .3s ease;
}
.menu__bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; overflow: clip; }
.menu__bg span {
  position: absolute; top: -60px;
  background-size: cover;
  opacity: .5;
  animation: fall linear infinite;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
}
@keyframes fall {
  from { transform: translateY(-80px) rotate(0deg); }
  to { transform: translateY(calc(var(--app-h) + 120px)) rotate(var(--rot, 180deg)); }
}

.menu__inner {
  position: relative;
  height: var(--app-h);
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.menu__top { width: 100%; display: flex; justify-content: space-between; align-items: center; }

.menu__logo { margin-top: auto; text-align: center; }
.logo-blocks {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  width: 78px; margin: 0 auto 12px;
  transform: rotate(-8deg);
  animation: float 3.2s ease-in-out infinite;
}
.logo-blocks i {
  aspect-ratio: 1; border-radius: 9px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .25), inset 0 3px 0 rgba(255, 255, 255, .35), 0 6px 14px rgba(0, 0, 0, .35);
}
.logo-blocks i:nth-child(1) { background: linear-gradient(160deg, #7fe3ff, #23b4f0); }
.logo-blocks i:nth-child(2) { background: linear-gradient(160deg, #dcb3ff, #a35cff); }
.logo-blocks i:nth-child(3) { background: linear-gradient(160deg, #ffe58a, #ffbf1f); }
.logo-blocks i:nth-child(4) { background: linear-gradient(160deg, #ff9eb0, #ff3d63); }
@keyframes float { 50% { transform: rotate(-4deg) translateY(-6px); } }

.menu__logo h1 {
  margin: 0;
  font-size: clamp(46px, 14vw, 64px);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 10%, #b9c0ff 60%, #8a7bff 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #2b2f7a) drop-shadow(0 10px 24px rgba(108, 123, 255, .5));
}
.menu__tag { margin: 10px 0 0; color: #b9c0ff; font-weight: 600; letter-spacing: .14em; font-size: 13px; text-transform: uppercase; }

.menu__best {
  margin-top: 22px;
  display: flex; flex-direction: column; align-items: center;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em;
}
.menu__best b { color: var(--text); font-size: 26px; letter-spacing: 0; }

.menu__play { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.btn--play {
  width: min(320px, 100%);
  font-size: 24px; font-weight: 700; letter-spacing: .06em;
  padding: 18px 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, #5cf0a0 0%, #22c46e 100%);
  color: #06301a;
  box-shadow: 0 6px 0 #148a4b, 0 14px 30px rgba(34, 196, 110, .4), inset 0 2px 0 rgba(255, 255, 255, .5);
  animation: breathe 2.2s ease-in-out infinite;
}
.btn--play .btn__svg { width: 26px; height: 26px; }
@keyframes breathe { 50% { transform: scale(1.035); } }

.menu__cards {
  width: 100%;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 18px;
}
.card {
  position: relative;
  border: 0; cursor: pointer;
  padding: 14px 8px 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .03));
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 20px rgba(0, 0, 0, .25);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .08s ease;
}
.card:active { transform: scale(.95); }
.card__icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2), inset 0 2px 0 rgba(255, 255, 255, .3);
}
.card__icon svg { width: 24px; height: 24px; color: #fff; }
.card__icon--blue { background: linear-gradient(160deg, #6fd6ff, #3a7bff); }
.card__icon--pink { background: linear-gradient(160deg, #ff9ee4, #d445ff); }
.card__icon--gold { background: linear-gradient(160deg, #ffe07a, #ff9d1f); }
.card__title { font-weight: 600; font-size: 15px; }
.card__sub { font-size: 12px; color: var(--muted); }
.card--glow { box-shadow: inset 0 0 0 1.5px rgba(255, 207, 77, .6), 0 0 22px rgba(255, 207, 77, .25); }

.badge {
  position: absolute; top: 6px; right: 8px;
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
  background: var(--danger); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px var(--bg);
  animation: pop .3s var(--ease-pop);
}
.badge--dot { min-width: 12px; width: 12px; height: 12px; padding: 0; top: 10px; right: 12px; }

/* ================= HOJAS ================= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5, 6, 16, .6);
  backdrop-filter: blur(3px);
  animation: fade .2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto;
  max-height: calc(var(--app-h) - 40px);
  overflow-y: auto;
  touch-action: pan-y;
  background: linear-gradient(180deg, #242b60, #171b3a 60%);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12);
  animation: slideup .32s var(--ease-pop);
}
.sheet::before {
  content: ''; display: block; width: 44px; height: 5px; border-radius: 3px;
  background: rgba(255, 255, 255, .2); margin: 0 auto 8px;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__head { display: flex; align-items: center; gap: 10px; }
.sheet__head h2 { margin: 0; font-size: 22px; flex: 1; }
.sheet__head .pill--sm + .icon-btn { margin-left: 0; }
.sheet__sub { margin: 2px 0 14px; color: var(--muted); font-size: 14px; }
.sheet__section { margin: 18px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.sheet__foot { color: var(--muted); font-size: 13px; text-align: center; margin: 14px 0 0; }
.sheet__section { display: flex; align-items: center; gap: 8px; }
.sheet__section--gem { color: #bdf3ff; }
.sheet__hint { margin: -4px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
#sheet-gems .btn { width: 100%; margin-top: 10px; }

.mission--gem { background: linear-gradient(120deg, rgba(111, 231, 255, .1), rgba(123, 92, 255, .1)); box-shadow: inset 0 0 0 1px rgba(111, 231, 255, .3); }
.mission--gem .mission__bar i { background: linear-gradient(90deg, #6fe7ff, #7b5cff); }
.mission__tier--gem { background: rgba(111, 231, 255, .15); }
.mission__tier--gem .gem { width: 18px; height: 18px; }
.mission__tag {
  display: inline-block; margin-top: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 8px;
}
.mission__tag--help { background: rgba(255, 207, 77, .15); color: var(--gold); }
.mission__tag--clean { background: rgba(255, 95, 207, .15); color: var(--pink); }
.mission__btn--gem { background: linear-gradient(180deg, #6fe7ff, #3f7bff); color: #041a3a; box-shadow: 0 3px 0 #2a4fb8; animation: breathe 1.6s ease-in-out infinite; }

.gem-wallet { text-align: center; margin: 8px 0 14px; }
.gem-wallet__big { display: inline-flex; align-items: center; gap: 12px; font-size: 52px; font-weight: 700; }
.gem-wallet__value { color: #bdf3ff; font-weight: 600; margin-top: 2px; }
.gem-log { display: flex; flex-direction: column; gap: 8px; }
.gem-log__row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .05); font-size: 14px;
}
.gem-log__row span:nth-child(2) { flex: 1; }
.gem-log__row small { color: var(--muted); font-size: 11px; }
.gem-log__empty { color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }

/* Fin de partida: progreso hacia la gema y vidas */
.go-gems { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.go-gem {
  text-align: left; padding: 10px 12px; border-radius: 14px;
  background: linear-gradient(120deg, rgba(111, 231, 255, .12), rgba(123, 92, 255, .12));
  box-shadow: inset 0 0 0 1px rgba(111, 231, 255, .3);
  font-size: 13px;
}
.go-gem b { color: #bdf3ff; }
.go-gem .mission__bar { margin-top: 6px; height: 7px; }
.go-gem .mission__bar i { background: linear-gradient(90deg, #6fe7ff, #7b5cff); }
.go-gem--done { box-shadow: inset 0 0 0 1px rgba(62, 224, 138, .5); }
.lives { display: flex; justify-content: center; gap: 6px; margin-top: -4px; font-size: 12px; color: var(--muted); align-items: center; }
.lives i { width: 10px; height: 10px; border-radius: 50%; background: #ff5c7a; box-shadow: 0 0 6px rgba(255, 92, 122, .6); }
.lives i.used { background: rgba(255, 255, 255, .15); box-shadow: none; }

/* Misiones */
.missions { display: flex; flex-direction: column; gap: 10px; }
.mission {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 18px;
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 0 0 0 1px var(--line);
}
.mission__tier {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.mission__tier--0 { background: rgba(62, 224, 138, .18); color: var(--green); }
.mission__tier--1 { background: rgba(108, 123, 255, .2); color: #b9c0ff; }
.mission__tier--2 { background: rgba(255, 95, 207, .18); color: var(--pink); }
.mission__body { flex: 1; min-width: 0; }
.mission__text { font-weight: 600; font-size: 15px; line-height: 1.25; }
.mission__bar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .35); margin-top: 8px; overflow: hidden; }
.mission__bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #6c7bff, #a35cff); transition: width .4s ease; }
.mission--done .mission__bar i { background: linear-gradient(90deg, #3ee08a, #b6ff5c); }
.mission__count { font-size: 12px; color: var(--muted); margin-top: 4px; }
.mission__btn {
  flex: none; border: 0; cursor: pointer;
  border-radius: 12px; padding: 9px 12px;
  font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, .07); color: var(--muted);
}
.mission__btn--claim { background: linear-gradient(180deg, #ffd96b, #f0aa22); color: #3a2600; box-shadow: 0 3px 0 #b37700; animation: breathe 1.6s ease-in-out infinite; }
.mission__btn--claimed { background: rgba(62, 224, 138, .15); color: var(--green); }

/* Tienda */
.free-coins {
  width: 100%; border: 0; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 18px; margin-top: 12px;
  background: linear-gradient(120deg, rgba(62, 224, 138, .22), rgba(108, 123, 255, .18));
  box-shadow: inset 0 0 0 1px rgba(62, 224, 138, .35);
  text-align: left;
}
.free-coins:disabled { opacity: .5; }
.free-coins__icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(160deg, #5cf0a0, #22c46e);
  display: flex; align-items: center; justify-content: center; color: #06301a;
}
.free-coins__text { flex: 1; display: flex; flex-direction: column; }
.free-coins__text small { color: var(--muted); font-size: 12px; }
.free-coins__amount { font-weight: 700; font-size: 18px; display: inline-flex; align-items: center; gap: 5px; color: var(--gold); }

.skins { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.skin {
  position: relative;
  border-radius: 20px; padding: 12px;
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 0 0 0 1px var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.skin--active { box-shadow: inset 0 0 0 2px var(--green), 0 0 20px rgba(62, 224, 138, .2); }
.skin canvas { width: 88px; height: 88px; }
.skin__name { font-weight: 600; font-size: 15px; text-align: center; }
.skin__desc { font-size: 12px; color: var(--muted); text-align: center; margin-top: -6px; }
.skin__btn {
  width: 100%; border: 0; cursor: pointer;
  border-radius: 12px; padding: 9px;
  font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.skin__btn--buy { background: linear-gradient(180deg, #ffd96b, #f0aa22); color: #3a2600; box-shadow: 0 3px 0 #b37700; }
.skin__btn--buy:disabled { background: rgba(255, 255, 255, .08); color: var(--muted); box-shadow: none; }
.skin__btn--use { background: linear-gradient(180deg, #7f8cff, #5563f0); box-shadow: 0 3px 0 #3a45b8; }
.skin__btn--active { background: rgba(62, 224, 138, .15); color: var(--green); cursor: default; }

/* Ajustes */
.settings { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600; cursor: pointer;
}
.toggle input { display: none; }
.toggle i {
  width: 50px; height: 30px; border-radius: 15px; position: relative;
  background: rgba(255, 255, 255, .15); transition: background .2s;
}
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  transition: transform .2s var(--ease-pop);
}
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { transform: translateX(20px); }
.howto p { margin: 0; color: #c3c7e8; line-height: 1.5; font-size: 15px; }

.pause-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.pause-actions .btn { width: 100%; }
.settings--compact { margin-top: 0; }

/* ================= FIN DE PARTIDA ================= */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 16, .72);
  backdrop-filter: blur(4px);
  z-index: 10;
  padding: 16px;
  animation: fade .25s ease;
}
.modal__card {
  width: min(340px, 100%);
  background: linear-gradient(180deg, #232a5c, #171b3a);
  border-radius: 24px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .1);
  animation: pop .3s var(--ease-pop);
}
.modal h2 { margin: 0; font-size: 22px; color: var(--muted); font-weight: 600; }
.modal__score { font-size: 56px; font-weight: 700; margin: 4px 0; }
.modal__record { color: var(--gold); font-weight: 700; margin-bottom: 6px; animation: breathe 1.4s ease-in-out infinite; }
.modal__line { color: var(--muted); margin: 4px 0; display: flex; gap: 6px; justify-content: center; align-items: center; }
.modal__line b { color: var(--text); }
.modal__actions { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.modal__actions > .btn { width: 100%; }
.modal__row { display: flex; gap: 10px; }

/* ================= TOAST ================= */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: #2a2f5c; color: var(--text);
  padding: 11px 18px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 0 0 1px var(--line);
  z-index: 60; max-width: calc(100% - 32px); text-align: center; font-weight: 600;
  animation: toastin .3s var(--ease-pop);
}
.toast--good { background: linear-gradient(180deg, #2f7a55, #1f5a3e); }
@keyframes toastin { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ================= ANUNCIO DE PRUEBA ================= */
.ad-test {
  position: fixed; inset: 0; z-index: 70;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.ad-test__box { text-align: center; }
.ad-test__tag { font-size: 22px; font-weight: 700; color: #fff; }
.ad-test__count { font-size: 64px; font-weight: 700; color: var(--gold); margin: 10px 0; }
.ad-test__place { color: #777; font-size: 13px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .menu__bg span, .btn--play, .logo-blocks, .mission__btn--claim, .modal__record { animation: none; }
}
@media (max-height: 640px) {
  .logo-blocks { width: 56px; margin-bottom: 8px; }
  .menu__best { margin-top: 12px; }
  .card { padding: 10px 6px; }
  .card__icon { width: 38px; height: 38px; }
}
