* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.screen {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    color: #667eea;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.home-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.option-card {
    background: #f8f9fa;
    border: 3px dashed #d0d0d0;
    border-radius: 16px;
    padding: 40px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.option-card:hover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.option-card.drag-over {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option-card .icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.option-card h2 {
    color: #333;
    font-size: 1.5em;
    margin-bottom: 10px;
}

.option-card p {
    color: #666;
    margin-bottom: 20px;
}

.join-section {
    margin-top: 40px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 16px;
    text-align: center;
}

.join-section h3 {
    color: #667eea;
    margin-bottom: 20px;
}

.join-form {
    display: flex;
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.join-form input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
    text-align: center;
}

.join-form .btn-primary {
    flex: 0 0 auto;
    padding: 12px 25px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.header-nav h1 {
    margin: 0;
    flex: 1;
}

.btn-back {
    background: #f5f5f5;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #e0e0e0;
}

.config-section {
    margin-bottom: 25px;
}

label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

input, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
}

small {
    color: #666;
    font-size: 0.85em;
}

small a {
    color: #667eea;
    text-decoration: none;
}

.api-key-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.api-key-container input {
    flex: 1;
}

.btn-icon {
    padding: 12px 16px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #e8e8ff;
    border-color: #667eea;
}

.api-key-actions {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.9em;
}

.difficulty-select {
    padding: 12px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.mode-toggle {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    background: #f5f5f5;
    color: #666;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: #e8e8ff;
    border-color: #667eea;
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.action-buttons {
    display: flex;
    gap: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header label {
    margin: 0;
}

.input-mode-toggle {
    display: flex;
    gap: 5px;
}

.input-mode-btn {
    padding: 6px 12px;
    background: #f5f5f5;
    color: #666;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.input-mode-btn:hover {
    background: #e8e8ff;
    border-color: #667eea;
}

.input-mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.visual-questions {
    display: block;
}

.raw-questions {
    display: block;
}

.hidden {
    display: none !important;
}

.question-card-edit {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s;
}

.question-card-edit:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-number {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
}

.btn-delete {
    background: #ffebee;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #f44336;
    transform: scale(1.1);
}

.question-card-edit input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.question-card-edit input:focus {
    outline: none;
    border-color: #667eea;
}

.question-card-edit .question-input {
    font-weight: 600;
    font-size: 1.05em;
}

.question-card-edit .correct-answer {
    border-color: #4caf50;
    background: #f1f8f4;
}

.btn-add {
    width: 100%;
    padding: 15px;
    background: #f5f5f5;
    color: #667eea;
    border: 2px dashed #667eea;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: #e8e8ff;
    border-style: solid;
}

.btn-primary {
    flex: 1;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e8e8ff;
    border-color: #667eea;
    color: #667eea;
}

.quiz-header {
    margin-bottom: 30px;
}

.timer-bar {
    width: 100%;
    height: 12px;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.1);
    position: relative;
}

.timer-bar::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    height: 4px;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
    border-radius: 20px 20px 0 0;
    pointer-events: none;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        #00e676 0%, 
        #69f0ae 20%,
        #b2ff59 40%, 
        #ffeb3b 60%, 
        #ff9800 80%, 
        #f44336 100%);
    background-size: 200% 100%;
    border-radius: 20px;
    transition: width 0.1s linear;
    width: 100%;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5), inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
}

.timer-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
    border-radius: 20px;
}

.timer-fill.low {
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
    animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-fill.critical {
    box-shadow: 0 0 25px rgba(244, 67, 54, 0.7), inset 0 1px 0 rgba(255,255,255,0.3);
    animation: timerPulse 0.3s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; transform: scaleY(1); }
    50% { opacity: 0.85; transform: scaleY(0.95); }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    width: 0%;
}

.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 10px;
}

.streak-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    animation: bounceIn 0.3s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.question-card {
    margin-bottom: 30px;
}

#question-text {
    color: #333;
    font-size: 1.8em;
    line-height: 1.4;
    margin-bottom: 30px;
}

.difficulty-badge {
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.difficulty-badge.fácil,
.difficulty-badge.facil {
    background: #4caf50;
    color: white;
}

.difficulty-badge.media {
    background: #ff9800;
    color: white;
}

.difficulty-badge.difícil,
.difficulty-badge.dificil {
    background: #f44336;
    color: white;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.option-btn {
    padding: 20px;
    background: #f5f5f5;
    border: 3px solid transparent;
    border-radius: 12px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.option-btn:hover {
    background: #e8e8ff;
    border-color: #667eea;
    transform: scale(1.02);
}

.option-btn.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
}

.option-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
}

.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.feedback {
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.feedback.hidden {
    display: none;
}

.feedback.correct {
    background: #e8f5e9;
    color: #2e7d32;
}

.feedback.incorrect {
    background: #ffebee;
    color: #c62828;
}

.results-summary {
    display: flex;
    justify-content: space-around;
    margin: 40px 0;
    flex-wrap: wrap;
    gap: 20px;
}

.results-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.results-actions .btn-primary,
.results-actions .btn-secondary {
    flex: 1;
}

.leaderboard-section {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 16px;
}

.leaderboard-section h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.leaderboard-entry.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.leaderboard-entry.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #e8a860 100%);
    color: white;
}

.leaderboard-position {
    font-size: 1.5em;
    font-weight: 700;
    width: 50px;
    text-align: center;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: 600;
    font-size: 1.1em;
}

.leaderboard-details {
    font-size: 0.85em;
    opacity: 0.8;
}

.leaderboard-score {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
}

.leaderboard-entry.gold .leaderboard-score,
.leaderboard-entry.bronze .leaderboard-score {
    color: inherit;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 15px;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
}

.modal-content input {
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.2em;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.share-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
}

.share-code span {
    font-size: 2em;
    font-weight: 700;
    letter-spacing: 5px;
    color: #667eea;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
    min-width: 150px;
}

.stat-value {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #666;
    margin-top: 5px;
    font-size: 1.1em;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.loading p {
    color: white;
    font-size: 1.2em;
    margin-top: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .screen {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    #question-text {
        font-size: 1.3em;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}

/* Quizzes Grid */
.quizzes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.quiz-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.quiz-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

.quiz-card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.quiz-card-info {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.quiz-card-stats {
    font-size: 0.85em;
    color: #888;
}

.modal-large {
    max-width: 500px;
}

.quiz-code-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    display: inline-block;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.quiz-code-display strong {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    margin-left: 8px;
}

.quiz-detail-info {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

#detail-leaderboard {
    margin: 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

#detail-leaderboard h3 {
    margin-bottom: 15px;
    text-align: center;
    color: #667eea;
}

.no-scores {
    text-align: center;
    color: #888;
    padding: 20px;
}

.no-quizzes {
    text-align: center;
    color: #888;
    padding: 40px;
    font-size: 1.1em;
}