/* =================================================
   Mathracers – Race Game Styles
   ================================================= */

body.game-mode { overflow: hidden; }

.race-page {
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 6px;
}

.race-card {
  margin: 2px 0;
  padding: 6px 8px;
}

/* ================================
   RACE TRACK
   ================================ */
.race-track {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.race-lane {
  position: relative;
  height: 42px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid var(--border-light);
}

.race-lane::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 0;
  width: 3px;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    #111 0px,
    #111 6px,
    transparent 6px,
    transparent 12px
  );
}



/* Let racer fill the lane */
.racer {
  position: absolute;      /* relative to .race-lane */
  left: 8px;
  top: 0;
  height: 100%;            /* fill lane height */
  display: flex;
  align-items: center;    /* vertical centering */
  transition: left 0.25s ease-out;
}

.racer.you {
  /* filter: drop-shadow(0 0 6px rgba(59,130,246,0.6)); */
}

.racer-name {
  position: absolute;
  left: 8px;
  top: -12px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.racer-name.you { color: var(--blue); }

/* Player racer alignment */
.racer.you {
  display: flex;
  align-items: center;
}

.racer.you {
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.9));
  transform: scale(1.03);
}

/* Normalize all racers (player + bots) to lane height */
.race-track .racer .composite-racer {
  height: 100%;
  width: auto;
}

.race-track .racer .composite-racer img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

/* ================================
   QUESTION + ANSWERS
   ================================ */
.question-text {
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 6px;
	white-space: nowrap;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.answer-btn {
  padding: 14px;
  font-size: 1.8rem;
  font-weight: 800;
  border-radius: var(--radius);
  border: 2px solid #c7d2fe;
  background: linear-gradient(180deg, #eef2ff, #e0e7ff);
  color: #1e3a8a;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.08);
  transition: transform 0.05s ease, box-shadow 0.05s ease, background 0.1s ease;
}

.answer-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  background: linear-gradient(180deg, #e0e7ff, #c7d2fe);
}

.answer-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
  background: linear-gradient(180deg, #c7d2fe, #e0e7ff);
}

/* ================================
   COUNTDOWN OVERLAY
   ================================ */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#countdownText {
  font-size: 6rem;
  font-weight: 900;
  color: var(--blue);
}

/* Outer countdown avatar box (layout only) */
.countdown-avatar {
  width: 80px;              /* anchor size — can be small */
  height: 80px;
  margin-bottom: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15));
}

.countdown-avatar-inner.composite-racer {
  left: 70%;
  top: 50%;
  transform: scale(2.6);
  transform-origin: center;
}

/*
  Inner element:
  - receives composite-racer markup
  - holds static scaling
  - receives revving/sprint animations
*/
.countdown-avatar-inner {
  width: 100%;
  height: 100%;
}

/* Rev-up wobble before GO (applies to INNER) */
@keyframes revWobble {
  0%   { transform: translateY(0) scale(2.6); }
  20%  { transform: translateY(-4px) scale(2.6); }
  40%  { transform: translateY(2px)  scale(2.6); }
  60%  { transform: translateY(-3px) scale(2.6); }
  80%  { transform: translateY(1px)  scale(2.6); }
  100% { transform: translateY(0) scale(2.6); }
}

.countdown-avatar-inner.revving {
  animation: revWobble 0.6s ease-in-out;
}

/* Sprint off screen on GO (applies to INNER) */
@keyframes avatarSprint {
  0%   { transform: translateX(0) scale(2.6); }
  15%  { transform: translateX(-80px) scale(2.6); }
  100% { transform: translateX(200vw) scale(2.6); }
}

.countdown-avatar-inner.sprint {
  animation: avatarSprint 0.7s cubic-bezier(0.25, 0.9, 0.2, 1) forwards;
}

/* Motion blur streak (on OUTER so it doesn't fight transforms) */
.countdown-avatar::after {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 12px;
  background: linear-gradient(to right, rgba(59,130,246,0.0), rgba(59,130,246,0.35));
  filter: blur(4px);
  opacity: 0;
  pointer-events: none;
}

.countdown-avatar-inner.sprint + #countdownText,
.countdown-avatar-inner.sprint ~ #countdownText { /* harmless, no-op safeguard */ }

.countdown-avatar-inner.sprint ~ .countdown-avatar::after { /* no-op; kept minimal */ }

