/* ============================= */
/* GLOBAL / APP                  */
/* ============================= */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: #0a0a14;
  color: #fff;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* ============================= */
/* GAME AREA                     */
/* ============================= */
.game-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}

.game-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  position: relative;
}

canvas {
  --canvas-bg: #050509;
  background-color: var(--canvas-bg);
  width: 100%;
  height: 100%;
  display: block;
  margin: 0 auto;
  border: 2px solid #333;
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(255,255,255,0.2);
  text-shadow: 1px 1px 2px #000;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

#canvasOverlay {
  pointer-events: none; /* allow clicks to pass through */
}

.game-topbar {
  position: relative;
  z-index: 10;
}

.game-wrap::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 12px;
  box-shadow: 0 0 50px rgba(0, 255, 255, 0.15);
  pointer-events: none;
  transition: box-shadow 0.5s ease;
}

/* ============================= */
/* TOP-RIGHT BUTTONS             */
/* ============================= */
.game-topbar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.6rem;
  z-index: 100;
}

.game-topbar .btn-glow {
  background: rgba(0, 255, 255, 0.15);
  border: 1px solid #0ff;
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0ff;
  cursor: pointer;
  transition: all 0.3s ease;
}
.game-topbar .btn-glow:hover {
  background: #0ff;
  color: #000;
  transform: scale(1.15);
  box-shadow: 0 0 15px #0ff, 0 0 30px #0ff inset;
}
.game-topbar .title {
  font-weight: 600;
  color: #0ff;
  text-shadow: 0 0 8px #0ff;
}

/* ============================= */
/* SETTINGS PANEL                */
/* ============================= */
.settings-panel {
  position: fixed;
  top: 0;
  right: -600px;
  width: 600px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: rgba(0, 10, 20, 0.85);
  border-left: 2px solid #0ff;
  overflow: hidden;
  transition: right 0.3s ease, background 0.5s ease;
  box-shadow: -5px 0 25px rgba(0, 255, 255, 0.1);
  z-index: 1000;
}

.settings-panel.active { right: 0; width: 40%; }
.settings-panel .top-section {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
}
.settings-panel .bottom-section {
  display: flex;
  justify-content: space-between;
  padding: 15px 20px;
  border-top: 1px solid rgba(0, 255, 255, 0.2);
  background: rgba(0,0,0,0.9);
}

.settings-panel .bottom-section button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  color: #fff;
  background: #0074D9;
  transition: background 0.2s;
}
.settings-panel .bottom-section button:hover {
  background: #005fa3;
}

/* ============================= */
/* SETTINGS GROUPS               */
/* ============================= */
.settings-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  color: #0ff;
  text-shadow: 0 0 8px #0ff;
}
.settings-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}
.settings-group label {
  font-weight: 600;
  margin-bottom: 6px;
  color: #0ff;
}
.settings-group select,
.settings-group input[type="range"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #0ff;
  border-radius: 8px;
  color: #0ff;
  padding: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
}
.settings-group select:hover,
.settings-group input[type="range"]:hover {
  box-shadow: 0 0 15px #0ff;
  transform: scale(1.05);
}

/* ============================= */
/* BUTTONS / GLOW                */
/* ============================= */
.btn-glow, button {
  background: #0ff;
  color: #000;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px #0ff55, 0 0 20px #0ff33;
}

.btn-glow:hover, button:hover {
  transform: scale(1.15);
  box-shadow: 0 0 20px #0ff, 0 0 40px #0ff inset;
}

/* ============================= */
/* RANGE SLIDER                  */
/* ============================= */
#difficultyRange {
  width: 100%;
  height: 10px;
  appearance: none;
  background: linear-gradient(90deg, #00ff66, #ffaa00, #ff3333);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  box-shadow: 0 0 12px #ffaa00;
  transition: all 0.3s ease;
}
#difficultyRange::-webkit-slider-thumb {
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background-color: #ffaa00;
  border: 2px solid #fff;
  box-shadow: 0 0 12px #ffaa00;
  transition: all 0.3s ease;
}
#difficultyRange::-webkit-slider-thumb:hover { transform: scale(1.2); }
#difficultyLabel {
  font-weight: bold;
  margin-left: 6px;
  text-shadow: 0 0 8px currentColor;
  color: #ffaa00;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* ============================= */
