/* ==============================
   RELIC RUN - Premium CSS
   ============================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Oswald:wght@300;400;700&display=swap');

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

:root {
  --gold: #f5c842;
  --gold-dark: #c9972a;
  --gold-glow: rgba(245, 200, 66, 0.6);
  --stone: #8b7355;
  --stone-dark: #3d2b1f;
  --jungle: #1a3a1a;
  --fire: #ff6b1a;
  --bg-dark: #0a0806;
  --text-light: #e8d5b0;
  --accent-green: #4CAF50;
  --accent-blue: #2196F3;
  --panel-bg: rgba(10, 8, 6, 0.85);
  --panel-border: rgba(245, 200, 66, 0.4);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Oswald', sans-serif;
  color: var(--text-light);
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#gameCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.screen.active { display: flex; }
.screen.hidden { display: none; }

/* ===== START SCREEN ===== */
#start-screen {
  background: transparent;
  overflow: hidden;
}

.start-bg-canvas-wrapper {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

#startCanvas {
  width: 100%;
  height: 100%;
}

.start-content {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px 20px;
  text-align: center;
}

.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.logo-subtitle {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(10px, 2vw, 14px);
  letter-spacing: 6px;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.8;
}

.logo-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(48px, 10vw, 96px);
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 20px var(--gold-glow),
    0 0 60px rgba(245, 200, 66, 0.3),
    4px 4px 0 var(--stone-dark),
    8px 8px 0 rgba(0,0,0,0.5);
  letter-spacing: 8px;
  line-height: 1;
  animation: logoGlow 3s ease-in-out infinite;
}

.logo-tagline {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(11px, 2vw, 15px);
  letter-spacing: 4px;
  color: var(--fire);
  opacity: 0.9;
}

@keyframes logoGlow {
  0%, 100% { text-shadow: 0 0 20px var(--gold-glow), 0 0 60px rgba(245,200,66,0.3), 4px 4px 0 var(--stone-dark), 8px 8px 0 rgba(0,0,0,0.5); }
  50% { text-shadow: 0 0 40px var(--gold-glow), 0 0 100px rgba(245,200,66,0.5), 4px 4px 0 var(--stone-dark), 8px 8px 0 rgba(0,0,0,0.5); }
}

.stats-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px 32px;
  backdrop-filter: blur(10px);
}

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

.stat-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold);
  opacity: 0.7;
}

.stat-value {
  font-family: 'Cinzel', serif;
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 700;
  color: #fff;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--panel-border);
}

/* ===== BUTTONS ===== */
.btn-primary {
  font-family: 'Cinzel', serif;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--stone-dark);
  background: linear-gradient(135deg, var(--gold) 0%, #e8a800 50%, var(--gold) 100%);
  border: none;
  border-radius: 6px;
  padding: 16px 48px;
  cursor: pointer;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px var(--gold-glow), 0 2px 0 #a07000, inset 0 1px 0 rgba(255,255,255,0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: btnShine 3s ease-in-out infinite;
}

@keyframes btnShine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--gold-glow), 0 2px 0 #a07000, inset 0 1px 0 rgba(255,255,255,0.3);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px var(--gold-glow), 0 1px 0 #a07000;
}

.btn-icon {
  margin-right: 8px;
}

.btn-secondary {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 400;
  letter-spacing: 2px;
  color: var(--text-light);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 12px 32px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.15);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-sound {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 20;
}

.btn-sound:hover { background: rgba(245,200,66,0.2); border-color: var(--gold); }
.btn-sound.muted { opacity: 0.5; }

.controls-hint {
  display: flex;
  gap: 20px;
  font-size: clamp(9px, 1.5vw, 12px);
  letter-spacing: 2px;
  color: rgba(232, 213, 176, 0.5);
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== GAME HUD ===== */
#game-hud {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
}

#game-hud.hidden { display: none; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: none;
}

.hud-distance {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  opacity: 0.7;
}

.hud-value {
  font-family: 'Cinzel', serif;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hud-coins {
  font-family: 'Cinzel', serif;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 700;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 0 10px var(--gold-glow);
}

.coin-icon {
  font-size: 1.2em;
  animation: coinSpin 1s linear infinite;
}

@keyframes coinSpin {
  0% { transform: scaleX(1); }
  25% { transform: scaleX(0.3); }
  50% { transform: scaleX(1); }
  75% { transform: scaleX(0.3); }
}

.speed-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.speed-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--fire);
  opacity: 0.8;
}

