:root {
    --bg-color: #F9F9FB; /* Light gray-blue updated */
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --primary: #46178f; /* Kahoot Purple */
    --secondary: #26890c; /* Kahoot Green */
    --accent-red: #e21b3c;
    --accent-blue: #1368ce;
    --accent-yellow: #d89e00;
    --success: #26890c;
    --danger: #e21b3c;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#app-container {
    width: 100%;
    max-width: 1000px;
}

.view-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typography & Basics */
h1, h2, h3 { color: var(--text-primary); margin-bottom: 12px; }
.subtitle, .info-text { color: var(--text-secondary); margin-bottom: 24px; }
.hidden { display: none !important; }

/* Kahoot Style Buttons */
button {
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    border: none;
    transition: transform 0.1s, filter 0.1s;
}

.kahoot-btn {
    display: block;
    width: 100%;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.kahoot-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.kahoot-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.kahoot-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: translateY(4px); }

.kahoot-student { background-color: var(--accent-red); padding: 30px; font-size: 2rem; }
.kahoot-enter { background-color: var(--text-primary); }
.primary-btn { background: var(--primary); color: white; padding: 15px 30px; font-size: 1.2rem; font-weight: 800; border-radius: var(--radius-md); box-shadow: 0 4px 0 rgba(0,0,0,0.2); }
.secondary-btn { background: #e2e8f0; color: var(--text-primary); padding: 10px 20px; font-size: 1rem; font-weight: 700; border-radius: var(--radius-sm); }
.text-link { background: none; border: none; color: var(--text-secondary); text-decoration: underline; font-size: 1rem; cursor: pointer; }
.back-link { background: none; border: none; color: var(--text-secondary); text-decoration: underline; font-size: 0.9rem; cursor: pointer; margin-top: 15px; display: inline-block;}

/* Screen: Start */
.kahoot-start { text-align: center; }
.logo-circle { font-size: 5rem; margin-bottom: 10px; }
.main-title { font-size: 3rem; font-weight: 900; color: var(--primary); margin-bottom: 40px; }
.role-buttons { max-width: 400px; margin: 0 auto; }

/* Screen: Boxes */
.kahoot-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.kahoot-input input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    text-align: center;
    border: 2px solid #ccc;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
}
.kahoot-input input:focus { outline: none; border-color: var(--primary); }
.error-msg { color: var(--danger); font-weight: bold; margin-bottom: 15px; }

