/* ─────────────────────────────────────────────
   HUNGRY CHAMELEONS — Main Synthwave Theme
   ───────────────────────────────────────────── */

:root {
  --navy:        #101133;
  --navy-light:  #1a1d4a;
  --navy-mid:    #141638;
  --blue:        #4AB0FF;
  --blue-dim:    #1e6fa8;
  --pink:        #FF00FF;
  --pink-dim:    #aa00aa;
  --green:       #39FF14;
  --green-dim:   #1d8a07;
  --purple:      #BF00FF;
  --purple-dim:  #7a00aa;
  --yellow:      #FFE600;
  --white:       #FFFFFF;
  --text-muted:  #8899cc;
  --card-bg:     rgba(20, 22, 56, 0.85);
  --card-border: rgba(74, 176, 255, 0.3);
  --hex-size:    60px;
  --transition:  0.3s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Exo 2', sans-serif;
  background: var(--navy);
  color: var(--white);
  font-size: 16px;
}

#app {
  position: fixed; inset: 0;
  overflow: hidden;
}

/* ── Background layers ── */
#bg-stars {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, #1a0a3a 0%, var(--navy) 70%);
  pointer-events: none;
}

#bg-grid {
  position: fixed; inset: 0; z-index: 1;
  background-image:
    linear-gradient(rgba(74,176,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,176,255,0.08) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(400px) rotateX(20deg) translateY(10%);
  transform-origin: center bottom;
  pointer-events: none;
}

#bg-scanlines {
  position: fixed; inset: 0; z-index: 2;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.04) 2px,
    rgba(0, 0, 0, 0.04) 4px
  );
  pointer-events: none;
}

/* ── View system ── */
.view {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateY(12px);
  overflow-y: auto;
}
.view.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── Typography ── */
h1, h2, h3 { font-family: 'Orbitron', monospace; letter-spacing: 2px; }

.neon-text-blue  { color: var(--blue);   text-shadow: 0 0 8px var(--blue),  0 0 20px var(--blue);  }
.neon-text-pink  { color: var(--pink);   text-shadow: 0 0 8px var(--pink),  0 0 20px var(--pink);  }
.neon-text-green { color: var(--green);  text-shadow: 0 0 8px var(--green), 0 0 20px var(--green); }
.neon-text-purple{ color: var(--purple); text-shadow: 0 0 8px var(--purple),0 0 20px var(--purple);}

.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.mt-sm { margin-top: 0.75rem; }

/* ── Landing ── */
.landing-center {
  display: flex; flex-direction: column; align-items: center;
  gap: 2.5rem; padding: 2rem; text-align: center; z-index: 10;
}

.logo-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.hex-logo {
  font-size: 5rem; line-height: 1;
  filter: drop-shadow(0 0 20px var(--green)) drop-shadow(0 0 40px var(--green));
  animation: float 3s ease-in-out infinite;
}

.title-glow {
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1.1;
  background: linear-gradient(135deg, var(--blue), var(--pink), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px rgba(74,176,255,0.5));
}

.tagline {
  font-size: 1rem; letter-spacing: 3px; text-transform: uppercase;
  font-family: 'Orbitron', monospace;
}

.landing-buttons {
  display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 360px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border: none; border-radius: 6px;
  font-family: 'Orbitron', monospace; font-size: 0.85rem; letter-spacing: 1px;
  cursor: pointer; transition: all var(--transition);
  text-transform: uppercase; font-weight: 700;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--blue-dim), var(--blue));
  color: var(--navy); box-shadow: 0 0 15px rgba(74,176,255,0.4);
}
.btn-primary:hover {
  box-shadow: 0 0 25px rgba(74,176,255,0.8), 0 0 50px rgba(74,176,255,0.3);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--pink);
  color: var(--pink);
  box-shadow: 0 0 10px rgba(255,0,255,0.3), inset 0 0 10px rgba(255,0,255,0.05);
}
.btn-secondary:hover {
  background: rgba(255,0,255,0.1);
  box-shadow: 0 0 20px rgba(255,0,255,0.6), inset 0 0 15px rgba(255,0,255,0.1);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent; border: 1px solid var(--text-muted);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

.btn-hint {
  background: transparent; border: 2px solid var(--yellow);
  color: var(--yellow); font-size: 0.8rem; padding: 0.5rem 1rem;
}
.btn-hint:not(.disabled):hover {
  background: rgba(255,230,0,0.1);
  box-shadow: 0 0 15px rgba(255,230,0,0.4);
}
.btn-hint.disabled { opacity: 0.4; cursor: not-allowed; }

.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); padding: 4px; }
.btn-icon:hover { color: var(--blue); }