.speed-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255,107,26,0.3);
}

.speed-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b1a, #ff3300);
  border-radius: 3px;
  transition: width 0.3s;
  box-shadow: 0 0 6px rgba(255,107,26,0.8);
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: all;
}

.btn-pause {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  width: 44px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-pause:hover { background: rgba(245,200,66,0.2); border-color: var(--gold); }

.hud-sound {
  position: relative;
  top: auto;
  right: auto;
  width: 36px;
  height: 36px;
  font-size: 16px;
}

.hud-powerups {
  position: absolute;
  bottom: 80px;
  left: 16px;
  pointer-events: none;
}

.powerup-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.powerup-slot.active { opacity: 1; }

.powerup-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 0 15px var(--gold-glow);
  animation: powerupPulse 1s ease-in-out infinite;
}

@keyframes powerupPulse {
  0%, 100% { box-shadow: 0 0 15px var(--gold-glow); }
  50% { box-shadow: 0 0 30px var(--gold-glow); }
}

.powerup-timer-bar {
  width: 48px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.powerup-timer-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ===== MOBILE CONTROLS ===== */
.mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 16px;
  pointer-events: all;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.mobile-left, .mobile-right {
  display: flex;
  align-items: center;
}

.mobile-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mobile-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(245, 200, 66, 0.15);
  border: 2px solid rgba(245, 200, 66, 0.4);
  color: var(--gold);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-btn:active {
  background: rgba(245, 200, 66, 0.35);
  transform: scale(0.9);
}

.mobile-jump {
  width: 72px;
  height: 72px;
  font-size: 28px;
  background: rgba(245, 200, 66, 0.2);
  border-color: var(--gold);
}

.mobile-slide {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

/* Show mobile controls only on touch devices */
@media (hover: hover) and (pointer: fine) {
  .mobile-controls { display: none; }
}

/* ===== PAUSE SCREEN ===== */
#pause-screen {
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
}

.pause-content, .death-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 48px 64px;
  backdrop-filter: blur(20px);
  max-width: 90vw;
}

.pause-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 8px;
  text-shadow: 0 0 20px var(--gold-glow);
}

/* ===== DEATH SCREEN ===== */
#death-screen {
  background: rgba(20,0,0,0.8);
  backdrop-filter: blur(8px);
}

.death-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 900;
  color: var(--fire);
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255,107,26,0.6);
}

.death-subtitle {
  font-size: clamp(12px, 2vw, 16px);
  color: rgba(232,213,176,0.6);
  letter-spacing: 2px;
}

.death-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.death-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 24px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.death-stat.highlight {
  border-color: var(--gold);
  background: rgba(245,200,66,0.1);
}

.death-stat-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold);
  opacity: 0.7;
}

.death-stat-value {
  font-family: 'Cinzel', serif;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 700;
  color: #fff;
}

.new-best-banner {
  font-family: 'Cinzel', serif;
  font-size: clamp(14px, 2.5vw, 20px);
  color: var(--gold);
  letter-spacing: 4px;
  text-shadow: 0 0 20px var(--gold-glow);
  animation: newBestPulse 0.5s ease-in-out infinite alternate;
}

.new-best-banner.hidden { display: none; }

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

/* ===== SCROLL ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.start-content > * {
  animation: fadeInUp 0.6s ease-out both;
}

.start-content > *:nth-child(1) { animation-delay: 0.1s; }
.start-content > *:nth-child(2) { animation-delay: 0.3s; }
.start-content > *:nth-child(3) { animation-delay: 0.5s; }
.start-content > *:nth-child(4) { animation-delay: 0.7s; }
.start-content > *:nth-child(5) { animation-delay: 0.8s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .stats-panel { flex-direction: column; gap: 12px; }
  .stat-divider { width: 80px; height: 1px; }
  .pause-content, .death-content { padding: 32px 24px; }
  .death-stats { gap: 16px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .start-content { gap: 12px; padding: 20px; }
  .logo-title { font-size: 40px; }
  .btn-primary { padding: 10px 32px; }
}
