:root {
  --bg-1: #F5ECDA;
  --bg-2: #D8ECDA;
  --ink: #1A2B1E;
  --ink-soft: #4A6455;
  --ink-muted: #7E9485;
  --card: #ffffffee;
  --primary: #1B8A4E;
  --primary-2: #2AAF63;
  --secondary: #F5A623;
  --accent: #FF6B4A;
  --good: #149954;
  --bad: #D93251;
  --focus: #0D5A8B;
  --shadow: 0 8px 24px rgba(26, 43, 30, 0.12);
  --shadow-sm: 0 2px 8px rgba(26, 43, 30, 0.08);
  --border: #C8DCC8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 15%, #faf3e5 0%, var(--bg-1) 35%, transparent 55%),
    radial-gradient(circle at 90% 8%, #e5f2e5 0%, var(--bg-2) 40%, transparent 60%),
    linear-gradient(155deg, #f5f0e8 0%, #e8f0e8 50%, #f5efe5 100%);
}

body.level-race-open {
  overflow: hidden;
}

button {
  font: inherit;
}

h1,
h2,
h3 {
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  margin: 0;
}

.app-shell {
  width: min(980px, 96vw);
  margin: 0 auto;
  padding: 1rem 0.75rem 5.5rem;
  display: grid;
  gap: 0.8rem;
}

.card {
  background: var(--card);
  border: 3px solid #ffffff;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* ═══ BOTTOM NAVIGATION BAR ═══ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: #ffffffee;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 2px solid #C8DCC8;
  padding: 0.25rem 0.4rem 0.6rem;
  padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
}

.bottom-nav__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem 0.15rem;
  border: none;
  background: transparent;
  color: #7E9485;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__tab:hover,
.bottom-nav__tab:focus-visible {
  color: var(--ink-soft);
}

.bottom-nav__tab.is-active {
  color: var(--primary);
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
}

.bottom-nav__tab--play {
  position: relative;
  margin-top: -0.6rem;
}

.bottom-nav__play-circle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 4px 12px rgba(27, 138, 78, 0.4);
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
}

.bottom-nav__tab--play:hover .bottom-nav__play-circle,
.bottom-nav__tab--play:focus-visible .bottom-nav__play-circle {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(27, 138, 78, 0.5);
}

.bottom-nav__tab--play.is-active .bottom-nav__play-circle {
  box-shadow: 0 4px 16px rgba(27, 138, 78, 0.5);
}

.bottom-nav__play-circle svg {
  width: 20px;
  height: 20px;
}

.view-panel {
  display: grid;
  gap: 0.8rem;
}

.toggle-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Old .settings styles removed — now using .settings-drawer */

.toggle {
  border: 0;
  border-radius: 12px;
  background: #e3fbfb;
  color: var(--ink);
  min-height: 48px;
  min-width: 120px;
  padding: 0.5rem 0.8rem;
  font-weight: 700;
}

.controls {
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  border-top: 2px solid #C8DCC8;
}

.controls .toggle-row {
  grid-column: 1 / -1;
}

.control-group {
  display: grid;
  gap: 0.25rem;
}

.controls label {
  font-weight: 700;
}

.controls select {
  border: 2px solid #cce2ff;
  border-radius: 10px;
  min-height: 46px;
  padding: 0.5rem;
  font: inherit;
  font-weight: 700;
}

.controls p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

#resetProgressBtn {
  align-self: end;
}

/* ═══ GAME TOP BAR ═══ */

.game-top-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.game-top-bar__back {
  border: none;
  background: #f0f4fa;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.3rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: background 0.15s;
}

.game-top-bar__back:hover,
.game-top-bar__back:focus-visible {
  background: #e0e8f4;
}

