:root {
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    --secondary-50: #ecfdf5;
    --secondary-100: #d1fae5;
    --secondary-200: #a7f3d0;
    --secondary-300: #6ee7b7;
    --secondary-400: #34d399;
    --secondary-500: #10b981;
    --secondary-600: #059669;
    --secondary-700: #047857;
    --secondary-800: #065f46;
    --secondary-900: #064e3b;

    --accent-50: #f0f9ff;
    --accent-100: #e0f2fe;
    --accent-200: #bae6fd;
    --accent-300: #7dd3fc;
    --accent-400: #38bdf8;
    --accent-500: #0ea5e9;
    --accent-600: #0284c7;
    --accent-700: #0369a1;
    --accent-800: #075985;
    --accent-900: #0c4a6e;
}

/* ============ Reset ============ */
* {
    --tw-bg-opacity: 1 !important;
}

/* ============ Space Utility Classes ============ */
.space-y-5 > * + * {
    margin-top: 1.25rem !important;
}

.space-y-4 > * + * {
    margin-top: 1rem !important;
}

.space-y-3 > * + * {
    margin-top: 0.75rem !important;
}

/* ============ Width Utility Classes ============ */
.max-w-2xl {
    max-width: 42rem !important;
}

.max-w-md {
    max-width: 28rem !important;
}

.max-w-4xl {
    max-width: 56rem !important;
}

/* ============ Padding Utility Classes ============ */
.p-10 {
    padding: 2.5rem !important;
}

/* ============ Grid Utility Classes ============ */
.grid {
    display: grid !important;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.gap-4 {
    gap: 1rem !important;
}

/* ============ Test Class for CSS Loading Check ============ */
.external-css-test {
    color: blue !important;
    font-weight: bold !important;
}

/* ============ Background Colors ============ */
.bg-primary-50 { background-color: var(--primary-50) !important; opacity: 1 !important; }
.bg-primary-100 { background-color: var(--primary-100) !important; opacity: 1 !important; }
.bg-primary-200 { background-color: var(--primary-200) !important; opacity: 1 !important; }
.bg-primary-500 { background-color: var(--primary-500) !important; opacity: 1 !important; }
.bg-primary-600 { background-color: var(--primary-600) !important; opacity: 1 !important; }
.bg-primary-700 { background-color: var(--primary-700) !important; opacity: 1 !important; }

.bg-secondary-50 { background-color: var(--secondary-50) !important; opacity: 1 !important; }
.bg-secondary-100 { background-color: var(--secondary-100) !important; opacity: 1 !important; }
.bg-secondary-500 { background-color: var(--secondary-500) !important; opacity: 1 !important; }
.bg-secondary-600 { background-color: var(--secondary-600) !important; opacity: 1 !important; }

.bg-accent-50 { background-color: var(--accent-50) !important; opacity: 1 !important; }

.bg-white { background-color: #ffffff !important; opacity: 1 !important; }
.bg-gray-50 { background-color: #f9fafb !important; opacity: 1 !important; }
.bg-slate-50 { background-color: #f8fafc !important; opacity: 1 !important; }
.bg-slate-100 { background-color: #f1f5f9 !important; opacity: 1 !important; }

/* ============ Text Colors ============ */
.text-primary-500 { color: var(--primary-500) !important; }
.text-primary-600 { color: var(--primary-600) !important; }
.text-primary-700 { color: var(--primary-700) !important; }
.text-secondary-600 { color: var(--secondary-600) !important; }
.text-accent-600 { color: var(--accent-600) !important; }

/* ============ Border Colors ============ */
.border-primary-200 { border-color: var(--primary-200) !important; }
.border-slate-200 { border-color: #e2e8f0 !important; }

/* ============ Focus Ring ============ */
.focus\:ring-primary-400:focus { --tw-ring-color: var(--primary-400) !important; }
.focus\:border-primary-400:focus { border-color: var(--primary-400) !important; }

/* ============ Rounded & Shadow ============ */
.rounded-2xl { border-radius: 1rem !important; }
.rounded-xl { border-radius: 0.75rem !important; }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04) !important; }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04) !important; }

/* ============ Page Background ============ */
.page-bg {
    background-color: #f8fafc;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.025) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(14, 165, 233, 0.025) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.02) 0%, transparent 50%);
}

/* ============ Header ============ */
.header-gradient {
    background: linear-gradient(135deg, #3730a3 0%, #4338ca 25%, #4f46e5 55%, #6366f1 100%);
    position: relative;
    overflow: hidden;
}

.header-gradient::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -5%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0%, transparent 70%);
    border-radius: 50%;
}

.header-gradient::after {
    content: '';
    position: absolute;
    bottom: -50%;
    left: -2%;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    border-radius: 50%;
}

.header-inner {
    position: relative;
    z-index: 1;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 2rem;
    padding: 0.375rem 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
}

/* ============ Navigation ============ */
.nav-wrap {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #64748b;
    border-radius: 0.5rem;
    transition: all 0.25s ease;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}

.nav-link.active {
    color: var(--primary-600);
    background: var(--primary-50);
    font-weight: 600;
}

.nav-separator {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 0.25rem;
}

/* ============ General Card ============ */
.card {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: box-shadow 0.3s ease;
}

.card-hoverable {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card-hoverable:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* ============ Card Accent Strip ============ */
.card-accent-purple {
    border-top: 3px solid var(--primary-500);
}

.card-accent-green {
    border-top: 3px solid var(--secondary-500);
}

.card-accent-blue {
    border-top: 3px solid var(--accent-500);
}

.card-accent-gray {
    border-top: 3px solid #94a3b8;
}

/* ============ Buttons ============ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    cursor: pointer;
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%);
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
    cursor: pointer;
    border: none;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-700) 100%);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: #ffffff;
    color: var(--primary-600);
    font-weight: 500;
    border-radius: 0.75rem;
    padding: 0.625rem 1.25rem;
    border: 2px solid var(--primary-200);
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-outline:hover {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

.btn-tab {
    padding: 0.5rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.25s ease;
    cursor: pointer;
    border: none;
    background: transparent;
}

.btn-tab:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-tab.active {
    background: #ffffff;
    color: var(--primary-600);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* ============ Form Input ============ */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    color: #334155;
    transition: all 0.25s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: #94a3b8;
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    color: #334155;
    transition: all 0.25s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.41 0L6 4.58L10.59 0L12 1.41L6 7.41L0 1.41L1.41 0Z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

/* ============ Quiz Options ============ */
.option-card {
    display: block;
    padding: 1rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
}

.option-card:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

.option-card input[type="radio"]:checked + span,
.option-card input[type="checkbox"]:checked + span {
    border-color: var(--primary-600);
}

.option-card:has(input:checked) {
    border-color: var(--primary-600);
    background: var(--primary-50);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.12);
}

.option-radio {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary-600);
    margin-right: 0.75rem;
    vertical-align: middle;
}

