/* ==========================================================
   Plantgirl Super Race V2 3D — Fullscreen game styles
   ========================================================== */

:root {
  --panel-bg: rgba(8, 14, 42, 0.88);
  --gold: #ffd74b;
  --mint: #6bff9e;
  --text: #f2f7ff;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #080e2a;
  font-family: "Trebuchet MS", "Verdana", "Arial Rounded MT Bold", sans-serif;
  color: var(--text);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- Loading screen (Phase 7.3) ---------- */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(180deg, #0a1530, #13245f);
  display: grid;
  place-items: center;
  transition: opacity 0.5s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-inner {
  text-align: center;
}

.loading-logo {
  font-size: 72px;
  animation: loadingBounce 1.2s ease-in-out infinite;
}

@keyframes loadingBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

.loading-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 900;
  color: #fff;
  margin: 16px 0 20px;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--mint);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-hint {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}

/* ---------- Scene mount: fills entire window ---------- */
#sceneMount {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#sceneMount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Back link ---------- */
.back-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 20;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: color 0.15s;
}

.back-link:hover {
  color: #fff;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  pointer-events: none;
}

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

.hud-right {
  flex-direction: row-reverse;
}

.hud-block {
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  backdrop-filter: blur(6px);
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.55);
}

.hud-value {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
}

.hud-icon {
  font-size: 18px;
  line-height: 1;
}

.stars-block {
  flex-direction: row;
  gap: 6px;
  align-items: center;
  border-color: rgba(255, 228, 77, 0.4);
}

.stars-block .hud-value {
  color: var(--gold);
  font-size: 22px;
}

.score-block .hud-value {
  color: #fff;
}

.level-block .hud-value {
  color: #a8c8ff;
}

/* Prize meter bar */
.meter-block {
  min-width: 80px;
}

.meter-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  margin-top: 4px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--mint), #2ecc71);
  width: 0%;
  transition: width 0.3s ease;
}

/* Freeze block pulses when active */
.freeze-block .hud-value {
  color: var(--mint);
  font-size: 16px;
}

.freeze-block.active {
  border-color: var(--mint);
  animation: freezePulse 0.5s ease-in-out infinite alternate;
}

@keyframes freezePulse {
  from { box-shadow: 0 0 6px rgba(107, 255, 158, 0.3); }
  to { box-shadow: 0 0 18px rgba(107, 255, 158, 0.6); }
}

/* ---------- Progress bar at bottom ---------- */
.progress-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #85ff95, #3eff5f);
  width: 0%;
  transition: width 0.25s ease;
}

/* ---------- Mobile touch controls ---------- */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.touch-zone {
  position: absolute;
  top: 0;
  bottom: 80px;
  width: 50%;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.touch-left {
  left: 0;
}

.touch-right {
  right: 0;
}

.touch-zone:active {
  background: rgba(255, 255, 255, 0.04);
}

.touch-power {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  border: 3px solid var(--mint);
  border-radius: 16px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: rgba(42, 180, 90, 0.55);
  backdrop-filter: blur(4px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.15s;
}

.touch-power:active {
  transform: translateX(-50%) scale(0.94);
  background: rgba(42, 180, 90, 0.8);
}

.touch-power.cooldown {
  opacity: 0.35;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ---------- Overlay panels ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 19, 0.5);
  z-index: 15;
  overflow-y: auto;
  padding: 20px;
}

.panel {
  width: min(680px, 100%);
  padding: 24px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: var(--panel-bg);
  text-align: center;
  backdrop-filter: blur(8px);
}

.panel-title {
  margin: 0 0 4px;
  font-size: clamp(28px, 5vw, 44px);
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: clamp(20px, 4vw, 30px);
}

.panel p {
  margin: 8px 0;
}

.controls-hint {
  font-size: 13px;
  color: #b8f9d0;
  line-height: 1.6;
}

.big-score {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.cheer-text {
  font-size: 16px;
  color: #dde8ff;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.choice {
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: linear-gradient(180deg, #253d98, #1a2d74);
  color: white;
  padding: 12px 8px;
  font-size: 14px;
  transition: transform 0.1s, border-color 0.1s;
}

.choice:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
}

.choice.selected {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(107, 255, 158, 0.25);
}

.choice.locked {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.1);
}

.action-btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 22px;
  font-weight: 900;
  color: #1d1f35;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe96d, #f3bf2a);
  box-shadow: 0 5px 0 #c99616;
  transition: transform 0.1s;
  margin-top: 8px;
}

