/* Reset e variáveis - Paleta Verde Militar */
:root {
    --primary: #4B5320;          /* Verde militar (army green) */
    --primary-dark: #333D1F;     /* Verde militar escuro */
    --secondary: #6B8E23;        /* Verde oliva (olive drab) */
    --danger: #8B2E2E;           /* Vermelho terroso (alerta camuflado) */
    --warning: #C9A227;          /* Mostarda / caqui escuro */
    --success: #6B8E23;
    --acertos: #556B2F;          /* Verde-oliva escuro */
    --code-bg: #1B2410;          /* Fundo do bloco de código */
    --code-fg: #C9D9A8;          /* Texto do bloco de código */
    --gray-50: #F4F5EF;
    --gray-100: #E7EAD9;
    --gray-200: #D3D8C1;
    --gray-300: #B8C0A0;
    --gray-400: #8F9873;
    --gray-500: #707A52;
    --gray-600: #545C3C;
    --gray-700: #3D4329;
    --gray-800: #2A2F1C;
    --gray-900: #1A1E10;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(160deg, #2A2F1C 0%, #4B5320 55%, #3D4329 100%);
    min-height: 100vh;
    line-height: 1.6;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: white;
    border-radius: var(--radius);
    padding: 32px 24px;
    margin-bottom: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.logo-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.logo-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Alerts */
.alert {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: var(--shadow);
    border-left: 4px solid;
}

.alert-warning {
    border-left-color: var(--warning);
}

.alert-danger {
    border-left-color: var(--danger);
}

.alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-content strong {
    display: block;
    margin-bottom: 4px;
    color: var(--gray-800);
}

.alert-content p {
    color: var(--gray-600);
    font-size: 14px;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: var(--shadow);
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-2px);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    font-size: 20px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.feature-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.feature-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.feature-card h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.feature-card p {
    font-size: 13px;
    color: var(--gray-500);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-small {
    max-width: 400px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 24px;
    color: var(--gray-800);
}

.modal-body {
    padding: 24px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.info-section p {
    color: var(--gray-600);
    font-size: 15px;
}

.topic-list, .rules-list {
    list-style: none;
    padding: 0;
}

.topic-list li, .rules-list li {
    padding: 8px 0 8px 24px;
    position: relative;
    color: var(--gray-700);
    font-size: 15px;
}

.topic-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.rules-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-size: 20px;
}

.modal-actions {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Simulado */
.simulado-body {
    background: linear-gradient(160deg, #2A2F1C 0%, #4B5320 55%, #3D4329 100%);
}

.simulado-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.stats-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    background: white;
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
}

.honesty-notice {
    background: linear-gradient(135deg, #E8D9A0 0%, #C9A227 100%);
    color: #2A2F1C;
    padding: 12px 16px;
    border-radius: var(--radius);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    border: 2px solid #8F9873;
}

/* Bloco de código PHP dentro da questão */
.code-block {
    background: var(--code-bg);
    color: var(--code-fg);
    border: 2px solid var(--secondary);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    overflow-x: auto;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.code-block code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14.5px;
    line-height: 1.6;
    white-space: pre;
}

.option-text code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 15px;
}

.timer-warning {
    color: #C9A227 !important;
    animation: pulseTimer 1s infinite;
}

@keyframes pulseTimer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.stat-card.stat-highlight-score {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--acertos) 100%);
    color: white;
    grid-column: span 2;
    border: 2px solid #C9A227;
}

.stat-card.stat-highlight-score .stat-number {
    color: white;
    font-size: 42px;
}

.stat-card.stat-highlight-score .stat-label {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    letter-spacing: 1px;
}

.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.question-counter {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.question-topic {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.question-text {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 20px;
    line-height: 1.6;
}

.options-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 16px;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--gray-50);
    transform: translateX(4px);
}

.option-letter {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.option-text {
    flex: 1;
    color: var(--gray-800);
    line-height: 1.5;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0;
}

.preview-item {
    text-align: center;
}

.preview-item strong {
    display: block;
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 4px;
}

.preview-item span {
    font-size: 13px;
    color: var(--gray-600);
}

/* Result */
.result-body {
    background: linear-gradient(160deg, #2A2F1C 0%, #4B5320 55%, #3D4329 100%);
}

.result-header {
    background: white;
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.result-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.result-title {
    font-size: 28px;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.result-subtitle {
    color: var(--gray-600);
    font-size: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card.stat-highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    grid-column: span 2;
}

.stat-card .stat-number {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--gray-800);
}

.stat-card.stat-highlight .stat-number {
    color: white;
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--gray-600);
}

.stat-card.stat-highlight .stat-label {
    color: rgba(255, 255, 255, 0.9);
}

.performance-section {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.performance-section h2 {
    font-size: 22px;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-700);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-correct {
    background: var(--acertos);
}

.legend-wrong {
    background: var(--danger);
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.chart-label {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 15px;
}

.chart-numbers {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.chart-correct {
    color: var(--success);
}

.chart-wrong {
    color: var(--danger);
}

.chart-bar {
    height: 32px;
    background: var(--gray-100);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
}

.chart-bar-correct {
    background: var(--acertos);
    transition: width 0.5s ease;
}

.chart-bar-wrong {
    background: var(--danger);
    transition: width 0.5s ease;
}

.feedback-message {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.feedback-message strong {
    display: block;
    font-size: 20px;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.feedback-message p {
    color: var(--gray-600);
    font-size: 15px;
}

.survey-prompt {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.survey-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.survey-prompt strong {
    display: block;
    color: var(--gray-800);
    margin-bottom: 4px;
    font-size: 16px;
}

.survey-prompt p {
    color: var(--gray-600);
    font-size: 14px;
}

/* Survey Form */
.survey-form {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.question-box {
    margin-bottom: 28px;
}

.question-box:last-of-type {
    margin-bottom: 32px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
    font-size: 16px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
}

.radio-label:hover {
    background: white;
    border-color: var(--primary);
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.radio-label input[type="radio"]:checked ~ .radio-custom {
    border-color: var(--primary);
    background: var(--primary);
}

.radio-label input[type="radio"]:checked ~ .radio-custom::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.radio-label input[type="radio"]:checked ~ span:last-child {
    color: var(--primary);
    font-weight: 600;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
}

.footer p {
    color: white;
    font-size: 14px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .logo-title {
        font-size: 28px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature-card {
        display: flex;
        align-items: center;
        gap: 16px;
        text-align: left;
        padding: 16px;
    }

    .feature-icon {
        font-size: 40px;
        margin-bottom: 0;
    }

    .stats-header {
        grid-template-columns: 1fr;
    }

    .stat-item {
        justify-content: center;
    }

    .question-text {
        font-size: 16px;
    }

    .option-btn {
        font-size: 15px;
        padding: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card.stat-highlight {
        grid-column: span 1;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-content {
        margin: 0 16px;
    }
}

@media (max-width: 480px) {
    .logo-title {
        font-size: 24px;
    }

    .logo-subtitle {
        font-size: 12px;
    }

    .btn-large {
        padding: 14px 24px;
        font-size: 16px;
    }

    .result-title {
        font-size: 24px;
    }

    .stat-card .stat-number {
        font-size: 28px;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .btn {
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    input[type="radio"] {
        -webkit-appearance: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Mantém o design atual - não aplica dark mode */
}

/* Ranking */
.ranking-section { background: white; border-radius: var(--radius); padding: 22px; margin-bottom: 24px; box-shadow: var(--shadow); }
.ranking-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-kicker { color: var(--secondary); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; }
.ranking-header h2 { color: var(--gray-800); font-size: 22px; margin-top: 2px; }
.ranking-limit { color: var(--gray-500); background: var(--gray-100); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ranking-table-wrap { overflow-x: auto; }
.ranking-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ranking-table th { color: var(--gray-500); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; text-align: left; padding: 8px; border-bottom: 2px solid var(--gray-100); }
.ranking-table td { padding: 10px 8px; border-bottom: 1px solid var(--gray-100); color: var(--gray-600); white-space: nowrap; }
.ranking-table tr:last-child td { border-bottom: 0; }
.ranking-position { color: var(--primary) !important; font-weight: 800; width: 30px; }
.ranking-points { color: var(--primary) !important; font-weight: 800; text-align: right; }
.ranking-empty { color: var(--gray-500); text-align: center; padding: 12px 0 4px; }
.score-register { background: linear-gradient(135deg, #f4f5ef 0%, #e7ead9 100%); border: 2px solid var(--gray-200); border-radius: var(--radius); padding: 20px; margin: 24px 0; }
.score-register h2 { color: var(--primary); font-size: 20px; margin-bottom: 5px; }
.score-register p { color: var(--gray-600); font-size: 14px; margin-bottom: 14px; }
.score-form { display: flex; gap: 10px; align-items: stretch; }
.score-form input { flex: 1; min-width: 0; border: 2px solid var(--gray-300); border-radius: 8px; padding: 12px; font-size: 16px; color: var(--gray-800); background: white; }
.score-form input:focus { outline: 3px solid rgba(107, 142, 35, .25); border-color: var(--secondary); }
.score-form .btn { width: auto; white-space: nowrap; }
.saved-score { text-align: center; color: var(--primary); font-weight: 700; margin: 12px 0; }
.alert-text { color: var(--danger) !important; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media print {
    body.quiz-protected::before { content: 'A impressão desta tela está desabilitada.'; display: block; padding: 30px; font-size: 24px; }
    body.quiz-protected > * { display: none !important; }
}
@media (max-width: 480px) { .score-form { flex-direction: column; } .score-form .btn { width: 100%; } }

.ranking-summary { color: rgba(255, 255, 255, .92); text-align: center; margin: -8px 0 24px; font-size: 14px; }
.ranking-modal-content { max-width: 760px; max-height: 90vh; overflow-y: auto; }
.ranking-modal-subtitle { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.ranking-modal-content .modal-body { padding-top: 12px; }
.ranking-modal-content .ranking-table td, .ranking-modal-content .ranking-table th { padding: 11px 8px; }
.ranking-modal-content .btn { margin-top: 4px; }
