:root {
  --primary: #ff0055;
  --primary-glow: #ff0055;
  --secondary: #00f0ff;
  --secondary-glow: #00f0ff;
  --accent-yellow: #ffe600;
  --accent-purple: #9d00ff;
  --dark-bg: #0b0c16;
  --card-bg: rgba(16, 18, 32, 0.96);
  --text-light: #ffffff;
  --text-dim: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  image-rendering: pixelated;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--dark-bg);
  font-family: 'Press Start 2P', 'Silkscreen', monospace;
  color: var(--text-light);
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 50vw; /* 2:1 aspect ratio */
  max-width: 1200px;
  max-height: 600px;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  box-shadow: 0 0 0 6px #000, 0 0 0 10px var(--secondary), 0 0 35px rgba(0, 240, 255, 0.5);
  background: #000;
}

/* Si la pantalla es más alta que ancha respecto a 2:1, limitar por el alto disponible */
@media (max-aspect-ratio: 2/1) {
  #game-container {
    width: 100vw;
    height: 50vw;
  }
}

@media (min-aspect-ratio: 2/1) {
  #game-container {
    height: 100vh;
    width: 200vh;
    max-width: 1200px;
    max-height: 600px;
  }
}

/* Efecto opcional de líneas CRT arcade sutiles */
#game-container::after {
  content: " ";
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 40;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ==================== HUD PIXEL ART ==================== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.hud-stat {
  display: flex;
  align-items: center;
  background: #0d1117;
  padding: 6px 14px;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 #000;
}

.score-box {
  border-color: var(--secondary);
  box-shadow: 4px 4px 0 #000, 0 0 10px var(--secondary-glow);
}

.dist-box {
  border-color: #39ff14;
  box-shadow: 4px 4px 0 #000, 0 0 10px rgba(57, 255, 20, 0.4);
}

.dist-box .hud-label {
  color: #39ff14;
}

.coins-box {
  border-color: var(--accent-yellow);
  box-shadow: 4px 4px 0 #000, 0 0 10px rgba(255, 230, 0, 0.4);
  gap: 8px;
}

.hud-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: var(--secondary);
  margin-right: 8px;
}

.hud-icon {
  font-size: 1rem;
}

.hud-number {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.95rem;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.multiplier-box {
  background: var(--primary);
  padding: 6px 12px;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 #000;
  animation: pixelPulse 0.8s steps(2) infinite alternate;
}

@keyframes pixelPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.hud-multiplier {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  color: #fff;
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: #161b22;
  border: 3px solid #fff;
  color: #fff;
  font-size: 1rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.1s;
}

.icon-btn:hover {
  background: var(--secondary);
  color: #000;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}

.icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

/* Power-up Meter */
.powerup-bar {
  position: absolute;
  top: 70px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0d1117;
  padding: 6px 12px;
  border: 3px solid var(--secondary);
  box-shadow: 4px 4px 0 #000;
}

.powerup-icon {
  font-size: 1.1rem;
}

.powerup-meter {
  width: 120px;
  height: 12px;
  background: #222;
  border: 2px solid #fff;
  overflow: hidden;
}

.powerup-fill {
  width: 100%;
  height: 100%;
  background: var(--accent-yellow);
  transition: width 0.1s linear;
}

.powerup-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  color: var(--secondary);
}

/* Trick Popup Notifications */
.trick-popup {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1rem;
  color: var(--accent-yellow);
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #ff0055;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s steps(4);
}

.trick-popup.show {
  opacity: 1;
  transform: translate(-50%, -60%) scale(1.1);
}

/* Zone Indicator & Banner */
.zone-box {
  border-color: #ff00ff;
  box-shadow: 4px 4px 0 #000, 0 0 12px rgba(255, 0, 255, 0.5);
}

.zone-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 12, 20, 0.95);
  border: 4px solid var(--accent-yellow);
  box-shadow: 6px 6px 0 #000, 0 0 30px rgba(255, 230, 0, 0.7);
  padding: 16px 28px;
  text-align: center;
  pointer-events: none;
  z-index: 35;
  animation: bannerPop 0.3s steps(3) forwards;
}

@keyframes bannerPop {
  0% { transform: translate(-50%, -70%) scale(0.85); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.zone-banner-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1rem;
  color: var(--accent-yellow);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.zone-banner-subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  color: var(--secondary);
  letter-spacing: 2px;
}

/* ==================== OVERLAYS & MODALS ==================== */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 18, 0.92);
  z-index: 50;
  padding: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.overlay-screen.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.overlay-screen.active {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.hidden {
  display: none !important;
}

.menu-card {
  background: var(--card-bg);
  border: 4px solid #fff;
  padding: 20px 28px;
  text-align: center;
  max-width: 540px;
  width: 92%;
  max-height: 94%;
  overflow-y: auto;
  box-shadow: 6px 6px 0 #000, 0 0 25px var(--primary-glow);
  position: relative;
  margin: auto;
}

.menu-card::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  height: 6px;
  background: var(--secondary);
}

