@import url('https://fonts.googleapis.com/css2?family=Fredoka+One:wght@400&display=swap');
body {
    margin: 0;
    padding: 20px;
    font-family: 'Fredoka One', 'Comic Sans MS', cursive, sans-serif;
    background: 
        radial-gradient(circle at 20% 80%, rgba(86, 171, 47, 0.3) 0%, transparent 50%),
        linear-gradient(135deg, #56ab2f 0%, #a8e6cf 50%, #dcedc1 100%);
    color: #4a4a4a;
    overflow: hidden;
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><circle cx='16' cy='16' r='12' fill='%23ffdb4d'/><path d='M16 4c-3 0-6 2-7 5l-1 2c0 1 1 2 2 2h14c1 0 2-1 2-2l-1-2c-1-3-4-5-7-5z' fill='%23333333'/><circle cx='12' cy='10' r='2' fill='white'/><circle cx='20' cy='10' r='2' fill='white'/><circle cx='12' cy='10' r='1' fill='black'/><circle cx='20' cy='10' r='1' fill='black'/><path d='M10 20c0 3 3 5 6 5s6-2 6-5' fill='none' stroke='%23333333' stroke-width='2'/></svg>"), auto;
    animation: bgShift 20s ease-in-out infinite alternate;
}
@media (prefers-reduced-motion: no-preference) {
    @keyframes wiggle { 0%, 100% { transform: translate(-50%, -50%) rotate(0deg); } 25% { transform: translate(-50%, -50%) rotate(5deg); } 75% { transform: translate(-50%, -50%) rotate(-5deg); } }
    @keyframes shake { 0%, 100% { transform: translate(-50%, -50%) translateX(0); } 25% { transform: translate(-50%, -50%) translateX(-10px); } 75% { transform: translate(-50%, -50%) translateX(10px); } }
}
@keyframes bgShift { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
@keyframes bob { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-10px); } }
@keyframes sparkle { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(2); } }
@keyframes slideInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounceIn { 0% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.05); } 70% { transform: scale(0.9); } 100% { transform: scale(1); opacity: 1; } }
@keyframes confettiFall { 0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }
@keyframes revealSection {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
#school-logo {
/* === Unlock Notification Style === */
#unlock-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: linear-gradient(135deg, #ffd700, #ffc107);
    color: #4a4a4a;
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 1002;
    text-align: center;
    border: 5px solid white;
    opacity: 0;
    animation: bounceIn 0.8s forwards, sparkle 2s 1s ease-in-out infinite alternate;
    transition: opacity 0.5s ease-out;
}
#unlock-notification h2 {
    font-size: clamp(24px, 4vw, 32px);
    margin-top: 0;
    color: #ff6b35;
}
    position: fixed;
    top: 10px;
    right: 10px;
    width: 80px;
    height: auto;
    z-index: 50;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    animation: bob 2s ease-in-out infinite;
}
#school-logo:hover { transform: scale(1.05); }
#hero-banner {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: block;
    animation: slideInDown 1s ease-out;
}
#hero-banner:not([src]) {
    height: 0;
    margin: 0;
}
#launcher {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    width: 90vw;
    max-width: 1200px;
    max-height: 95vh;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    animation: fadeIn 1s ease-out;
}
#launcher h1 {
    font-size: clamp(28px, 5vw, 48px);
    color: #ff6b35;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
#student-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    animation: bounceIn 0.8s ease-out;
}
#student-form input {
    display: block;
    margin: 10px auto;
    padding: 10px;
    font-size: 18px;
    border: 2px solid #4ecdc4;
    border-radius: 10px;
    text-align: center;
    width: 80%;
    max-width: 250px;
    font-family: inherit;
    transition: border-color 0.2s;
}
#student-form input:focus { border-color: #ff6b35; outline: none; }
#student-form button {
    background: #4ecdc4;
    /* Styles moved to .btn and .btn-primary */
}
#student-form button:hover { background: #44a08d; }