/* SCOREBOARD / HUD              */
/* ============================= */
.scoreboard, .hud-box {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(0,0,0,0.5);
  padding: 8px 12px;
  border-radius: 8px;
  color: #fff;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.4;
  z-index: 100;
  pointer-events: none;
}
.scoreboard div, .hud-box div { margin-bottom: 2px; }

/* ============================= */
/* LEVEL UP / MODALS / CERTS     */
/* ============================= */
.level-up-banner,
.level-modal, .level-complete-overlay,
.completion-certificate, .certificate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.5s ease;
}

.level-up-banner {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #4ecca3;
  color: #000;
  font-size: 1.2rem;
  padding: 10px 30px;
  border-radius: 10px;
  font-weight: bold;
  animation: slideDownFade 2.5s ease forwards;
}

.level-modal-content,
.level-complete-box,
.completion-certificate div,
.certificate-frame {
  border-radius: 16px;
  padding: 30px 50px;
  text-align: center;
  background: linear-gradient(145deg, #222, #333);
  color: #fff;
  box-shadow: 0 0 40px gold;
  animation: popIn 0.4s ease;
}


.rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    backdrop-filter: blur(5px);
}

.rules-window {
    background: #1a1a1a;
    color: #fff;
    padding: 50px 60px;
    border-radius: 25px;
    width: 500px;
    text-align: center;
    border: 3px solid #0ff;
    box-shadow: 0 0 30px rgba(0,255,255,0.5), 0 0 60px rgba(0,255,255,0.3);
    animation: fadeIn 0.3s ease-out;
}

.rules-window h2 {
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 0 0 8px #0ff, 0 0 16px #0ff;
}

.rules-window ul {
    text-align: left;
    margin: 0 0 30px 0;
    padding-left: 25px;
    font-size: 20px;
    line-height: 1.6;
    color: #e0f7ff;
}

#startLevelBtn {
    background: linear-gradient(45deg, #0ff, #00f);
    color: #fff;
    border: none;
    padding: 16px 40px;
    font-size: 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 0 15px #0ff, 0 0 25px #00f, 0 0 40px #0ff inset;
    transition: 0.25s ease;
}

#startLevelBtn:hover {
    box-shadow: 0 0 25px #0ff, 0 0 50px #00f, 0 0 60px #0ff inset;
    transform: scale(1.08);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.scoreboard {
  border: 3px solid #fff;
  transition: border-color 0.25s ease;
}

.scoreboard.correct {
  border-color: #00ff66;
}

.scoreboard.wrong {
  border-color: #ff3333;
}


.level-complete-box h1,
.completion-certificate h1,
.certificate-inner h1 { color: #ffd700; }

.next-buttons button,
.cert-buttons button,
.modal-btn.glow,
.continue-btn,
.save-cert-btn,
.close-cert-btn { transition: all 0.3s ease; }
.next-buttons button:hover,
.cert-buttons button:hover,
.modal-btn.glow:hover,
.continue-btn:hover,
.save-cert-btn:hover,
.close-cert-btn:hover { transform: scale(1.05); }

/* ============================= */
/* ANIMATIONS                     */
/* ============================= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideDownFade { 0% { opacity: 0; transform: translateY(-30px) translateX(-50%); } 15% { opacity: 1; transform: translateY(0) translateX(-50%); } 85% { opacity:1;} 100% {opacity:0; transform: translateY(-20px) translateX(-50%);} }
@keyframes fadeOut { to { opacity: 0; transform: scale(0.95); } }
@keyframes zoomIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================= */
/* RESPONSIVE                     */
/* ============================= */
@media (max-width: 768px) { .settings-panel.active { width: 60%; } }
@media (max-width: 480px) { .game-topbar { flex-direction: column; top: 0.5rem; right: 0.5rem; gap: 0.4rem; } }

/* ============================= */
/* THEME VARIANTS                 */
/* ============================= */
[data-theme="neon"] canvas { --canvas-bg: #010a1e; }
[data-theme="sunset"] canvas { --canvas-bg: #2a0700; }

