:root {
  --ink: #1f2430;
  --ink-soft: #5b6272;
  --night: #14182a;
  --gold: #f2c230;
  --gold-dark: #c99a22;
  --accent: #c8342e;
  --accent-dark: #9e2520;
  --card: rgba(255, 255, 255, 0.94);
  --pill: rgba(20, 24, 42, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #a8dcf5;
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

.game {
  position: fixed;
  inset: 0;
}

.game canvas {
  display: block;
  width: 100%;
  height: 100%;
}

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

.hud {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

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

.hud-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--pill);
  color: #fff;
}

.hud-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 0.9rem;
  opacity: 0.85;
}

.collectible-icon {
  align-self: center;
  width: 26px;
  height: 26px;
}

.festival-banner {
  position: fixed;
  top: calc(var(--safe-top) + 72px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 22px 14px;
  border-radius: 20px;
  background: var(--festival-color, var(--night));
  box-shadow: 0 10px 30px rgba(20, 24, 42, 0.3);
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.festival-banner.is-showing {
  animation: banner-in-out 2.8s ease both;
}

.festival-banner p {
  margin: 0;
}

.festival-banner-lap {
  margin-bottom: 4px !important;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 800;
}

.festival-banner-name {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.1;
}

.festival-banner-phrase {
  margin-top: 2px !important;
  font-size: 1.05rem;
  font-weight: 600;
  opacity: 0.92;
}

@keyframes banner-in-out {
  0% {
    opacity: 0;
    transform: translate(-50%, -16px) scale(0.92);
  }
  12%,
  82% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .festival-banner.is-showing,
  .flash.is-flashing,
  .toast.is-showing,
  .discovery.is-showing,
  .screen.is-rising:not([hidden]),
  .screen.is-rising:not([hidden]) > .card,
  .tutorial-gesture,
  .loading-bar-fill {
    animation: none !important;
  }
}

.hud-pause {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--pill);
  pointer-events: auto;
  cursor: pointer;
}

.pause-icon {
  width: 16px;
  height: 18px;
  border-left: 5px solid #fff;
  border-right: 5px solid #fff;
}

.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.hud-powerup {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--pill);
}

.powerup-icon {
  width: 30px;
  height: 30px;
}

.powerup-track {
  width: 90px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.powerup-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--gold);
}

.hud-shield {
  width: 40px;
  height: 40px;
  padding: 5px;
  border-radius: 50%;
  background: var(--pill);
  box-shadow: 0 0 0 3px var(--gold);
}

/* Small pill below the character, over the road already run, so it never
   hides what is coming. */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 6%);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  column-gap: 8px;
  width: max-content;
  max-width: min(calc(100% - 32px), 440px);
  padding: 6px 16px;
  border-radius: 18px;
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(20, 24, 42, 0.25);
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.toast.is-showing {
  animation: toast-in 0.18s ease-out both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

.toast[data-variant="powerup"] {
  background: var(--night);
  box-shadow: 0 0 0 3px var(--gold);
}

.toast[data-variant="golden"] {
  background: var(--gold);
  color: var(--night);
}

.toast-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.toast-detail {
  font-size: 0.85rem;
  font-weight: 600;
}

/* First pickup of each power-up or golden object (slow motion): a card
   below the character, over the road already run, so the road ahead stays
   clear. Icon on the left, what it does on the right. */
.discovery {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 3%);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(calc(100% - 24px), 440px);
  padding: 10px 16px 10px 12px;
  border-radius: 20px;
  background: var(--night);
  box-shadow:
    0 0 0 3px var(--gold),
    0 10px 30px rgba(20, 24, 42, 0.35);
  color: #fff;
  text-align: left;
  pointer-events: none;
}

.discovery[data-variant="golden"] {
  background: linear-gradient(180deg, #fff6d6, #f7d667);
  color: var(--night);
  box-shadow:
    0 0 0 3px #fff,
    0 0 30px rgba(255, 214, 90, 0.8);
}

.discovery.is-showing {
  animation: discovery-in-out 4.2s ease both;
}

.discovery-icon {
  flex: none;
  width: 56px;
  height: 56px;
}

.discovery-text {
  display: flex;
  flex-direction: column;
}

.discovery-kicker {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.discovery[data-variant="golden"] .discovery-kicker {
  color: var(--accent-dark);
}

.discovery-title {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.15;
}

.discovery-detail {
  margin-top: 2px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}

.discovery-extra {
  margin-top: 2px;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 900;
}

.discovery[data-variant="golden"] .discovery-extra {
  color: var(--accent);
}

/* Rises from the bottom edge, stays, and sinks back. */
@keyframes discovery-in-out {
  0% {
    opacity: 0;
    transform: translate(-50%, 24px) scale(0.92);
  }

  8% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.03);
  }

  13%,
  86% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, 24px) scale(0.96);
  }
}

.flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 236, 160, 0.75), rgba(255, 210, 90, 0.2) 70%);
  pointer-events: none;
  opacity: 0;
}

.flash.is-flashing {
  animation: flash 0.6s ease-out both;
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ---- Screens ---- */

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  touch-action: pan-y;
  background: rgba(20, 24, 42, 0.35);
}

/* After a crash the screen rises slowly, leaving a moment to see the chaser
   that caught the player. */
.screen.is-rising:not([hidden]) {
  animation: screen-fade-in 1.2s ease both;
}

.screen.is-rising:not([hidden]) > .card {
  animation: screen-rise-in 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes screen-fade-in {
  from {
    background-color: transparent;
  }
}

@keyframes screen-rise-in {
  from {
    opacity: 0;
    transform: translateY(60vh);
  }
}

.screen-home {
  background: linear-gradient(rgba(20, 24, 42, 0.05), rgba(20, 24, 42, 0.3));
}

.card > * + button,
.card > button + * {
  margin-top: 10px;
}

.card-text {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.4;
}

.card-note {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.card-subtitle {
  margin: 18px 0 8px;
  font-size: 1.1rem;
}

.card-wide {
  max-width: 520px;
}

.button-secondary,
.button-ad,
.button-share {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.button-secondary {
  border: 2px solid rgba(31, 36, 48, 0.18);
  background: transparent;
  color: var(--ink);
}

.button-ad {
  border: 0;
  background: var(--gold);
  box-shadow: 0 4px 0 var(--gold-dark);
  color: var(--night);
}

.button-ad::before {
  content: "▶ ";
}

/* A free gift instead of an ad (gifts.js). */
.button-ad.is-gift::before {
  content: "🎁 ";
}

.button-link {
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 1rem;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
}

.button-secondary:focus-visible,
.button-ad:focus-visible,
.button-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.home-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 8px;
}

.reached {
  margin: 0 0 14px;
  font-weight: 700;
}

.record-badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--gold);
  font-weight: 800;
}