/* ── Auth cards ── */
.auth-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 2.5rem;
  width: 100%; max-width: 440px;
  box-shadow: 0 0 40px rgba(74,176,255,0.15), inset 0 0 40px rgba(74,176,255,0.03);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.auth-card h2 { margin-bottom: 1.5rem; font-size: 1.4rem; }

.auth-form { display: flex; flex-direction: column; gap: 1.25rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label {
  font-family: 'Orbitron', monospace; font-size: 0.7rem;
  letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: 6px; padding: 0.75rem 1rem;
  color: var(--white); font-family: 'Exo 2', sans-serif; font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(74,176,255,0.3);
}

/* PIN inputs */
.pin-inputs {
  display: flex; gap: 0.75rem; justify-content: flex-start;
}
.pin-digit {
  width: 56px; height: 56px;
  text-align: center; font-size: 1.5rem; font-weight: 700;
  background: rgba(255,255,255,0.05);
  border: 2px solid var(--card-border);
  border-radius: 8px; color: var(--white);
  caret-color: var(--blue); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.pin-digit:focus {
  border-color: var(--blue);
  box-shadow: 0 0 15px rgba(74,176,255,0.4);
}
.pin-digit.filled { border-color: var(--green); }

/* Age group picker */
.age-group-picker { display: flex; gap: 1rem; }
.age-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 0.3rem; padding: 1rem 0.5rem;
  background: rgba(255,255,255,0.03);
  border: 2px solid var(--card-border); border-radius: 10px;
  cursor: pointer; transition: all var(--transition); color: var(--white);
}
.age-btn:hover { border-color: var(--blue); background: rgba(74,176,255,0.08); }
.age-btn.selected {
  border-color: var(--green);
  background: rgba(57,255,20,0.1);
  box-shadow: 0 0 15px rgba(57,255,20,0.3);
}
.age-emoji { font-size: 2rem; }
.age-label { font-family: 'Orbitron', monospace; font-size: 0.7rem; letter-spacing: 1px; }
.age-range { font-size: 0.7rem; color: var(--text-muted); }

.form-error {
  background: rgba(255,0,80,0.15); border: 1px solid rgba(255,0,80,0.4);
  border-radius: 6px; padding: 0.6rem 0.8rem;
  font-size: 0.85rem; color: #ff5577;
}
.form-error.hidden { display: none; }

/* ── Game layout (hub + game views) ── */
.game-layout {
  align-items: stretch; justify-content: flex-start;
  flex-direction: row; padding: 0;
}

.game-main {
  flex: 1; min-width: 0;
  padding: 1.5rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.25rem;
}

/* ── Hub ── */
.hub-header h2 { font-size: 1.6rem; }

.mascot-container { display: flex; justify-content: center; }

.progress-section { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 1rem 1.25rem; }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; font-size: 0.9rem; }
.progress-track {
  position: relative; height: 18px; background: rgba(255,255,255,0.08);
  border-radius: 9px; overflow: visible;
}
.progress-fill {
  height: 100%; border-radius: 9px; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--blue));
  transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1), background 1s ease;
  box-shadow: 0 0 10px var(--blue);
}
.progress-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  font-size: 1.3rem; transition: left 0.8s cubic-bezier(0.34,1.56,0.64,1);
  filter: drop-shadow(0 0 6px currentColor);
}

.activity-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── Hexagon pattern overlay on cards ── */
.hex-pattern {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='70'%3E%3Cpolygon points='30,0 60,17.5 60,52.5 30,70 0,52.5 0,17.5' fill='none' stroke='rgba(74,176,255,0.06)' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 60px 70px;
}

/* ── Game header ── */
.game-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.game-title-area { flex: 1; }
.game-title-area h2 { font-size: 1.2rem; }
.round-badge {
  display: inline-block; font-size: 0.7rem;
  font-family: 'Orbitron', monospace; letter-spacing: 1px;
  padding: 2px 8px; border-radius: 20px;
  background: rgba(74,176,255,0.15); border: 1px solid var(--blue);
  color: var(--blue);
}

