/* ==========================================================================
   Design System & Variables
   ========================================================================== */
   :root {
    /* Colors */
    --red: #E4002B;
    --red-dark: #b30022;
    --white: #FFFFFF;
    --gold: #FFD700;
    --gold-light: #ffe44d;
    --dark: #0a0a1a;
    --dark-card: #1a1a2e;
    --dark-surface: #16213e;
    --accent-blue: #0f3460;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --gray: #a0a0b5;
    
    /* Typography */
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-circle: 50%;
    
    /* Transitions */
    --transition-fast: all 0.2s ease;
    --transition-normal: all 0.3s ease;
    --transition-slow: all 0.5s ease;
    
    /* Shadows */
    --shadow-glow-red: 0 0 20px rgba(228, 0, 43, 0.4);
    --shadow-glow-gold: 0 0 20px rgba(255, 215, 0, 0.4);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: radial-gradient(circle at top right, var(--dark-surface), var(--dark) 70%);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--dark);
}
::-webkit-scrollbar-thumb {
    background: var(--red);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--red-dark);
}

/* Typography Base */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-gold { color: var(--gold); }
.text-red { color: var(--red); }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 2rem; }

.p-1 { padding: 1rem; }
.p-2 { padding: 2rem; }

.w-100 { width: 100%; }
.max-w-700 { max-width: 700px; }
.max-w-800 { max-width: 800px; }
.full-width { width: 100%; }

.flex-row { display: flex; flex-direction: row; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 2rem; }

.hidden { display: none !important; }

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
button {
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-normal);
}

.btn-primary {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: var(--white);
    padding: 12px 32px;
    border-radius: var(--radius-xl);
    font-size: 1.1rem;
    box-shadow: var(--shadow-glow-red);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(228, 0, 43, 0.6);
}

.btn-secondary {
    background: transparent;
    color: var(--white);
    padding: 12px 32px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    font-size: 1rem;
}

.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
}

.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(5px);
    z-index: 10;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
}

.glassmorphism {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* ==========================================================================
   Screen Management
   ========================================================================== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.4s ease forwards;
}

/* ==========================================================================
   Screen 1: Welcome
   ========================================================================== */
#screen-welcome.active {
    justify-content: center;
}

.particles-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.header {
    position: absolute;
    top: 30px;
    z-index: 10;
}

.logo-area img {
    max-height: 80px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.3));
}

.hero-area {
    position: relative;
    z-index: 10;
    max-width: 800px;
}

.badge-shimmer {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 30px;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    letter-spacing: 2px;
    animation: shimmer 2s infinite linear;
    background-image: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
    background-size: 200% 100%;
}

.main-title {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.highlight-81 {
    font-size: 8rem;
    font-weight: 900;
    background: linear-gradient(to right, var(--red), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    display: block;
    margin: 10px 0;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
}

.subtitle {
    font-size: 2.5rem;
    letter-spacing: 4px;
    margin-bottom: 1rem;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.date-badge {
    display: inline-block;
    background: var(--red);
    padding: 5px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.tagline {
    font-size: 1.1rem;
    color: var(--gray);
    margin-bottom: 2rem;
}

.description {
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto 3rem auto;
    color: #cccccc;
}

.pulse-btn {
    animation: pulse 2s infinite;
}

.footer {
    position: absolute;
    bottom: 20px;
    color: var(--gray);
    font-size: 0.8rem;
    z-index: 10;
}

/* ==========================================================================
   Screen 2: Register
   ========================================================================== */
#screen-register .card-container {
    width: 100%;
    max-width: 600px;
    padding: 40px;
    margin-top: 40px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #e0e0e0;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--white);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition-normal);
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: var(--shadow-glow-red);
}

.form-group select option {
    background: var(--dark-card);
    color: var(--white);
}

.mode-cards {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.mode-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-normal);
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
}

.mode-card.selected {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.05);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.mode-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.mode-card h3 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mode-card p {
    font-size: 0.75rem;
    color: var(--gray);
}

/* ==========================================================================
   Screen 3: Categories
   ========================================================================== */
.categories-header {
    margin-top: 30px;
}

.section-title {
    font-size: 2.5rem;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 1000px;
}

.category-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--category-color, var(--red));
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px var(--category-color-shadow, rgba(228, 0, 43, 0.3));
    background: rgba(255, 255, 255, 0.08);
}

.cat-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.cat-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.cat-desc {
    font-size: 0.85rem;
    color: var(--gray);
}

/* ==========================================================================
   Screen 4: Quiz
   ========================================================================== */
.quiz-top-bar {
    width: 100%;
    max-width: 700px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    margin-top: 20px;
}