/* === New Unified Button Styles === */
.btn {
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
    margin-top: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.btn-primary { background: #4ecdc4; }
.btn-primary:hover { background: #44a08d; }
.btn-secondary { background: #ff6b35; }
.btn-secondary:hover { background: #e55a2b; }
.btn-danger { background: #ff4757; }
.btn-danger:hover { background: #e0404f; }
.btn-special { background: linear-gradient(135deg, #ffd700, #ffc107); color: #4a4a4a; }
.btn-special:hover { background: linear-gradient(135deg, #ffca00, #ffb300); }
.btn-small {
    font-size: 14px;
    padding: 8px 12px;
}
/* === End New Button Styles === */

#session-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
#change-student-btn { /* Now uses .btn classes */
    background: #ff6b35;
}
/* === New Level Selector Styles === */
#level-selector {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 5px;
    display: flex;
    gap: 5px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.level-option {
    position: relative;
}
.level-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.level-option label {
    display: block;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: bold;
    color: #555;
    transition: all 0.3s ease;
    -webkit-user-select: none;
    user-select: none;
}
.level-option input[type="radio"]:checked + label {
    background: #ff6b35;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#session-info {
    margin-bottom: 20px;
    font-size: clamp(14px, 2vw, 18px);
    color: #4a4a4a;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px;
    border-radius: 15px;
    word-break: break-word;
    text-align: center; /* Center align the content */
}
.inline-edit {
    font-family: inherit;
    font-size: inherit;
    color: #ff6b35;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ff6b35;
    border-radius: 5px;
    padding: 2px 5px;
}
#student-stats {
    margin-top: 10px;
    font-size: 0.9em;
}
#stars-bar {
    width: 100%;
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    margin-top: 5px;
    overflow: hidden;
}
#stars-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffdb4d, #ffd700);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 5px;
} 
#badge-btn { /* Now uses .btn classes */
    background: #4ecdc4; 
    font-size: clamp(14px, 2vw, 16px); 
}
.game-card {
    padding: 20px;
    font-size: clamp(18px, 3vw, 24px);
    background: linear-gradient(135deg, #ff6b35, #e55a2b);
    color: white;
    border: none;
    border-radius: 25px;
    font-family: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}
.game-card-content {
    display: block;
    transition: transform 0.3s ease;
}
.game-card:hover .game-card-content {
    transform: translateY(-5px) scale(1.05);
}
.game-card::before { /* Shimmer effect */
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}
.game-card:hover::before { left: 100%; }
.game-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.game-card:active { transform: scale(0.98); }
.game-card-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
}
.game-card {
    animation: bounceIn 0.5s ease-out forwards;
    opacity: 0; /* Start hidden for animation */
}
#badge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}
#badge-gallery {
    background: linear-gradient(135deg, #fff, #f0f8ff);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #4a4a4a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#art-custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}
#art-custom-form {
    background: linear-gradient(135deg, #fff, #f0f8ff);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #4a4a4a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#art-custom-form h2 { color: #ff6b35; }
#art-custom-form input { display: inline-block; width: 40%; margin: 5px; }
#custom-art-list { margin-top: 20px; text-align: left; }
.custom-art-item { background: #eee; padding: 5px; border-radius: 5px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; }
.custom-art-item button { background: #ff4757; font-size: 12px; padding: 2px 8px; }
#badge-gallery {
    background: linear-gradient(135deg, #fff, #f0f8ff);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #4a4a4a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#badge-gallery h2 { 
    color: #ff6b35; 
    animation: sparkle 2s ease-in-out infinite alternate; 
}
#badge-gallery button {
    margin-top: 20px;
}
.badge-item {
    margin: 10px 0;
    font-size: clamp(18px, 3vw, 24px);
    background: rgba(255, 215, 0, 0.2);
    padding: 10px;
    border-radius: 10px;
}
#leaderboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}
#leaderboard {
    background: linear-gradient(135deg, #fff, #f0f8ff);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #4a4a4a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#leaderboard h2 { color: #ff6b35; }
#leaderboard-list {
    list-style-type: none;
    padding: 0;
    text-align: left;
}
.leaderboard-item {
    font-size: clamp(18px, 3vw, 24px);
    background: rgba(255, 215, 0, 0.2);
    padding: 10px; border-radius: 10px; margin: 10px 0;
}
#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}
#settings-menu {
    background: linear-gradient(135deg, #fff, #f0f8ff);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #4a4a4a;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#settings-menu h2 {
    color: #ff6b35;
    margin-bottom: 25px;
}
.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section button { margin: 5px; }
#time-spent-section {
    margin-top: 20px;
}
#time-spent-section h3 {
    color: #ff6b35;
}
.time-spent-item {
    font-size: clamp(16px, 2.5vw, 20px);
    background: rgba(78, 205, 196, 0.15);
    padding: 8px;
    border-radius: 8px;
    margin: 5px 0;
}
#game-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    z-index: 1;
    animation: fadeIn 0.5s ease-out;
}
.back-btn {
    z-index: 30 !important;
    background: linear-gradient(135deg, #ff6b35, #e55a2b) !important;
    color: white !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 20px !important;
    font-size: 16px !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
    cursor: pointer;
    position: absolute; /* Added for consistent positioning */
    top: 20px;          /* Added for consistent positioning */
    left: 20px;         /* Added for consistent positioning */
}
.back-btn:hover { transform: scale(1.1); box-shadow: 0 6px 12px rgba(0,0,0,0.3); }
.hud-score, .hud-timer {
    position: absolute;
    font-size: 20px;
    font-weight: bold;
    z-index: 20;
    background: rgba(255,255,255,0.9);
    padding: 5px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    min-width: 150px; /* Ensure a minimum width */
    text-align: center;
}
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 110px 15px 15px; /* top, right, bottom, left - Added space on the right for the logo */
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 30;
    pointer-events: none; /* Allow clicks to pass through the container */
}
#game-hud > * {
    pointer-events: all; /* Make sure buttons inside are clickable */
}
.hud-left, .hud-center, .hud-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.hud-left { align-items: flex-start; }
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }

.back-btn {
    z-index: 30 !important;
    background: linear-gradient(135deg, #ff6b35, #e55a2b) !important;
    color: white !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 20px !important;
    font-size: 16px !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
    cursor: pointer;
    position: static; /* Remove absolute positioning */
}
.back-btn:hover { transform: scale(1.1); box-shadow: 0 6px 12px rgba(0,0,0,0.3); }
.hud-score, .hud-timer {
    position: static; /* Remove absolute positioning */
    font-size: 20px;
    font-weight: bold;
    z-index: 20;
    background: rgba(255,255,255,0.9);
    padding: 5px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    min-width: 150px; /* Ensure a minimum width */
    text-align: center;
}
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 30;
    pointer-events: none; /* Allow clicks to pass through the container */
}
#game-hud > * {
    pointer-events: all; /* Make sure buttons inside are clickable */
}
.hud-left, .hud-center, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.back-btn {
    z-index: 30 !important;
    background: linear-gradient(135deg, #ff6b35, #e55a2b) !important;
    color: white !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 20px !important;
    font-size: 16px !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
    cursor: pointer;
    position: static; /* Remove absolute positioning */
}
.back-btn:hover { transform: scale(1.1); box-shadow: 0 6px 12px rgba(0,0,0,0.3); }
.hud-score, .hud-timer {
    position: static; /* Remove absolute positioning */
    font-size: 20px;
    font-weight: bold;
    z-index: 20;
    background: rgba(255,255,255,0.9);
    padding: 5px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    max-width: 150px;
    word-wrap: break-word;
}
.progress-bar {
    width: 100px;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    margin-top: 2px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.3s;
}
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #ffd700;
    pointer-events: none;
    z-index: 100;
    animation: confettiFall 3s linear forwards;
}
.tutorial-pointer {
    position: absolute;
    z-index: 1001;
    font-size: 40px;
    pointer-events: none;
    transition: transform 0.5s ease-in-out;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.5));
}
.tutorial-highlight {
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 15px 5px #ffc107;
    border-radius: 15px;
    z-index: 1000;
    pointer-events: none;
    transition: all 0.3s ease-in-out;
}

/* === New Generic Game Canvas Style === */
.game-canvas {
    position: absolute;
    top: 100px; /* Space for the HUD */
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 3px dashed #ff6b35;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
}
#mobile-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #56ab2f, #a8e6cf);
    display: none;
    z-index: 999;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    font-size: 24px;
    animation: bounceIn 1s ease-out;
}
@media (max-width: 768px) {
    #launcher { width: 95vw; padding: 15px; }
    #student-form input { width: 90%; }
    #hero-banner { max-height: 150px; }
    #school-logo { width: 60px; right: 10px; }
}
#games-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    width: 100%;
}
.games-category-title {
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: clamp(22px, 4vw, 28px);
    color: #4a4a4a;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.7);
    text-align: left;
}
#archived-games-container.unlocked {
    background: linear-gradient(to bottom, rgba(255, 235, 153, 0.3), transparent);
    border: 2px solid #ffd700;
    border-radius: 25px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    animation: revealSection 1s ease-out;
}
.level-locked {
    background: linear-gradient(to bottom, rgba(150, 150, 150, 0.2), transparent);
    border: 2px dashed #aaa;
    border-radius: 25px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
@media (max-width: 550px) {
    #games-section { grid-template-columns: 1fr; }
}
.tutorial-pointer {
    position: absolute;
    z-index: 1001;
    font-size: 40px;
    pointer-events: none;
    transition: transform 0.5s ease-in-out;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.5));
}
.tutorial-highlight {
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 15px 5px #ffc107;
    border-radius: 15px;
    z-index: 1000;
    pointer-events: none;
    transition: all 0.3s ease-in-out;
}