@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@600;700;800&display=swap');

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

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
  color: #333;
}

/* Twinkling stars background */
.stars { position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; background: white; border-radius: 50%; animation: twinkle 2s ease-in-out infinite alternate; }
@keyframes twinkle { 0% { opacity: 0.3; transform: scale(1); } 100% { opacity: 1; transform: scale(1.3); } }

/* Layout */
.container { position: relative; z-index: 1; max-width: 800px; margin: 0 auto; padding: 30px 20px; }
.container-wide { max-width: 960px; }

/* Header */
.header { text-align: center; margin-bottom: 40px; }
.mascot { font-size: 80px; line-height: 1; margin-bottom: 10px; animation: bounce 2s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.title { font-family: 'Fredoka One', cursive; font-size: 42px; color: #fff; text-shadow: 3px 3px 0 rgba(0,0,0,0.2); letter-spacing: 2px; }
.subtitle { color: rgba(255,255,255,0.85); font-size: 18px; margin-top: 8px; font-weight: 600; }

/* Cards */
.card {
  background: white;
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Game cards grid */
.games-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.game-card {
  background: white; border-radius: 24px; padding: 28px 20px; text-align: center;
  text-decoration: none; color: #333; transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15); display: flex; flex-direction: column;
  align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.game-card:hover, .game-card:active { transform: translateY(-6px) scale(1.02); box-shadow: 0 15px 35px rgba(0,0,0,0.25); }
.game-icon { font-size: 64px; line-height: 1; margin-bottom: 12px; }
.game-name { font-family: 'Fredoka One', cursive; font-size: 20px; margin-bottom: 6px; color: #333; }
.game-desc { font-size: 14px; color: #777; line-height: 1.4; }
.game-badge { display: inline-block; margin-top: 10px; padding: 4px 14px; border-radius: 20px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.badge-runner { background: #e0f7fa; color: #00838f; }
.badge-memory { background: #fce4ec; color: #c62828; }
.badge-tracing { background: #f3e5f5; color: #7b1fa2; }
.badge-catching { background: #e8f5e9; color: #2e7d32; }

/* PIN pad */
.pin-display { display: flex; justify-content: center; gap: 16px; margin: 30px 0; }
.pin-dot {
  width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.3);
  border: 3px solid rgba(255,255,255,0.6); transition: all 0.2s;
}
.pin-dot.filled { background: #fff; border-color: #fff; transform: scale(1.2); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.pin-btn {
  width: 88px; height: 88px; border-radius: 50%; border: none; background: rgba(255,255,255,0.2);
  color: #fff; font-family: 'Fredoka One', cursive; font-size: 36px; cursor: pointer;
  transition: all 0.15s; -webkit-tap-highlight-color: transparent; display: flex;
  align-items: center; justify-content: center; margin: 0 auto;
}
.pin-btn:hover, .pin-btn:active { background: rgba(255,255,255,0.35); transform: scale(1.1); }
.pin-btn.backspace { font-size: 24px; }
.pin-message {
  text-align: center; color: #fff; font-size: 18px; font-weight: 700; min-height: 28px;
  margin-top: 20px; transition: all 0.3s;
}
.pin-message.error { animation: shake 0.4s ease-in-out; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* Timer bar */
.timer-bar {
  background: rgba(255,255,255,0.2); border-radius: 16px; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
  color: #fff; font-weight: 700;
}
.timer-bar .child-info { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.timer-bar .time-left { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.timer-warning { background: rgba(255,193,7,0.35); }
.timer-expired { background: rgba(244,67,54,0.35); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border-radius: 16px; border: none; font-family: 'Nunito', sans-serif;
  font-weight: 800; font-size: 16px; cursor: pointer; transition: all 0.2s;
  -webkit-tap-highlight-color: transparent; text-decoration: none;
}
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; transform: translateY(-2px); }
.btn-secondary { background: rgba(255,255,255,0.2); color: #fff; }
.btn-secondary:hover { background: rgba(255,255,255,0.3); }
.btn-danger { background: #ef5350; color: #fff; }
.btn-danger:hover { background: #e53935; }
.btn-sm { padding: 8px 18px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }

/* Forms (parent pages) */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; color: #555; }
.form-input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 2px solid #e0e0e0;
  font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600;
  transition: border-color 0.2s; outline: none;
}
.form-input:focus { border-color: #667eea; }
.form-error { color: #ef5350; font-size: 14px; font-weight: 700; margin-top: 8px; }
.form-link { color: rgba(255,255,255,0.85); text-decoration: underline; cursor: pointer; font-weight: 700; }
.form-link:hover { color: #fff; }

/* Admin dashboard */
.section { margin-bottom: 32px; }
.section-title { font-family: 'Fredoka One', cursive; font-size: 22px; color: #fff; margin-bottom: 16px; }
.child-card {
  background: white; border-radius: 20px; padding: 20px; margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 16px;
}
.child-avatar { font-size: 48px; }
.child-info-admin { flex: 1; }
.child-info-admin .child-name-admin { font-family: 'Fredoka One', cursive; font-size: 20px; }
.child-info-admin .child-meta { color: #777; font-size: 14px; font-weight: 600; }
.child-actions { display: flex; gap: 8px; }
.progress-bar { background: #e0e0e0; border-radius: 10px; height: 8px; margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #667eea, #764ba2); transition: width 0.3s; }
.progress-fill.warning { background: linear-gradient(90deg, #ffc107, #ff9800); }
.progress-fill.full { background: linear-gradient(90deg, #ef5350, #c62828); }

/* Activity table */
.activity-table { width: 100%; border-collapse: separate; border-spacing: 0; background: white; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.activity-table th { background: #f5f5f5; padding: 12px 16px; text-align: left; font-weight: 800; font-size: 13px; text-transform: uppercase; color: #777; }
.activity-table td { padding: 12px 16px; border-top: 1px solid #f0f0f0; font-weight: 600; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white; border-radius: 24px; padding: 32px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-title { font-family: 'Fredoka One', cursive; font-size: 24px; margin-bottom: 20px; text-align: center; }
.modal-close { float: right; background: none; border: none; font-size: 24px; cursor: pointer; color: #999; }

/* Emoji picker grid */
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 8px; }
.emoji-option {
  width: 48px; height: 48px; border-radius: 12px; border: 2px solid #e0e0e0;
  background: white; font-size: 24px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.emoji-option:hover { border-color: #667eea; transform: scale(1.1); }
.emoji-option.selected { border-color: #667eea; background: #ede7f6; }

/* Game access toggles */
.game-toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.toggle-switch {
  width: 48px; height: 26px; background: #ccc; border-radius: 13px; position: relative;
  cursor: pointer; transition: background 0.2s;
}
.toggle-switch.on { background: #667eea; }
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: white; transition: left 0.2s;
}
.toggle-switch.on::after { left: 25px; }

/* Game iframe overlay */
.game-frame-container { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; background: #000; display: none; }
.game-frame-container.active { display: block; }
.game-frame-container iframe { width: 100%; height: 100%; border: none; }
.game-back-btn {
  position: fixed; top: 12px; left: 12px; z-index: 51; background: rgba(0,0,0,0.6);
  color: white; border: none; border-radius: 12px; padding: 10px 18px; font-family: 'Nunito', sans-serif;
  font-weight: 800; font-size: 14px; cursor: pointer; transition: background 0.2s;
}
.game-back-btn:hover { background: rgba(0,0,0,0.8); }

/* Footer */
.footer { text-align: center; margin-top: 40px; color: rgba(255,255,255,0.6); font-size: 13px; }
.parent-link { color: rgba(255,255,255,0.5); text-decoration: none; font-size: 13px; font-weight: 600; }
.parent-link:hover { color: rgba(255,255,255,0.8); }

/* Responsive */
@media (max-width: 500px) {
  .games-grid { grid-template-columns: 1fr; }
  .title { font-size: 32px; }
  .mascot { font-size: 60px; }
  .pin-btn { width: 76px; height: 76px; font-size: 30px; }
  .child-card { flex-wrap: wrap; }
}