.badge-gold {
    background: rgba(255, 215, 0, 0.15);
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.score-display {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
}

.timer-section {
    position: relative;
    width: 120px;
    height: 120px;
}

.timer-svg {
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--success);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.timer-warning .timer-progress { stroke: var(--warning); }
.timer-danger .timer-progress { stroke: var(--danger); }
.timer-danger .timer-text { color: var(--danger); animation: pulse 1s infinite; }

.question-section {
    padding: 30px;
    position: relative;
    overflow: hidden;
}

.progress-bar-container {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: rgba(255,255,255,0.1);
}

.progress-fill {
    height: 100%;
    width: 20%; /* Akan diupdate via JS */
    background: linear-gradient(90deg, var(--red), var(--gold));
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--gray);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 1.5rem;
    line-height: 1.4;
    margin-top: 10px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    color: var(--white);
    font-size: 1.1rem;
    text-align: left;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.option-btn:hover:not(.option-disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(8px);
    border-left: 4px solid var(--gold);
}

.option-correct {
    background: rgba(40, 167, 69, 0.2) !important;
    border-color: var(--success) !important;
    border-left: 4px solid var(--success) !important;
}

.option-wrong {
    background: rgba(220, 53, 69, 0.2) !important;
    border-color: var(--danger) !important;
    border-left: 4px solid var(--danger) !important;
    animation: shake 0.5s;
}

.option-disabled {
    pointer-events: none;
    opacity: 0.7;
}

.feedback-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.feedback-overlay.active {
    display: flex;
}

.feedback-icon {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-text {
    font-size: 2rem;
    font-family: var(--font-heading);
    font-weight: 700;
}

/* ==========================================================================
   Screen 5: Result
   ========================================================================== */
#confetti-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 50;
}

.result-card {
    padding: 40px;
    width: 100%;
    max-width: 600px;
    margin-top: 40px;
    position: relative;
    z-index: 60;
}

.result-name {
    font-size: 1.5rem;
    font-weight: 600;
}

.result-score-circle {
    width: 150px;
    height: 150px;
    border-radius: var(--radius-circle);
    background: conic-gradient(var(--gold) var(--score-deg, 0deg), rgba(255,255,255,0.1) 0deg);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    position: relative;
}

.result-score-circle::before {
    content: '';
    position: absolute;
    top: 10px; left: 10px; right: 10px; bottom: 10px;
    background: var(--dark-card);
    border-radius: var(--radius-circle);
}

#result-score-percent {
    position: relative;
    font-size: 2.5rem;
    font-weight: 800;
    font-family: var(--font-heading);
}

.result-detail {
    color: var(--gray);
    font-size: 1.1rem;
}

.result-grade {
    font-size: 4rem;
    font-weight: 900;
    font-family: var(--font-heading);
    line-height: 1;
    text-shadow: 0 0 20px currentColor;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-card {
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    padding: 15px 10px;
}

.stat-val { font-size: 1.5rem; font-weight: 700; }
.stat-lbl { font-size: 0.8rem; color: var(--gray); }

.result-answers {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    padding: 15px;
}

/* ==========================================================================
   Screen 6: Leaderboard
   ========================================================================== */
.leaderboard-container {
    padding: 30px;
    margin-top: 40px;
}

.filter-btn {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.filter-btn.active {
    background: var(--gold);
    color: var(--dark);
}

.table-responsive {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

th {
    color: var(--gray);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

tbody tr:hover {
    background: rgba(255,255,255,0.05);
}

.rank-1 td { background: rgba(255, 215, 0, 0.1); }
.rank-2 td { background: rgba(192, 192, 192, 0.1); }
.rank-3 td { background: rgba(205, 127, 50, 0.1); }

/* ==========================================================================
   Screen 7: Certificate
   ========================================================================== */
.certificate-container {
    margin-top: 40px;
}

.canvas-wrapper {
    overflow: hidden;
    max-width: 100%;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

@keyframes shimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.fadeInUp { animation: fadeInUp 0.6s ease forwards; }
.scaleIn { animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.delay-1 { animation-delay: 0.2s; }

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .main-title { font-size: 2rem; }
    .highlight-81 { font-size: 6rem; }
    .subtitle { font-size: 1.5rem; letter-spacing: 2px; }
    
    .mode-cards { flex-direction: column; }
    
    .screen { padding: 60px 15px 20px 15px; }
    .btn-back { top: 10px; left: 10px; font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .category-grid { grid-template-columns: 1fr; }
    .result-stats { grid-template-columns: 1fr; gap: 10px; }
    .btn-group { flex-direction: column; }
    
    .timer-section { width: 80px; height: 80px; }
    .timer-text { font-size: 1.5rem; }
    
    .question-text { font-size: 1.2rem; }
    .option-btn { font-size: 1rem; padding: 12px 16px; }
}
