/* ============================================================
   CAFFÉ FORTALEZA · BARISTA RUSH — Hoja de estilos
   Organización:
     1. Variables (paleta café + tipografía)
     2. Reset y base
     3. Contenedor del juego + sistema de pantallas
     4. Botones reutilizables
     5. HUD
     6. Menú, paneles (instrucciones/créditos)
     7. Nivel 1 (canvas)
     8. Transición
     9. Nivel 2 (barista)
    10. Pantallas de resultado (game over / victoria)
    11. Animaciones (@keyframes)
    12. Responsive
   ============================================================ */

/* ---------- 1. VARIABLES ---------- */
:root {
  --cafe-oscuro:  #3E2723;
  --cafe-claro:   #6D4C41;
  --beige:        #EFEBE9;
  --crema:        #FFF8E1;
  --verde:        #4CAF50;
  --dorado:       #FFB300;
  --blanco:       #FFFFFF;

  --sombra-suave: 0 6px 18px rgba(0, 0, 0, .25);
  --sombra-fuerte: 0 12px 32px rgba(0, 0, 0, .40);
  --radio: 16px;
  --fuente: 'Segoe UI', 'Poppins', system-ui, -apple-system, sans-serif;
}

/* ---------- 2. RESET Y BASE ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--fuente);
  color: var(--cafe-oscuro);
  /* Fondo de cafetería moderna simulado con degradados (sin imágenes externas) */
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 179, 0, .18), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(109, 76, 65, .35), transparent 45%),
    linear-gradient(160deg, #2b1a15 0%, #3E2723 45%, #4e342e 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

kbd {
  background: var(--cafe-oscuro);
  color: var(--crema);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .85em;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.4);
}

/* ---------- 3. CONTENEDOR + PANTALLAS ---------- */
.game {
  position: relative;
  width: min(96vw, 1000px);
  height: min(92vh, 620px);
  margin: max(2vh, 12px) auto;
  background: var(--cafe-oscuro);
  border-radius: var(--radio);
  box-shadow: var(--sombra-fuerte);
  overflow: hidden;
}

/* Cada pantalla ocupa todo el contenedor y se apila; solo la activa se ve. */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .4s ease;
}
.screen--active { display: flex; }

