html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* important */
}

#tft-game-container {
  position: fixed;
  top: 0;
  left: 50%;               /* move anchor to middle */
  transform: translateX(-50%); /* pull back half width */
  width: 100%;
  max-width: 480px;        /* desktop width */
  height: 100vh;
  background: linear-gradient(#6ec6ff, #b3e5fc);
  overflow: hidden;
}

.tft-page {
  padding: 0;
  margin: 0;
  width: 100%;
}

.tft-card {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Desktop only — constrain width */
@media (min-width: 768px) {
  #tft-game-container {
    max-width: 480px;
    margin: 0 auto;
  }
}

/* -------------------------
   LAYERS
   ------------------------- */

/* Walls behind UI */
.wall {
  z-index: 2;
}

/* Turtle above walls */
#turtle {
  z-index: 3;
}

/* UI above everything */
#problem-ui, #hud {
  z-index: 10;
}

/* -------------------------
   TURTLE
   ------------------------- */

#turtle {
  position: absolute;
  width: 100px;
  height: 100px;
  left: 60px;
  top: 50%;
  transform: translateY(-50%);
  background: url('../images/turtle.png') no-repeat center / contain;
}

/* Thrust sprite */
#turtle.thrusting {
  background-image: url('../images/turtle2.png');
}

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

#hud {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

#distance {
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: bold;
}

/* -------------------------
   WALL
   ------------------------- */

.wall {
  position: absolute;
  top: 0;
  height: 100%;
  width: 56px; /* slightly wider looks better */

  /* Main pipe body */
  background: linear-gradient(
    to right,
    #1b5e20 0%,
    #43a047 20%,
    #66bb6a 50%,
    #43a047 80%,
    #1b5e20 100%
  );

  border: 3px solid #000;      /* black outline */
  border-radius: 6px;

  box-shadow:
    inset -4px 0 0 rgba(0,0,0,0.35),  /* right side depth */
    inset 4px 0 0 rgba(255,255,255,0.15); /* left highlight */
}

/* Wrong-answer shake */
@keyframes wallShake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-6px); }
  50%  { transform: translateX(6px); }
  75%  { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.wall.shake {
  animation: wallShake 0.15s ease;
}

/* Correct-answer explode */
@keyframes wallExplode {
  to {
    opacity: 0;
    transform: scale(1.2);
  }
}

.wall.explode {
  animation: wallExplode 0.2s ease forwards;
}

/* Wall Drop Down Animation */
@keyframes wallDropDown {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(120%);
  }
}

.wall.drop {
  animation: wallDropDown 0.18s ease-in forwards;
}

/* -------------------------
   PARALLAX BACKGROUND
   ------------------------- */

.parallax {
  position: absolute;
  inset: 0;
  z-index: 1;        /* behind walls (2), turtle (3), UI (10) */
  overflow: hidden;
  pointer-events: none;
}

/* The moving strip (we'll translateX it in JS) */
.parallax-track {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 200%; /* two tiles side-by-side for seamless wrap */
  background-repeat: repeat-x;
  background-position: bottom left;
  background-size: auto 55%; /* tweak height of silhouettes */
  will-change: transform;
  opacity: 0.9;
}

/* Mountains option */
.parallax--mountains .parallax-track {
  background-image: url("../images/tft/mountains.png");
  background-position: bottom left;
  background-size: auto 58%;
}

/* Buildings option */
.parallax--buildings .parallax-track {
  background-image: url("../images/tft/buildings.png");
  background-position: bottom left;
  background-size: auto 52%;
}

/* Optional: add a subtle atmospheric fade so it sits "back" */
.parallax::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), rgba(0,0,0,0.08));
}

/* -------------------------
   CLOUD LAYER
   ------------------------- */

.parallax--clouds {
  z-index: 0;   /* furthest back */
}

.parallax--mountains {
  z-index: 1;   /* in front of clouds */
}

.parallax--clouds .parallax-track {
  background-image: url("../images/tft/clouds.png");
  background-repeat: repeat-x;
  background-position: left 20%;
  background-size: auto 35%;  /* smaller than mountains */
  opacity: 0.85;
}

/* -------------------------
   PROBLEM UI
   ------------------------- */

#problem-ui {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  pointer-events: none; /* buttons enable pointer */
}

#problem-text {
  color: white;
  font-size: 30px;          /* was 22px */
  font-weight: 900;
  margin-bottom: 14px;
  text-shadow: 0 3px 8px rgba(0,0,0,0.65);
  letter-spacing: 0.5px;
}

#answers {
  display: flex;
  justify-content: center;
  gap: 12px;
  pointer-events: auto;
}

.answer-btn {
  min-width: 80px;          /* was 52px */
  padding: 16px 22px;       /* was 10px 12px */
  border-radius: 999px;

  background: #ffb703;
  color: #222;
  font-weight: 900;
  font-size: 22px;          /* was 18px */

  border: none;
  box-shadow: 0 6px 0 #e09f00;
  transition: transform 0.08s ease, opacity 0.12s ease;

  touch-action: manipulation; /* helps mobile tap responsiveness */
}

.answer-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #e09f00;
}

.answer-btn.disabled {
  opacity: 0.4;
  filter: grayscale(1);
  pointer-events: none;
}

/* ================================
   RESULTS OVERLAY
   ================================ */

.results-overlay {
  position: fixed;
  top: 52px; /* header height */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

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

/* Make results readable */
.results-panel,
.results-panel * {
  color: #1f2937; /* dark slate */
}

.results-panel .result-value {
  font-weight: 800;
  font-size: 1.4rem;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
}

/* Hide header on mobile during gameplay */
@media (max-width: 768px) {
  body.game-mode .site-header {
    display: none;
  }
}

body.game-active .site-header {
  display: none;
}

/* 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;
  }
}

body.game-mode footer {
  display: none;
}

/* ================================
   RESULTS OVERLAY (match race.html)
   ================================ */

/* Overlay shell */
.results-overlay {
  position: fixed;
	top: 52px; /* header height */

  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Panel container */
.results-panel {
  position: relative;
  max-width: 520px;          /* race feels a touch wider */
  width: calc(100% - 32px);
  margin: 0 auto;            /* extra safety */
}

/* Grid of stat boxes */
.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;
}

.result-label {
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.result-value {
  font-weight: 900;
  font-size: 1.6rem;
  color: var(--text-main);
}

/* Home button (top-right pill icon) */
.results-home-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  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);
}

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

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

/* Ad block matches race */
.ad-results {
  margin: 12px auto 0;
  padding: 6px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  width: 320px;
  display: flex;
  justify-content: center;
  align-items: center;
}

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