.countdown-avatar.sprint::after,
.countdown-avatar-inner.sprint ~ #countdownText { /* no-op; safe */ }

.countdown-avatar.sprint::after { opacity: 1; } /* if you ever add .sprint to outer */

/* ================================
   RESULTS OVERLAY
   ================================ */
.results-overlay {
  position: fixed;
  top: 52px;      /* height of compact race header */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 998;
}

.results-panel {
  position: relative;
  max-width: 420px;
  width: calc(100% - 32px);
}

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

.result-box {
  background: var(--bg-panel);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.results-home-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--blue);
  background: white;
  border: 2px solid var(--border-light);
  border-radius: 999px;
  padding: 6px 12px;
}

/* Center the Play Again button */
#playAgainBtn {
  display: block;
  margin: 16px auto 0;
}

/* Play Again button themed by mode */
body.mode-add #playAgainBtn {
  background: #22c55e;
  color: white;
  border-color: #16a34a;
}

body.mode-sub #playAgainBtn {
  background: #f97316;
  color: white;
  border-color: #ea580c;
}

body.mode-mul #playAgainBtn {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
}

body.mode-div #playAgainBtn {
  background: #8b5cf6;
  color: white;
  border-color: #7c3aed;
}

.problem-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 6px 0 10px;
}


.mode-label {
  font-weight: 800;
  font-size: 1.5rem;
  opacity: 0.25;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
  color: white;
/*text-shadow: 0 1px 0 rgba(0,0,0,0.25);  helps on bright green/orange */
}

/* Mobile: keep it readable */
@media (max-width: 480px) {
  .mode-label {
    font-size: 0.7rem;
    opacity: 0.25;
  }
}

/* ================================
   COIN BURST ANIMATION
   ================================ */
.coins-burst {
  position: absolute;
  top: 48px;
  right: 12px;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--yellow);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}

.coins-burst.show {
  animation: coinsPop 0.9s ease-out forwards;
}

@keyframes coinsPop {
  0%   { opacity: 0; transform: translateY(10px) scale(0.9); }
  20%  { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-14px) scale(1); }
}

/* In-game answer buttons ONLY */
body.mode-add .race-question .answer-btn { 
  background: linear-gradient(180deg, #dcfce7, #bbf7d0);
  border-color: #22c55e;
  color: #14532d;
}

body.mode-sub .race-question .answer-btn {
  background: linear-gradient(180deg, #ffedd5, #fed7aa);
  border-color: #f97316;
  color: #7c2d12;
}

body.mode-mul .race-question .answer-btn {
  background: linear-gradient(180deg, #e0e7ff, #c7d2fe);
  border-color: #3b82f6;
  color: #1e3a8a;
}

body.mode-div .race-question .answer-btn {
  background: linear-gradient(180deg, #ede9fe, #ddd6fe);
  border-color: #8b5cf6;
  color: #4c1d95;
}

/* Results overlay should always be readable */
.results-panel,
.results-panel * {
  color: var(--text-main);
}

.results-panel .result-value {
  color: var(--text-main);
}

.results-home-icon {
  width: 48px;
  height: 48px;
  padding: 6px;
  border-radius: 999px;
  background: white;
  border: 2px solid var(--border-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
}

.results-home-icon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.results-home-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
}

.results-home-icon:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.problem-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  margin: 6px 0 8px;
}

/* Make the math problem always readable */
.question-text {
  color: black;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

/* Compact header for race page only */
body.game-mode .site-header .site-wrapper {
  padding: 6px 0;           /* was 14px */
}

body.game-mode .logo img {
  height: 40px;            /* smaller logo */
}

body.game-mode .avatar {
  width: 32px;
  height: 32px;
}

body.game-mode .coins {
  padding: 4px 8px;
  font-size: 0.85rem;
}

body.game-mode .coin-icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 480px) {
  body.game-mode .site-header .site-wrapper {
    padding: 4px 0;
  }

  body.game-mode .logo img {
    height: 34px;
  }

  body.game-mode .avatar {
    width: 28px;
    height: 28px;
  }
}

.ad-results {
  margin: 12px auto 0;     /* space above, centered */
  padding: 6px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  width: 320px;            /* match ad width */
  display: flex;
  justify-content: center; /* center the <ins> */
  align-items: center;
}

@media (max-width: 360px) {
  .ad-results {
    width: 300px;
  }
}
