/* ============================================
   CodeClubs Perfect Run — Global Styles
   ============================================ */

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

:root {
  --green:  #00df82;
  --red:    #f93a5a;
  --yellow: #f2c94c;
  --blue:   #2d9cdb;
  --purple: #bb6bd9;
  --dark:   #0a0a0e;
  --card:   rgba(15, 18, 22, 0.65);
  --border: rgba(255, 255, 255, 0.06);
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--dark);
  color: #fff;
  font-family: var(--font-main);
  touch-action: none;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ============================================
   CANVAS
   ============================================ */
#game-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  display: block;
  z-index: 1;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */
#splash-screen {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(0,255,136,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(170,68,255,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(0,170,255,0.08) 0%, transparent 70%),
    #050510;
  animation: bgPulse 6s ease-in-out infinite;
}

@keyframes bgPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 600px;
  padding: 2rem;
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.logo-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 20px var(--green));
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { filter: drop-shadow(0 0 20px var(--green)); }
  50% { filter: drop-shadow(0 0 40px var(--green)) drop-shadow(0 0 80px rgba(0,255,136,0.4)); }
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.tagline {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 6px;
  text-shadow: 0 0 10px rgba(255,204,0,0.6);
}

.splash-desc {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.splash-desc strong { color: var(--green); }

.hud-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.hud-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.hud-item .icon { font-size: 1.1rem; }
.hud-item .icon.green { filter: drop-shadow(0 0 6px var(--green)); }
.hud-item .icon.red   { filter: drop-shadow(0 0 6px var(--red)); }
.hud-item .icon.yellow{ filter: drop-shadow(0 0 6px var(--yellow)); }
.hud-item .icon.blue  { filter: drop-shadow(0 0 6px var(--blue)); }

.controls-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-display);
  letter-spacing: 1px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2.5rem;
  border: 1px solid rgba(0, 223, 130, 0.4);
  border-radius: 8px;
  background: rgba(0, 223, 130, 0.1);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 223, 130, 0.15);
}

.btn-primary:hover {
  background: rgba(0, 223, 130, 0.2);
  border-color: rgba(0, 223, 130, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 223, 130, 0.25);
}

.btn-primary:active { transform: translateY(0); }

.btn-text {
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #fff;
  position: relative;
  z-index: 1;
}

.btn-glow {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(0,255,136,0.15), transparent);
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================
   FLOATING PARTICLES
   ============================================ */
.floating-particles {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  animation: floatUp linear infinite;
  opacity: 0.6;
}

@keyframes floatUp {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ============================================
   HUD
   ============================================ */
#hud {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

#hud-hearts {
  position: absolute;
  top: 20px; left: 20px;
  display: flex;
  gap: 8px;
}

.heart {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px var(--red));
  transition: all 0.3s ease;
}

.heart.lost {
  opacity: 0.2;
  filter: none;
  transform: scale(0.8);
}

#hud-score {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.score-val {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.score-val .lbl {
  font-size: 0.65rem;
  font-family: var(--font-display);
  letter-spacing: 1px;
  color: rgba(255,255,255,0.5);
}

.score-val span:last-child {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

#hud-solutions {
  position: absolute;
  top: 80px; left: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  min-width: 220px;
}

.sol-header {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--green);
  margin-bottom: 8px;
  font-weight: 700;
}

#sol-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sol-item {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: rgba(255,255,255,0.5);
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sol-item::before { content: '○'; font-size: 0.6rem; }

.sol-item.collected {
  color: var(--green);
  background: rgba(0,255,136,0.1);
  text-decoration: line-through;
}

.sol-item.collected::before { content: '✓'; }

.sol-item.active {
  color: var(--yellow);
  animation: pulse 1s ease-in-out infinite;
}

.sol-item.active::before { content: '▶'; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#next-perk-label {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 18, 22, 0.8);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 20px;
  font-family: var(--font-main);
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.8);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.nlbl { margin-right: 6px; }

#perk-timer {
  color: var(--green);
  font-weight: 700;
  font-size: 0.9rem;
}

/* ============================================
   FLOATING MESSAGE
   ============================================ */
#float-msg {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 3px;
  text-align: center;
  pointer-events: none;
  animation: floatMsg 2.5s ease-out forwards;
  white-space: nowrap;
}

#float-msg.perk { color: var(--green); text-shadow: 0 0 20px var(--green), 0 0 40px rgba(0,255,136,0.5); }
#float-msg.obstacle { color: var(--red); text-shadow: 0 0 20px var(--red), 0 0 40px rgba(255,51,102,0.5); }
#float-msg.missed { color: var(--yellow); text-shadow: 0 0 20px var(--yellow); }
#float-msg.coin { color: var(--yellow); font-size: 1rem; }

@keyframes floatMsg {
  0%   { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.8); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-10px) scale(1.1); }
  30%  { transform: translateX(-50%) translateY(-20px) scale(1); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(-60px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-100px) scale(0.9); }
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */
#gameover-screen {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
}