.subtitle-tag {
  display: inline-block;
  background: var(--secondary);
  color: #000;
  font-size: 0.65rem;
  letter-spacing: 2px;
  padding: 4px 10px;
  margin-bottom: 12px;
  box-shadow: 3px 3px 0 #000;
}

.game-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 2.1rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 4px 4px 0px var(--primary), 8px 8px 0px #000;
  margin-bottom: 12px;
  line-height: 1.3;
}

.game-title .highlight {
  color: var(--secondary);
  text-shadow: 4px 4px 0px var(--primary), 8px 8px 0px #000;
}

.tagline {
  color: var(--text-dim);
  font-size: 0.6rem;
  margin-bottom: 14px;
  line-height: 1.4;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  padding: 10px 16px;
  border: 3px solid #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 4px 4px 0 #000;
  transition: transform 0.08s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
  background: #ff1a6b;
}

.btn-primary:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #000;
}

.pulse {
  animation: retroBlink 1.2s steps(2) infinite;
}

@keyframes retroBlink {
  0% { border-color: #fff; }
  50% { border-color: var(--accent-yellow); }
}

.btn-secondary {
  background: #1e2433;
  color: #fff;
  border-color: #718096;
}

.btn-secondary:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
}

.btn-secondary:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #000;
}

.high-score-tag {
  background: #000;
  border: 2px solid #333;
  padding: 8px 14px;
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-bottom: 15px;
}

.high-score-tag strong {
  color: var(--accent-yellow);
}

.quick-controls-hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.55rem;
  color: var(--text-dim);
  border-top: 2px dashed #333;
  padding-top: 12px;
  line-height: 1.4;
}

.quick-controls-hint b {
  color: var(--secondary);
}

/* ==================== GAME OVER ==================== */
.game-over-card {
  box-shadow: 8px 8px 0 #000, 0 0 35px rgba(255, 0, 85, 0.6);
  border-color: var(--primary);
  padding: 18px 24px;
}

.game-over-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.25rem;
  color: var(--primary);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 8px;
  line-height: 1.3;
}

.crash-avatar {
  font-size: 1.6rem;
  margin-bottom: 10px;
  animation: retroShake 0.4s steps(2) infinite;
}

@keyframes retroShake {
  0% { transform: translate(-3px, 0); }
  50% { transform: translate(3px, -2px); }
  100% { transform: translate(0, 2px); }
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  background: #0d1117;
  padding: 6px 8px;
  border: 2px solid #444;
  box-shadow: 2px 2px 0 #000;
}

.stat-card.full-span {
  grid-column: span 2;
  border-color: var(--accent-yellow);
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.95rem;
  color: #fff;
}

.stat-value.highlight-gold {
  color: var(--accent-yellow);
}

.stat-value.highlight-cyan {
  color: #00f0ff;
}

.new-record-badge {
  background: var(--accent-yellow);
  color: #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  padding: 6px 12px;
  margin-bottom: 18px;
  border: 2px solid #fff;
  box-shadow: 4px 4px 0 #000;
  animation: retroBlink 0.5s steps(2) infinite;
}

/* ==================== SKATE SHOP PIXEL ==================== */
.shop-card {
  max-width: 650px;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #333;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.shop-header h2 {
  font-size: 1.1rem;
  color: var(--secondary);
}

.shop-balance {
  font-size: 0.75rem;
  background: #000;
  border: 2px solid var(--accent-yellow);
  padding: 5px 10px;
}

.shop-balance strong {
  color: var(--accent-yellow);
}

.shop-subtitle {
  color: var(--text-dim);
  font-size: 0.6rem;
  margin-bottom: 16px;
}

.skins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.skin-item {
  background: #0d1117;
  border: 3px solid #444;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  transition: transform 0.1s;
}

.skin-item:hover {
  transform: translate(-2px, -2px);
  border-color: var(--secondary);
  box-shadow: 6px 6px 0 #000;
}

.skin-item.active {
  border-color: var(--accent-yellow);
  background: rgba(255, 230, 0, 0.08);
  box-shadow: 4px 4px 0 var(--accent-yellow);
}

.character-preview-box {
  width: 76px;
  height: 76px;
  background: #060913;
  border: 2px solid #384252;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 0 #000;
  margin: 4px 0;
}