.festival-counts {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.festival-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.festival-count img {
  width: 32px;
  height: 32px;
}

.festival-count.is-unreached {
  opacity: 0.3;
}

.goldens {
  margin: 0 0 14px;
  color: var(--gold-dark);
  font-weight: 700;
}

.countdown {
  margin: 0 0 6px;
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
}

/* ---- Loading ---- */

.screen-loading {
  background: var(--night);
}

.loading-bar {
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(31, 36, 48, 0.12);
  overflow: hidden;
}

.loading-bar-fill {
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  animation: loading 1.1s ease-in-out infinite alternate;
}

@keyframes loading {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(210%);
  }
}

/* ---- Tutorial ---- */

.tutorial-hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18%);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 14px 22px;
  border-radius: 20px;
  background: rgba(20, 24, 42, 0.82);
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.tutorial-text {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.tutorial-gesture {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, rgba(255, 255, 255, 0.25) 32%);
}

.tutorial-gesture[data-gesture="dodge"] {
  animation: gesture-sideways 1s ease-in-out infinite alternate;
}

.tutorial-gesture[data-gesture="jump"] {
  animation: gesture-up 0.9s ease-in-out infinite;
}

.tutorial-gesture[data-gesture="slide"] {
  animation: gesture-down 0.9s ease-in-out infinite;
}

@keyframes gesture-sideways {
  from {
    transform: translateX(-40px);
  }
  to {
    transform: translateX(40px);
  }
}

@keyframes gesture-up {
  from {
    transform: translateY(20px);
    opacity: 1;
  }
  to {
    transform: translateY(-20px);
    opacity: 0.2;
  }
}

@keyframes gesture-down {
  from {
    transform: translateY(-20px);
    opacity: 1;
  }
  to {
    transform: translateY(20px);
    opacity: 0.2;
  }
}

/* ---- Simulated ad ---- */

.ad-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #101322;
  color: #fff;
  text-align: center;
}

.ad-box {
  width: 100%;
  max-width: 380px;
}

.ad-label {
  display: inline-block;
  margin: 0 0 18px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ad-message {
  margin: 0 0 12px;
  font-size: 1.8rem;
  font-weight: 800;
}

.ad-countdown {
  margin: 0 0 22px;
  color: rgba(255, 255, 255, 0.75);
}

.ad-box .button-primary:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- Statistics ---- */

.stats-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  margin: 0;
  text-align: left;
}

.stats-list dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.stats-table {
  width: 100%;
  margin-bottom: 16px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stats-table th,
.stats-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(31, 36, 48, 0.12);
}

.stats-table td:first-child,
.stats-table th:first-child {
  text-align: left;
}

.card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 24px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(20, 24, 42, 0.35);
  text-align: center;
}

.title {
  margin: 0;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--night);
}

.subtitle {
  margin: 4px 0 18px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.controls-hint,
.error-message {
  margin: 0 0 22px;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.card-title {
  margin: 0 0 18px;
  font-size: 2rem;
  font-weight: 900;
}

.button-primary {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 5px 0 var(--accent-dark);
  color: #fff;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}

.button-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--accent-dark);
}

.button-primary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.score {
  margin: 0 0 14px;
}

.score-value {
  display: block;
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-label,
.stat-label {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 22px;
}

.stat {
  margin: 0;
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---- Home extras ---- */

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

.button-row .button-secondary {
  flex: 1;
}

.missions {
  margin-top: 18px;
  text-align: left;
}

.missions-title {
  margin: 0 0 8px;
  font-size: 1rem;
}

.missions-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mission {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(31, 36, 48, 0.06);
  font-size: 0.92rem;
}

.mission-reward {
  /* "+60" reads the same in Hebrew. */
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--gold-dark);
  font-weight: 800;
}

.mission-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 36, 48, 0.12);
  overflow: hidden;
}

.mission-bar span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.mission.is-done {
  background: rgba(242, 194, 48, 0.2);
}

.mission.is-done .mission-text {
  text-decoration: line-through;
  opacity: 0.7;
}

/* ---- Shop ---- */

.screen-shop {
  align-items: end;
  padding: 0;
  background: none;
}

.shop-panel {
  width: 100%;
  max-width: 560px;
  max-height: 58vh;
  margin: 0 auto;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  box-shadow: 0 -10px 40px rgba(20, 24, 42, 0.3);
}

/* On wide screens the panel goes to the right, leaving the character big on
   the left. */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .screen-shop {
    justify-items: end;
    align-items: stretch;
  }

  .shop-panel {
    width: 440px;
    max-width: 44vw;
    max-height: none;
    margin: 0;
    padding-top: calc(var(--safe-top) + 16px);
    border-radius: 22px 0 0 22px;
    box-shadow: -10px 0 40px rgba(20, 24, 42, 0.3);
  }
}

/* Arrows on each side of the character; shop-screen.js places them. */
.shop-turn {
  position: fixed;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(20, 24, 42, 0.25);
  color: var(--ink);
  font-size: 1.2rem;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.shop-turn:active {
  transform: translate(-50%, -50%) scale(0.92);
}

.shop-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shop-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
}

.shop-piggy {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.button-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 36, 48, 0.08);
  font-size: 1.2rem;
  cursor: pointer;
}

.shop-tabs,
.shop-filters {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  touch-action: pan-x;
}

