﻿/* ═══════════════════════════════════════════════════════════════
   LABIRINTO DOS ATALHOS: O GUARDIÃO DA LUZ — F5 PRATIQUE
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #030712;
  --panel-bg: rgba(10, 20, 42, 0.94);
  --panel-border: rgba(56, 189, 248, 0.25);
  --gold: #facc15;
  --gold-glow: rgba(250, 204, 21, 0.45);
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --emerald: #10b981;
  --coral: #f43f5e;
  --purple: #a855f7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-main: 'Nunito', sans-serif;
  --font-title: 'Baloo 2', cursive;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  user-select: none;
}

.game-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 10%, #0d1e38 0%, #030712 85%);
}

/* ── TOPBAR DO JOGO ── */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: rgba(8, 16, 32, 0.96);
  border-bottom: 2px solid rgba(56, 189, 248, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 50;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-wrap img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.brand-text strong {
  display: block;
  font-family: var(--font-title);
  font-size: 1rem;
  color: #fff;
  line-height: 1.1;
}
.brand-text span {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.world-selector-nav {
  display: flex;
  gap: 4px;
  background: rgba(12, 24, 48, 0.9);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-wrap: wrap;
}
.world-tab-btn {
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.world-tab-btn:hover:not(:disabled) {
  color: #fff;
  background: rgba(56, 189, 248, 0.18);
}
.world-tab-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(2, 132, 199, 0.4);
}
.world-tab-btn:disabled, .world-tab-btn.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.top-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(12, 24, 48, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 5px 10px;
  border-radius: 9px;
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}
.stat-pill.light-power {
  color: var(--gold);
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.18);
}
.btn-sound, .btn-exit, .btn-fullscreen {
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 24, 48, 0.95);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-fullscreen {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(2, 132, 199, 0.28);
  color: #38bdf8;
}
.btn-sound:hover, .btn-exit:hover, .btn-fullscreen:hover {
  background: rgba(56, 189, 248, 0.3);
  border-color: var(--cyan);
  color: #fff;
}

/* ── PALCO DO LABIRINTO ── */
.game-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  padding: 12px 18px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  align-items: start;
}

.canvas-viewport-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2.5px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.75), 0 0 25px rgba(56, 189, 248, 0.12);
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
}

.canvas-viewport-wrap:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  background: #000000 !important;
}

#mazeCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #000000;
  image-rendering: pixelated;
}

/* ── HUD SOBRE O CANVAS ── */
.canvas-hud-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}
.hud-card {
  pointer-events: auto;
  background: rgba(6, 14, 28, 0.9);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}