.character-avatar-canvas {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

.character-tagline {
  font-size: 0.45rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
  min-height: 22px;
}

.skin-name {
  font-size: 0.65rem;
  line-height: 1.3;
  color: #fff;
  text-align: center;
}

.skin-price {
  font-size: 0.65rem;
  color: var(--accent-yellow);
  font-weight: bold;
}

.btn-shop-action {
  font-size: 0.55rem;
  padding: 8px 10px;
  width: 100%;
  margin-top: 4px;
}

.btn-shop-action.equipped {
  background: var(--secondary);
  color: #000;
  border-color: #fff;
  cursor: default;
}


/* ==================== HOW TO PLAY ==================== */
.instructions-card {
  max-width: 620px;
  text-align: left;
}

.instructions-card h2 {
  font-size: 1.2rem;
  color: var(--secondary);
  margin-bottom: 16px;
  text-align: center;
}

.instructions-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #0d1117;
  padding: 10px 12px;
  border: 2px solid #333;
  border-left: 5px solid var(--secondary);
  font-size: 0.6rem;
  line-height: 1.6;
}

.instr-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* ==================== CONTROLES MÓVILES ==================== */
.mobile-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
  z-index: 20;
}

.touch-btn {
  pointer-events: auto;
  width: 75px;
  height: 75px;
  border: 3px solid #fff;
  background: #0d1117;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
}

.touch-btn span {
  font-size: 1.4rem;
  line-height: 1;
}

.touch-btn small {
  font-size: 0.45rem;
  margin-top: 4px;
}

.touch-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #000;
  background: var(--primary);
}

.slide-btn {
  border-color: var(--secondary);
}

.jump-btn {
  border-color: var(--primary);
}

.mt-15 {
  margin-top: 15px;
}

/* ==================== PANTALLA GIRA TU DISPOSITIVO ==================== */
.orientation-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 12, 22, 0.98);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
}

.orientation-content {
  max-width: 420px;
  background: #101220;
  border: 4px solid var(--secondary);
  box-shadow: 6px 6px 0 #000, 0 0 25px rgba(0, 240, 255, 0.4);
  padding: 30px 20px;
}

.phone-rotate-icon {
  font-size: 3.5rem;
  display: inline-block;
  margin-bottom: 16px;
  animation: rotatePhone 2s infinite ease-in-out;
}

@keyframes rotatePhone {
  0%, 10% {
    transform: rotate(0deg);
  }
  50%, 70% {
    transform: rotate(90deg);
  }
  90%, 100% {
    transform: rotate(0deg);
  }
}

.orientation-content h2 {
  font-size: 1.1rem;
  color: var(--accent-yellow);
  margin-bottom: 14px;
  line-height: 1.5;
  text-shadow: 2px 2px 0 #000;
}

.orientation-content p {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.orientation-content strong {
  color: var(--secondary);
}

/* Mostrar overlay solo en pantallas móviles o tablets en orientación vertical */
@media screen and (orientation: portrait) and (max-width: 900px) {
  .orientation-overlay {
    display: flex;
  }
}

/* Ajustes compactos para móviles en horizontal */
@media screen and (max-height: 520px) {
  .menu-card {
    padding: 12px 18px;
    max-height: 96%;
  }
  .game-title {
    font-size: 1.4rem;
    margin-bottom: 6px;
  }
  .subtitle-tag {
    font-size: 0.5rem;
    padding: 2px 6px;
    margin-bottom: 6px;
  }
  .tagline {
    font-size: 0.5rem;
    margin-bottom: 8px;
  }
  .btn {
    font-size: 0.6rem;
    padding: 7px 12px;
  }
  .high-score-tag {
    padding: 4px 8px;
    font-size: 0.5rem;
    margin-bottom: 8px;
  }
  .quick-controls-hint {
    display: none; /* Ocultar tips extensos en pantallas bajas para dar espacio */
  }
  
  /* Game over card ultra compacta */
  .game-over-card {
    padding: 12px 16px;
  }
  .game-over-title {
    font-size: 1rem;
    margin-bottom: 4px;
  }
  .crash-avatar {
    font-size: 1.2rem;
    margin-bottom: 6px;
  }
  .stats-grid {
    gap: 6px;
    margin-bottom: 8px;
  }
  .stat-card {
    padding: 4px 6px;
  }
  .stat-label {
    font-size: 0.45rem;
    margin-bottom: 2px;
  }
  .stat-value {
    font-size: 0.75rem;
  }
  .new-record-badge {
    font-size: 0.5rem;
    padding: 4px 8px;
    margin-bottom: 8px;
  }

  /* HUD */
  .hud-top {
    top: 6px;
    left: 8px;
    right: 8px;
    gap: 4px;
  }
  .hud-stat {
    padding: 3px 8px;
    border-width: 2px;
  }
  .hud-label {
    font-size: 0.5rem;
    margin-right: 4px;
  }
  .hud-number {
    font-size: 0.75rem;
  }
  .hud-actions .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  .touch-btn {
    width: 60px;
    height: 60px;
    border-width: 2px;
  }
  .touch-btn span {
    font-size: 1.1rem;
  }
  .touch-btn small {
    font-size: 0.4rem;
  }
  .mobile-controls {
    bottom: 8px;
    padding: 0 12px;
  }
}
