/* ==========================================================================
   ALVACOLOR // "BUG HUNTER" ARCADE GAME (FULLSCREEN MODAL & TOUCH NATIVE)
   ========================================================================== */

/* The Game Cabinet acts as a Fullscreen Overlay Modal */
.game-arcade-cabinet.game-modal-fullscreen {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  background: var(--arcade-bg);
  box-shadow: none;
  flex-direction: column !important;
}

.game-arcade-cabinet.game-modal-fullscreen.is-fullscreen {
  display: flex !important;
}

.game-arcade-cabinet.game-modal-fullscreen .game-canvas-wrap {
  flex-grow: 1;
  height: calc(100vh - 60px) !important;
}

/* Top Arcade HUD Bar */
.game-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 133, 0, 0.08);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .game-topbar {
    padding: 12px 24px;
  }
}

.game-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.game-hud-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

@media (min-width: 768px) {
  .game-hud-stats {
    gap: 14px;
    font-size: 0.84rem;
  }
}

.hud-stat-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.hud-stat-badge strong {
  color: var(--alva-orange);
  font-weight: 700;
}

.health-track {
  display: inline-block;
  width: 50px;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
  margin-left: 4px;
}

@media (min-width: 768px) {
  .health-track {
    width: 70px;
    margin-left: 6px;
  }
}

.health-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #FF8500, #00ff88);
  transition: width 0.2s ease-out;
}

/* Close/Exit Fullscreen Button */
.btn-game-fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transition: var(--transition);
}

.btn-game-fullscreen:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.btn-game-fullscreen svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Game Canvas Container */
.game-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #03060d;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#bug-hunter-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* Active Power-up HUD Bar inside Canvas */
.active-powerup-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(0, 122, 255, 0.25);
  border: 1px solid var(--alva-blue);
  box-shadow: var(--glow-blue);
  backdrop-filter: blur(8px);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  z-index: 10;
  pointer-events: none;
}

.active-powerup-bar.active {
  display: flex;
}

/* Floating Screens (Start & End) */
.game-overlay-modal {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 18, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  text-align: center;
  overflow-y: auto;
  box-sizing: border-box;
  transition: opacity 0.3s;
}

.game-overlay-modal.hidden {
  display: none !important;
}

.game-modal-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--alva-orange);
  border: 1px solid rgba(255, 133, 0, 0.4);
  background: rgba(255, 133, 0, 0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.game-modal-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3.8vw, 2.2rem);
  font-weight: 900;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  color: #ffffff;
  line-height: 1.15;
}

.game-modal-desc {
  font-size: clamp(0.85rem, 1.6vw, 0.96rem);
  color: #ffffff;
  max-width: 480px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.game-controls-legend {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #cbd5e1;
  margin-top: 12px;
}

/* ==========================================================================
   END MODAL DASHBOARD GRID (PERFECT VIEWPORT FIT)
   ========================================================================== */
.end-modal-container {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  box-sizing: border-box;
  padding: 4px 0;
}

.end-modal-header {
  margin-bottom: 8px;
}

.end-modal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
  align-items: stretch;
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  .end-modal-grid {
    grid-template-columns: 1.05fr 0.95fr;
    gap: 14px;
  }
}

.end-col-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.end-col-leaderboard {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.end-stats-grid {
  display: flex;
  gap: 10px;
  width: 100%;
  margin: 0;
  font-family: var(--font-mono);
}

.end-stat-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-sizing: border-box;
}

.end-stat-card .num {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--alva-orange);
  line-height: 1.2;
}

.end-stat-card .lbl {
  font-size: 0.64rem;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.end-quote-box {
  background: rgba(0, 122, 255, 0.12);
  border: 1px solid rgba(0, 122, 255, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 0;
  text-align: left;
  box-sizing: border-box;
}

.end-quote-title {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 2px;
}

.end-quote-desc {
  font-size: 0.76rem;
  color: #e2e8f0;
  line-height: 1.35;
  margin: 0;
}

.end-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* Botón Volver a Jugar */
.btn-arcade-restart {
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.6) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
}

.btn-arcade-restart:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  border-color: #ffffff !important;
  color: #ffffff !important;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4) !important;
  transform: translateY(-2px);
}

.btn-arcade-restart svg {
  stroke: #ffffff !important;
}

/* ==========================================================================
   SISTEMA DE RÉCORDS & SALÓN DE LA FAMA (LEADERBOARDS)
   ========================================================================== */
.hud-record-badge strong {
  color: #ffd700 !important;
}

.hud-health-badge.is-critical {
  animation: pulseHealthCritical 0.8s ease-in-out infinite alternate;
  border-color: #ef4444 !important;
}

@keyframes pulseHealthCritical {
  0% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.3); }
  100% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.9); }
}

/* Formulario Nuevo Récord */
.game-new-record-box {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 133, 0, 0.22));
  border: 1.5px solid #ffd700;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  width: 100%;
  margin: 0;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.25);
  animation: bounceInRecord 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@keyframes bounceInRecord {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.game-new-record-box.hidden {
  display: none !important;
}

.record-crown-badge {
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 900;
  color: #ffd700;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.record-congrats-txt {
  font-size: 0.74rem;
  color: #ffffff;
  margin-bottom: 8px;
}

.record-input-group {
  display: flex;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.record-player-input {
  flex-grow: 1;
  background: rgba(0, 0, 0, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
}

.record-player-input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.btn-save-record {
  padding: 6px 12px !important;
  font-size: 0.74rem !important;
  white-space: nowrap;
  background: #ffd700 !important;
  color: #000000 !important;
  font-weight: 900 !important;
  border: none !important;
}

.btn-save-record:hover {
  background: #ffffff !important;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.8) !important;
}

/* Leaderboards Tables */
.start-leaderboard-wrap,
.end-leaderboard-wrap {
  width: 100%;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-sizing: border-box;
}

.start-leaderboard-wrap {
  max-width: 380px;
  margin-bottom: 12px;
}

.leaderboard-header-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  color: #cbd5e1;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
  margin-bottom: 6px;
  text-align: center;
}

.leaderboard-mini-list,
.leaderboard-full-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #ffffff;
}

.leaderboard-row.is-current-player {
  background: rgba(255, 215, 0, 0.18);
  border: 1px solid rgba(255, 215, 0, 0.5);
}

.lb-rank-col {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.15);
}

.lb-rank-num.rank-1 { background: #ffd700; color: #000; }
.lb-rank-num.rank-2 { background: #c0c0c0; color: #000; }
.lb-rank-num.rank-3 { background: #cd7f32; color: #000; }

.lb-player-name {
  font-weight: 700;
  color: #ffffff;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score-col {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-bugs-txt {
  font-size: 0.64rem;
  color: var(--alva-orange);
}

.lb-pts-txt {
  font-weight: 800;
  color: #00ff88;
}