.game-top-bar__mode {
  flex: 1;
  font-family: "Fredoka", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.game-top-bar__actions {
  display: flex;
  gap: 0.3rem;
}

.game-top-bar__icon-btn {
  border: none;
  background: #f0f4fa;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}

.game-top-bar__icon-btn:hover,
.game-top-bar__icon-btn:focus-visible {
  background: #e0e8f4;
}

/* ═══ GAME HUD ═══ */

.game-hud {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.2rem;
}

.game-hud__level {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-hud__level-text {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  white-space: nowrap;
}

.game-hud__xp-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #dfebff;
  overflow: hidden;
}

.game-hud__xp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.game-hud__streak {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.game-hud__streak-fire {
  font-size: 1.1rem;
}

/* ═══ GAME SCORE BAR ═══ */

.game-score-bar {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.round {
  padding: 0.9rem;
}

/* ═══ COLLECTION VIEW ═══ */

.collection-view {
  gap: 0.75rem;
}

.collection-header {
  padding: 1rem;
}

.collection-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.collection-header h2 {
  margin-bottom: 0.4rem;
}

.collection-discovery {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.collection-discovery-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #dfebff;
  overflow: hidden;
}

.collection-discovery-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--good), #84e36f);
  border-radius: 999px;
  transition: width 0.5s ease;
}

.collection-filters {
  display: grid;
  grid-template-columns: 1.65fr 1fr 1fr;
  gap: 0.55rem;
}

.collection-filters input,
.collection-filters select {
  border: 2px solid #cce2ff;
  border-radius: 10px;
  min-height: 46px;
  padding: 0.5rem;
  font: inherit;
  font-weight: 700;
  width: 100%;
  background: #fff;
}

.collection-meta {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
}

/* library-meta kept for backwards compat */

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.55rem;
}

.library-card {
  border-radius: 16px;
  border: 2px solid #d6e8ff;
  background:
    linear-gradient(145deg, #fffef8 0%, #f4fbff 65%, #edf4ff 100%);
  box-shadow: inset 0 0 0 2px #ffffff;
  padding: 0.65rem;
  display: grid;
  gap: 0.35rem;
}

.library-card-top {
  display: grid;
  place-items: center;
  min-height: 86px;
  border-radius: 12px;
  background: linear-gradient(160deg, #edf7ff 0%, #f7fbff 100%);
}

.library-card .emoji {
  font-size: 2.2rem;
}

.library-card .animal-img {
  width: 72px;
  height: 72px;
}

.library-name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
}

.library-scientific {
  font-size: 0.76rem;
  font-style: italic;
  color: var(--ink-soft);
  min-height: 1.15rem;
}

.library-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.library-stat {
  border-radius: 10px;
  background: #F5F2ED;
  padding: 0.3rem 0.35rem;
  display: grid;
  gap: 0.12rem;
}

.library-stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.library-stat-value {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}

.library-stat-value.is-missing {
  color: #788aa5;
}

.library-empty {
  margin: 0;
  padding: 0.8rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

.library-pagination {
  padding: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.library-pagination .secondary {
  min-height: 44px;
  padding: 0.4rem 0.8rem;
}

.library-page-numbers {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.library-page-btn {
  border: 2px solid #cce2ff;
  border-radius: 10px;
  background: #f5f9ff;
  color: var(--ink);
  min-height: 40px;
  min-width: 40px;
  padding: 0.2rem 0.55rem;
  font-weight: 700;
}

.library-page-btn.is-current {
  border-color: #ffb14a;
  background: #ffe8bd;
  color: #893400;
}

.library-page-ellipsis {
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0 0.2rem;
}

.category-banner {
  text-align: center;
  margin-bottom: 0.8rem;
}

.category-banner p {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.category-banner strong {
  font-family: "Fredoka", sans-serif;
  font-size: 1.45rem;
}

.arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.multi-arena {
  display: grid;
  gap: 0.55rem;
}

.multi-prompt {
  margin: 0;
  text-align: center;
  font-weight: 700;
  color: var(--ink-soft);
}

.multi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.multi-card {
  min-height: 156px;
  padding: 0.5rem 0.35rem;
}

.multi-card .emoji {
  font-size: 2.35rem;
}

.multi-card .name {
  font-size: 1.03rem;
}

.multi-card .habitat {
  font-size: 0.85rem;
}

.animal-card {
  min-height: 180px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #faffff 0%, #edf7ff 100%);
  box-shadow: inset 0 0 0 3px #d8ebff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
  min-width: 48px;
  padding: 0.5rem 0.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.animal-card:hover,
.animal-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 3px #8ac4ff;
}

.animal-card.is-selected {
  box-shadow: inset 0 0 0 4px var(--focus);
}

.animal-card:disabled {
  cursor: default;
  opacity: 0.97;
}

.emoji {
  font-size: 3rem;
  line-height: 1;
}

.name {
  font-weight: 700;
  font-size: 1.15rem;
}

.scientific-name {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.habitat {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.versus {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink-soft);
}

.feedback {
  margin-top: 0.8rem;
  padding: 0.7rem;
  font-weight: 700;
  min-height: 58px;
  text-align: center;
}

.feedback__heading {
  display: block;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}

.feedback.good .feedback__heading {
  color: var(--good);
}

.feedback.bad .feedback__heading {
  color: var(--bad);
}

.feedback__sub {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}


.actions {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
}

.primary {
  border: 0;
  border-radius: 16px;
  border-bottom: 4px solid #126B3A;
  min-height: 52px;
  min-width: 180px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #2AAF63 0%, #1B8A4E 100%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.1s, border-bottom-width 0.1s;
}

.primary:active:not(:disabled) {
  transform: translateY(2px) scale(0.96);
  border-bottom-width: 2px;
}

.primary:disabled {
  filter: grayscale(0.5);
  opacity: 0.65;
  cursor: default;
}

.secondary {
  border: 2px solid #cce2ff;
  border-radius: 16px;
  border-bottom: 4px solid #b3cfe8;
  min-height: 52px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  color: var(--ink);
  background: #f3f8ff;
  cursor: pointer;
  transition: transform 0.1s, border-bottom-width 0.1s;
}

.secondary:active:not(:disabled) {
  transform: translateY(2px) scale(0.96);
  border-bottom-width: 2px;
}

.reveal-zone {
  margin-top: 0.8rem;
  border-radius: 16px;
  background: #f3f8ff;
  padding: 0.8rem;
  overflow: visible;
}

.reveal-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.race-track {
  display: grid;
  gap: 0.6rem;
}

.race-duel {
  display: grid;
  gap: 0.7rem;
}

.race-lane {
  display: grid;
  gap: 0.35rem;
}

.race-name {
  font-weight: 700;
}

.race-track-line {
  position: relative;
  height: 64px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dce8ff 0%, #cfdfff 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px #ffffff;
}

.finish-line {
  position: absolute;
  right: 10px;
  top: 6px;
  bottom: 6px;
  width: 10px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    180deg,
    #ffffff 0 4px,
    #2f3950 4px 8px
  );
}

.race-runner {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateX(0) translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 0;
  background: transparent;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}

.race-runner span {
  font-size: 1.5rem;
  line-height: 1;
}

.race-speed {
  font-weight: 700;
  color: var(--accent);
}

.multi-race-track {
  display: grid;
  gap: 0.45rem;
}

.multi-race-lane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.8fr);
  gap: 0.35rem;
  align-items: center;
}

.multi-race-name {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-race-line {
  position: relative;
  height: 48px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dce8ff 0%, #cfdeff 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px #ffffff;
}

.multi-race-runner {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateX(0) translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: transparent;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}

.multi-race-runner span {
  font-size: 1.2rem;
  line-height: 1;
}

.multi-race-lane.is-winner .multi-race-name {
  color: #b1450f;
}

.multi-race-lane.is-winner .multi-race-line {
  box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px #ffc043;
}

.multi-race-lane.is-picked .multi-race-name {
  color: #155dcb;
}

.multi-race-summary {
  margin: 0.55rem 0 0;
  font-size: 0.93rem;
  font-weight: 700;
  color: #7f4c14;
}

.multi-size-metric {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.multi-size-board {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.42rem;
}

.multi-size-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1.2fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 0.38rem;
}

.multi-size-row.is-picked .multi-size-name {
  color: #155dcb;
}

.multi-size-rank {
  min-width: 2.2rem;
  text-align: center;
  font-weight: 900;
  color: #7c4c14;
}

.multi-size-name {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-size-bar-wrap {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #dce8ff;
  overflow: hidden;
}

.multi-size-bar {
  height: 100%;
  width: 3%;
  border-radius: 999px;
  background: linear-gradient(90deg, #20c997, #84e36f);
  transition: width 1.4s cubic-bezier(0.3, 0.8, 0.2, 1);
}

.multi-size-value {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.multi-size-row.is-winner .multi-size-rank,
.multi-size-row.is-winner .multi-size-name {
  color: #b1450f;
}

.lane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) auto;
  gap: 0.4rem;
  align-items: center;
}

.lane > * {
  min-width: 0;
}

.progress {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #dce8ff;
  overflow: hidden;
}

.runner {
  height: 100%;
  width: 2%;
  background: linear-gradient(90deg, #3a8dff, #00c8ff);
  transition: width 1.6s cubic-bezier(0.3, 0.8, 0.2, 1);
}

/* ── Seesaw Scale ── */
.scale-wrap {
  position: relative;
  padding: 0;
  overflow: visible;
}

.scale-scene {
  position: relative;
  width: 100%;
  height: 190px;
  margin-bottom: 8px;
}

.scale-beam-pivot {
  position: absolute;
  bottom: 85px;
  left: 50%;
  width: 76%;
  height: 10px;
  transform: translateX(-50%) rotate(0deg);
  transform-origin: center center;
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scale-arm {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(180deg, #6b7fa3, #4a5e7d);
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* ── Plate groups (left & right) ── */
.scale-plate-group {
  position: absolute;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scale-plate-left {
  left: 0;
  transform: translateX(-25%);
}

.scale-plate-right {
  right: 0;
  transform: translateX(25%);
}

.scale-chain {
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, #7a8ba8, #9aabc4);
  border-radius: 2px;
}

.scale-dish {
  width: 90px;
  height: 12px;
  background: linear-gradient(180deg, #c8a96e, #a8863a);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  box-shadow: 0 3px 6px rgba(0,0,0,0.15), inset 0 2px 2px rgba(255,255,255,0.25);
  position: relative;
}

.scale-dish::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(180deg, #ddc07a, #c8a96e);
  border-radius: 4px 4px 0 0;
}

.scale-animal {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  z-index: 2;
}

.scale-animal.is-landed {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.scale-animal .animal-img {
  width: 56px;
  height: 56px;
}

.scale-animal .plate-animal {
  font-size: 2.2rem;
  line-height: 1;
  display: block;
}

.scale-label {
  text-align: center;
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.scale-label span {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.scale-label strong {
  font-size: 1.05rem;
  font-family: "Fredoka", sans-serif;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.scale-label strong.is-visible {
  opacity: 1;
}

/* ── Fulcrum (triangle base) ── */
.scale-fulcrum {
  position: absolute;
  bottom: 47px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 38px solid #4a5e7d;
  z-index: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.scale-fulcrum::after {
  content: "";
  position: absolute;
  top: 8px;
  left: -12px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 26px solid #5a6f8d;
}

.scale-base {
  position: absolute;
  bottom: 39px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 10px;
  background: linear-gradient(180deg, #5a6f8d, #4a5e7d);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ── Duel arena reveal transition (all categories) ── */
.arena.is-reveal-exiting {
  animation: cards-exit 0.5s ease-in forwards;
  pointer-events: none;
}

@keyframes cards-exit {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.85) translateY(20px); }
}

.reveal-panel.is-reveal-entering {
  animation: reveal-enter 0.5s ease-out 0.3s both;
}

@keyframes reveal-enter {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Mobile adjustments ── */
@media (max-width: 600px) {
  .scale-scene {
    height: 220px;
  }

  .scale-beam-pivot {
    width: 82%;
  }

  .scale-dish {
    width: 76px;
  }

  .scale-animal .animal-img {
    width: 46px;
    height: 46px;
  }

  .scale-animal .plate-animal {
    font-size: 1.8rem;
  }

  .scale-label span {
    font-size: 0.72rem;
    max-width: 80px;
  }
}

.runner.measure {
  background: linear-gradient(90deg, #20c997, #84e36f);
}

/* ═══ HOME VIEW ═══ */

.home-view {
  gap: 0.75rem;
}

.home-hero {
  padding: 1.1rem;
}

.home-greeting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.home-avatar {
  font-size: 2.4rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff6dd, #ffe6b7);
  flex-shrink: 0;
}

.home-greeting__text {
  min-width: 0;
}

.home-title {
  font-size: 1.35rem;
  line-height: 1.15;
}

.home-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.home-level-bar {
  display: grid;
  gap: 0.3rem;
}

.home-level-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.home-level-badge {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
}

.home-level-xp {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.home-xp-track {
  height: 10px;
  border-radius: 999px;
  background: #dfebff;
  overflow: hidden;
}

.home-xp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ═══ DAILY CHALLENGE WIDGET ═══ */

.daily-challenge {
  padding: 1.2rem;
  position: relative;
  overflow: hidden;
}

.daily-challenge::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 20px 20px 0 0;
}

.daily-challenge__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.daily-challenge__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), #F7B84E);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(245, 166, 35, 0.3);
}

.daily-challenge__title {
  font-family: "Fredoka", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.daily-challenge__subtitle {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
  margin-top: 0.1rem;
}

.daily-challenge__progress {
  width: 100%;
  height: 6px;
  background: #EEEBE6;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.daily-challenge__progress-fill {
  height: 100%;
  width: 0%;
  background: var(--secondary);
  border-radius: 9999px;
  transition: width 0.4s ease-out;
}

.daily-challenge__result {
  text-align: center;
  margin-bottom: 0.6rem;
}

.daily-challenge__score {
  font-family: "Fredoka", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.daily-challenge__score-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
  display: block;
  margin-top: 0.15rem;
}

.daily-challenge__streak-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.daily-challenge__streak {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
}

.daily-challenge__streak-icon {
  font-size: 1.1rem;
}

.daily-challenge__streak-num {
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.daily-challenge__best {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.daily-challenge__yesterday {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-1);
  border-radius: 10px;
}

.daily-challenge__yesterday strong {
  color: var(--primary);
}

.daily-challenge__btn {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--secondary), #E8941A);
  border-bottom: 3px solid #C47A12;
  color: white;
  font-family: "Fredoka", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.daily-challenge__btn:hover {
  transform: translateY(-1px);
}

.daily-challenge__btn:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
}

.daily-challenge__btn:disabled {
  background: var(--bg-2);
  border-bottom-color: var(--border);
  color: var(--ink-muted);
  cursor: default;
  transform: none;
}

/* ═══ DAILY CHALLENGE IN-GAME PROGRESS ═══ */

.daily-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: var(--bg-1);
  border: 2px solid var(--secondary);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.daily-progress__label {
  font-family: "Fredoka", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--secondary);
}

.daily-progress__round {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.daily-progress__dots {
  display: flex;
  gap: 0.4rem;
}

.daily-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.daily-dot--correct {
  background: var(--good);
}

.daily-dot--wrong {
  background: var(--bad);
}

.daily-dot--current {
  background: var(--secondary);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.3);
}

/* ═══ DAILY CHALLENGE RESULTS OVERLAY ═══ */

.daily-results-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.daily-results-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 43, 30, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.daily-results-overlay__dialog {
  position: relative;
  max-width: 380px;
  width: 100%;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  animation: dailyResultsIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dailyResultsIn {
  0% { opacity: 0; transform: scale(0.85) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.daily-results__emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.daily-results__title {
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.daily-results__score {
  font-family: "Fredoka", sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.daily-results__score-label {
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

.daily-results__dots {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.daily-results__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.daily-results__dot--correct {
  background: var(--good);
}

.daily-results__dot--wrong {
  background: var(--bad);
}

.daily-results__streak-box {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-1);
  border: 2px solid var(--secondary);
  border-radius: 14px;
  padding: 0.6rem 1.2rem;
  margin-bottom: 1rem;
}

.daily-results__streak-icon {
  font-size: 1.3rem;
}

.daily-results__streak-num {
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.daily-results__streak-text {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: left;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
}

.daily-results__streak-best {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.daily-results__yesterday {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.daily-results__yesterday strong {
  color: var(--primary);
}

.daily-results-overlay__actions {
  margin-top: 1rem;
}

.daily-results__btn {
  width: 100%;
}

.daily-results__share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.65rem 1rem;
  margin-bottom: 0.6rem;
  border: 2px solid var(--accent);
  border-radius: 9999px;
  background: #fff;
  color: var(--accent);
  font-family: "Fredoka", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.daily-results__share-btn:hover {
  background: var(--accent);
  color: #fff;
}

.daily-results__share-btn--copied {
  border-color: var(--good);
  color: var(--good);
}

.daily-results__share-btn--copied:hover {
  background: var(--good);
  color: #fff;
}

/* Quick Play button */
.quick-play-btn {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border-bottom: 4px solid #126B3A;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, border-bottom-width 0.1s;
}

.quick-play-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.quick-play-btn__icon {
  font-size: 1.6rem;
  line-height: 1;
}

.quick-play-btn__text {
  display: grid;
  gap: 0.1rem;
}

.quick-play-btn__text strong {
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.quick-play-btn__text small {
  font-size: 0.82rem;
  opacity: 0.85;
}

/* Home stat cards (goal + streak) */
.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.home-stat-card {
  padding: 0.75rem;
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}

.home-stat-card__icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.home-stat-card__body {
  min-width: 0;
}

.home-stat-card__body strong {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.home-stat-card__body p {
  margin: 0.15rem 0 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}

.home-stat-sub {
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  color: var(--ink-soft) !important;
}

.home-goal-bar {
  margin-top: 0.35rem;
  height: 6px;
  border-radius: 999px;
  background: #dfebff;
  overflow: hidden;
}

.home-goal-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #20c997);
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* Home stats row */
.home-stats-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.home-mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.home-mini-stat__value {
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.home-mini-stat__label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Home fun fact */
.home-fun-fact {
  padding: 0.75rem 1rem;
}

.home-fun-fact strong {
  font-size: 0.82rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.home-fun-fact__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-fun-fact__share-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.home-fun-fact__share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.home-fun-fact__share-btn--copied {
  color: var(--good);
  border-color: var(--good);
}

.home-fun-fact p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* ═══ MODES VIEW ═══ */

.modes-view {
  gap: 0.75rem;
}

.modes-header {
  font-size: 1.5rem;
  text-align: center;
  padding: 0.3rem 0;
}

.modes-list {
  display: grid;
  gap: 0.6rem;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px #11224433;
}

.mode-card__icon {
  font-size: 2rem;
  line-height: 1;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff6dd, #ffe6b7);
  flex-shrink: 0;
}

.mode-card__body {
  flex: 1;
  min-width: 0;
}

.mode-card__body h3 {
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

.mode-card__body p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.mode-card__meta {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.mode-card__badge {
  background: #ffe1f0;
  color: #c0306a;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.mode-card__arrow {
  font-size: 1.2rem;
  color: #bbb;
  flex-shrink: 0;
}

/* Mode-specific accent colors on cards */
.mode-card[data-mode="standard"] .mode-card__icon {
  background: linear-gradient(135deg, #fff0dd, #ffe0b7);
}

.mode-card[data-mode="multi-race"] .mode-card__icon {
  background: linear-gradient(135deg, #ddeeff, #b7d9ff);
}

.mode-card[data-mode="multi-size"] .mode-card__icon {
  background: linear-gradient(135deg, #ddffe8, #b7ffc8);
}

/* ═══ PROFILE VIEW ═══ */

.profile-view {
  gap: 0.75rem;
}

.profile-hero {
  padding: 1.1rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.profile-avatar {
  font-size: 2.4rem;
  line-height: 1;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff6dd, #ffe6b7);
  flex-shrink: 0;
}

.profile-identity {
  flex: 1;
  min-width: 0;
}

.profile-switch-btn {
  border: 2px solid #C8DCC8;
  border-radius: 999px;
  background: #f5f9ff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.profile-switch-btn:hover {
  border-color: var(--primary);
  background: #fff0e0;
  color: var(--primary);
}

.profile-switch-btn:active {
  transform: scale(0.95);
}

.profile-identity h2 {
  font-size: 1.25rem;
}

.profile-identity p {
  margin: 0.1rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.profile-xp-track {
  height: 8px;
  border-radius: 999px;
  background: #dfebff;
  overflow: hidden;
}

.profile-xp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.profile-xp-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 0.15rem;
  display: block;
}

.profile-stats {
  padding: 1rem;
}

.profile-stats h3 {
  margin-bottom: 0.6rem;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.profile-stat {
  background: #f5f9ff;
  border-radius: 12px;
  padding: 0.6rem;
  text-align: center;
}

.profile-stat__value {
  display: block;
  font-family: "Fredoka", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.profile-stat__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.profile-section {
  padding: 1rem;
}

.profile-section h3 {
  margin-bottom: 0.5rem;
}

.profile-section__count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.profile-achievement-grid,
.profile-collectible-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.4rem;
}

.profile-empty {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
  grid-column: 1 / -1;
}

.profile-settings {
  padding: 1rem;
}

.profile-settings h3 {
  margin-bottom: 0.5rem;
}

.profile-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.profile-settings-grid .control-group {
  grid-column: 1 / -1;
}

.profile-settings-grid select {
  border: 2px solid #cce2ff;
  border-radius: 10px;
  min-height: 46px;
  padding: 0.5rem;
  font: inherit;
  font-weight: 700;
  width: 100%;
}

/* ── Sound settings ── */

.sound-volume-group {
  grid-column: 1 / -1;
}

.sound-volume-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
}

.sound-volume-value {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.sound-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  background: linear-gradient(to right, var(--primary-light, #2AAF63), var(--primary, #1B8A4E));
  outline: none;
  margin-top: 2px;
}

.sound-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary, #1B8A4E);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.sound-volume-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary, #1B8A4E);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.sound-layer-toggles {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.toggle--sm {
  border: 0;
  border-radius: 12px;
  background: #e3fbfb;
  color: var(--ink);
  min-height: 38px;
  min-width: 0;
  padding: 0.35rem 0.65rem;
  font-weight: 700;
  font-size: 0.78rem;
  flex: 1;
  text-align: center;
}

.toggle--sm[aria-pressed="false"] {
  background: #eee;
  color: var(--ink-muted, #7E9485);
}

.profile-settings-footer {
  text-align: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e8e8e8;
}

.profile-settings-link {
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: underline;
}

.profile-settings-sep {
  color: var(--ink-muted);
  margin: 0 0.3rem;
}

/* ═══ SKIP LINK ═══ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 0;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ═══ XP FLYUP ═══ */

.xp-flyup-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.xp-flyup {
  position: absolute;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  animation: xp-fly 1.2s ease-out forwards;
  pointer-events: none;
}

@keyframes xp-fly {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* ── Confetti particles ── */
.confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti-fall 1.2s ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(120px) rotate(720deg) scale(0.3); }
}

/* ── Screen shake ── */
.is-shaking {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* ── Streak popup ── */
.streak-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: "Fredoka", sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 2px 8px rgba(27, 138, 78, 0.4);
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  animation: streak-pop 1.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) forwards;
}
@keyframes streak-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

/* ── Level celebration enhancements ── */
.level-celebration--active .level-celebration__dialog h2 {
  text-shadow: 0 0 20px #F5A623, 0 0 40px #1B8A4E;
  animation: level-glow 1.5s ease-in-out infinite alternate;
}
@keyframes level-glow {
  0% { text-shadow: 0 0 10px #F5A623, 0 0 20px #1B8A4E; }
  100% { text-shadow: 0 0 30px #F5A623, 0 0 60px #1B8A4E, 0 0 80px #F5A623; }
}
.level-celebration__stats {
  font-size: 0.9rem;
  color: #667;
  margin-top: 0.5rem;
  font-weight: 600;
}

.level-celebration {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.level-celebration[hidden] {
  display: none;
}

.level-celebration__backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, #fff7b0aa 0%, transparent 38%),
    radial-gradient(circle at 80% 80%, #ffd1e4aa 0%, transparent 45%),
    #132749b0;
  animation: celebration-fade-in 220ms ease-out;
}

.level-celebration__dialog {
  position: relative;
  z-index: 1;
  width: min(460px, 94vw);
  padding: 1.4rem 1.2rem 1.1rem;
  text-align: center;
  border: 3px solid #fff8d9;
  background: linear-gradient(140deg, #fffef5 0%, #fff3d8 55%, #ffe8f2 100%);
  box-shadow: 0 18px 40px #0d193366;
  animation: celebration-pop 420ms cubic-bezier(0.12, 0.9, 0.2, 1.04);
}

.level-celebration.is-race-takeover {
  padding: 0;
  place-items: stretch;
  overflow: hidden;
}

.level-celebration.is-race-takeover .level-celebration__dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: -webkit-fill-available;
  border-radius: 0;
  border: 0;
  padding: 1.1rem 1rem 0;
  box-shadow: none;
  animation: celebration-fade-in 220ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.level-celebration__eyebrow {
  margin: 0;
  color: #7a5200;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.level-celebration h2 {
  margin-top: 0.1rem;
  font-size: 1.75rem;
  color: #d84e13;
  text-shadow: 0 2px 0 #fff8c7;
}

.level-celebration__dialog p {
  margin: 0.35rem 0 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.level-race-sequence {
  margin-top: 0.85rem;
  border-radius: 14px;
  border: 2px solid #ffe6a8;
  background: #fffdfa;
  padding: 0.65rem;
  text-align: left;
}

.level-celebration.is-race-takeover .level-celebration__body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.level-celebration.is-race-takeover .level-race-sequence {
  margin-top: 0.6rem;
  min-height: 0;
  overflow: visible;
  display: block;
  padding: 0.7rem;
}

.level-race-sequence h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #a95508;
}

.level-race-track {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.45rem;
}

.level-celebration.is-race-takeover .level-race-track {
  margin-top: 0.55rem;
  min-height: 0;
  overflow: visible;
  align-content: start;
  padding-right: 0.2rem;
}

.level-race-lane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.8fr);
  gap: 0.35rem;
  align-items: center;
}

.level-race-name {
  font-size: 0.92rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-race-line {
  position: relative;
  height: 48px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e2ecff 0%, #d6e4ff 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px #ffffff;
}

.level-celebration.is-race-takeover .level-race-line {
  height: 56px;
}

.level-race-runner {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateX(0) translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: transparent;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}

.level-celebration.is-race-takeover .level-race-runner {
  width: 48px;
  height: 48px;
}

.level-race-runner span {
  font-size: 1.15rem;
  line-height: 1;
}

.level-race-lane.is-winner .level-race-name {
  color: #b1450f;
}

.level-race-lane.is-winner .level-race-line {
  box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px #ffc043;
}

.level-race-summary {
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #7f4c14;
}

/* --- Level Championship: intro, roster, winner card --- */

.level-race-intro {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft, #4A6455);
  text-align: center;
  line-height: 1.35;
}

.level-race-roster {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.35rem 0.2rem;
  margin-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.level-race-roster__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink, #1A2B1E);
  background: #ffffffcc;
  border: 1.5px solid var(--border, #C8DCC8);
  white-space: nowrap;
}

.level-race-winner-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: linear-gradient(145deg, #fff8ed 0%, #fef3d9 100%);
  border: 2px solid #ffc043;
  margin-top: 0.3rem;
  animation: winner-card-pop 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.level-race-winner-card__crown {
  font-size: 2.2rem;
  line-height: 1;
  animation: trophy-bounce 600ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.level-race-winner-card__name {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink, #1A2B1E);
}

.level-race-winner-card__speed {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary, #1B8A4E);
}

.level-race-winner-card__context {
  font-size: 0.88rem;
  font-weight: 600;
  font-style: italic;
  color: var(--ink-soft, #4A6455);
}

.level-race-winner-card__podium {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-muted, #7E9485);
}

.level-race-explorer-note {
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: #EDF5EE;
  border-left: 3px solid var(--primary, #1B8A4E);
  text-align: left;
  max-width: 340px;
}

.level-race-explorer-note__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary, #1B8A4E);
  margin-bottom: 0.15rem;
}

.level-race-explorer-note p {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft, #4A6455);
  line-height: 1.35;
}

@keyframes trophy-bounce {
  0% {
    transform: scale(0) rotate(-15deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.25) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes winner-card-pop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.level-celebration__sparkles {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 0.15rem;
}

.sparkle {
  display: inline-block;
  font-size: 1.3rem;
  animation: sparkle-bounce 900ms ease-in-out infinite;
}

.sparkle:nth-child(2n) {
  animation-delay: 90ms;
}

.sparkle:nth-child(3n) {
  animation-delay: 180ms;
}

.level-celebration__hint {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: #8a7050;
  font-weight: 600;
  text-align: center;
  font-style: italic;
}

.level-celebration__hint[hidden] {
  display: none;
}

.level-celebration__close {
  min-width: 190px;
}

.level-celebration__actions {
  margin-top: 0.95rem;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.level-celebration__replay {
  min-width: 170px;
}

.level-celebration__start {
  min-width: 170px;
}

.level-celebration__skip {
  min-width: 170px;
}

.level-celebration__replay:disabled {
  opacity: 0.6;
  cursor: default;
}

.level-celebration.is-race-takeover .level-celebration__actions {
  flex-shrink: 0;
  margin-top: 0.7rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  flex-wrap: nowrap;
}

.level-celebration.is-race-takeover .level-celebration__actions > button {
  min-width: 0;
  flex: 1 1 0;
}

@keyframes celebration-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes celebration-pop {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: translateY(-3px) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sparkle-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-6px) scale(1.09);
  }
}

.rarity-pill {
  display: inline-block;
  margin-left: 0.35rem;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.rarity-common .rarity-pill {
  background: #677b93;
}

.rarity-rare .rarity-pill {
  background: #1d9f7a;
}

.rarity-epic .rarity-pill {
  background: #d44f17;
}

/* ── Race results layout (track + side panel) ── */

/* Results layout — full width, no side panel */
.race-results-layout {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.race-results-layout > .race-scene {
  flex: 1;
  min-width: 0;
}

/* Lanes go full-width in results (name overlays track) */
.race-results-layout .multi-race-lane,
.race-results-layout .level-race-lane {
  grid-template-columns: 1fr;
}

.race-results-layout .multi-race-name,
.race-results-layout .level-race-name {
  grid-column: 1;
  grid-row: 1;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8rem;
  font-size: 0.82rem;
  line-height: 1.15;
}

.race-results-layout .multi-race-line,
.race-results-layout .level-race-line {
  grid-column: 1;
  grid-row: 1;
}

.level-race-results-layout {
  flex-direction: row !important;
  align-items: stretch;
}

.level-race-results-layout > .race-scene {
  min-width: 0;
}

/* ── Inline lane result badge (frosted pill at right end of track) ── */
.lane-result-badge {
  position: absolute;
  right: 42px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  z-index: 3;
  white-space: nowrap;
  opacity: 0;
  animation: badge-fade-in 0.35s ease-out forwards;
}

/* Duel lanes have larger runners (56px) */
.race-lane .lane-result-badge {
  right: 58px;
}

/* Level race takeover has 48px runners */
.level-celebration.is-race-takeover .lane-result-badge {
  right: 50px;
}

@keyframes badge-fade-in {
  from { opacity: 0; transform: translateY(-50%) translateX(8px); }
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

.lane-result-badge__rank {
  font-weight: 900;
  font-size: 0.82rem;
  color: #734607;
  line-height: 1;
}

.lane-result-badge__speed {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* Winner badge treatment */
.lane-result-badge.is-winner {
  background: rgba(255, 243, 216, 0.92);
  box-shadow: 0 1px 6px rgba(255, 192, 67, 0.35), inset 0 0 0 1.5px rgba(255, 215, 64, 0.5);
}

.lane-result-badge.is-winner .lane-result-badge__rank {
  color: #b1450f;
}

/* Race-scene (dark background) variant */
.race-scene .lane-result-badge {
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.race-scene .lane-result-badge__rank {
  color: #ffe082;
}

.race-scene .lane-result-badge__speed {
  color: #b3d4fc;
}

.race-scene .lane-result-badge.is-winner {
  background: rgba(90, 60, 0, 0.75);
  box-shadow: 0 1px 6px rgba(255, 215, 64, 0.4), inset 0 0 0 1.5px rgba(255, 215, 64, 0.45);
}

.race-scene .lane-result-badge.is-winner .lane-result-badge__rank {
  color: #ffe082;
}

.race-scene .lane-result-badge.is-winner .lane-result-badge__speed {
  color: #fff8e1;
}

@media (max-width: 480px) {
  .race-results-layout .multi-race-lane,
  .race-results-layout .level-race-lane {
    grid-template-columns: 1fr;
  }
  .lane-result-badge {
    padding: 0.1rem 0.4rem 0.1rem 0.3rem;
    gap: 0.2rem;
  }
  .lane-result-badge__rank {
    font-size: 0.75rem;
  }
  .lane-result-badge__speed {
    font-size: 0.68rem;
  }
  .home-cards {
    grid-template-columns: 1fr;
  }
  .home-title {
    font-size: 1.15rem;
  }
  .profile-stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .collection-filters {
    grid-template-columns: 1fr;
  }

  .arena {
    grid-template-columns: 1fr;
  }

  .multi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .versus {
    justify-self: center;
  }

  .lane {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
  }

  .level-celebration__dialog {
    padding: 1.2rem 0.9rem 0.9rem;
  }

  .level-celebration h2 {
    font-size: 1.8rem;
  }

  .level-race-lane {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr);
    gap: 0.2rem;
  }

  .level-celebration.is-race-takeover .level-celebration__dialog {
    padding: 0.95rem 0.75rem 0.75rem;
  }

  .multi-race-lane {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr);
    gap: 0.2rem;
  }

  .multi-race-name {
    font-size: 0.78rem;
  }

  .multi-race-line {
    height: 38px;
  }

  .multi-race-runner {
    width: 32px;
    height: 32px;
  }

  .multi-size-row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.2rem 0.32rem;
  }

  .multi-size-bar-wrap {
    grid-column: 1 / -1;
  }

  .library-pagination {
    flex-direction: column;
    align-items: stretch;
  }

}

/* ── Animal image styles ── */

.animal-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: auto;
  transform: scaleX(-1);
  transition: opacity 0.15s ease-in;
}

.animal-img.ai-sprite {
  transform: none;
}

.animal-card .animal-img {
  width: 140px;
  height: 140px;
}

.race-runner .animal-img {
  width: 48px;
  height: 48px;
}

.plate .animal-img {
  width: 48px;
  height: 48px;
}

.level-race-runner .animal-img {
  width: 34px;
  height: 34px;
}

.level-celebration.is-race-takeover .level-race-runner .animal-img {
  width: 40px;
  height: 40px;
}

.multi-race-runner .animal-img {
  width: 34px;
  height: 34px;
}

@media (max-width: 600px) {
  .animal-card .animal-img {
    width: 112px;
    height: 112px;
  }
}

.multi-card .animal-img {
  width: 80px;
  height: 80px;
}

/* ── Race Scene ── */

.race-scene {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  min-height: 180px;
}

.race-scene__sky {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38%;
  overflow: hidden;
  pointer-events: none;
}

.race-scene__cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  box-shadow: 18px 0 24px rgba(255, 255, 255, 0.45), -18px 0 24px rgba(255, 255, 255, 0.45);
}

.race-scene__cloud--1 {
  width: 60px;
  height: 22px;
  top: 18%;
  left: -8%;
  animation: cloud-drift 38s linear infinite;
}

.race-scene__cloud--2 {
  width: 45px;
  height: 16px;
  top: 32%;
  left: -6%;
  animation: cloud-drift 52s linear infinite;
  animation-delay: -18s;
}

.race-scene__cloud--3 {
  width: 55px;
  height: 18px;
  top: 8%;
  left: -10%;
  animation: cloud-drift 44s linear infinite;
  animation-delay: -30s;
}

@keyframes cloud-drift {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 80px)); }
}

.race-scene__horizon {
  position: absolute;
  top: 33%;
  left: 0;
  right: 0;
  height: 7%;
  opacity: 0.45;
  pointer-events: none;
}

.race-scene__ground {
  position: relative;
  margin-top: 0;
  padding: 0 0.5rem 0.5rem;
  min-height: 100px;
}

.race-scene__markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.race-scene__marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.25) 0 4px, transparent 4px 8px);
}

.race-scene__finish {
  position: absolute;
  right: 6px;
  top: 0;
  bottom: 0;
  width: 5px;
  background: repeating-linear-gradient(180deg, #ffffff 0 4px, #2a3340 4px 8px);
  opacity: 0.4;
  pointer-events: none;
}

.race-scene__lanes {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.3rem;
  padding-top: 0.4rem;
}

/* ── Race scene habitat variants ── */

.race-scene--savanna {
  background: linear-gradient(180deg, #7ec8e3 0%, #b8ddf0 28%, #e2c97a 38%, #c8d87e 55%, #a8b86a 100%);
}

.race-scene--savanna .race-scene__horizon {
  background: #6a8a3a;
  clip-path: polygon(0% 100%, 3% 45%, 7% 60%, 12% 35%, 18% 55%, 24% 30%, 30% 50%, 38% 40%, 45% 55%, 52% 35%, 58% 50%, 65% 42%, 72% 55%, 78% 38%, 85% 50%, 92% 42%, 97% 55%, 100% 40%, 100% 100%);
}

.race-scene--forest {
  background: linear-gradient(180deg, #5a9ab5 0%, #8abfcc 28%, #4a8a40 38%, #3a7530 55%, #2d5a25 100%);
}

.race-scene--forest .race-scene__horizon {
  background: #2d5a25;
  clip-path: polygon(0% 100%, 2% 20%, 5% 45%, 8% 15%, 12% 40%, 16% 10%, 20% 35%, 24% 18%, 28% 42%, 32% 12%, 36% 38%, 40% 20%, 44% 40%, 48% 15%, 52% 35%, 56% 22%, 60% 40%, 64% 10%, 68% 38%, 72% 18%, 76% 42%, 80% 15%, 84% 35%, 88% 20%, 92% 40%, 96% 25%, 100% 38%, 100% 100%);
}

.race-scene--ocean {
  background: linear-gradient(180deg, #3a6da8 0%, #5a9ac5 28%, #3a8ab5 38%, #2a6a95 55%, #1a4a70 100%);
}

.race-scene--ocean .race-scene__horizon {
  background: #4a8ab0;
  clip-path: polygon(0% 100%, 5% 55%, 12% 45%, 20% 55%, 28% 42%, 35% 55%, 42% 45%, 50% 55%, 58% 42%, 65% 55%, 72% 45%, 80% 55%, 88% 45%, 95% 55%, 100% 48%, 100% 100%);
}

.race-scene--desert {
  background: linear-gradient(180deg, #c58a4a 0%, #e8b570 28%, #daa855 38%, #c8953a 55%, #b88030 100%);
}

.race-scene--desert .race-scene__horizon {
  background: #c0903a;
  clip-path: polygon(0% 100%, 8% 50%, 20% 35%, 35% 50%, 50% 30%, 65% 48%, 80% 35%, 92% 48%, 100% 42%, 100% 100%);
}

.race-scene--arctic {
  background: linear-gradient(180deg, #b8d8f0 0%, #d5e8f5 28%, #e8f0f5 38%, #dce8f0 55%, #c8dae8 100%);
}

.race-scene--arctic .race-scene__horizon {
  background: #c8d8e5;
  clip-path: polygon(0% 100%, 10% 55%, 25% 45%, 40% 55%, 55% 48%, 70% 55%, 85% 48%, 100% 52%, 100% 100%);
}

.race-scene--freshwater {
  background: linear-gradient(180deg, #6aabb8 0%, #8ac5c8 28%, #5aaa98 38%, #4a9585 55%, #3a7a6a 100%);
}

.race-scene--freshwater .race-scene__horizon {
  background: #4a8a70;
  clip-path: polygon(0% 100%, 5% 55%, 15% 40%, 25% 55%, 35% 35%, 45% 50%, 55% 38%, 65% 52%, 75% 35%, 85% 50%, 95% 42%, 100% 50%, 100% 100%);
}

.race-scene--mountain {
  background: linear-gradient(180deg, #7088a8 0%, #95a8c0 28%, #8a9a88 38%, #728570 55%, #5a6a58 100%);
}

.race-scene--mountain .race-scene__horizon {
  background: #6a7a68;
  clip-path: polygon(0% 100%, 5% 60%, 12% 25%, 20% 55%, 28% 15%, 38% 50%, 45% 20%, 55% 45%, 62% 18%, 70% 50%, 78% 30%, 85% 52%, 92% 35%, 100% 48%, 100% 100%);
}

.race-scene--urban {
  background: linear-gradient(180deg, #8898a8 0%, #a8b4c0 28%, #b0aa98 38%, #a8a090 55%, #959085 100%);
}

.race-scene--urban .race-scene__horizon {
  background: #8a8a80;
  clip-path: polygon(0% 100%, 3% 40%, 5% 15%, 8% 15%, 10% 40%, 13% 40%, 15% 25%, 18% 25%, 20% 40%, 25% 40%, 27% 10%, 30% 10%, 32% 40%, 38% 50%, 40% 20%, 43% 20%, 45% 50%, 50% 45%, 52% 15%, 55% 15%, 57% 45%, 62% 40%, 65% 30%, 68% 30%, 70% 50%, 75% 45%, 78% 18%, 82% 18%, 84% 50%, 88% 40%, 90% 22%, 93% 22%, 95% 42%, 100% 45%, 100% 100%);
}

/* ── Race scene lane styling (within scene) ── */

.race-scene .race-lane {
  gap: 0.2rem;
}

.race-scene .race-track-line,
.race-scene .multi-race-line,
.race-scene .level-race-line {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  box-shadow: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  overflow: visible;
}

.race-scene .race-name,
.race-scene .multi-race-name,
.race-scene .level-race-name {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.race-scene .level-race-line {
  overflow: visible;
}

.race-scene .multi-race-lane.is-winner .multi-race-name,
.race-scene .level-race-lane.is-winner .level-race-name {
  color: #ffd740;
}

.race-scene .multi-race-lane.is-winner .multi-race-line,
.race-scene .level-race-lane.is-winner .level-race-line {
  box-shadow: 0 0 0 2px rgba(255, 215, 64, 0.6);
  background: rgba(255, 215, 64, 0.15);
}

.race-scene .multi-race-lane.is-picked .multi-race-name {
  color: #4fc3f7;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 0 0 6px rgba(79, 195, 247, 0.5);
}

.race-scene .finish-line {
  display: none;
}

/* ── Running animation ── */

@keyframes run-gallop {
  0%, 100% { transform: translateY(0) scaleX(-1); }
  25% { transform: translateY(-6px) scaleX(-1.04); }
  50% { transform: translateY(0) scaleX(-0.96); }
  75% { transform: translateY(-4px) scaleX(-1.02); }
}

@keyframes run-gallop-sprite {
  0%, 100% { transform: translateY(0) scaleX(1); }
  25% { transform: translateY(-6px) scaleX(1.04); }
  50% { transform: translateY(0) scaleX(0.96); }
  75% { transform: translateY(-4px) scaleX(1.02); }
}

.race-runner.is-racing .animal-img,
.level-race-runner.is-racing .animal-img,
.multi-race-runner.is-racing .animal-img {
  animation: run-gallop 0.3s ease-in-out infinite;
}

.race-runner.is-racing .animal-img.ai-sprite,
.level-race-runner.is-racing .animal-img.ai-sprite,
.multi-race-runner.is-racing .animal-img.ai-sprite {
  animation: run-gallop-sprite 0.3s ease-in-out infinite;
}

.race-runner.is-racing span,
.level-race-runner.is-racing span,
.multi-race-runner.is-racing span {
  animation: run-gallop 0.3s ease-in-out infinite;
}

/* ── Dust trail effect ── */

.race-runner.is-racing::after,
.multi-race-runner.is-racing::after,
.level-race-runner.is-racing::after {
  content: '';
  position: absolute;
  left: -4px;
  bottom: 2px;
  width: 16px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(180, 160, 120, 0.5) 0%, transparent 70%);
  animation: dust-puff 0.25s ease-out infinite alternate;
  pointer-events: none;
}

@keyframes dust-puff {
  from { opacity: 0.6; transform: scale(1) translateX(0); }
  to { opacity: 0; transform: scale(1.4) translateX(-6px); }
}

/* ── Speed lines ── */

.race-runner.is-racing::before,
.multi-race-runner.is-racing::before,
.level-race-runner.is-racing::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 2px;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.5), transparent);
  animation: speed-line 0.18s linear infinite;
  pointer-events: none;
}

@keyframes speed-line {
  from { opacity: 0.7; width: 14px; }
  to { opacity: 0; width: 22px; }
}

/* ── Finish celebration ── */

.race-runner.is-finished .animal-img,
.multi-race-runner.is-finished .animal-img,
.level-race-runner.is-finished .animal-img {
  animation: finish-pop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards;
}

@keyframes finish-pop {
  0% { transform: scaleX(-1) scaleY(1); filter: drop-shadow(0 0 0 transparent); }
  50% { transform: scaleX(-1.25) scaleY(1.25); filter: drop-shadow(0 0 8px rgba(255, 200, 0, 0.7)); }
  100% { transform: scaleX(-1) scaleY(1); filter: drop-shadow(0 0 3px rgba(255, 200, 0, 0.3)); }
}

.race-runner.is-finished .animal-img.ai-sprite,
.multi-race-runner.is-finished .animal-img.ai-sprite,
.level-race-runner.is-finished .animal-img.ai-sprite {
  animation: finish-pop-sprite 0.4s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards;
}

@keyframes finish-pop-sprite {
  0% { transform: scaleX(1) scaleY(1); filter: drop-shadow(0 0 0 transparent); }
  50% { transform: scaleX(1.25) scaleY(1.25); filter: drop-shadow(0 0 8px rgba(255, 200, 0, 0.7)); }
  100% { transform: scaleX(1) scaleY(1); filter: drop-shadow(0 0 3px rgba(255, 200, 0, 0.3)); }
}

/* ── Info panel overlay ── */

/* ── Fun fact card ── */
.fun-fact-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 14px;
  background: #EDF5EE;
  border: 1px solid #C8DCC8;
  animation: fact-fade-in 0.3s ease-out;
}

.fun-fact-card__header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.fun-fact-card__icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.fun-fact-card__label {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ink);
}

.fun-fact-card__text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #4A6455;
}

@keyframes fact-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Multi-arena exit / Reveal-zone enter crossfade ── */

.multi-arena.is-exiting {
  animation: arena-exit 0.4s ease-in forwards;
  pointer-events: none;
}

.reveal-zone.is-entering {
  animation: reveal-enter 0.4s ease-out;
}

@keyframes arena-exit {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}

@keyframes reveal-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pokédex toggle ── */

.pokedex-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  user-select: none;
}

.pokedex-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d6e0ee;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.pokedex-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.pokedex-toggle input[type="checkbox"]:checked {
  background: var(--accent);
}

.pokedex-toggle input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

/* ── Library card badges & discovery states ── */

.library-card {
  position: relative;
  cursor: pointer;
}

.library-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.library-card-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  line-height: 1;
  z-index: 2;
  background: #e0e8f0;
  color: #8a99ab;
  border: 2px solid #fff;
}

.library-card-badge.is-discovered {
  background: var(--good);
  color: #fff;
}

.library-card-heart {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  color: #ff4d6a;
  font-size: 0.95rem;
  z-index: 2;
  pointer-events: none;
}

/* Undiscovered card in Pokédex mode */
.library-card.is-undiscovered {
  cursor: default;
  opacity: 0.75;
  border-color: #c0ccdd;
}

.library-card.is-undiscovered .library-card-top {
  filter: grayscale(1) sepia(0.3) brightness(0.85) contrast(0.6);
  opacity: 0.45;
}

.library-card.is-undiscovered .library-name {
  color: var(--ink-soft);
  font-style: italic;
}

.library-undiscovered-prompt {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  padding: 0.5rem 0;
}

/* ── Animal Detail Modal ── */

.animal-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.animal-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.animal-detail-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #fffef8 0%, #f4fbff 65%, #edf4ff 100%);
  border-radius: 24px 24px 0 0;
  padding: 1.2rem 1.2rem calc(5rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  animation: detail-slide-up 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes detail-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.animal-detail-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  z-index: 2;
}

.animal-detail-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

.animal-detail-hero {
  display: grid;
  place-items: center;
  padding: 1rem 0;
}

.animal-detail-img {
  width: 140px;
  height: 140px;
  object-fit: contain;
}

.animal-detail-hero .emoji {
  font-size: 4rem;
}

.animal-detail-name {
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
  line-height: 1.2;
}

.animal-detail-scientific {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
  margin: 0.15rem 0 0.8rem;
}

.animal-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.animal-detail-stat {
  background: #f0f6ff;
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.animal-detail-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.animal-detail-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.animal-detail-stat-value.is-missing {
  color: #bbb;
}

.animal-detail-facts-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}

.animal-detail-fact {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
  padding-left: 0.8rem;
  position: relative;
}

.animal-detail-fact::before {
  content: "\2022";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 900;
}

.animal-detail-fav-btn {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.65rem;
  border: 2px solid #d6e8ff;
  border-radius: 14px;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.animal-detail-fav-btn:hover {
  border-color: #ff4d6a;
  color: #ff4d6a;
}

.animal-detail-fav-btn.is-favorited {
  background: #fff0f3;
  border-color: #ff4d6a;
  color: #ff4d6a;
}

.animal-detail-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.animal-detail-share-btn:hover {
  background: var(--accent);
  color: #fff;
}

.animal-detail-share-btn--copied {
  border-color: var(--good);
  color: var(--good);
}

/* ── Report Incorrect Data (Animal Detail) ── */

.animal-detail-report-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.55rem;
  border: 2px solid var(--border);
  border-radius: 9999px;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.animal-detail-report-btn:hover {
  border-color: var(--ink-soft);
  color: var(--ink-soft);
}

.animal-report-form {
  margin-top: 0.6rem;
  padding: 0.75rem;
  border-radius: 14px;
  background: #fefaf2;
  border: 1px solid var(--border);
  animation: fact-fade-in 0.3s ease-out;
}

.animal-report-form__prompt {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.animal-report-form__checks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.animal-report-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.animal-report-check input[type="checkbox"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

.animal-report-note {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  resize: vertical;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
}

.animal-report-note:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.animal-report-send {
  width: 100%;
  padding: 0.6rem;
  border: none;
  border-radius: 9999px;
  background: var(--primary);
  color: white;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.1s ease;
}

.animal-report-send:hover {
  background: var(--primary-2);
}

/* ── In-Game Report Hint ── */

.report-data-hint {
  text-align: center;
  margin-top: 1.5rem;
}

.report-data-link {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0.25rem;
}

.report-data-link:hover {
  color: var(--ink-soft);
}

body.modal-open {
  overflow: hidden;
}

/* ── Profile Picker Modal ── */

.profile-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.profile-picker-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #fffef8 0%, #f4fbff 65%, #edf4ff 100%);
  border-radius: 24px;
  padding: 1.4rem 1.2rem 1.4rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  animation: picker-pop 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes picker-pop {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.profile-picker-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  z-index: 2;
}

.profile-picker-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

.profile-picker-title {
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-size: 1.4rem;
  text-align: center;
  margin: 0 0 1rem;
  color: var(--ink);
}

.profile-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.profile-picker-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.9rem 0.5rem 0.7rem;
  background: var(--card);
  border: 3px solid #C8DCC8;
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.profile-picker-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.profile-picker-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 138, 78, 0.25), 0 6px 16px rgba(27, 138, 78, 0.15);
}

.profile-picker-card--add {
  border-style: dashed;
  border-color: #c4d8f5;
  background: rgba(227, 239, 255, 0.35);
}

.profile-picker-card--add:hover {
  border-color: var(--primary);
  background: rgba(255, 237, 219, 0.3);
}

.profile-picker-card__emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.profile-picker-card__name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-picker-card__level {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.profile-picker-card__check {
  font-size: 0.75rem;
  color: var(--primary);
}

.profile-picker-card__delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff5a5a;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.1s;
}

.profile-picker-card__delete:hover {
  transform: scale(1.15);
}

.profile-picker-card__add-icon {
  font-size: 2rem;
  line-height: 1;
  color: var(--ink-soft);
}

.profile-picker-card__add-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.profile-picker-confirm {
  margin-top: 1rem;
  padding: 1rem;
  background: #fff5f5;
  border: 2px solid #ffcccc;
  border-radius: 14px;
  text-align: center;
}

.profile-picker-confirm p {
  margin: 0 0 0.7rem;
  font-weight: 700;
  color: var(--ink);
}

.profile-picker-confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.profile-picker-remove-btn {
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1.4rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: #ff5a5a;
  color: #fff;
  border-bottom: 3px solid #c43c3c;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.profile-picker-remove-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
}

/* Home avatar switch indicator */
.home-avatar {
  cursor: pointer;
  position: relative;
}

.home-avatar-switch {
  position: absolute;
  bottom: -2px;
  right: -4px;
  font-size: 0.6rem;
  background: var(--primary);
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  line-height: 1;
}

/* ── Discovery Toast ── */

.discovery-toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #1d9f7a, #149954);
  color: #fff;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 55;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(20, 153, 84, 0.3);
}

.discovery-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══ ONBOARDING OVERLAY ═══ */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: radial-gradient(circle at 12% 15%, #faf3e5 0%, var(--bg-1) 35%, transparent 55%),
    radial-gradient(circle at 90% 8%, #e5f2e5 0%, var(--bg-2) 40%, transparent 60%),
    linear-gradient(155deg, #f5f0e8 0%, #e8f0e8 50%, #f5efe5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.onboarding-step {
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 2rem 1.5rem;
  text-align: center;
  animation: onboarding-fadeIn 0.4s ease;
}

@keyframes onboarding-fadeIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Splash */
.onboarding-splash__logo {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.onboarding-splash__emoji {
  font-size: 3.5rem;
  animation: onboarding-bounce 1.2s ease infinite;
}

.onboarding-splash__emoji--delay1 { animation-delay: 0.2s; }
.onboarding-splash__emoji--delay2 { animation-delay: 0.4s; }

@keyframes onboarding-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

.onboarding-splash__title {
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-size: 2.2rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}

.onboarding-splash__tagline {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0;
}

/* Shared onboarding button */
.onboarding-btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.85rem 2.4rem;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  border-bottom: 4px solid #c75600;
  transition: transform 0.1s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin-top: 0.6rem;
}

.onboarding-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.onboarding-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.onboarding-heading {
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-size: 1.65rem;
  margin: 0;
}

.onboarding-subtext {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0;
}

/* Guide Picker */
.onboarding-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  width: 100%;
}

.onboarding-guide-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  background: var(--card);
  border: 3px solid #C8DCC8;
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.onboarding-guide-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.onboarding-guide-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 138, 78, 0.25), 0 6px 16px rgba(27, 138, 78, 0.15);
  transform: translateY(-3px);
}

.onboarding-guide-card__emoji {
  font-size: 2.5rem;
}

.onboarding-guide-card__name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

/* Name Entry */
.onboarding-name__avatar {
  font-size: 3.5rem;
  animation: onboarding-bounce 1.2s ease infinite;
}

.onboarding-name-input {
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  padding: 0.8rem 1.2rem;
  border: 3px solid #C8DCC8;
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
  max-width: 280px;
  outline: none;
  transition: border-color 0.15s;
}

.onboarding-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 138, 78, 0.2);
}

/* Tutorial */
.onboarding-tutorial {
  gap: 1rem;
}

.onboarding-tutorial__progress {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.onboarding-tutorial__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d0dbe8;
  transition: background 0.25s, transform 0.25s;
}

.onboarding-tutorial__dot.is-active {
  background: var(--primary);
  transform: scale(1.25);
}

.onboarding-tutorial__dot.is-done {
  background: var(--good);
}

.onboarding-tutorial__bubble {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: var(--card);
  border: 3px solid #C8DCC8;
  border-radius: 18px;
  padding: 1rem 1.2rem;
  text-align: left;
  box-shadow: var(--shadow);
  width: 100%;
}

.onboarding-tutorial__guide {
  font-size: 2.2rem;
  flex-shrink: 0;
}

.onboarding-tutorial__bubble p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink);
}

.onboarding-tutorial__arena {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  justify-content: center;
}

.onboarding-tutorial__card {
  flex: 1;
  max-width: 160px;
  padding: 1.2rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: var(--card);
  border: 3px solid #C8DCC8;
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.onboarding-tutorial__card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.onboarding-tutorial__card .emoji {
  font-size: 2.8rem;
  display: block !important;
}

.onboarding-tutorial__card .name {
  font-size: 1rem;
  font-weight: 700;
}

.onboarding-tutorial__card.is-correct {
  border-color: var(--good);
  background: #eafff3;
  box-shadow: 0 0 0 3px rgba(20, 153, 84, 0.2);
}

.onboarding-tutorial__card.is-wrong {
  border-color: var(--bad);
  opacity: 0.65;
}

.onboarding-tutorial__result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  animation: onboarding-fadeIn 0.3s ease;
}

.onboarding-tutorial__result p {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

/* Hub reveal animation */
.onboarding-overlay.is-revealing {
  animation: onboarding-hubReveal 0.6s ease forwards;
}

@keyframes onboarding-hubReveal {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.08); pointer-events: none; }
}

/* ═══ WELCOME BACK TOAST ═══ */

.welcome-back-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 180;
  background: var(--card);
  border: 3px solid var(--primary);
  border-radius: 16px;
  padding: 0.8rem 1.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(27, 138, 78, 0.2);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.welcome-back-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══ HOME TOUR (Coach Marks) ═══ */

.home-tour {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.home-tour__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  transition: clip-path 0.35s ease;
}

.home-tour__spotlight {
  position: absolute;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4), inset 0 0 12px rgba(255, 255, 255, 0.15);
  background: transparent;
  transition: top 0.35s ease, left 0.35s ease, width 0.35s ease, height 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.home-tour__tooltip {
  position: absolute;
  z-index: 2;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  background: #fff;
  border-radius: 16px;
  padding: 1rem 1.2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  max-width: min(360px, 88vw);
  transition: top 0.35s ease, left 0.35s ease, opacity 0.25s ease;
}

.home-tour__guide {
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}

.home-tour__body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.home-tour__body p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink);
}

.home-tour__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.home-tour__actions button {
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}

.home-tour__actions button:active {
  transform: scale(0.96);
}

.home-tour__tooltip::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  z-index: -1;
}

.home-tour__tooltip.arrow-down::after {
  bottom: -7px;
  left: 50px;
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.1);
}

.home-tour__tooltip.arrow-up::after {
  top: -7px;
  left: 50px;
  box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.1);
}

.home-tour__btn-primary {
  background: var(--primary);
  color: #fff;
}

.home-tour__btn-secondary {
  background: #e8ecf1;
  color: var(--ink);
}

/* ── Sprint 5: Micro-animations & UI polish ── */

/* Card press feedback */
.animal-card:active:not(:disabled),
.multi-entrant-card:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  transition: transform 0.1s ease;
}

/* Achievement toast notification */
.achievement-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 180;
  background: linear-gradient(135deg, #F5A623, #E8941A);
  color: #1A2B1E;
  padding: 0.75rem 1.5rem;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: achievement-slide-in 0.4s ease-out;
  pointer-events: none;
}
@keyframes achievement-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-2rem); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* XP bar glow pulse at milestones */
@keyframes xp-glow-pulse {
  0%   { box-shadow: 0 0 4px rgba(27, 138, 78, 0.4); }
  50%  { box-shadow: 0 0 16px rgba(27, 138, 78, 0.9); }
  100% { box-shadow: 0 0 4px rgba(27, 138, 78, 0.4); }
}
.xp-bar-fill.is-glowing,
.home-xp-fill.is-glowing,
.game-hud-xp-fill.is-glowing {
  animation: xp-glow-pulse 0.6s ease-in-out 2;
}

/* View slide transitions */
@keyframes view-slide-in-right {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes view-slide-in-left {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.view-slide-right {
  animation: view-slide-in-right 0.25s ease-out;
}
.view-slide-left {
  animation: view-slide-in-left 0.25s ease-out;
}

/* Streak fire animated emoji */
@keyframes flame-flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25%      { transform: scale(1.1) rotate(-3deg); }
  50%      { transform: scale(1.05) rotate(2deg); }
  75%      { transform: scale(1.15) rotate(-2deg); }
}
.streak-fire {
  display: inline-block;
  animation: flame-flicker 0.5s ease-in-out infinite;
}

/* Profile achievement grid */
.profile-achievement-item {
  background: #f5f9ff;
  border-radius: 10px;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.profile-achievement-item.is-locked {
  opacity: 0.35;
  filter: grayscale(0.6);
}
.profile-achievement-desc {
  font-size: 0.72rem;
  font-weight: 500;
  color: #677b93;
  margin-top: 0.15rem;
}

/* Score counter pop animation */
@keyframes score-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.score-bump {
  animation: score-bump 0.35s ease-out;
}

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