:root {
    --bg-dark: #0a0b10;
    --app-bg: #12141d;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #f43f5e;     
    --primary-hover: #e11d48;
    --success: #10b981;
    --error: #ef4444;
    --font: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--app-bg);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.1);
}

.btn {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: none;
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #b91c1c);
    color: #fff;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.2);
}

.secondary-btn {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--card-border);
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-family: var(--font);
    font-size: 1rem;
    padding: 10px;
    margin-top: 10px;
    cursor: pointer;
}

.text-btn:hover {
    color: var(--text-main);
}

#home-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle at top, rgba(244,63,94,0.1) 0%, transparent 60%);
}

.brand {
    margin-bottom: 60px;
}

.brand h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.brand h1 span {
    color: var(--primary);
}

.brand p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.menu-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-wrap {
    position: relative;
    width: 100%;
}

.badge {
    position: absolute;
    top: -10px;
    right: -5px;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 20px;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.series-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-bottom: 40px;
}

.series-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 3/4;
    cursor: pointer;
    border: 1px solid var(--card-border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.series-card:active {
    transform: scale(0.96);
}

.series-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 3s ease;
}

.series-card:hover img {
    transform: scale(1.05);
}

.series-card .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    display: flex;
    align-items: flex-end;
    padding: 16px;
}

.series-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    line-height: 1.2;
}

.setup-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
}

.selected-series-preview {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--primary);
    text-align: center;
    background: var(--card-bg);
    padding: 12px 24px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

.setup-content h3 {
    margin-bottom: 24px;
    font-weight: 500;
    color: var(--text-muted);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.setup-opt-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 24px 0;
    font-size: 1.25rem;
}

.setup-opt-btn:active {
    background: rgba(255,255,255,0.08);
}

.quiz-header {
    margin-bottom: 30px;
    justify-content: space-between;
}

.progress-bar-container {
    flex: 1;
    height: 8px;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 16px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 10%;
    transition: width 0.3s ease;
}

#quiz-progress-text {
    font-weight: 600;
    font-size: 1.1rem;
}

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.media-container {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
    max-height: 200px;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.media-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.media-container.hidden {
    display: none;
}

.question-text {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 30px;
}

.answers-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-btn {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: 16px;
    font-family: var(--font);
    font-size: 1.1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    transition-property: background-color, border-color, transform;
}

.answer-btn:active {
    transform: scale(0.98);
}

.answer-btn.correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
}

.answer-btn.wrong {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
}

.answer-btn:disabled {
    cursor: default;
}

.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.result-content h2 {
    font-size: 2.5rem;
    margin-bottom: 30px;
}

.score-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0%, var(--card-bg) 0%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 0 0 30px rgba(244, 63, 94, 0.2);
    position: relative;
    overflow: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.score-circle::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    top: 15px;
    left: 15px;
    background-color: var(--app-bg);
    border-radius: 50%;
    z-index: 0;
}

.score-circle span, .score-circle small {
    position: relative;
    z-index: 1;
}

.score-circle span {
    font-size: 4rem;
    font-weight: 700;
}

.score-circle small {
    font-size: 1.2rem;
    color: var(--text-muted);
}

#result-message {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.save-score-form {
    width: 100%;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
}

.save-score-form input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 16px;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 1.1rem;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.save-score-form input:focus {
    border-color: var(--primary);
}

.leaderboard-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.leaderboard-series-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--card-bg);
    padding: 12px;
    border-radius: 12px;
}

.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

.lb-rank {
    font-size: 1.2rem;
    font-weight: 700;
    width: 30px;
    color: var(--text-muted);
}

.leaderboard-item:nth-child(1) .lb-rank { color: #fbbf24; } 
.leaderboard-item:nth-child(2) .lb-rank { color: #9ca3af; } 
.leaderboard-item:nth-child(3) .lb-rank { color: #b45309; } 

.lb-name {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 500;
}

.lb-score {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}