.shop-tab,
.shop-filter {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 2px solid rgba(31, 36, 48, 0.15);
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* The five tabs share the width, so "Poderes" fits on a phone too. */
.shop-tab {
  flex: 1 1 auto;
  padding: 0 6px;
  font-size: 0.82rem;
}

.shop-tabs {
  flex-wrap: wrap;
  gap: 4px;
}

.shop-tab[aria-selected="true"] {
  border-color: var(--night);
  background: var(--night);
  color: #fff;
}

.shop-filter {
  min-height: 34px;
  font-size: 0.85rem;
}

.shop-filter[aria-pressed="true"] {
  border-color: var(--festival-color, var(--night));
  background: var(--festival-color, var(--night));
  color: #fff;
}

.shop-filter.is-complete::after {
  content: " ★";
  color: var(--gold);
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.shop-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 2px solid transparent;
  border-left: 6px solid var(--festival-color);
  border-radius: 14px;
  background: rgba(31, 36, 48, 0.05);
  cursor: pointer;
}

.shop-item.is-selected {
  border-color: var(--festival-color);
}

.shop-item.is-golden {
  background: rgba(242, 194, 48, 0.18);
}

.shop-item-festival {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.shop-item-name {
  font-weight: 800;
}

.shop-item-button {
  min-height: 40px;
  margin-top: auto;
  border: 2px solid rgba(31, 36, 48, 0.15);
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}

.shop-item-button.is-buy {
  border-color: var(--gold-dark);
  background: var(--gold);
}

.shop-item-button.is-confirming {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #fff;
}

.shop-item-button:disabled {
  color: var(--ink-soft);
  cursor: default;
}

/* ---- Leaderboard, nickname and settings ---- */

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rank-note {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 800;
}

.segmented {
  display: flex;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(31, 36, 48, 0.08);
}

.segment {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}

.segment[aria-selected="true"] {
  background: #fff;
  box-shadow: 0 2px 6px rgba(20, 24, 42, 0.15);
}

.ranking-list {
  max-height: 46vh;
  margin: 0 0 10px;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  text-align: left;
}

.ranking-entry {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(31, 36, 48, 0.08);
}

.ranking-entry.is-me {
  border-radius: 10px;
  background: rgba(242, 194, 48, 0.25);
}

.ranking-rank {
  color: var(--ink-soft);
  font-weight: 800;
}

.ranking-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.ranking-badge {
  width: 18px;
  height: 18px;
}

.ranking-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.recovery-code {
  margin: 0 0 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 2px;
  -webkit-user-select: text;
  user-select: text;
}

.settings-preferences {
  margin-bottom: 8px;
}

.preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid rgba(31, 36, 48, 0.08);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.preference-switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: rgba(31, 36, 48, 0.2);
  transition: background 0.2s;
}

.preference-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 24, 42, 0.3);
  transition: transform 0.2s;
}

.preference[aria-checked="true"] .preference-switch {
  background: var(--accent);
}

.preference[aria-checked="true"] .preference-switch::after {
  transform: translateX(18px);
}

.text-input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 0 12px;
  border: 2px solid rgba(31, 36, 48, 0.2);
  border-radius: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.1rem;
  text-transform: uppercase;
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}

.card-note.is-error {
  color: var(--accent);
  font-weight: 700;
}

/* Ajustes → "Menos destellos" */
.reduce-flashes .flash {
  display: none;
}