.action-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c99616;
}

/* ---------- Celebration FX ---------- */
.celebration-fx {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 12;
}

.drop {
  position: absolute;
  top: -40px;
  font-size: 28px;
  animation: fall linear forwards;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.35);
}

@keyframes fall {
  from {
    transform: translateY(-10px) rotate(0deg);
  }
  to {
    transform: translateY(120vh) rotate(360deg);
  }
}

/* ---------- Freeze screen flash (Phase 1.3) ---------- */
.freeze-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(80, 255, 140, 0.35), rgba(30, 200, 80, 0.18));
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease;
}

.freeze-flash.active {
  opacity: 1;
  animation: freezeFlashFade 0.4s ease-out forwards;
}

@keyframes freezeFlashFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Garage (Phase 4.1) ---------- */
.garage-car {
  width: 200px;
  height: 120px;
  margin: 12px auto;
  background: linear-gradient(180deg, #253d98, #1a2d74);
  border-radius: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
}

.garage-stickers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.garage-stickers span {
  font-size: 28px;
  animation: stickerBob 1.5s ease-in-out infinite;
}

@keyframes stickerBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.small-hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.small-btn {
  font-size: 16px;
  padding: 10px 20px;
}

.end-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ---------- Trophy shelf (Phase 4.3) ---------- */
.trophy-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}

.trophy-item {
  background: rgba(255, 215, 75, 0.12);
  border: 2px solid rgba(255, 215, 75, 0.3);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
}

/* ---------- Milestone (Phase 4.4) ---------- */
.milestone-overlay {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 17;
  pointer-events: none;
}

.milestone-text {
  font-size: clamp(36px, 7vw, 60px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 215, 75, 0.8), 0 4px 0 rgba(0, 0, 0, 0.3);
  animation: milestoneAnim 2s ease-out forwards;
}

@keyframes milestoneAnim {
  0%   { transform: scale(0.5); opacity: 0; }
  15%  { transform: scale(1.2); opacity: 1; }
  30%  { transform: scale(1); opacity: 1; }
  80%  { transform: scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(0.8); opacity: 0; }
}

/* ---------- Countdown overlay (Phase 2.5) ---------- */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 16;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.25);
}

.countdown-text {
  font-size: clamp(80px, 18vw, 180px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(255, 215, 75, 0.7), 0 6px 0 rgba(0, 0, 0, 0.3);
  animation: countdownPop 0.7s ease-out forwards;
}

@keyframes countdownPop {
  0%   { transform: scale(2.5); opacity: 0; }
  30%  { transform: scale(1); opacity: 1; }
  80%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.7); opacity: 0; }
}

/* ---------- Combo display (Phase 2.3) ---------- */
.combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  pointer-events: none;
}

.combo-text {
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 75, 0.6), 0 4px 0 rgba(0, 0, 0, 0.3);
  animation: comboFloat 0.8s ease-out forwards;
}

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

.hidden {
  display: none !important;
}

/* ---------- Landscape rotation prompt (Phase 6.3) ---------- */
.rotate-prompt {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 8, 19, 0.92);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}

.rotate-inner {
  text-align: center;
  padding: 24px;
}

.rotate-icon {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
  animation: rotateWiggle 2s ease-in-out infinite;
}

@keyframes rotateWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  75% { transform: rotate(90deg); }
}

.rotate-inner p {
  font-size: 18px;
  color: #fff;
  line-height: 1.5;
}

/* ---------- Mobile adjustments ---------- */
@media (max-width: 640px) {
  .hud {
    padding: 6px 8px;
  }

  .hud-block {
    padding: 4px 8px;
    border-radius: 8px;
    min-width: 48px;
  }

  .hud-value {
    font-size: 16px;
  }

  .hud-label {
    font-size: 9px;
  }

  .stars-block .hud-value {
    font-size: 18px;
  }

  .panel {
    padding: 16px;
  }

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

  .touch-power {
    bottom: 12px;
    padding: 10px 18px;
    font-size: 14px;
  }
}