.hint-area { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-end; }
.hint-timer-bar { width: 120px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; }
.hint-timer-fill { height: 100%; width: 0%; background: var(--yellow); border-radius: 2px; transition: width 1s linear; }

.game-instructions {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 1rem 1.25rem;
  font-size: 1rem; line-height: 1.6;
}

.game-container {
  flex-shrink: 0;
  min-height: 300px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 1.5rem;
  position: relative;
}

.game-feedback {
  padding: 1rem; border-radius: 8px; font-size: 0.95rem; text-align: center;
  font-weight: 600;
}
.game-feedback.correct { background: rgba(57,255,20,0.1); border: 1px solid var(--green); color: var(--green); }
.game-feedback.incorrect { background: rgba(255,0,80,0.1); border: 1px solid #ff3355; color: #ff5577; }
.game-feedback.hidden { display: none; }

.game-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  position: sticky; bottom: 0;
  background: var(--navy); padding: 0.75rem 0 0;
  z-index: 5;
}
.round-dots { display: flex; gap: 8px; }
.round-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255,255,255,0.2); border: 2px solid transparent;
  transition: all var(--transition);
}
.round-dot.active { background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.round-dot.complete { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ── Modals ── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,30,0.8); backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card-bg); border: 1px solid var(--blue);
  border-radius: 12px; padding: 2rem;
  max-width: 440px; width: 90%;
  box-shadow: 0 0 40px rgba(74,176,255,0.3);
  text-align: center; display: flex; flex-direction: column; gap: 1rem;
}
.modal-box h3 { font-size: 1.2rem; }
.modal-icon { font-size: 3rem; }
.modal-explanation { font-size: 0.9rem; line-height: 1.6; color: var(--text-muted); }

/* ── Toast notifications ── */
#toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 2000;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 0.75rem 1rem;
  font-size: 0.85rem; max-width: 320px;
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease forwards;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: #ff3355; }
.toast.warning { border-color: var(--yellow); }
.toast.out { animation: toast-out 0.3s ease forwards; }

/* ── Completion screen ── */
.complete-screen {
  display: flex; flex-direction: column; align-items: center;
  gap: 1.5rem; padding: 2rem; text-align: center;
  position: relative; z-index: 10; max-width: 700px; width: 100%;
}
.complete-title { font-size: clamp(2rem, 6vw, 3.5rem); }
.complete-subtitle { font-size: clamp(1rem, 3vw, 1.5rem); }

.hacker-chameleon {
  position: relative;
}
.hacker-scene {
  font-size: 5rem; position: relative; display: inline-block;
}
.hacker-cham {
  filter: drop-shadow(0 0 20px var(--green)) drop-shadow(0 0 40px var(--blue));
  animation: hacker-pulse 2s ease-in-out infinite;
}
.hacker-keyboard { font-size: 2rem; margin-top: -1rem; }
.hacker-glow {
  position: absolute; inset: -20px;
  background: radial-gradient(circle, rgba(57,255,20,0.2) 0%, transparent 70%);
  animation: glow-pulse 2s ease-in-out infinite;
}

.complete-stats { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 1rem 1.5rem; min-width: 120px; text-align: center;
}
.stat-value { font-family: 'Orbitron', monospace; font-size: 1.8rem; color: var(--blue); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.complete-note { font-size: 0.85rem; color: var(--text-muted); max-width: 400px; line-height: 1.5; }
.complete-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ── Particles ── */
.particles-container {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.particle {
  position: absolute; border-radius: 50%; pointer-events: none;
  animation: particle-burst 1.5s ease-out forwards;
}

/* ── TTS panel ── */
#tts-panel {
  position: fixed; bottom: 1rem; left: 1rem; z-index: 500;
  display: flex; align-items: center; gap: 0.5rem;
}
#tts-panel.hidden { display: none; }
#tts-toggle {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 50%; width: 40px; height: 40px; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
#tts-toggle:hover { border-color: var(--blue); box-shadow: 0 0 10px rgba(74,176,255,0.3); }
#tts-voice-picker select {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 6px; padding: 0.4rem 0.6rem; color: var(--white);
  font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .game-layout { flex-direction: column; }
  .auth-card { padding: 1.5rem; margin: 1rem; }
  .age-group-picker { flex-direction: column; }
  .activity-grid { grid-template-columns: 1fr 1fr; }
  .game-nav { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .activity-grid { grid-template-columns: 1fr; }
  .complete-stats { flex-direction: column; align-items: center; }
}
