/* ── Variables & Reset ───────────────────────────────── */
:root {
  --bg: #0f1b2d;
  --bg-light: #162a4a;
  --accent: #ffb347;
  --accent-hover: #ffc97a;
  --correct: #5dd39e;
  --incorrect: #ff6b6b;
  --ocean: #1a6daa;
  --ocean-deep: #0e4a75;
  --land: #8ecfa0;
  --highlight: #ffe066;
  --text: #f0f0f0;
  --font-heading: "Playfair Display", serif;
  --font-body: "Poppins", sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screens ────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* ── Start Screen ───────────────────────────────────── */
#start-screen {
  background-image: url("splash.jpg");
  background-position: center 40%;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: var(--bg);
  justify-content: space-between;
  padding: 10vh 0;
}

@media (max-width: 600px) {
  #start-screen {
    background-size: 90% auto;
    background-position: center 30%;
  }
}

.title {
  font-family: var(--font-heading);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  color: var(--accent);
  text-shadow:
    0 4px 0 #c97e20,
    0 8px 20px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
}

.subtitle {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: rgba(240, 240, 240, 0.8);
  margin-bottom: 10px;
}

.btn-play {
  font-family: var(--font-body);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 700;
  color: #1a1a2e;
  background: var(--accent);
  border: none;
  border-radius: 50px;
  padding: 16px 60px;
  cursor: pointer;
  box-shadow:
    0 6px 0 #c97e20,
    0 10px 25px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.btn-play:hover {
  transform: translateY(-3px);
  box-shadow:
    0 9px 0 #c97e20,
    0 14px 30px rgba(0, 0, 0, 0.5);
  background: var(--accent-hover);
}

.btn-play:active {
  transform: translateY(2px);
  box-shadow:
    0 3px 0 #c97e20,
    0 6px 15px rgba(0, 0, 0, 0.3);
}

/* ── Game Screen ────────────────────────────────────── */
#game-screen {
  background: radial-gradient(ellipse at 50% 60%, #162a4a 0%, var(--bg) 80%);
  flex-direction: column;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#timer-container {
  width: min(90%, 420px);
  height: 14px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #5dd39e, #a3e635);
  border-radius: 7px;
  transition: width 0.1s linear;
}

#timer-bar.warning {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

#country-name {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 5vw, 2.4rem);
  font-weight: 700;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

#score-display {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  opacity: 0.8;
}

#scene-container {
  position: absolute;
  inset: 0;
  z-index: 0;
  touch-action: none;
}

/* ── Accelerate Button ────────────────────────────── */
.btn-accelerate {
  display: none;
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-family: var(--font-body);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 700;
  color: #1a1a2e;
  background: var(--accent);
  border: none;
  border-radius: 40px;
  padding: 12px 36px;
  cursor: pointer;
  opacity: 0.85;
  box-shadow:
    0 4px 0 #c97e20,
    0 6px 15px rgba(0, 0, 0, 0.4);
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn-accelerate.visible {
  display: block;
}

.btn-accelerate:active,
.btn-accelerate.pressing {
  opacity: 1;
  transform: translateX(-50%) scale(0.95);
  box-shadow:
    0 2px 0 #c97e20,
    0 3px 8px rgba(0, 0, 0, 0.3);
}

/* ── Feedback Chicken Image ─────────────────────────── */
#feedback-chicken,
#feedback-chicken-point {
  position: absolute;
  bottom: 5%;
  left: 50%;
  width: min(40vw, 220px);
  max-height: min(40vw, 220px);
  object-fit: contain;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#feedback-chicken.show,
#feedback-chicken-point.show {
  opacity: 1;
  transform: scale(1) !important;
}

/* ── Feedback Overlay ───────────────────────────────── */
#feedback-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 5;
}

#feedback-overlay.correct {
  background: radial-gradient(
    circle at center,
    rgba(93, 211, 158, 0.25) 0%,
    transparent 70%
  );
  opacity: 1;
}

#feedback-overlay.incorrect {
  background: radial-gradient(
    circle at center,
    rgba(255, 107, 107, 0.25) 0%,
    transparent 70%
  );
  opacity: 1;
}

/* ── Particles Canvas ───────────────────────────────── */
#particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* ── End Screen ─────────────────────────────────────── */
#end-screen {
  background: radial-gradient(ellipse at 50% 40%, #1e3a5f 0%, var(--bg) 70%);
  gap: 24px;
}

.end-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
}

.final-score {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  color: var(--accent);
  font-weight: 700;
}

/* ── Animations ─────────────────────────────────────── */
@keyframes globe-grow {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.globe-enter {
  animation: globe-grow 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.4s ease;
}

/* ── Utility ───────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Language Toggle ───────────────────────────────── */
.lang-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.btn-lang {
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1;
}

.btn-lang:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-lang.selected {
  border-color: var(--accent);
  background: rgba(255, 179, 71, 0.2);
}

/* ── Mode Buttons ──────────────────────────────────── */
.mode-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 16px;
}

.btn-mode {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  color: #1a1a2e;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  padding: 20px 36px;
  cursor: pointer;
  min-width: 140px;
  box-shadow:
    0 6px 0 #c97e20,
    0 10px 25px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}

.btn-mode:hover {
  transform: translateY(-3px);
  box-shadow:
    0 9px 0 #c97e20,
    0 14px 30px rgba(0, 0, 0, 0.5);
  background: var(--accent-hover);
}

.btn-mode:active {
  transform: translateY(2px);
  box-shadow:
    0 3px 0 #c97e20,
    0 6px 15px rgba(0, 0, 0, 0.3);
}

/* ── Flag Emoji (flags mode) ───────────────────────── */
.flag-emoji {
  font-size: clamp(3rem, 10vw, 5rem);
  line-height: 1;
}

/* ── Secondary Button ──────────────────────────────── */
.btn-secondary {
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
  color: rgba(240, 240, 240, 0.7);
  background: transparent;
  border: 1px solid rgba(240, 240, 240, 0.3);
  border-radius: 30px;
  padding: 10px 28px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}