/* ---------- 4. BOTONES ---------- */
.btn {
  font-family: var(--fuente);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .5px;
  color: var(--crema);
  background: var(--cafe-claro);
  border: none;
  border-radius: 999px;
  padding: 14px 34px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--sombra-suave);
  transition: transform .12s ease, box-shadow .12s ease, background .2s ease, filter .2s ease;
  user-select: none;
}
.btn:hover { transform: translateY(-3px) scale(1.03); filter: brightness(1.08); box-shadow: var(--sombra-fuerte); }
.btn:active { transform: translateY(0) scale(.98); }
.btn--primary { background: linear-gradient(135deg, var(--verde), #388E3C); }
.btn--gold    { background: linear-gradient(135deg, var(--dorado), #FB8C00); color: var(--cafe-oscuro); }
.btn--danger  { background: linear-gradient(135deg, #e57373, #c62828); }

/* ---------- Botón de silencio ---------- */
.btn-mute {
  position: absolute;
  bottom: 10px; right: 10px;
  z-index: 50;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(62, 39, 35, .8);
  color: var(--crema);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--sombra-suave);
  transition: transform .12s ease, filter .2s ease;
}
.btn-mute:hover { transform: scale(1.1); filter: brightness(1.15); }
.btn-mute--off { opacity: .55; }

/* ---------- 5. HUD ---------- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  gap: 6px;
  justify-content: space-around;
  align-items: center;
  padding: 10px 14px;
  background: rgba(62, 39, 35, .82);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--dorado);
  color: var(--crema);
  font-weight: 700;
  font-size: clamp(.75rem, 2.2vw, 1.05rem);
}
.hud--hidden { display: none; }
.hud__item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 4px 10px;
  background: rgba(255, 255, 255, .06);
  border-radius: 999px;
}
.hud__item span { color: var(--dorado); }

/* ---------- 6. MENÚ Y PANELES ---------- */
.menu { gap: 22px; text-align: center; }
.menu__cup { font-size: clamp(3rem, 12vw, 5.5rem); animation: float 3s ease-in-out infinite; filter: drop-shadow(0 8px 12px rgba(0,0,0,.4)); }
.menu__title {
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  color: var(--crema);
  letter-spacing: 2px;
  text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 22px rgba(255, 179, 0, .35);
}
.menu__subtitle {
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  color: var(--dorado);
  font-style: italic;
  letter-spacing: 4px;
}
.menu__buttons { display: flex; flex-direction: column; gap: 14px; width: min(300px, 80%); }
.menu__hint { color: rgba(255,248,225,.55); font-size: .85rem; margin-top: 8px; }

.panel { gap: 18px; }
.panel__title { color: var(--dorado); font-size: clamp(1.4rem, 5vw, 2.2rem); }
.panel__body {
  max-width: 640px;
  background: rgba(255, 248, 225, .95);
  color: var(--cafe-oscuro);
  border-radius: var(--radio);
  padding: 22px 26px;
  box-shadow: var(--sombra-suave);
  line-height: 1.55;
  overflow-y: auto;
  max-height: 62vh;
}
.panel__body h3 { color: var(--cafe-claro); margin: 14px 0 6px; }
.panel__body p { margin-bottom: 8px; }
.panel__body--center { text-align: center; }
.panel__small { color: var(--cafe-claro); font-style: italic; margin-top: 10px; }

/* ---------- Intro (cómic) ---------- */
.intro {
  padding: 0;
  background: #000;
  justify-content: center;
  align-items: center;
}
.intro__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity .5s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.intro__img--show { opacity: 1; }
/* Puntos de progreso (uno por imagen mostrada) */
.intro__dots {
  position: absolute;
  bottom: 58px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 5;
}
.intro__dots i {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255, 248, 225, .35);
  transition: background .2s ease, transform .2s ease;
}
.intro__dots i.active { background: var(--dorado); transform: scale(1.25); }
.intro__controls {
  position: absolute;
  bottom: 14px; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 5;
}
.intro__hint {
  color: rgba(255, 248, 225, .7);
  font-size: .82rem;
  background: rgba(0, 0, 0, .4);
  padding: 6px 14px;
  border-radius: 999px;
}
.intro__skip { padding: 8px 20px; font-size: .85rem; }

/* ---------- 7. NIVEL 1 (CANVAS) ---------- */
.level1 { padding: 0; justify-content: flex-start; }
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  background: linear-gradient(#bfe0ff, #e9f6ff 60%, #d8f0d0);
}
.level1__hint {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  color: var(--crema);
  background: rgba(62,39,35,.6);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: .85rem;
  pointer-events: none;
  animation: pulse 2s ease-in-out infinite;
}

/* ---------- 8. TRANSICIÓN ---------- */
.transition { background: radial-gradient(circle at center, #4e342e, #2b1a15); }
.transition__content { text-align: center; color: var(--crema); }
.transition__cup { font-size: 4rem; animation: float 1.6s ease-in-out infinite; }
.transition h2 { color: var(--dorado); font-size: clamp(1.4rem, 5vw, 2.4rem); margin: 14px 0; }
.transition__loader {
  width: 220px; height: 10px;
  margin: 20px auto 0;
  background: rgba(255,255,255,.15);
  border-radius: 999px; overflow: hidden;
}
.transition__loader span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--dorado), var(--verde));
  animation: loadbar 3s ease forwards;
}

/* ---------- 9. NIVEL 2 (BARISTA) ---------- */
.level2 { padding: 54px 12px 12px; justify-content: flex-start; }
.level2__grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 12px;
  width: 100%;
  height: 100%;
}
.l2-col {
  background: rgba(255, 248, 225, .95);
  border-radius: var(--radio);
  padding: 12px;
  box-shadow: var(--sombra-suave);
  overflow-y: auto;
}
.l2-col__title { color: var(--cafe-claro); text-align: center; margin-bottom: 10px; font-size: 1rem; }

/* Ingredientes */
.l2-ingredients { display: flex; flex-direction: column; gap: 8px; }
.l2-ing {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--blanco);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--cafe-oscuro);
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.l2-ing:hover { transform: translateX(4px); border-color: var(--dorado); }
.l2-ing:active { transform: scale(.96); }
.l2-ing__icon { font-size: 1.3rem; }

/* Centro: máquina + taza */
.l2-center { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.l2-machine {
  width: 100%;
  background: linear-gradient(160deg, #4e342e, var(--cafe-oscuro));
  border-radius: var(--radio);
  padding: 14px;
  text-align: center;
  color: var(--crema);
  box-shadow: var(--sombra-suave);
  border: 2px solid var(--dorado);
}
.l2-machine__top { font-weight: 700; letter-spacing: 2px; font-size: .8rem; color: var(--dorado); }
.l2-machine__brand { font-style: italic; font-size: .85rem; margin-top: 6px; color: rgba(255,248,225,.7); }
.l2-cup {
  width: 90px; height: 90px;
  margin: 12px auto 6px;
  background: var(--blanco);
  border-radius: 0 0 44px 44px / 0 0 30px 30px;
  border: 4px solid #d7ccc8;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 -4px 10px rgba(0,0,0,.15);
}
.l2-cup::after { /* asa de la taza */
  content: ""; position: absolute; right: -20px; top: 22px;
  width: 26px; height: 34px;
  border: 6px solid var(--blanco); border-left: none;
  border-radius: 0 20px 20px 0;
}
.l2-cup__fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(var(--cafe-claro), var(--cafe-oscuro));
  transition: height .3s ease;
}

.l2-build { width: 100%; background: rgba(62,39,35,.08); border-radius: 12px; padding: 8px; min-height: 52px; }
.l2-build__label { font-size: .75rem; color: var(--cafe-claro); font-weight: 700; }
.l2-build__list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.l2-chip {
  background: var(--cafe-claro); color: var(--crema);
  padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  animation: pop .25s ease;
}
.l2-actions { display: flex; gap: 10px; }
.l2-actions .btn { padding: 12px 20px; font-size: .9rem; }

.l2-powerups { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 24px; }
.l2-powerup {
  background: var(--dorado); color: var(--cafe-oscuro);
  padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  animation: pop .3s ease;
}

/* Clientes */
.l2-clients { display: flex; flex-direction: column; gap: 10px; }
.l2-client {
  position: relative;
  background: var(--blanco);
  border-radius: 12px;
  padding: 10px 12px 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  border-left: 6px solid var(--cafe-claro);
  animation: slideIn .3s ease;
}
.l2-client--active { border-left-color: var(--verde); box-shadow: 0 0 0 3px rgba(76,175,80,.35), var(--sombra-suave); }
.l2-client--vip { border-left-color: var(--dorado); }
.l2-client--hurry { border-left-color: #e57373; }
.l2-client__head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.l2-client__avatar { font-size: 1.4rem; }
.l2-client__tag { font-size: .68rem; padding: 2px 8px; border-radius: 999px; background: var(--beige); color: var(--cafe-claro); font-weight: 700; }
.l2-client__order { font-size: .82rem; color: var(--cafe-claro); margin-top: 4px; line-height: 1.35; }
.l2-client__bar { height: 6px; background: var(--beige); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.l2-client__bar > i { display: block; height: 100%; background: var(--verde); transition: width .2s linear, background .2s; }

/* Flash central (combos / power-ups) */
.l2-flash {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  z-index: 40;
  font-size: clamp(1.6rem, 6vw, 3rem);
  font-weight: 900;
  color: var(--dorado);
  text-shadow: 0 4px 0 rgba(0,0,0,.4), 0 0 24px rgba(255,179,0,.6);
  opacity: 0; pointer-events: none;
  text-align: center;
}
.l2-flash--show { animation: flashPop 1s ease forwards; }

/* ---------- 10. RESULTADOS ---------- */
.result { gap: 16px; text-align: center; }
.result--over { background: radial-gradient(circle at center, #5d4037, #2b1a15); }
.result--win  { background: radial-gradient(circle at center, #4e342e, #1b0f0b); }
.result__title { color: var(--crema); font-size: clamp(1.6rem, 6vw, 3rem); text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.result--win .result__title { color: var(--dorado); }
.result__stars { font-size: clamp(1.6rem, 7vw, 3rem); color: var(--dorado); letter-spacing: 6px; animation: pulse 1.6s ease-in-out infinite; }
.result__stats {
  background: rgba(255, 248, 225, .95);
  color: var(--cafe-oscuro);
  border-radius: var(--radio);
  padding: 18px 26px;
  box-shadow: var(--sombra-suave);
  min-width: min(320px, 80%);
  text-align: left;
  line-height: 1.7;
}
.result__stats .row { display: flex; justify-content: space-between; gap: 24px; }
.result__stats .row strong { color: var(--cafe-claro); }
.result__buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.result__title, .result__stars, .result__stats, .result__buttons { position: relative; z-index: 2; }

/* ---------- 11. ANIMACIONES ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .7; transform: scale(1.06); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes loadbar { from { width: 0%; } to { width: 100%; } }
@keyframes flashPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.5); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  70%  { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-70%) scale(1); }
}
/* Vibración de pantalla al golpear (Nivel 1) */
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -4px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(6px, 3px); }
}
.shake { animation: shake .35s ease; }

/* ---------- 12. RESPONSIVE ---------- */
@media (max-width: 720px) {
  .level2__grid { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .l2-col { max-height: 130px; }
  .l2-center { order: -1; }
}
@media (max-width: 480px) {
  .hud { font-size: .7rem; gap: 2px; padding: 8px 6px; }
  .hud__item { padding: 3px 6px; }
  .btn { padding: 12px 22px; }
}
