/* =============================================
   TEMPLE ESCAPE RUN — Stylesheet
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:root {
  --gold: #f5c842;
  --amber: #e07b00;
  --red: #c0392b;
  --purple: #8e44ad;
  --blue: #2980b9;
  --stone: #a08060;
  --dark: #1a1008;
  --text-light: #f0e6c8;
  --font-adventure: 'Georgia', serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-adventure);
  color: var(--text-light);
}

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

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* =============================================
   LOADING SCREEN
   ============================================= */
#loading-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: #0a0605;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-corridor {
  position: relative;
  width: min(480px, 90vw);
  padding: 40px 20px;
  text-align: center;
  background: radial-gradient(ellipse at center bottom, #3d1f00 0%, #0a0605 70%);
  border: 2px solid #5a3a18;
  border-radius: 8px;
  box-shadow: 0 0 60px #8b450030, inset 0 0 40px #00000080;
}

.torch {
  position: absolute;
  top: 20px;
  width: 18px;
}
.torch-left { left: 18px; }
.torch-right { right: 18px; }
.torch::before {
  content: '';
  display: block;
  width: 18px;
  height: 40px;
  background: linear-gradient(#6b4020, #3a1a08);
  border-radius: 3px 3px 0 0;
  margin: 0 auto;
}

.flame {
  width: 18px;
  height: 30px;
  background: radial-gradient(ellipse at 50% 80%, #fff 0%, #ffdd00 20%, #ff6600 55%, transparent 100%);
  border-radius: 50% 50% 20% 20%;
  margin: 0 auto -8px;
  animation: flicker 0.15s infinite alternate;
  filter: blur(1px);
}

@keyframes flicker {
  from { transform: scaleX(1) scaleY(1) translateX(0); opacity: 1; }
  to   { transform: scaleX(0.85) scaleY(1.1) translateX(2px); opacity: 0.88; }
}

.loading-title {
  margin-bottom: 24px;
}
.loading-title span {
  display: block;
  letter-spacing: 0.15em;
  text-shadow: 0 0 12px #ff8c00;
}
.title-temple  { font-size: clamp(24px, 6vw, 40px); color: #c8a050; }
.title-escape  { font-size: clamp(18px, 4vw, 28px); color: #d4aa60; }
.title-run     { font-size: clamp(14px, 3vw, 20px); color: #a08040; letter-spacing: 0.4em; }

.loading-bar-wrap {
  width: 80%;
  height: 8px;
  background: #2a1608;
  border-radius: 4px;
  margin: 0 auto 12px;
  border: 1px solid #5a3a18;
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c87820, #f5c842, #c87820);
  border-radius: 4px;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px #f5c842;
}
.loading-text {
  font-size: 13px;
  color: #a08040;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* =============================================
   START SCREEN
   ============================================= */
#start-screen {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 70%, #8b3a0050 0%, transparent 60%),
    linear-gradient(180deg, #1a0a02 0%, #0d0703 50%, #050302 100%);
}

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

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.game-title .t1 {
  font-size: clamp(28px, 7vw, 52px);
  color: #c8a050;
  text-shadow: 0 0 20px #ff8c00, 0 2px 4px #000;
}
.game-title .t2 {
  font-size: clamp(20px, 5vw, 38px);
  color: #e0b870;
  text-shadow: 0 0 15px #ff7000, 0 2px 4px #000;
}
.game-title .t3 {
  font-size: clamp(13px, 3vw, 22px);
  color: #a08040;
  letter-spacing: 0.35em;
  text-shadow: 0 0 10px #aa6600;
}

.start-tagline {
  font-size: clamp(11px, 2.5vw, 15px);
  color: #a09070;
  letter-spacing: 0.08em;
  font-style: italic;
}

.start-silhouette {
  width: min(240px, 55vw);
  height: min(160px, 36vw);
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 160"><defs><radialGradient id="g" cx="50%25" cy="60%25" r="50%25"><stop offset="0%25" stop-color="%23ff8800" stop-opacity="0.3"/><stop offset="100%25" stop-color="%23ff8800" stop-opacity="0"/></radialGradient></defs><rect width="240" height="160" fill="url(%23g)"/><path d="M100 140 L105 100 L95 80 L108 60 L112 40 L120 35 L128 40 L132 60 L145 80 L135 100 L140 140Z" fill="%23000" opacity="0.85"/><ellipse cx="120" cy="30" rx="14" ry="12" fill="%23000" opacity="0.85"/><path d="M108 40 Q90 50 85 70 L95 80Z" fill="%23000" opacity="0.85"/><path d="M132 40 Q150 50 155 70 L145 80Z" fill="%23000" opacity="0.85"/><path d="M105 100 Q95 120 90 140" stroke="%23000" stroke-width="6" fill="none" opacity="0.85"/><path d="M135 100 Q145 120 150 140" stroke="%23000" stroke-width="6" fill="none" opacity="0.85"/></svg>') center/contain no-repeat;
  filter: drop-shadow(0 0 20px #ff880080);
}

.start-controls {
  font-size: clamp(10px, 2.2vw, 13px);
  color: #806040;
  line-height: 1.7;
  letter-spacing: 0.05em;
}

kbd {
  background: #2a1808;
  border: 1px solid #6a4820;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
  color: #c8a050;
  font-family: monospace;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  padding: 14px 36px;
  font-size: clamp(14px, 3.5vw, 18px);
  font-family: var(--font-adventure);
  font-weight: bold;
  letter-spacing: 0.15em;
  color: #1a0a00;
  background: linear-gradient(135deg, #f5c842 0%, #c87820 50%, #f5c842 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 16px #f5c84260, 0 2px 0 #8b4a00;
  text-transform: uppercase;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 8px #f5c84260; }

.btn-secondary {
  padding: 10px 24px;
  font-size: clamp(12px, 2.5vw, 15px);
  font-family: var(--font-adventure);
  letter-spacing: 0.1em;
  color: #c8a050;
  background: transparent;
  border: 1px solid #5a3a18;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover { background: #2a1808; border-color: #8a5a28; }

.btn-icon {
  background: none;
  border: 1px solid #4a2e10;
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 16px;
  cursor: pointer;
  color: #c8a050;
  line-height: 1;
  transition: background 0.2s;
  position: absolute;
  top: 16px; right: 16px;
}
.btn-icon:hover { background: #2a1808; }

.btn-icon-hud {
  background: rgba(0,0,0,0.45);
  border: 1px solid #5a3a1880;
  border-radius: 6px;
  width: 36px; height: 36px;
  font-size: 15px;
  cursor: pointer;
  color: #c8a050;
  line-height: 1;
  transition: background 0.15s;
}
.btn-icon-hud:hover { background: rgba(0,0,0,0.7); }

.pulse-btn {
  animation: pulse-glow 1.6s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 16px #f5c84260, 0 2px 0 #8b4a00; }
  50%       { box-shadow: 0 6px 28px #f5c842aa, 0 2px 0 #8b4a00, 0 0 40px #f5c84250; }
}

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

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.65) 0%, transparent 100%);
  pointer-events: none;
}

.hud-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 8px #f5c84280;
  min-width: 80px;
}
.coin-icon { font-size: 0.9em; }

.hud-distance {
  font-size: clamp(18px, 4.5vw, 26px);
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px #ff8c0080, 0 1px 3px #000;
  letter-spacing: 0.05em;
}
.hud-dist-unit { font-size: 0.65em; color: #c8a050; margin-left: 2px; }

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

.hud-powerup {
  background: rgba(0,0,0,0.5);
  border: 1px solid #5a3a18;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #f5c842;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 90px;
}
.powerup-icon { font-size: 15px; }
.powerup-bar {
  flex: 1;
  height: 4px;
  background: #2a1808;
  border-radius: 2px;
  overflow: hidden;
}
.powerup-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Speed Lines */
.speed-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.sl {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent 0%, rgba(255,200,100,0.3) 50%, transparent 100%);
  animation: speed-slide 0.2s linear infinite;
}
.sl1 { left: 5%; animation-delay: 0s; }
.sl2 { left: 12%; animation-delay: 0.04s; }
.sl3 { left: 88%; animation-delay: 0.02s; }
.sl4 { right: 12%; animation-delay: 0.06s; }
.sl5 { left: 3%;  animation-delay: 0.08s; opacity: 0.5; }
.sl6 { right: 3%; animation-delay: 0.01s; opacity: 0.5; }
@keyframes speed-slide {
  from { opacity: 0.5; }
  to   { opacity: 0.1; }
}

/* Turn Prompt */
.turn-prompt {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.turn-arrow {
  font-size: clamp(48px, 14vw, 90px);
  color: #ff3300;
  text-shadow: 0 0 20px #ff3300, 0 0 40px #ff330080;
  line-height: 1;
  animation: turn-pulse 0.3s ease-in-out infinite alternate;
}
.turn-label {
  font-size: clamp(16px, 4vw, 24px);
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px #ff3300, 0 2px 4px #000;
  letter-spacing: 0.15em;
}
.turn-countdown {
  font-size: clamp(22px, 5vw, 32px);
  color: #ff6600;
  font-weight: bold;
}
@keyframes turn-pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}

.mult-badge {
  position: absolute;
  top: 60px;
  right: 14px;
  background: linear-gradient(135deg, #8e44ad, #c0392b);
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 6px;
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 0 12px #8e44ad80;
  animation: badge-glow 1s ease-in-out infinite alternate;
}
@keyframes badge-glow {
  from { box-shadow: 0 0 12px #8e44ad80; }
  to   { box-shadow: 0 0 24px #8e44adcc, 0 0 40px #c0392b60; }
}

/* =============================================
   OVERLAYS
   ============================================= */
.overlay-blur {
  position: absolute;
  inset: 0;
  background: rgba(5,2,0,0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pause-panel, .gameover-panel, .shop-panel {
  position: relative;
  z-index: 1;
  text-align: center;
  background: linear-gradient(160deg, #1e0e04 0%, #140a02 100%);
  border: 2px solid #5a3a18;
  border-radius: 12px;
  padding: 32px 40px;
  box-shadow: 0 8px 40px #00000080, inset 0 1px 0 #8a5a2840;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: min(320px, 85vw);
}

#pause-screen, #gameover-screen, #shop-screen {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-panel h2, .gameover-panel h2, .shop-panel h2 {
  font-size: clamp(20px, 5vw, 28px);
  color: #c8a050;
  letter-spacing: 0.15em;
  text-shadow: 0 0 12px #ff8c0060;
}

.go-title {
  font-size: clamp(26px, 7vw, 38px) !important;
  color: #c0392b !important;
  text-shadow: 0 0 20px #c0392b80 !important;
}

.go-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.go-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: #0a0602;
  border: 1px solid #3a2010;
  border-radius: 8px;
  min-width: 90px;
}
.go-stat.highlight { border-color: #f5c842; }
.go-stat-label { font-size: 11px; color: #806040; letter-spacing: 0.1em; text-transform: uppercase; }
.go-stat-value { font-size: 22px; color: #f5c842; font-weight: bold; }

.go-new-best {
  font-size: 20px;
  color: #f5c842;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 0 0 12px #f5c84280;
  animation: pulse-glow 0.8s ease-in-out infinite;
}

/* =============================================
   SHOP
   ============================================= */
.shop-balance {
  font-size: 18px;
  color: var(--gold);
  font-weight: bold;
}

.shop-skins {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.skin-card {
  width: 100px;
  border: 2px solid #3a2010;
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #0a0602;
}
.skin-card:hover { border-color: #8a5a28; background: #140a02; }
.skin-card.active-skin { border-color: #f5c842; }
.skin-card.locked { opacity: 0.6; }

.skin-preview {
  width: 60px;
  height: 70px;
  margin: 0 auto 8px;
  border-radius: 4px;
  background: #1a0a02;
}
.sk-default  { background: linear-gradient(160deg, #c87820 0%, #6a3a00 100%); }
.sk-ninja    { background: linear-gradient(160deg, #1a1a2e 0%, #16213e 100%); }
.sk-archaeo  { background: linear-gradient(160deg, #6b8f71 0%, #4a6741 100%); }
.sk-phantom  { background: linear-gradient(160deg, #4a0a6b 0%, #200030 100%); }

.skin-name  { font-size: 11px; color: #c8a050; margin-bottom: 4px; }
.skin-cost  { font-size: 10px; color: #806040; }

/* =============================================
   UTILITIES
   ============================================= */
.hidden { display: none !important; }

@media (max-width: 480px) {
  .pause-panel, .gameover-panel {
    padding: 24px 20px;
    gap: 12px;
  }
  .go-stats { gap: 10px; }
}