.torch-meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.torch-meter-label {
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.torch-meter-bar {
  width: 110px;
  height: 7px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.torch-meter-fill {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, #f59e0b 0%, #facc15 100%);
  border-radius: inherit;
  box-shadow: 0 0 10px var(--gold);
  transition: width 0.35s ease;
}

.turbo-torch-badge {
  display: none;
  background: linear-gradient(135deg, #f43f5e 0%, #fb923c 100%);
  color: #fff;
  font-family: var(--font-title);
  font-size: 0.76rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 99px;
  animation: pulseTurbo 0.8s infinite alternate;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.6);
}
@keyframes pulseTurbo {
  to { transform: scale(1.06); box-shadow: 0 0 26px rgba(251, 146, 60, 0.9); }
}

/* ── SIDEBAR ── */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-card {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.world-info-card h2 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: #fff;
  margin-top: 2px;
}
.world-kicker {
  font-size: 0.64rem;
  font-weight: 900;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.world-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 5px 0 10px;
}

.crystals-tracker {
  background: rgba(4, 10, 24, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.crystal-count-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
}
.crystal-dots {
  display: flex;
  gap: 6px;
}
.c-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.c-dot.active {
  background: var(--gold);
  border-color: #fff;
  box-shadow: 0 0 12px var(--gold);
  transform: scale(1.2);
}

.controls-card h3 {
  font-family: var(--font-title);
  font-size: 0.92rem;
  color: #fff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.controls-keys-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.key-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 800;
  color: var(--cyan);
  font-size: 0.7rem;
}

/* ── MODAL RPG ── */
.rpg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.88);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: none;
  place-items: center;
  padding: 16px;
}
.rpg-modal-overlay.active {
  display: grid;
  animation: fadeIn 0.25s ease;
}

.rpg-dialog-card {
  width: min(540px, 100%);
  background: linear-gradient(145deg, #0e2246 0%, #061022 100%);
  border: 2.5px solid var(--cyan);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 45px rgba(56, 189, 248, 0.35);
  position: relative;
  overflow: hidden;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guardian-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.guardian-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #38bdf8 0%, #1e40af 100%);
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}
.guardian-meta h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: #fff;
  line-height: 1.1;
}
.guardian-meta span {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rpg-alert-banner {
  display: none;
  background: rgba(244, 63, 94, 0.25);
  border: 1.5px solid var(--coral);
  border-radius: 10px;
  padding: 8px 12px;
  color: #fecdd3;
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 12px;
  animation: shake 0.4s ease;
}

.rpg-question-box {
  background: rgba(2, 6, 23, 0.7);
  border: 1.5px solid rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.rpg-question-box p {
  font-size: 0.92rem;
  line-height: 1.45;
  color: #e2e8f0;
  font-weight: 700;
}
.rpg-question-box strong {
  color: var(--cyan);
  font-size: 0.98rem;
}

.rpg-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.rpg-option-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 24, 48, 0.85);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}
.rpg-option-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--cyan);
  transform: translateX(4px);
}
.rpg-option-btn .opt-key-kbd {
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 7px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--gold);
}
.rpg-option-btn.correct {
  background: rgba(16, 185, 129, 0.35) !important;
  border-color: var(--emerald) !important;
  color: #a7f3d0 !important;
}
.rpg-option-btn.wrong {
  background: rgba(244, 63, 94, 0.35) !important;
  border-color: var(--coral) !important;
  color: #fecdd3 !important;
  animation: shake 0.35s ease;
}

.rpg-tip-foot {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ── MODAL DE VITÓRIA ── */
.victory-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.92);
  backdrop-filter: blur(14px);
  z-index: 120;
  display: none;
  place-items: center;
  padding: 16px;
}
.victory-modal-overlay.active {
  display: grid;
  animation: fadeIn 0.3s ease;
}
.victory-card {
  width: min(480px, 100%);
  background: linear-gradient(145deg, #0d254b 0%, #050f20 100%);
  border: 3px solid var(--gold);
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.95), 0 0 50px rgba(250, 204, 21, 0.35);
  animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.victory-trophy {
  font-size: 3.4rem;
  line-height: 1;
  margin-bottom: 6px;
  animation: bounce 1.4s infinite alternate;
}
.victory-card h2 {
  font-family: var(--font-title);
  font-size: 1.7rem;
  color: #fff;
}
.victory-card p {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin: 5px 0 16px;
  line-height: 1.45;
}
.victory-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}
.v-stat {
  background: rgba(2, 6, 23, 0.75);
  border: 1px solid rgba(250, 204, 21, 0.25);
  padding: 8px;
  border-radius: 10px;
}
.v-stat strong {
  display: block;
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--gold);
}
.v-stat span {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}
.btn-next-world {
  background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
  color: #08111e;
  border: none;
  padding: 11px 24px;
  border-radius: 11px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(250, 204, 21, 0.4);
  transition: all 0.2s ease;
}

/* ── CONTROLES MOBILE TOUCH ── */
.mobile-dpad-wrap {
  display: none;
  margin-top: 10px;
  justify-content: center;
  align-items: center;
}
.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 4px;
}
.dpad-btn {
  background: rgba(12, 24, 48, 0.9);
  border: 2px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.dpad-btn:active {
  background: var(--cyan);
  color: #020617;
  transform: scale(0.92);
}
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; opacity: 0.3; pointer-events: none; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* ── ANIMAÇÕES ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounce { to { transform: translateY(-6px); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ── RESPONSIVIDADE ── */
@media (max-width: 1024px) {
  .game-main {
    grid-template-columns: 1fr;
  }
  .canvas-viewport-wrap {
    min-height: 380px;
  }
  .mobile-dpad-wrap {
    display: flex;
  }
}
@media (max-width: 768px) {
  .game-topbar {
    padding: 6px 12px;
  }
  .world-selector-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