.settings-link {
  display: block;
  margin: 4px 0 12px;
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---- Cómo se juega: the videos, side by side ---- */

.howto {
  max-width: 760px;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.howto-clip {
  margin: 0;
}

/* On phones the third video sits centered below the other two, and its
   list of power-ups uses the whole width. */
.howto-clip-wide {
  grid-column: 1 / -1;
}

.howto-clip.howto-clip-wide video {
  width: calc(50% - 6px);
  margin: 0 auto;
}

.howto-clip video {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  background: var(--night);
  object-fit: cover;
}

.howto-clip figcaption {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

@media (min-width: 700px) {
  .howto-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .howto-clip-wide {
    grid-column: auto;
  }

  .howto-clip.howto-clip-wide video {
    width: 100%;
  }
}

/* ---- Home screen: compact, everything leads to "Jugar" ---- */

.card-home {
  position: relative;
  padding: 22px 20px 18px;
}

.card-home .title {
  font-size: 2.5rem;
  line-height: 1.05;
}

.card-home .subtitle {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.card-home .home-stats {
  margin-bottom: 14px;
}

.card-home .stat-value {
  font-size: 1.35rem;
}

.card-home .stat-label {
  font-size: 0.85rem;
}

.home-settings {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.home-settings svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.home-settings:hover,
.home-settings:focus-visible {
  background: rgba(31, 36, 48, 0.08);
}

/* The language flag, top left, across from Ajustes (language-picker.js). */
.home-language {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  cursor: pointer;
}

.home-language .flag {
  width: 26px;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(31, 36, 48, 0.18);
}

.home-language:hover,
.home-language:focus-visible {
  background: #f3f0ea;
}

.language-menu {
  position: absolute;
  z-index: 5;
  top: 60px;
  left: 10px;
  display: grid;
  gap: 4px;
  min-width: 170px;
  padding: 6px;
  border-radius: 16px;
  background: #fff;
  box-shadow:
    0 3px 0 var(--line),
    0 10px 24px rgba(31, 36, 48, 0.18);
}

.language-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}

.language-option .flag {
  flex: none;
  width: 30px;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(31, 36, 48, 0.18);
}

.language-option:hover,
.language-option:focus-visible {
  background: #f3f0ea;
}

.language-option[aria-current="true"] {
  background: #fdf3d6;
}

.button-tutorial {
  display: block;
  min-height: 38px;
  margin: 12px auto 12px;
  padding: 6px 26px;
  border: 2px solid rgba(31, 36, 48, 0.15);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

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

.home-row .button-secondary {
  flex: 1;
}

.button-podium {
  display: grid;
  flex: none;
  place-items: center;
  width: 64px;
  min-height: 48px;
  border: 2px solid rgba(31, 36, 48, 0.15);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.button-podium svg {
  width: 40px;
  height: 34px;
}

.button-podium text {
  fill: var(--night);
  font-family: inherit;
  font-size: 9px;
  font-weight: 900;
}

.card-home .missions {
  margin-top: 14px;
}

.card-home .missions-title {
  font-size: 0.9rem;
}

.card-home .mission {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* ---- Ajustes: the recovery code, compact ---- */

.recovery {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(31, 36, 48, 0.1);
}

.recovery-label {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: 800;
}

.recovery-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.save-code-row {
  margin: 4px 0 16px;
  padding: 12px 10px;
  border: 3px dashed var(--line);
  border-radius: 16px;
  background: #fffdf5;
}

.save-code-row .save-code {
  margin: 0;
  font-size: clamp(1.4rem, 7vw, 1.9rem);
}

.recovery .recovery-code {
  margin: 0;
  font-size: 1.3rem;
}

.recovery-copy {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(31, 36, 48, 0.15);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.recovery-copy svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.recovery-help {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.recovery-toggle {
  min-height: 40px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

#recover-form {
  margin-top: 6px;
}

/* "Shofar → Monedas x2": the power-ups under their video. */
.howto-powerups {
  display: grid;
  gap: 3px;
  width: fit-content;
  margin: 6px auto 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.howto-powerups li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.howto-powerups img {
  width: 22px;
  height: 22px;
}

/* The coins of the five festivals take turns, one second each. */
.coin-cycle {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  margin-top: 2px;
}

.coin-cycle img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: coin-turn 5s infinite;
}

@keyframes coin-turn {
  0%,
  17% {
    opacity: 1;
    transform: scale(1);
  }

  20%,
  97% {
    opacity: 0;
    transform: scale(0.6);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coin-cycle img {
    animation: none;
  }

  .coin-cycle img:not(:first-child) {
    display: none;
  }
}

/* Next to a number (the piggy bank on the home screen). */
.coin-cycle.coin-cycle-inline {
  width: 22px;
  height: 22px;
  margin: 0 0 0 4px;
  vertical-align: -3px;
}

/* ---- Mantel de Shabat: the button at the start of a run ---- */

.tablecloth-button {
  position: fixed;
  top: 42%;
  left: calc(var(--safe-left) + 12px);
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  box-shadow:
    0 0 0 3px var(--gold),
    0 8px 22px rgba(20, 24, 42, 0.35);
  cursor: pointer;
  animation: tablecloth-call 1.2s ease-in-out infinite alternate;
}

.tablecloth-button img {
  width: 58px;
  height: 58px;
}

.tablecloth-count {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
}

@keyframes tablecloth-call {
  to {
    transform: scale(1.07);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tablecloth-button {
    animation: none;
  }
}

/* ---- Shop: the "Poderes" tab ---- */

.shop-power {
  grid-column: 1 / -1;
  border-left-color: var(--gold);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: center;
  text-align: left;
}

.shop-power-icon {
  grid-row: span 3;
  width: 64px;
  height: 64px;
}

.shop-power-description {
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.3;
}

.shop-power-owned {
  font-size: 0.9rem;
  font-weight: 800;
}

.shop-power .shop-item-button {
  grid-column: 1 / -1;
  margin-top: 8px;
}

/* ==========================================================================
   Visual theme: warm cards with a golden rim, chunky "candy" buttons,
   outlined titles, pills with icons. Comes last, so it shapes the look of
   every screen built above.
   ========================================================================== */

:root {
  --cream: #fff8ea;
  --cream-deep: #ffefcb;
  --rim: #ffc940;
  --line: #f0dfb6;
  --line-deep: #e3cd96;
  --red: #ef4b3c;
  --red-light: #ff7a4f;
  --red-dark: #a52b1f;
  --green: #3cb35c;
  --green-dark: #23823d;
  --orange: #ff9f1c;
  --ink-warm: #5a4a2c;
}

/* ---- Screens and cards ---- */

.screen {
  background: radial-gradient(ellipse at 50% 20%, rgba(255, 210, 120, 0.12), rgba(20, 24, 42, 0.55));
}

.screen-home {
  background: linear-gradient(rgba(20, 24, 42, 0), rgba(20, 24, 42, 0.35));
}

.card {
  border: 4px solid #fff;
  border-radius: 30px;
  background: linear-gradient(180deg, #fffdf7 0%, var(--cream-deep) 100%);
  box-shadow:
    0 0 0 4px var(--rim),
    0 24px 60px rgba(20, 24, 42, 0.45);
}

.card-title,
.shop-title {
  margin-bottom: 14px;
  background: linear-gradient(180deg, var(--red-light), var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  filter: drop-shadow(0 3px 0 rgba(165, 43, 31, 0.25));
}

.card-subtitle {
  color: var(--ink);
  font-weight: 900;
}

.card-text,
.card-note {
  color: var(--ink-warm);
}

/* ---- Logo ---- */

.title {
  color: #ffd23f;
  font-size: 3.1rem;
  letter-spacing: 2px;
  text-shadow:
    3px 0 0 var(--ink),
    -3px 0 0 var(--ink),
    0 3px 0 var(--ink),
    0 -3px 0 var(--ink),
    2px 2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px -2px 0 var(--ink),
    0 7px 0 var(--ink);
}

.subtitle {
  display: inline-block;
  margin: 6px 0 16px;
  padding: 4px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 4px 0 var(--red-dark);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 900;
  transform: rotate(-2deg);
}

/* ---- Buttons ---- */

.button-primary {
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--red-light) 0%, var(--red) 55%, #d63a2c 100%);
  box-shadow:
    0 6px 0 var(--red-dark),
    0 12px 20px rgba(165, 43, 31, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 0 rgba(120, 20, 10, 0.45);
  transition: transform 0.08s;
}

.button-primary:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 var(--red-dark),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.button-secondary {
  border: 3px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, var(--cream));
  box-shadow: 0 5px 0 var(--line-deep);
  color: var(--ink);
  font-weight: 800;
  transition: transform 0.08s;
}

.button-secondary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--line-deep);
}

.button-ad {
  border-radius: 18px;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow:
    0 5px 0 #d08f00,
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  color: #4a3000;
  font-weight: 900;
}

.button-link {
  color: var(--ink-warm);
  font-weight: 700;
}

/* Jugar: big, with a play icon, gently pulsing. */
.button-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 66px;
  font-size: 1.7rem;
  animation: play-call 1.6s ease-in-out infinite;
}

.button-play svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  filter: drop-shadow(0 2px 0 rgba(120, 20, 10, 0.45));
}

@keyframes play-call {
  50% {
    transform: scale(1.03);
  }
}

.button-tutorial {
  border: 3px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  font-weight: 800;
}

/* ---- Home ---- */

.card-home .home-stats {
  gap: 8px;
  margin-bottom: 14px;
}

.stat-pill {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 170px;
  margin: 0;
  padding: 5px 10px 5px 5px;
  border: 2px solid #f6e7c2;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  text-align: left;
}

.stat-icon {
  flex: none;
  width: 32px;
  height: 32px;
}

.stat-pill.is-record .stat-icon {
  padding: 6px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  fill: #8a5a00;
}

.stat-texts {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.card-home .stat-pill .stat-value {
  font-size: 1.25rem;
  font-weight: 900;
}

.card-home .stat-pill .stat-label {
  color: var(--ink-warm);
  font-size: 0.75rem;
  font-weight: 700;
}

.button-shop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-shop svg {
  width: 24px;
  height: 24px;
  fill: #ffd23f;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

/* How many pieces the piggy bank can pay for. */
.shop-call {
  position: absolute;
  top: -10px;
  right: -8px;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 900;
  animation: shop-call 1.4s ease-in-out infinite;
}

@keyframes shop-call {
  50% {
    transform: translateY(-3px) scale(1.08);
  }
}

.button-podium {
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--line-deep);
}

.home-settings {
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}

/* ---- Missions ---- */

.missions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.missions-header .missions-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.missions-count {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
}

.mission,
.card-home .mission {
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "tier text reward"
    "bar bar count";
  align-items: center;
  gap: 6px 8px;
  padding: 9px 10px 8px;
  border-left: 6px solid var(--tier-color);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-size: 0.86rem;
}

.mission.is-easy {
  --tier-color: var(--green);
}

.mission.is-medium {
  --tier-color: var(--orange);
}

.mission.is-hard {
  --tier-color: var(--red);
}

.mission-tier {
  grid-area: tier;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tier-color);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mission-text {
  grid-area: text;
  font-weight: 700;
  line-height: 1.25;
}

.mission-reward {
  grid-area: reward;
  padding: 2px 8px 2px 24px;
  border-radius: 999px;
  background: url("../assets/icons/januca.svg") no-repeat 4px center / 16px, #fff2c2;
  color: #94600a;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.mission-bar {
  grid-area: bar;
  height: 9px;
  background: #f3e7c8;
}

.mission-bar span {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tier-color), color-mix(in srgb, var(--tier-color) 60%, #fff));
}

.mission-count {
  grid-area: count;
  color: var(--ink-warm);
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mission.is-done {
  background: #eefaf0;
}

.mission.is-done .mission-reward {
  padding-left: 8px;
  background: var(--green);
  color: #fff;
}

.missions-bonus {
  margin: 8px 0 0;
  color: #94600a;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

/* ---- Shop ---- */

.shop-panel {
  border-top: 4px solid #fff;
  background: linear-gradient(180deg, #fffdf7, var(--cream-deep));
  box-shadow:
    0 -4px 0 var(--rim),
    0 -14px 40px rgba(20, 24, 42, 0.3);
}

@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .shop-panel {
    border-top: 0;
    border-left: 4px solid #fff;
    box-shadow:
      -4px 0 0 var(--rim),
      -14px 0 40px rgba(20, 24, 42, 0.3);
  }
}

.shop-title {
  margin: 0;
  font-size: 1.9rem;
}

.shop-piggy {
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow:
    0 3px 0 #d08f00,
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  color: #4a3000;
  font-size: 1.15rem;
  font-weight: 900;
}

.button-close {
  border: 3px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
}

.shop-tab {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  color: var(--ink);
  font-weight: 800;
}

.shop-tab[aria-selected="true"] {
  border-color: var(--red);
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 3px 0 var(--red-dark);
  color: #fff;
}

.shop-filter {
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 800;
}

.shop-filter[aria-pressed="true"] {
  border-color: var(--festival-color, var(--ink));
  background: var(--festival-color, var(--ink));
  color: #fff;
}

.shop-items {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.shop-item {
  position: relative;
  gap: 4px;
  padding: 7px 7px 9px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: #fff;
  box-shadow:
    0 4px 0 var(--line),
    0 8px 18px rgba(80, 60, 20, 0.08);
  transition: transform 0.12s;
}

.shop-item.is-selected {
  border-color: var(--rim);
  transform: translateY(-2px);
}

.shop-item-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 38%, #fff 0%, color-mix(in srgb, var(--festival-color) 38%, #fff) 100%);
}

.shop-item-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Golden pieces shine. */
.shop-item.is-golden {
  background: linear-gradient(180deg, #fff9e0, #ffeaa0);
}

.shop-item.is-golden .shop-item-art {
  background: radial-gradient(circle at 50% 38%, #fffbe8 0%, #ffd75a 100%);
}

.shop-item.is-golden .shop-item-art::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.75) 50%, transparent 60%);
  animation: golden-shine 2.6s ease-in-out infinite;
}

@keyframes golden-shine {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(60%);
  }
}

.shop-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.shop-badge.is-equipped {
  background: var(--green);
}

.shop-badge.is-owned {
  background: #3d7be0;
}

.shop-badge.is-free {
  background: #23a5a0;
}

.shop-badge.is-affordable {
  background: var(--red);
  animation: shop-call 1.4s ease-in-out infinite;
}

.shop-item-festival {
  padding: 0 2px;
  color: color-mix(in srgb, var(--festival-color) 70%, var(--ink));
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.shop-item-name {
  min-height: 2.4em;
  padding: 0 2px;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.2;
}

.shop-item-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 900;
}

.shop-item-button.is-buy {
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow:
    0 4px 0 #d08f00,
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  color: #4a3000;
}

.shop-item-button.is-confirming {
  flex-wrap: wrap;
  gap: 2px 6px;
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 4px 0 var(--red-dark);
  color: #fff;
  animation: play-call 0.8s ease-in-out infinite;
}

.shop-item-button.is-use {
  background: linear-gradient(180deg, #5fd17c, var(--green));
  box-shadow: 0 4px 0 var(--green-dark);
  color: #fff;
}

.shop-item-button.is-remove {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  color: var(--ink-warm);
}

.shop-item-button.is-missing {
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  background: #f4eedf;
  color: #8f8366;
  font-size: 0.78rem;
  font-weight: 800;
}

.shop-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2d7bd;
}

.shop-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffc32e, #ffe27a);
}

.shop-coin {
  width: 22px;
  height: 22px;
}

/* A power: picture on the left, what it does, and the price below. */
.shop-power {
  grid-template-columns: 96px 1fr;
  grid-template-rows: auto;
  gap: 8px 12px;
  border-left-color: transparent;
}

.shop-power .shop-item-art {
  --festival-color: #7fb0ff;
}

.shop-power-icon {
  grid-row: auto;
  width: 78%;
  height: 78%;
}

.shop-power-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.shop-power-owned {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
}

/* ---- Leaderboard, nickname, settings, summary ---- */

.segmented {
  border-radius: 999px;
  background: #f3e7c8;
}

.segment {
  border-radius: 999px;
  font-weight: 900;
}

.segment[aria-selected="true"] {
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 3px 0 var(--red-dark);
  color: #fff;
}

.ranking-entry {
  margin-bottom: 6px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}

.ranking-rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f3e7c8;
  color: var(--ink-warm);
  font-size: 0.85rem;
}

.ranking-entry.is-me {
  background: #fff2c2;
  box-shadow: 0 0 0 2px var(--rim);
}

.preference {
  margin-bottom: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}

.preference[aria-checked="true"] .preference-switch {
  background: var(--green);
}

.recovery {
  border-top-color: var(--line);
}

.recovery-copy {
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}

.score-value {
  background: linear-gradient(180deg, #3a3550, var(--ink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 3.6rem;
}

.record-badge {
  padding: 5px 16px;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow: 0 3px 0 #d08f00;
  color: #4a3000;
  font-weight: 900;
  transform: rotate(-2deg);
}

.stats .stat {
  padding: 8px 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}

.festival-count {
  padding: 6px 4px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}

.countdown {
  background: linear-gradient(180deg, var(--red-light), var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 3.4rem;
}

@media (prefers-reduced-motion: reduce) {
  .button-play,
  .shop-call,
  .shop-badge.is-affordable,
  .shop-item-button.is-confirming,
  .shop-item.is-golden .shop-item-art::after {
    animation: none;
  }
}

/* The six shop tabs as a tidy 3 × 2 grid; the festival filters scroll
   sideways without a visible bar. */
.shop-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 6px;
  padding-bottom: 3px;
}

.shop-filters {
  padding: 2px 2px 6px;
  scrollbar-width: none;
}

.shop-filters::-webkit-scrollbar {
  display: none;
}

/* Short of coins: the price on top, greyed, then what is missing. */
.shop-price-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #6e6450;
  font-size: 1.05rem;
  font-weight: 900;
}

.shop-price-row .shop-coin {
  width: 20px;
  height: 20px;
  filter: grayscale(0.4);
}

.shop-item-button.is-missing {
  gap: 3px;
}

/* ---- Home: Ranking button with the player's nickname and position ---- */

.home-row .button-shop {
  flex: 0.8;
}

.home-row .button-podium {
  display: flex;
  flex: 1.2;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 0;
  padding: 4px 10px;
  position: relative;
}

.button-podium svg {
  flex: none;
  width: 28px;
  height: 24px;
}

.podium-texts {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
  text-align: left;
}

.podium-title {
  font-weight: 900;
}

.podium-nickname {
  overflow: hidden;
  color: var(--ink-warm);
  font-size: 0.7rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* This week's position, as a gold chip on the corner. */
.podium-rank {
  position: absolute;
  top: -10px;
  right: -8px;
  padding: 2px 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  color: #6a4500;
  font-size: 0.8rem;
  font-weight: 900;
}

/* ---- Home: "save your progress" banner ---- */

.home-save {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 6px 6px 10px;
  border: 2px solid #b9d7ff;
  border-radius: 16px;
  background: linear-gradient(180deg, #f2f8ff, #e2efff);
  text-align: left;
}

.home-save[hidden] {
  display: none;
}

/* A friend's challenge on the home screen: warm, like the flag. */
.home-challenge {
  border-color: #f5c27a;
  background: linear-gradient(180deg, #fff6e6, #ffe9c7);
}

.home-challenge .home-save-text {
  color: #7a3b12;
}

.home-challenge .home-save-button {
  background: linear-gradient(180deg, #ff7a4f, #e0483d);
  box-shadow: 0 3px 0 #a52b1f;
}

.home-challenge-icon {
  flex: none;
  font-size: 1.3rem;
}

.challenge-flag {
  margin: 0;
  font-size: 2.6rem;
  line-height: 1;
}

.challenge-note {
  margin: 6px 0 10px;
  color: var(--ink);
  font-weight: 800;
}

.challenge-note.is-won {
  color: #2f8a3c;
}

/* Meters left to beat the friend, under the meters. */
.hud-challenge {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(60vw, 320px);
  padding: 6px 14px;
  border-radius: 18px;
  background: rgba(224, 72, 61, 0.92);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
}

.hud-challenge[hidden] {
  display: none;
}

.hud-challenge.is-won {
  background: rgba(47, 138, 60, 0.94);
}

.home-save-icon {
  flex: none;
  width: 22px;
  height: 22px;
  fill: #2f6fd0;
}

.home-save-text {
  flex: 1;
  color: #1f3f73;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
}

.home-save-button {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #5b9bff, #2f6fd0);
  box-shadow: 0 3px 0 #1f4f9a;
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.home-save-close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #5d7aa6;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
}

/* ---- Deleting the player's data ---- */

.delete-link {
  margin-top: 6px;
  color: #a52b1f;
  font-size: 0.85rem;
}

.button-delete {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-bottom: 10px;
  border: 3px solid #c8342e;
  border-radius: 16px;
  background: #fff;
  color: #c8342e;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}

.button-delete.is-armed {
  background: #c8342e;
  color: #fff;
}

/* ---- Settings: passkey ---- */

.passkey-box {
  margin: 14px 0 4px;
  padding: 12px;
  border: 2px solid #b9d7ff;
  border-radius: 18px;
  background: linear-gradient(180deg, #f2f8ff, #e2efff);
}

.passkey-box[hidden] {
  display: none;
}

.passkey-title {
  margin: 0 0 4px;
  color: #1f3f73;
  font-size: 1.05rem;
  font-weight: 900;
}

.passkey-status {
  margin: 0 0 10px;
  color: #3d5378;
  font-size: 0.85rem;
  line-height: 1.35;
}

.passkey-status.is-saved {
  color: var(--green-dark);
  font-weight: 800;
}

.button-passkey {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(180deg, #5b9bff, #2f6fd0);
  box-shadow:
    0 5px 0 #1f4f9a,
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 0 rgba(20, 50, 110, 0.4);
}

.button-passkey:active {
  box-shadow: 0 2px 0 #1f4f9a;
}

.button-passkey svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.passkey-box .button-link {
  margin-top: 8px;
}

/* ---- Leaderboard: the player's own card and row ---- */

.ranking-you {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0 0 14px;
  padding: 12px 44px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #2b2f4a, var(--ink));
  box-shadow: 0 4px 0 #0c0e18;
  color: #fff;
}

.ranking-you-label {
  color: #ffd23f;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ranking-you-name {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.ranking-you-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
}

.ranking-you-chip {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.85rem;
  font-weight: 800;
}

.ranking-you-chip:empty {
  display: none;
}

.ranking-you-chip.is-rank {
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  color: #4a3000;
  font-weight: 900;
}

.ranking-you-chip.is-rank.is-unranked {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ranking-you-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}

.ranking-you-edit svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.ranking-list {
  position: relative;
  padding: 4px;
}

.ranking-entry.is-me {
  background: linear-gradient(180deg, #fff6d0, #ffe9a3);
  box-shadow:
    0 0 0 3px var(--rim),
    0 3px 0 #d9a300;
}

.ranking-entry.is-me .ranking-name {
  color: #6a4500;
  font-weight: 900;
}

.ranking-you-tag {
  margin-right: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---- Shop: "Especiales", the jaguim's characters ---- */

.shop-tab.is-special {
  grid-column: 1 / -1;
  border-color: #e5a800;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow:
    0 3px 0 #d08f00,
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  color: #4a3000;
  font-weight: 900;
}

.shop-tab.is-special::before {
  content: "★ ";
}

.shop-tab.is-special[aria-selected="true"] {
  border-color: var(--red);
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 3px 0 var(--red-dark);
  color: #fff;
}

/* ---- After "Jugar": tap to start, the special maps below ---- */

.screen-prestart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(20, 24, 42, 0) 55%, rgba(20, 24, 42, 0.55));
  cursor: pointer;
}

.prestart-back {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  cursor: pointer;
}

.prestart-back svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prestart-call {
  margin-top: 18vh;
  text-align: center;
  pointer-events: none;
}

.prestart-title {
  margin: 0;
  color: #ffd23f;
  font-size: 2.3rem;
  font-weight: 900;
  text-shadow:
    3px 0 0 var(--ink),
    -3px 0 0 var(--ink),
    0 3px 0 var(--ink),
    0 -3px 0 var(--ink),
    0 6px 0 var(--ink);
  animation: play-call 1.2s ease-in-out infinite;
}

.prestart-hint {
  margin: 10px 0 0;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(20, 24, 42, 0.6);
}

.prestart-maps {
  width: 100%;
  max-width: 560px;
  padding: 12px;
  border: 4px solid #fff;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdf7, var(--cream-deep));
  box-shadow:
    0 0 0 4px var(--rim),
    0 18px 40px rgba(20, 24, 42, 0.4);
  cursor: default;
}

.prestart-maps-title {
  margin: 0 0 8px;
  font-weight: 900;
  text-align: center;
}

.prestart-map-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-card-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 10px 8px;
  border: 3px solid var(--map-color);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--map-color) 18%, #fff));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--map-color) 60%, #000);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.map-card.is-locked .map-card-button {
  border-color: #c9bfa6;
  background: linear-gradient(180deg, #fff, #f1ead8);
  box-shadow: 0 4px 0 #b9ad8e;
}

.map-card-art {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--map-color) 25%, #fff);
}

.map-card.is-locked .map-card-art {
  filter: grayscale(0.6);
}

.map-card-coin {
  width: 42px;
  height: 42px;
}

.map-card-texts {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.map-card-name {
  font-size: 1.05rem;
  font-weight: 900;
}

.map-card-detail {
  color: var(--ink-warm);
  font-size: 0.75rem;
  font-weight: 700;
}

.map-card-play {
  padding: 4px 18px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 3px 0 var(--red-dark);
  color: #fff;
  font-weight: 900;
}

.map-card-price {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe27a, #ffc32e);
  box-shadow: 0 3px 0 #d08f00;
  color: #4a3000;
  font-weight: 900;
}

.map-card-price.is-missing {
  background: #f4eedf;
  box-shadow: none;
  color: #8f8366;
}

.map-card-price.is-confirming {
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 3px 0 var(--red-dark);
  color: #fff;
}

.map-card-missing {
  font-size: 0.72rem;
  font-weight: 800;
}

/* ---- Summary of a special map's run: its coin ---- */

.stat-coin {
  width: 30px;
  height: 30px;
}

.stat-coin[hidden],
.coin-cycle[hidden] {
  display: none;
}

/* ---- Shop: a special map's characters, under their map ---- */

.shop-section {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 12px;
  border-left: 6px solid var(--festival-color);
  border-radius: 16px;
  background: color-mix(in srgb, var(--festival-color) 14%, #fff);
}

.shop-section.is-locked {
  filter: grayscale(0.4);
}

.shop-section-coin {
  width: 34px;
  height: 34px;
}

.shop-section-texts {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.shop-section-title {
  font-weight: 900;
}

.shop-section-detail {
  color: var(--ink-warm);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Compact map cards, so the jogging player stays in view. */
.prestart-call {
  margin-top: 9vh;
}

.prestart-maps {
  padding: 10px;
}

.map-card-button {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-areas:
    "art texts"
    "art action";
  align-items: center;
  justify-items: start;
  gap: 2px 8px;
  padding: 8px;
  text-align: left;
}

.map-card-art {
  grid-area: art;
  width: 44px;
  height: 44px;
}

.map-card-coin {
  width: 34px;
  height: 34px;
}

.map-card-texts {
  grid-area: texts;
  align-items: flex-start;
}

.map-card-name {
  font-size: 0.95rem;
}

.map-card-play,
.map-card-price {
  grid-area: action;
  padding: 2px 12px;
  font-size: 0.85rem;
}

.map-card-price {
  align-items: flex-start;
}

.map-card-detail,
.map-card-cost {
  white-space: nowrap;
}

.map-card-detail {
  font-size: 0.7rem;
}

/* The special mission, in a special map: its own color and coin. */
.mission.is-special {
  --tier-color: #2f8fd8;
}

.mission.is-special .mission-reward {
  background: var(--reward-coin) no-repeat 4px center / 16px, #e3f0ff;
  color: #1f4f9a;
}

.mission.is-special.is-done .mission-reward {
  padding-left: 8px;
  background: var(--green);
  color: #fff;
}

/* ---- Nickname: one historical character at a time, with arrows ---- */

.nickname-current {
  margin: 0 0 10px;
  font-weight: 900;
}

.nickname-wheel {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 8px;
  margin: 6px 0 6px;
}

.wheel-button {
  height: 52px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Right to left (Hebrew): "previous" sits on the right, so its arrow points right. */
[dir="rtl"] .wheel-button {
  transform: scaleX(-1);
}

.wheel-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line-deep);
}

[dir="rtl"] .wheel-button:active {
  transform: scaleX(-1) translateY(2px);
}

.wheel-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.nickname-name {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--red);
}

.nickname-name.is-locked {
  color: var(--ink-soft);
}

/* A padlock before a name that needs its character from the shop. */
.nickname-name.is-locked::before {
  content: "\1F512\FE0E  ";
  font-size: 0.8em;
}

.nickname-hint {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-weight: 700;
}

.nickname-hint.is-locked {
  color: var(--ink-warm);
}

#nickname-save:disabled {
  opacity: 0.5;
  box-shadow: none;
}

/* ---- Leaderboard: what each tab is, and the podium of the first three ---- */

.ranking-help {
  margin: 8px 0 12px;
  color: var(--ink-warm);
  font-size: 0.85rem;
  font-weight: 700;
}

.ranking-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.ranking-podium[hidden] {
  display: none;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  text-align: center;
}

.podium-place .ranking-name {
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
  font-size: 0.82rem;
  line-height: 1.1;
}

.podium-meters {
  color: var(--ink-warm);
  font-size: 0.78rem;
  font-weight: 800;
}

.podium-step {
  display: grid;
  place-items: center;
  width: 100%;
  border-radius: 14px 14px 4px 4px;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.podium-place.is-rank-1 .podium-step {
  height: 78px;
  background: linear-gradient(180deg, #ffe27a, #e8a800);
}

.podium-place.is-rank-2 .podium-step {
  height: 58px;
  background: linear-gradient(180deg, #e6e9ef, #a9b0bc);
}

.podium-place.is-rank-3 .podium-step {
  height: 44px;
  background: linear-gradient(180deg, #f4c79a, #c97a3a);
}

.podium-place.is-me .podium-step {
  box-shadow: 0 0 0 3px var(--red);
}

/* Long nicknames ("Iehudá Macabí 01") wrap inside the row instead of
   running into the distance; the badges move below them if needed. */
.ranking-entry {
  grid-template-columns: 38px minmax(0, 1fr) auto;
}

.ranking-entry .ranking-name {
  flex-wrap: wrap;
}

/* ---- Daily streak: the week's seven days, every 7th a chest ---- */

.streak-days {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.streak-day {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 84px;
  padding: 8px 4px 6px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line-deep);
  font-weight: 800;
}

.streak-day .coin-cycle {
  width: 26px;
  height: 26px;
}

.streak-day-label {
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.streak-day-reward {
  font-size: 0.95rem;
}

.streak-day-reward:empty {
  display: none;
}

/* From day 29 every day also gives a Mantel de Shabat. */
.streak-day-reward.has-tablecloth::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 3px;
  vertical-align: -3px;
  background: url("../assets/icons/shop/tablecloth.svg") center / contain no-repeat;
}

/* Days still to come: a mystery. */
.streak-mystery {
  font-size: 1.6rem;
  line-height: 1;
  animation: streak-wonder 2.4s ease-in-out infinite;
}

.streak-day:nth-child(2n) .streak-mystery {
  animation-delay: -1.2s;
}

@keyframes streak-wonder {
  0%,
  100% {
    transform: rotate(-8deg) scale(1);
  }
  50% {
    transform: rotate(8deg) scale(1.08);
  }
}

.streak-chest {
  width: 34px;
  height: 34px;
}

.streak-day.is-chest {
  grid-column: span 2;
  background: linear-gradient(180deg, #fff3c4, #ffd76a);
}

.streak-day.is-chest .streak-chest {
  width: 46px;
  height: 46px;
}

.streak-day.is-chest.is-today .streak-chest {
  animation: streak-chest-call 1.1s ease-in-out infinite;
}

@keyframes streak-chest-call {
  0%,
  100% {
    transform: scale(1) rotate(0);
  }
  20% {
    transform: scale(1.12) rotate(-6deg);
  }
  40% {
    transform: scale(1.12) rotate(6deg);
  }
  60% {
    transform: scale(1);
  }
}

.streak-day.is-done > * {
  opacity: 0.45;
}

.streak-day.is-done::after {
  content: "✓";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.streak-day.is-today {
  border-color: var(--red);
  box-shadow: 0 3px 0 var(--red-dark), 0 0 0 3px rgba(239, 75, 60, 0.25);
  transform: scale(1.06);
}

.streak-life {
  margin: -4px 0 14px;
  color: var(--ink-warm);
  font-size: 0.9rem;
  font-weight: 800;
}

/* ---- The chest opening: it shakes, bursts and shows the prize ---- */

.streak-reveal {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  margin: 0 0 16px;
}

.streak-reveal > * {
  grid-area: 1 / 1;
}

.streak-reveal-chest {
  width: 130px;
  height: 130px;
}

.streak-reveal.is-opening .streak-reveal-chest {
  animation: streak-chest-shake 0.9s ease-in both;
}

.streak-reveal.is-open .streak-reveal-chest {
  animation: streak-chest-burst 0.45s ease-out forwards;
}

@keyframes streak-chest-shake {
  0% {
    transform: scale(0.6);
  }
  25% {
    transform: scale(1) rotate(0);
  }
  40% {
    transform: scale(1.05) rotate(-9deg);
  }
  55% {
    transform: scale(1.08) rotate(9deg);
  }
  70% {
    transform: scale(1.12) rotate(-12deg);
  }
  85% {
    transform: scale(1.16) rotate(12deg);
  }
  100% {
    transform: scale(1.2) rotate(0);
  }
}

@keyframes streak-chest-burst {
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

.streak-confetti {
  position: relative;
  width: 0;
  height: 0;
}

.streak-confetti span {
  position: absolute;
  left: -5px;
  top: -7px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  opacity: 0;
}

.streak-reveal.is-open .streak-confetti span {
  animation: streak-confetti 1.3s cubic-bezier(0.15, 0.7, 0.3, 1) var(--delay) forwards;
}

@keyframes streak-confetti {
  0% {
    transform: translate(0, 0) rotate(0) scale(0.4);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), calc(var(--y) + 60px)) rotate(var(--spin)) scale(1);
    opacity: 0;
  }
}

.streak-prizes {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  opacity: 0;
}

.streak-reveal.is-open .streak-prizes {
  animation: streak-prize-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 0.15s forwards;
}

@keyframes streak-prize-pop {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.streak-prize {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 3px solid var(--gold);
  border-radius: 16px;
  background: #fff8e1;
  box-shadow: 0 4px 0 var(--gold-dark);
  font-size: 1.25rem;
  font-weight: 900;
}

.streak-prize img {
  width: 40px;
  height: 40px;
}

@media (prefers-reduced-motion: reduce) {
  .streak-mystery,
  .streak-day.is-chest.is-today .streak-chest {
    animation: none;
  }
}

/* ---- Sharing the run: a green button with a share arrow ---- */

.button-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #4fd27a, #25a957);
  box-shadow:
    0 5px 0 #17803f,
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 900;
}

.button-share::before {
  content: "";
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: url("../assets/icons/share.svg") center / contain no-repeat;
  mask: url("../assets/icons/share.svg") center / contain no-repeat;
}

.button-share:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #17803f;
}