/* Screen: Setup & Grade Selector */
.card { background: white; padding: 40px; border-radius: var(--radius-lg); box-shadow: var(--shadow); text-align: center; max-width: 600px; margin: 0 auto; }
.grade-selector { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 30px; }
.grade-btn { background: #f1f5f9; border: 2px solid #cbd5e1; padding: 15px 25px; border-radius: var(--radius-md); font-size: 1.1rem; font-weight: 800; color: var(--text-secondary); }
.grade-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* Screen: Projector / Lobby */
.projector-view { text-align: center; }
.lobby-header { background: white; padding: 30px; border-radius: var(--radius-lg); margin-bottom: 30px; box-shadow: var(--shadow); }
.giant-pin { font-size: 6rem; font-weight: 900; letter-spacing: 10px; color: var(--text-primary); margin: 20px 0; background: #f1f5f9; display: inline-block; padding: 10px 40px; border-radius: var(--radius-md); }
.players-grid { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; margin-bottom: 30px; min-height: 100px; }
.player-tag { background: var(--primary); color: white; padding: 10px 20px; border-radius: 999px; font-weight: 800; font-size: 1.2rem; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* Screen: Test / Questions */
.badge { background: var(--primary); color: white; padding: 5px 15px; border-radius: 999px; font-weight: bold; margin-bottom: 20px; display: inline-block; }
.progress-bar-container { height: 10px; background: #e2e8f0; border-radius: 5px; margin-bottom: 30px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }
.question-text { font-size: 2.2rem; font-weight: 800; text-align: center; }
.audio-btn { background: #f1f5f9; width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; border: 2px solid #e2e8f0; }
.audio-btn:hover { background: #e2e8f0; }

.image-container { text-align: center; margin-bottom: 30px; min-height: 120px; }
.emoji-image { font-size: 5rem; }

.kahoot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.answer-btn { 
    padding: 30px 20px; 
    font-size: 1.5rem; 
    font-weight: 800; 
    background-color: #f1f5f9;
    color: var(--text-primary); 
    border: 2px solid #cbd5e1;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.answer-btn:hover { background-color: #e2e8f0; }

.answer-btn.correct { background-color: var(--success) !important; border-color: var(--success) !important; box-shadow: 0 0 20px rgba(38, 137, 12, 0.5) !important; color: white !important;}
.answer-btn.wrong { opacity: 0.3; } /* Fade out wrong answers */
.answer-btn.selected-wrong { background-color: var(--danger) !important; border-color: var(--danger) !important; color: white !important; opacity: 1; animation: shake 0.4s; }

@keyframes shake { 0%, 100% {transform: translateX(0);} 25% {transform: translateX(-5px);} 50% {transform: translateX(5px);} 75% {transform: translateX(-5px);} }

.explanation-box { background: #fffbeb; border: 2px solid #fde68a; border-radius: var(--radius-md); padding: 15px; margin-top: 20px; display: flex; gap: 10px; text-align: left; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Screen: Teacher Dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; background: white; padding: 20px; border-radius: var(--radius-md); box-shadow: var(--shadow); }
.dashboard-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.stat-card { background: white; padding: 20px; border-radius: var(--radius-md); text-align: center; box-shadow: var(--shadow); }
.stat-card h3 { color: var(--text-secondary); font-size: 1rem; }
.stat-card p { font-size: 2rem; font-weight: 900; color: var(--primary); }

.table-container { background: white; border-radius: var(--radius-md); box-shadow: var(--shadow); overflow: hidden; }
.results-table { width: 100%; border-collapse: collapse; text-align: left; }
.results-table th { background: #f8fafc; padding: 15px; font-weight: 800; border-bottom: 2px solid #e2e8f0; }
.results-table td { padding: 15px; border-bottom: 1px solid #e2e8f0; }
.td-error { color: var(--danger); font-size: 0.9rem; }
.td-success { color: var(--success); font-weight: bold; }

/* Lobby: PIN og QR-kode */
.pin-row { display: flex; gap: 30px; justify-content: center; align-items: center; flex-wrap: wrap; }
.qr-wrap { text-align: center; }
.qr-wrap #lobby-qr { display: inline-block; background: white; padding: 8px; border-radius: var(--radius-md); }
.qr-url { font-size: 0.85rem; color: var(--text-secondary); margin-top: 6px; word-break: break-all; }
.mode-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 15px; border-radius: var(--radius-md); font-size: 0.9rem; max-width: 520px; margin: 10px auto 0; }

/* Hide scrollbar for grid */
.answers-grid::-webkit-scrollbar { display: none; }

/* === PRINT STYLES FOR TEACHER REPORT === */
@media print {
    body { background: white; padding: 0; margin: 0; }
    .no-print, .back-link, #btn-print-pdf, #btn-export-excel { display: none !important; }
    
    .view-section { display: none; }
    #student-details-view { display: block !important; box-shadow: none; border: none; max-width: 100%; margin: 0; padding: 0; }
    
    .report-section { page-break-inside: avoid; margin-bottom: 20px; }
    canvas { max-height: 250px !important; }
    #details-meta { display: block !important; }
}

/* === MOBIL === */
@media (max-width: 600px) {
    body { padding: 10px; }
    .card, .kahoot-box { padding: 20px; }
    .question-text { font-size: 1.4rem; }
    .question-title-wrapper { flex-wrap: wrap; }
    .answer-btn { padding: 18px 10px; font-size: 1.1rem; }
    .giant-pin { font-size: 3.5rem; padding: 10px 20px; }
    .dashboard-header { flex-direction: column; gap: 10px; }
    .dashboard-stats { grid-template-columns: 1fr !important; }
    .table-container { overflow-x: auto; }
}
.audio-btn { flex-shrink: 0; }
.secondary-btn.confirm-pending { background: var(--danger); color: white; }
