:root {
    /* Default variables - will be overridden by classes */
    --primary: #FFD700;
    --primary-dark: #E6C200;
    --bg: #000000;
    --card: #000000;
    --text: #FFFFFF;
    --gray: #aaaaaa;
    --border-color: #FFD700;
    --success: #4ade80;
    --error: #f87171;
    --success-bg: #14532d;
    --error-bg: #450a0a;
}

/* Tema Alto Contraste (Default) */
html.theme-contrast {
    --primary: #FFD700;
    --primary-dark: #E6C200;
    --bg: #000000;
    --card: #000000;
    --text: #FFFFFF;
    --gray: #aaaaaa;
    --border-color: #FFD700;
    --success: #4ade80;
    --error: #f87171;
    --success-bg: #14532d;
    --error-bg: #450a0a;
}

/* Tema Claro (Blanco y Negro) */
html.theme-light {
    --primary: #000000;
    --primary-dark: #333333;
    --bg: #ffffff;
    --card: #f3f4f6;
    --text: #000000;
    --gray: #4b5563;
    --border-color: #000000;
    --success: #15803d;
    --error: #b91c1c;
    --success-bg: #dcfce7;
    --error-bg: #fee2e2;
}

/* Tema Sepia (Lectura Suave) */
html.theme-sepia {
    --primary: #5c4033; /* Marrón oscuro */
    --primary-dark: #3e2723;
    --bg: #f5f5dc; /* Beige crema */
    --card: #e8e4c9;
    --text: #3e2723;
    --gray: #795548;
    --border-color: #8d6e63;
    --success: #388e3c;
    --error: #d32f2f;
    --success-bg: #c8e6c9;
    --error-bg: #ffcdd2;
}

html {
    font-size: 18px;
}

html.font-medium {
    font-size: 18px;
}

html.font-large {
    font-size: 22px;
}

html.font-xlarge {
    font-size: 26px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh; /* Adapt to mobile viewport height */
}

#app {
    width: 100%;
    max-width: 600px;
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    padding: 20px;
    flex: 1;
}

.screen.active {
    display: flex;
}

/* Home Screen */
#home-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
}

h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 1rem;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.config-box {
    margin: 2rem 0;
    padding: 1rem;
    background: var(--card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.font-size-buttons, .theme-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.font-btn, .theme-btn {
    width: auto;
    flex: 1;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.font-btn.active, .theme-btn.active {
    background: var(--primary);
    color: var(--bg); /* Adapts to theme background */
}

input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 80px;
    text-align: center;
}

/* Quiz Screen */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--gray);
    font-weight: 500;
}

.text-btn {
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    font-size: 0.9rem;
}

.question-card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.meta-info {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 10px;
}

#q-prompt {
    font-size: 1.1rem;
    line-height: 1.5;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

#q-image-container {
    margin: 1rem 0;
    text-align: center;
}

#q-image {
    max-width: 100%;
    max-height: 300px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white; /* Ensure visibility in dark mode */
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-btn {
    background: var(--card);
    color: var(--text);
    border: 1px solid #ddd;
    padding: 16px;
    border-radius: 8px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    white-space: normal;
    line-height: 1.4;
}

.choice-btn::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid currentColor;
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
}

.choice-btn:active {
    background: #eef2ff;
    border-color: var(--primary);
    transform: scale(0.99);
}

.choice-selected {
    border: 3px solid var(--primary) !important;
    background-color: var(--primary) !important;
    color: var(--bg) !important;
    font-weight: bold;
}

.choice-selected::before {
    background-color: var(--bg);
    border-color: var(--bg);
    box-shadow: inset 0 0 0 4px var(--primary);
}


/* Results Screen */
#result-screen {
    align-items: center;
}

.feedback-message {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
}

.feedback-success {
    color: var(--success);
    background-color: var(--success-bg);
    border: 1px solid var(--success);
}

.feedback-fail {
    color: var(--error);
    background-color: var(--error-bg);
    border: 1px solid var(--error);
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 8px solid var(--primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
}

#score-text {
    font-size: 1.5rem;
    font-weight: bold;
}

#score-pct {
    font-size: 1rem;
    color: var(--gray);
}

#review-list {
    width: 100%;
    text-align: left;
    margin-bottom: 2rem;
}

/* Review Items */
.review-item {
    background: var(--card);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.item-wrong {
    border-left: 4px solid var(--error);
}

.item-correct {
    border-left: 4px solid var(--success);
}

.review-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--gray);
}

.review-q {
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.review-choices {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.review-choice {
    padding: 8px 12px;
    border-radius: 6px;
    background: transparent;
    font-size: 0.95rem;
    border: 1px solid var(--gray);
    color: var(--text);
}

.choice-correct {
    background-color: var(--success-bg);
    color: var(--text);
    border-color: var(--success);
    font-weight: 500;
}

.choice-wrong {
    background-color: var(--error-bg);
    color: var(--text);
    border-color: var(--error);
    text-decoration: line-through;
}

.choice-user-correct {
    /* Special style if user selected correct answer (optional, same as correct) */
    background-color: var(--success-bg);
    border: 2px solid var(--success);
}


/* Buttons */
button {
    background: var(--bg);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

button:disabled {
    background: #333;
    border-color: #555;
    color: #777;
    cursor: not-allowed;
}

button:active {
    background: var(--primary);
    color: black;
}

.font-btn.active {
    background: var(--primary);
    color: black;
}

input, select {
    background: black;
    color: white;
    border: 1px solid var(--primary);
    padding: 8px;
    border-radius: 4px;
}

/* Navigation Buttons */
.nav-buttons {
    display: flex;
    gap: 12px;
    margin-top: auto; /* Push to bottom */
    padding-top: 20px;
}

.nav-btn {
    flex: 1;
}
