:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --success: #22c55e;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --success: #16a34a;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Accessibility: Focus visible outline & Screen reader utility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.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;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 10px;
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 10px;
}

.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    text-decoration: none;
}

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

.search-bar {
    flex: 1;
    max-width: 440px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar input {
    width: 100%;
    padding: 10px 42px 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.search-clear {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.search-clear:hover {
    background: var(--accent);
    color: white;
}

.search-clear.hidden {
    display: none !important;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-primary);
}

.btn-signup {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-signup:hover {
    background: var(--accent-hover);
}

.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 44px 24px 20px;
    text-align: center;
}

.hero h1 {
    font-size: 32px;
    margin-bottom: 12px;
}

.hero p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.quiz-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px 48px;
    flex-grow: 1;
    width: 100%;
}

#quizGrid {
    display: flex;
    flex-direction: column;
    gap: 36px;
    width: 100%;
}

.category-block {
    width: 100%;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s ease;
}

.category-header:hover {
    opacity: 0.8;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-icon {
    font-size: 14px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.category-block.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.category-block.collapsed .category-grid {
    display: none;
}

.category-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.quiz-count {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

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

@media (max-width: 992px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
}

.quiz-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.quiz-card:not(.disabled):hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.15);
}

.quiz-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.quiz-icon {
    font-size: 28px;
}

.badge-completed {
    background: var(--success);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

.badge-coming-soon {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(100, 116, 139, 0.25);
}

[data-theme="dark"] .badge-coming-soon {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.25);
}

.quiz-card.disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-disabled {
    background: var(--border);
    color: var(--text-secondary);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: not-allowed;
    opacity: 0.75;
}

.btn-share-icon {
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-share-icon:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.05);
}

.share-tooltip {
    position: absolute;
    bottom: -36px;
    right: 0;
    background: var(--accent);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.share-tooltip::after {
    content: '';
    position: absolute;
    top: -4px;
    right: 12px;
    border-width: 0 5px 5px 5px;
    border-style: solid;
    border-color: transparent transparent var(--accent) transparent;
}

.share-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.quiz-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.quiz-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.4;
    flex-grow: 1;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.quiz-questions {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-start {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-start:hover {
    background: var(--accent-hover);
}

.completed-actions {
    display: flex;
    gap: 8px;
}

.btn-retake {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-certificate {
    background: transparent;
    color: var(--success);
    border: 1px solid var(--success);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px 24px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.modal-card h2,
.modal-card h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.modal-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 24px;
}

.input-group input,
.form-field input,
.form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
}

.form-field {
    text-align: left;
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-modal {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-confirm {
    background: var(--accent);
    border: none;
    color: white;
}

/* Cookie Consent Sticky Bottom Banner */
.cookie-banner {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: 24px;
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 22px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.cookie-banner.hidden {
    display: none !important;
}

.cookie-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cookie-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.cookie-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cookie {
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reject {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-reject:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-standard {
    background: var(--accent);
    border: none;
    color: white;
}

.btn-standard:hover {
    background: var(--accent-hover);
}

/* Standard Certification Sticky Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    margin-top: auto;
    width: 100%;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.footer-nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    font-size: 14px;
}

.footer-nav-links a,
.btn-footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-nav-links a:hover,
.btn-footer-link:hover {
    color: var(--accent);
}

.footer-copyright {
    color: var(--text-secondary);
    font-size: 13px;
}

.footer-copyright a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.footer-disclaimer-note {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 800px;
    opacity: 0.8;
}

@media (max-width: 640px) {
    .header-container {
        flex-wrap: wrap;
    }

    .search-bar {
        order: 3;
        max-width: 100%;
    }

    .footer-nav-links {
        flex-direction: column;
        gap: 12px;
    }
}

/* iOS 3D Wheel Picker Empty Search State */
.no-results-card {
    text-align: center;
    padding: 40px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    max-width: 560px;
    margin: 20px auto;
    box-shadow: var(--shadow);
    width: 100%;
}

.no-results-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.no-results-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.search-term-highlight {
    color: var(--accent);
    background: rgba(124, 58, 237, 0.12);
    padding: 2px 10px;
    border-radius: 6px;
    word-break: break-word;
}

.no-results-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* iOS 3D Drum Picker Cylinder Container */
.picker-container {
    position: relative;
    height: 170px;
    max-width: 320px;
    margin: 0 auto 24px;
    perspective: 800px;
    overflow: hidden;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
    touch-action: none;
}

[data-theme="dark"] .picker-container {
    background: rgba(0, 0, 0, 0.25);
}

.picker-selection-lens {
    position: absolute;
    top: 50%;
    left: 12px;
    right: 12px;
    height: 44px;
    margin-top: -22px;
    background: rgba(124, 58, 237, 0.12);
    border-top: 1.5px solid var(--accent);
    border-bottom: 1.5px solid var(--accent);
    pointer-events: none;
    z-index: 10;
    border-radius: 8px;
}

.picker-wheel {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 44px;
    margin-top: -22px;
    transform-style: preserve-3d;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: grab;
}

.picker-wheel:active {
    cursor: grabbing;
}

.picker-item {
    position: absolute;
    left: 0;
    right: 0;
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    backface-visibility: hidden;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s, color 0.2s;
}

.picker-item.active {
    color: var(--accent);
    font-size: 17px;
    font-weight: 700;
}

.btn-picker-start {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-picker-start:hover {
    transform: translateY(-2px);
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

/* 404 & Disclaimer Special Pages Styling */
.special-page-hero {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px 24px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

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

.special-page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}

.special-page-body {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 28px;
    text-align: left;
}

.btn-primary-action {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.btn-primary-action:hover {
    background: var(--accent-hover);
}
