/* Kahoot-style Quiz Game */
.kahoot-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.kahoot-lobby {
    text-align: center;
    padding: 60px 20px;
}

.kahoot-logo {
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #e21b3c, #1368ce, #d89e00, #26890c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kahoot-lobby h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 15px;
}

.kahoot-lobby p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 40px;
}

.kahoot-subtitle {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

/* Rules modal - must read before starting */
.kahoot-rules-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.kahoot-rules-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.kahoot-rules-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kahoot-rules-modal-title {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
    padding: 24px 24px 16px;
    border-bottom: 2px solid #46178f;
    flex-shrink: 0;
}

.kahoot-rules-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.kahoot-rules-modal-body .kahoot-instructions-section {
    margin-bottom: 20px;
}

.kahoot-rules-modal-body .kahoot-instructions-section:last-child {
    margin-bottom: 0;
}

.kahoot-rules-modal-p {
    font-size: 0.95rem;
    line-height: 1.6;
}

.kahoot-rules-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    text-align: center;
}

.kahoot-rules-modal-btn {
    background: linear-gradient(135deg, #e21b3c 0%, #1368ce 50%, #26890c 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kahoot-rules-modal-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Teacher instructions - collapsible */
.kahoot-instructions-wrap {
    margin-top: 48px;
    text-align: right;
}

[dir="ltr"] .kahoot-instructions-wrap {
    text-align: left;
}

.kahoot-instructions-toggle {
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #46178f;
    background: rgba(70, 23, 143, 0.08);
    border: 1px solid rgba(70, 23, 143, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.kahoot-instructions-toggle:hover {
    background: rgba(70, 23, 143, 0.15);
    border-color: rgba(70, 23, 143, 0.5);
}

.kahoot-instructions {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-out;
    margin-top: 16px;
    padding: 0 0 0 0;
}

.kahoot-instructions.kahoot-instructions--open {
    max-height: 1200px;
    transition: max-height 0.5s ease-in;
    padding: 20px;
    background: rgba(70, 23, 143, 0.04);
    border-radius: 12px;
    border: 1px solid rgba(70, 23, 143, 0.12);
}

.kahoot-instructions-heading {
    font-size: 1.35rem;
    color: #333;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #46178f;
}

.kahoot-instructions-section {
    margin-bottom: 24px;
    text-align: right;
}

[dir="ltr"] .kahoot-instructions-section {
    text-align: left;
}

.kahoot-instructions-section h4 {
    font-size: 1.1rem;
    color: #46178f;
    margin: 0 0 8px 0;
    font-weight: 700;
}

.kahoot-instructions-p {
    font-size: 0.95rem;
    line-height: 1.65;
    color: #444;
    margin: 0;
}

.kahoot-instructions-p br {
    display: block;
    content: "";
    margin-top: 0.35em;
}

.kahoot-start-btn {
    background: linear-gradient(135deg, #e21b3c 0%, #1368ce 50%, #26890c 100%);
    color: white;
    border: none;
    padding: 20px 60px;
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.kahoot-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

/* Grade selection */
.kahoot-grade-selection {
    text-align: center;
    padding: 40px 20px;
}

.kahoot-grade-selection h3 {
    font-size: 1.75rem;
    color: #333;
    margin-bottom: 30px;
}

.kahoot-grade-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 15px auto;
    padding: 20px 40px;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kahoot-grade-btn:nth-child(1) { background: #e21b3c; color: white; }
.kahoot-grade-btn:nth-child(2) { background: #1368ce; color: white; }
.kahoot-grade-btn:nth-child(3) { background: #d89e00; color: white; }
.kahoot-grade-btn:nth-child(4) { background: #26890c; color: white; }

.kahoot-grade-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.kahoot-back-btn {
    margin-top: 30px;
    padding: 12px 24px;
    background: #666;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

/* Game screen */
.kahoot-game {
    padding: 20px;
    padding-bottom: 56px; /* Reserve space so exit button never overlaps answers */
    position: relative;
    min-height: 320px;
}

.kahoot-exit-game-btn {
    position: absolute;
    bottom: 16px;
    right: 20px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #46178f;
    background: rgba(70, 23, 143, 0.1);
    border: 1px solid rgba(70, 23, 143, 0.35);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.kahoot-exit-game-btn:hover {
    background: rgba(70, 23, 143, 0.2);
    border-color: rgba(70, 23, 143, 0.5);
}

.kahoot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px 20px;
    background: #46178f;
    color: white;
    border-radius: 12px;
}

.kahoot-score {
    font-size: 1.5rem;
    font-weight: 700;
}

.kahoot-question-number {
    font-size: 1rem;
    opacity: 0.9;
}

.kahoot-question-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    text-align: center;
}

.kahoot-question-text {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    line-height: 1.4;
}

/* Answer grid - 2x2 like Kahoot */
.kahoot-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 700px;
    margin: 0 auto 1rem;
}

.kahoot-answer-btn {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px 30px;
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: right;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kahoot-answer-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kahoot-shape {
    font-size: 2rem;
    opacity: 0.9;
}

.kahoot-answer-text {
    flex: 1;
}

/* Results screen */
.kahoot-results {
    text-align: center;
    padding: 60px 20px;
}

.kahoot-results h2 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 20px;
}

.kahoot-final-score {
    font-size: 4rem;
    font-weight: 900;
    color: #46178f;
    margin: 20px 0;
}

.kahoot-final-percentage {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 40px;
}

.kahoot-results-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.kahoot-results-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kahoot-play-again {
    background: linear-gradient(135deg, #e21b3c, #1368ce);
    color: white;
}

.kahoot-exit-btn {
    background: #666;
    color: white;
}

.kahoot-results-btn:hover {
    transform: scale(1.05);
}

/* RTL support */
[dir="rtl"] .kahoot-answer-btn {
    text-align: left;
    flex-direction: row-reverse;
}

/* Responsive */
@media (max-width: 768px) {
    .kahoot-answers {
        grid-template-columns: 1fr;
    }
    
    .kahoot-question-text {
        font-size: 1.35rem;
    }
    
    .kahoot-answer-btn {
        padding: 20px;
        font-size: 1.1rem;
    }
}