#gameover-screen.hidden { display: none !important; }

.go-content {
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.go-icon { font-size: 5rem; margin-bottom: 1rem; animation: shake 0.5s ease-out; }

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

.go-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--red);
  text-shadow: 0 0 30px rgba(255,51,102,0.8);
  letter-spacing: 4px;
  margin-bottom: 0.5rem;
}

.go-sub {
  color: rgba(255,255,255,0.5);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.go-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.slbl {
  font-size: 0.65rem;
  font-family: var(--font-display);
  letter-spacing: 2px;
  color: rgba(255,255,255,0.4);
}

.stat span:last-child {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* ============================================
   WIN SCREEN
   ============================================ */
#win-screen {
  position: fixed; inset: 0;
  z-index: 150;
  display: flex !important;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#win-screen.hidden { display: none !important; }

.win-content {
  text-align: center;
  animation: fadeInUp 0.8s ease-out;
  position: relative;
  z-index: 2;
}

.win-icon {
  font-size: 6rem;
  animation: spin 3s linear infinite;
  filter: drop-shadow(0 0 30px var(--purple));
  margin-bottom: 1rem;
}

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

.win-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  margin-bottom: 1rem;
}

.win-sub {
  color: rgba(255,255,255,0.8);
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.win-portal-hint {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 3px;
  color: var(--purple);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   WARP OVERLAY
   ============================================ */
#warp-overlay {
  position: fixed; inset: 0;
  z-index: 500;
  background: #000;
  display: flex !important;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#warp-overlay.hidden { display: none !important; }

.warp-ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid;
  animation: warpExpand 1.5s ease-out infinite;
}

.warp-ring.r1 { width: 50px; height: 50px; border-color: var(--purple); animation-delay: 0s; }
.warp-ring.r2 { width: 150px; height: 150px; border-color: var(--blue); animation-delay: 0.2s; }
.warp-ring.r3 { width: 300px; height: 300px; border-color: var(--green); animation-delay: 0.4s; }
.warp-ring.r4 { width: 500px; height: 500px; border-color: var(--yellow); animation-delay: 0.6s; }
.warp-ring.r5 { width: 800px; height: 800px; border-color: var(--red); animation-delay: 0.8s; }

@keyframes warpExpand {
  0% { transform: scale(0.1); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}

.warp-text {
  position: relative;
  z-index: 10;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 20px var(--purple), 0 0 40px var(--blue);
  animation: warpText 0.5s ease-in-out infinite alternate;
}

@keyframes warpText {
  from { transform: scale(1); }
  to   { transform: scale(1.05); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  .brand { font-size: 2rem; }
  .hud-preview { grid-template-columns: 1fr; }
  .controls-info { flex-direction: column; gap: 0.3rem; font-size: 0.7rem; }
  #hud-solutions { display: none; }
  .go-title, .win-title { font-size: 2rem; }
}

/* ============================================
   HUD PAUSE BUTTON
   ============================================ */
.hud-pause-btn {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 1.2rem;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.hud-pause-btn:hover {
  background: rgba(0,170,255,0.2);
  border-color: var(--blue);
  color: var(--blue);
  transform: translateX(-50%) scale(1.1);
}

/* ============================================
   PAUSE SCREEN
   ============================================ */
#pause-screen {
  position: fixed; inset: 0;
  z-index: 400;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(24px);
}
#pause-screen.hidden { display: none !important; }

.pause-content {
  text-align: center;
  animation: fadeInUp 0.3s ease-out;
  max-width: 480px;
  padding: 2rem;
}

.pause-icon {
  font-size: 4rem;
  margin-bottom: 0.8rem;
  filter: drop-shadow(0 0 20px var(--blue));
}

.pause-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--blue);
  text-shadow: 0 0 30px rgba(0,170,255,0.6);
  margin-bottom: 0.4rem;
}

.pause-sub {
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.pause-controls {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 1rem 1.4rem;
  margin-bottom: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ctrl-row {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

kbd {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: var(--font-main);
  color: #fff;
  line-height: 1.6;
}

.c-red    { color: var(--red); font-weight: 700; }
.c-orange { color: #ff8800;    font-weight: 700; }

.pause-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-secondary {
  padding: 0.75rem 1.8rem;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-secondary:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(255,51,102,0.08);
}

/* ============================================
   OBSTACLE HINT TAGS  (jump / duck)
   ============================================ */
/* These are CSS classes for 3D overlay indicators
   rendered as DOM elements above the canvas */
.obs-hint {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 20px;
  z-index: 45;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s;
  white-space: nowrap;
}
.obs-hint.jump { color: var(--red);    background: rgba(255,30,60,0.18); border: 1px solid var(--red);  }
.obs-hint.duck { color: #ff8800; background: rgba(255,130,0,0.18);  border: 1px solid #ff8800; }