/* ============ Tables ============ */
.table-rounded {
    overflow: hidden;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.modern-table thead {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.modern-table th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.025em;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.modern-table td {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
}

.modern-table tbody tr {
    transition: background 0.15s ease;
}

.modern-table tbody tr:hover {
    background: #f8fafc;
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============ Stats Cards ============ */
.stat-card {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card-purple {
    border: 1px solid #e2e8f0;
    border-top: 3px solid var(--primary-500);
}

.stat-card-green {
    border: 1px solid #e2e8f0;
    border-top: 3px solid var(--secondary-500);
}

.stat-card-blue {
    border: 1px solid #e2e8f0;
    border-top: 3px solid var(--accent-500);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============ Quiz Progress Bar ============ */
.quiz-progress-bg {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ============ Tag/Badge ============ */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 2rem;
    letter-spacing: 0.01em;
}

.tag-purple {
    background: var(--primary-50);
    color: var(--primary-600);
}

.tag-blue {
    background: var(--accent-50);
    color: var(--accent-600);
}

.tag-green {
    background: var(--secondary-50);
    color: var(--secondary-600);
}

.tag-gray {
    background: #f1f5f9;
    color: #64748b;
}

/* ============ Result Page ============ */
.result-circle {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    animation: popIn 0.5s ease;
}

/* ============ Timer Pulse ============ */
.timer-urgent {
    animation: pulse 0.8s ease infinite;
}

/* ============ Animations ============ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    70% { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.anim-fade-in     { animation: fadeIn 0.5s ease forwards; }
.anim-fade-in-up  { animation: fadeInUp 0.5s ease forwards; }
.anim-delay-1 { animation-delay: 0.1s; opacity: 0; }
.anim-delay-2 { animation-delay: 0.2s; opacity: 0; }
.anim-delay-3 { animation-delay: 0.3s; opacity: 0; }
.anim-delay-4 { animation-delay: 0.4s; opacity: 0; }

/* ============ Modal ============ */
#modal .modal-content {
    background-color: #ffffff !important;
    opacity: 1 !important;
    background-image: none !important;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
}

/* ============ Rank Medals ============ */
.rank-gold   { color: #f59e0b; }
.rank-silver { color: #94a3b8; }
.rank-bronze { color: #fb923c; }

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}

.rank-badge-1 { background: #fef3c7; color: #92400e; }
.rank-badge-2 { background: #f1f5f9; color: #475569; }
.rank-badge-3 { background: #ffedd5; color: #9a3412; }
.rank-badge-n { background: #f8fafc; color: #94a3b8; }

/* ============ Tab Bar ============ */
.tab-bar {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 0.75rem;
    padding: 0.25rem;
}

/* ============ Footer ============ */
.site-footer {
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

/* ============ Color Strip for index rules ============ */
.rule-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-500);
    flex-shrink: 0;
    margin-top: 0.4rem;
}
