/* ==========================================================================
   MINIJUGO CAFETERÍA CHARLS - STYLES & RESPONSIVE LAYOUT
   ========================================================================== */

:root {
  --primary-color: #BC8D4B;
  --primary-dark: #8c6328;
  --primary-light: #dfb271;
  --accent-gold: #f59e0b;
  --chocolate-dark: #2a1810;
  --chocolate-medium: #451a03;
  --bg-dark: #0f172a;
  --bg-overlay: rgba(15, 23, 42, 0.82);
  --glass-bg: rgba(30, 27, 75, 0.7);
  --glass-border: rgba(188, 141, 75, 0.3);
  --text-white: #ffffff;
  --text-gold: #fcd34d;
  --font-main: 'Poppins', sans-serif;
  --font-heading: 'Outfit', sans-serif;
}

/* RESET & NATIVE UI LOCK */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  background-color: var(--bg-dark);
  font-family: var(--font-main);
  color: var(--text-white);
  overscroll-behavior: none;
}

/* GAME CONTAINER (Vertical Mobile Phone Screen) */
#game-container {
  width: 100vw;
  height: 100vh;
  max-width: 540px; /* Standard vertical mobile screen width constraint on desktop */
  max-height: 100vh;
  margin: 0 auto;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1e1b4b 0%, #090d16 100%);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

/* CANVAS */
#game-canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
}

/* UI OVERLAY LAYER */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  padding: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* CARDS & CONTAINERS */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 20px 24px;
  text-align: center;
  max-width: 480px;
  width: 92%;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 12px auto;
  margin-top: calc(2vh + env(safe-area-inset-top, 0px));
  animation: cardFadeIn 0.4s ease-out;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* LOGO & HEADINGS */
.brand-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.brand-logo.pulse {
  animation: logoPulse 2s infinite ease-in-out;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 10px rgba(188, 141, 75, 0.3)); }
  50% { transform: scale(1.06); filter: drop-shadow(0 8px 20px rgba(245, 158, 11, 0.6)); }
}

.main-heading {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1.2;
}

.highlight {
  color: var(--text-gold);
  text-shadow: 0 0 15px rgba(252, 211, 77, 0.5);
}

.tagline {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
}

/* BUTTONS */
.btn {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
  color: #ffffff;
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.22);
}

.btn-share {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
}

.pulse-btn {
  animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 12px 35px rgba(245, 158, 11, 0.7); }
}

.btn-group {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.btn-group.vertical {
  flex-direction: column;
}

/* LOADER SCREEN */
#screen-loader {
  background: #0d0f19;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 400px;
  width: 85%;
}

.game-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.progress-bar-container {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(188, 141, 75, 0.4);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-gold));
  border-radius: 20px;
  transition: width 0.2s ease;
}

.loading-status {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

/* START SCREEN */
.high-score-badge {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 0.95rem;
  color: var(--text-gold);
}

.controls-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  padding: 14px;
  border-radius: 16px;
}

.control-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.key-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 8px;
  font-family: monospace;
  font-weight: 700;
  color: var(--text-gold);
}

/* HUD SCREEN */
#screen-hud {
  justify-content: flex-start;
  align-items: stretch;
  padding: 16px 20px;
  pointer-events: none;
}

.hud-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.hud-row-lives {
  justify-content: flex-start;
}

.hud-box {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
}

.hud-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-gold);
}

.reward-text {
  font-size: 0.85rem;
  color: #6ee7b7;
}

.hearts-container {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 240px;
}

/* Touch Crouch Button for Mobile */
.hud-bottom-controls {
  position: absolute;
  bottom: 24px;
  right: 20px;
  pointer-events: auto;
  z-index: 30;
}

.btn-touch-crouch {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.9) 0%, rgba(180, 83, 9, 0.95) 100%);
  color: #ffffff;
  border: 2px solid var(--text-gold);
  border-radius: 50px;
  padding: 14px 28px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(245, 158, 11, 0.4);
  cursor: pointer;
  outline: none;
  user-select: none;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.btn-touch-crouch:active, .btn-touch-crouch.active {
  background: #fcd34d;
  color: #451a03;
  transform: scale(0.92);
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.8);
}

.heart-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  animation: heartPop 0.3s ease;
}

@keyframes heartPop {
  0% { transform: scale(0.5); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

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

.btn-icon {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  cursor: pointer;
}

/* HUD TOAST NOTIFICATION */
.hud-toast {
  position: absolute;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1e1b4b 0%, #431407 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 50px;
  padding: 10px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(245, 158, 11, 0.4);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

.hud-toast.hidden {
  opacity: 0;
  transform: translate(-50%, -20px) scale(0.8);
  pointer-events: none;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

#toast-icon {
  font-size: 1.8rem;
}

.toast-info h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--text-gold);
  margin: 0;
}

.toast-info p {
  font-size: 0.8rem;
  color: #ffffff;
  margin: 0;
}

/* RESULT CARDS (GAMEOVER & VICTORY) */
.badge-header {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 16px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.gameover-badge {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.victory-badge {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

/* POWERUP EXPLANATION CARD */
.powerup-explain-card {
  max-width: 440px;
  gap: 14px;
  border: 2px solid var(--accent-gold);
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.95) 0%, rgba(67, 20, 7, 0.95) 100%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(245, 158, 11, 0.4);
}

.powerup-img-wrapper {
  width: 130px;
  height: 130px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.35) 0%, rgba(0, 0, 0, 0) 70%);
  border-radius: 50%;
}

.powerup-figure {
  height: 110px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 15px rgba(245, 158, 11, 0.6));
  animation: pulseGlowImg 1.8s infinite ease-in-out;
}

@keyframes pulseGlowImg {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 6px 15px rgba(245, 158, 11, 0.5)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 10px 25px rgba(252, 211, 77, 0.8)); }
}

.explain-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.92);
}

.result-stats {
  display: flex;
  justify-content: space-around;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.4rem;
}

.grand-prize-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(120, 53, 15, 0.4) 100%);
  border: 2px dashed var(--accent-gold);
  border-radius: 18px;
  padding: 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.prize-icon {
  font-size: 2.2rem;
}

.grand-prize-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-gold);
}

.text-link {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 20, 0.85);
  backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  background: #1e1b4b;
  border: 2px solid var(--primary-color);
  border-radius: 24px;
  padding: 20px;
  max-width: 650px;
  width: 92%;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  z-index: 101;
  margin-top: calc(2vh + env(safe-area-inset-top, 0px));
}

.btn-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.share-canvas-wrapper {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

#share-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* RESPONSIVE SCALING FOR SMALL DISPOSITIVES & SHORT SCREENS */
@media (max-height: 720px) or (max-width: 540px) {
  .screen {
    padding: 8px;
    justify-content: flex-start;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .card {
    padding: 14px 18px;
    gap: 8px;
    width: 95%;
    max-height: calc(100dvh - 24px);
    margin-top: 8px;
  }

  .modal-content {
    padding: 14px;
    gap: 10px;
    width: 95%;
    max-height: calc(100dvh - 24px);
    margin-top: 8px;
  }

  .main-heading {
    font-size: 1.5rem;
  }

  .brand-logo {
    height: 40px;
  }

  .tagline {
    font-size: 0.78rem;
  }

  .controls-guide {
    padding: 6px 10px;
    gap: 4px;
  }

  .control-item {
    font-size: 0.75rem;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.95rem;
  }

  .hud-box {
    padding: 4px 8px;
  }

  .hud-value {
    font-size: 0.95rem;
  }
}
