:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --accent: #e74c3c;
    --bg: #ecf0f1;
    --text: #2c3e50;
    --border: #bdc3c7;
    --success: #27ae60;
    --warning: #f39c12;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

header {
    background: var(--primary);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

header p {
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

/* Hamburger menu button - hidden on desktop */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

header {
    position: relative;
}

nav {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

nav button {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

nav button:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

nav button.active {
    background: var(--secondary);
    border-color: var(--secondary);
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.section {
    display: none;
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section.active {
    display: block;
}

.controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-weight: 500;
}

.controls select {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 5px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

#comparison-table {
    overflow-x: auto;
    overflow-y: auto;
    max-width: 100%;
    max-height: 70vh;
    position: relative;
    /* Enable hardware acceleration for better mobile performance */
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
    position: relative;
}

thead {
    position: sticky;
    top: 0;
    z-index: 100;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* Force GPU acceleration on mobile */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Prevent visual glitches */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Sticky first column */
th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
}

th:first-child {
    z-index: 110; /* Higher than other headers to stay on top when scrolling both directions */
    background: var(--primary);
    box-shadow: 4px 0 8px rgba(0,0,0,0.15);
    border-right: 1px solid rgba(255,255,255,0.2);
}

td:first-child {
    background: white !important;
    box-shadow: 4px 0 8px rgba(0,0,0,0.1);
    border-right: 1px solid var(--border);
}

tr:hover td:first-child {
    background: #f5f9fc !important;
}

tr.selected-row td:first-child {
    background: #d9f2e4 !important;
    box-shadow: 4px 0 8px rgba(0,0,0,0.1);
    border-right: 1px solid var(--border);
}

tr.selected-row:hover td:first-child {
    background: #c9edda !important;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: var(--secondary);
}

tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

tr.selected-row {
    background: rgba(39, 174, 96, 0.15);
    border-left: 4px solid var(--success);
}

tr.selected-row:hover {
    background: rgba(39, 174, 96, 0.2);
}

.score {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-align: center;
    min-width: 2rem;
}

.score-5 { background: #27ae60; color: white; }
.score-4 { background: #2ecc71; color: white; }
.score-3 { background: #f39c12; color: white; }
.score-2 { background: #e67e22; color: white; }
.score-1 { background: #e74c3c; color: white; }

.tradition-name {
    font-weight: 600;
    color: var(--secondary);
}

.tradition-name-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-icon {
    color: var(--secondary);
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.info-icon:hover {
    opacity: 1;
}

.tradition-popover {
    display: none;
    position: fixed;
    z-index: 1000;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 300px;
    max-width: 400px;
    max-height: 50vh;
    overflow-y: auto;
    pointer-events: auto;
}

/* On mobile, show as bottom sheet */
@media (max-width: 768px) {
    .tradition-popover {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto !important;
        max-width: 100%;
        width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
        padding: 1.5rem;
        padding-bottom: 2rem;
    }

    .tradition-popover::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 0 auto 1rem;
    }
}

.popover-description {
    margin-bottom: 0.75rem;
    color: var(--text);
    line-height: 1.5;
}

.popover-practices,
.popover-time {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.popover-practices strong,
.popover-time strong {
    color: var(--primary);
}

.tradition-origin {
    font-size: 0.85rem;
    color: #7f8c8d;
}

#evolution-tree {
    min-height: 600px;
    position: relative;
}

#evolution-tree svg {
    width: 100%;
    height: 600px;
}

.node circle {
    fill: var(--secondary);
    stroke: var(--primary);
    stroke-width: 2px;
    cursor: pointer;
}

.node:hover circle {
    fill: var(--accent);
}

.node text {
    font-size: 12px;
    fill: var(--text);
}

.link {
    fill: none;
    stroke: var(--border);
    stroke-width: 2px;
}

.content {
    max-width: 800px;
}

.content h2 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 2rem;
}

.content h3 {
    color: var(--secondary);
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.content ul {
    margin-left: 2rem;
    margin-top: 0.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content a {
    color: var(--secondary);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

footer {
    text-align: center;
    padding: 2rem;
    color: #7f8c8d;
    margin-top: 4rem;
}

footer a {
    color: var(--secondary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Collapsible dimension legend */
details.dimension-legend summary span {
    transition: transform 0.2s;
}

details.dimension-legend[open] summary span {
    transform: rotate(90deg);
}

/* Quiz Styles */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-step {
    display: none;
}

.quiz-step.active {
    display: block;
}

#quiz-intro {
    text-align: center;
    padding: 3rem 2rem;
}

#quiz-intro h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

#quiz-intro p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: var(--text);
    opacity: 0.8;
}

.primary-button {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-button:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.primary-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

/* Finder hero */
.finder-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.finder-hero h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.finder-hero p {
    font-size: 1.15rem;
    color: #666;
}

/* Finder tabs */
.finder-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 2px solid #e0e0e0;
    background: white;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    border-radius: 10px;
}

.tab-icon {
    font-size: 1.1rem;
}

.tab-button.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.tab-button:hover:not(.active) {
    border-color: var(--secondary);
    color: var(--secondary);
}

/* Finder card */
.finder-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.finder-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

.finder-content.active {
    display: block;
}

.finder-description {
    font-size: 1rem;
    color: #555;
    margin-bottom: 1.5rem;
    text-align: center;
}

.finder-cta {
    display: block;
    margin: 0 auto;
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
}

.finder-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #999;
    margin-top: 1rem;
}

/* Filter checkbox */
.filter-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
}

.filter-checkbox input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.finder-disclaimer {
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    margin-top: 1rem;
}

/* Chat form */
.chat-form {
    display: flex;
    gap: 0.5rem;
}

.chat-form input {
    flex: 1;
    padding: 0.85rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--secondary);
}

.chat-form button {
    padding: 0.85rem 1.5rem;
    border-radius: 10px;
}

.chat-response {
    display: none;
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: left;
    line-height: 1.7;
}

.chat-response:not(:empty) {
    display: block;
}

/* Chat recommendation styles */
.chat-recommendations {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.recommendation-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1rem;
    transition: border-color 0.2s;
}

.recommendation-item:hover {
    border-color: var(--secondary);
}

.rec-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.rec-header strong {
    color: var(--primary);
    font-size: 1.05rem;
}

.rec-tradition {
    font-size: 0.85rem;
    color: #666;
}

.tradition-link {
    color: var(--secondary);
    text-decoration: none;
}

.tradition-link:hover {
    text-decoration: underline;
}

.rec-why {
    color: #555;
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.rec-try {
    background: #e8f4f8;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin: 0.75rem 0;
}

.try-label {
    color: var(--secondary);
    font-weight: 600;
}

.rec-actions {
    margin-top: 0.5rem;
}

.action-link {
    font-size: 0.85rem;
    color: var(--secondary);
    text-decoration: none;
}

.action-link:hover {
    text-decoration: underline;
}

/* Deeper exploration invitation */
.deeper-exploration {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e8f4f8 100%);
    border-radius: 10px;
    border-left: 3px solid var(--secondary);
}

.explore-note {
    font-size: 0.9rem;
    color: #555;
    margin: 0 0 1rem 0;
    font-style: italic;
}

.explore-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.secondary-button.small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.chat-note {
    font-size: 0.85rem;
    color: #888;
    margin-top: 1rem;
    text-align: center;
}

/* Finder links */
.finder-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.finder-links a {
    color: #888;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.finder-links a:hover {
    color: var(--secondary);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .finder-hero h2 {
        font-size: 1.8rem;
    }

    .finder-tabs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tab-button {
        justify-content: center;
    }

    .finder-card {
        padding: 1.5rem;
        margin: 0 1rem;
    }

    .chat-form {
        flex-direction: column;
    }

    .chat-form button {
        width: 100%;
    }
}

.secondary-button {
    background: white;
    color: var(--secondary);
    border: 2px solid var(--secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.secondary-button:hover {
    background: var(--bg);
}

.question-progress {
    text-align: center;
    margin-bottom: 2rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--success));
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.question-progress span {
    font-size: 0.9rem;
    color: var(--secondary);
    font-weight: 600;
}

#questionContainer h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.question-hint {
    font-size: 0.9rem;
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 1rem;
    font-style: italic;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.option-checkbox,
.option-radio {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.option-checkbox:hover,
.option-radio:hover {
    border-color: var(--secondary);
    background: rgba(52, 152, 219, 0.05);
}

.option-checkbox input,
.option-radio input {
    margin-right: 1rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.option-checkbox input:checked + span,
.option-radio input:checked + span {
    font-weight: 600;
    color: var(--secondary);
}

.option-checkbox:has(input:checked),
.option-radio:has(input:checked) {
    border-color: var(--secondary);
    background: rgba(52, 152, 219, 0.1);
}

.quiz-navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

/* Results Styles */
.recommendations {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.recommendation-card {
    position: relative;
    padding: 1.5rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    transition: all 0.3s;
}

.recommendation-card:hover {
    border-color: var(--secondary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.recommendation-rank {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--secondary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.recommendation-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    padding-right: 60px;
}

.recommendation-card p {
    margin-bottom: 1rem;
}

.recommendation-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.detail-item {
    font-size: 0.95rem;
}

.detail-item strong {
    color: var(--primary);
    display: block;
    margin-bottom: 0.25rem;
}

#restartQuiz {
    display: block;
    margin: 2rem auto 0;
}

/* Form Styles */
.form-container {
    max-width: 600px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--primary);
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
    background: white;
}

.form-group input[type="email"]:focus,
.form-group input[type="text"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary);
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.form-group label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    margin-right: 1.5rem;
    font-weight: normal;
    cursor: pointer;
}

.form-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 5px;
    display: none;
}

.form-message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.form-container button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    /* Reduce header padding */
    header {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.4rem;
        padding-right: 2.5rem;
        margin-bottom: 0.25rem;
    }

    header p {
        font-size: 0.8rem;
        margin-bottom: 0;
        padding-right: 2.5rem;
    }

    /* Show hamburger on mobile */
    .hamburger {
        display: flex;
        top: 1rem;
        right: 1rem;
    }

    /* Mobile nav - vertical dropdown */
    nav {
        display: none;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.75rem 0 0 0;
        margin-top: 0.75rem;
        border-top: 1px solid rgba(255,255,255,0.2);
    }

    nav.open {
        display: flex;
    }

    nav button {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        text-align: left;
        border-radius: 6px;
        border: none;
        background: transparent;
    }

    nav button:hover {
        background: rgba(255,255,255,0.1);
    }

    nav button.active {
        background: var(--secondary);
    }

    /* Full width on mobile */
    main {
        margin: 0;
        padding: 0;
    }

    .section {
        padding: 1rem;
        border-radius: 0;
        box-shadow: none;
    }

    /* Finder section tighter */
    .finder-hero {
        margin-bottom: 1rem;
    }

    .finder-hero h2 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    .finder-hero p {
        font-size: 0.9rem;
    }

    .finder-tabs {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        flex: 1;
    }

    .finder-card {
        max-width: 100%;
        margin: 0;
        border-radius: 10px;
        padding: 1rem;
    }

    .finder-description {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .chat-form {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chat-form input {
        width: 100%;
        padding: 0.75rem;
    }

    .chat-form button {
        width: 100%;
        padding: 0.75rem;
    }

    /* Quiz landing page mobile */
    #quiz-intro h2 {
        font-size: 1.8rem !important;
    }

    #quiz-intro p {
        font-size: 1rem !important;
    }

    #quiz-intro .primary-button {
        font-size: 1rem !important;
        padding: 0.75rem 1.5rem !important;
    }

    #quiz-intro a {
        display: block;
        margin: 0.5rem 0 !important;
    }

    #quiz-intro span {
        display: none;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .controls label {
        width: 100%;
        max-width: 100%;
    }

    .controls select {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .dimension-legend {
        max-width: 100% !important;
        width: 100%;
    }

    /* Stack visualizations vertically on mobile */
    .visualization-grid {
        grid-template-columns: 1fr !important;
    }

    .form-group label:has(input[type="checkbox"]) {
        display: flex;
        margin-bottom: 0.5rem;
    }

    /* Reduce chart sizes on mobile */
    .visualization-grid canvas,
    .visualization-grid > div {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Override inline max-width for radar chart container */
    .visualization-grid > div > div {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Ensure complexity section containers don't overflow */
    #complexity-section .visualization-grid > div {
        overflow: hidden;
    }

    /* Complexity table sticky column fix */
    #complexityTable td:first-child {
        background: white;
        box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    }
    #complexityTable tr.selected-row td:first-child {
        background: #d9f2e4;
    }
    #complexityTable tr:hover td:first-child {
        background: #f5f9fc;
    }
    #complexityTable tr.selected-row:hover td:first-child {
        background: #c9edda;
    }

    #scatterPlot,
    #violinPlot,
    #verticalViolinPlot {
        min-height: 300px !important;
        width: 100% !important;
        overflow-x: auto;
    }

    /* Ensure canvas elements fit container */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.4rem;
    }

    #quiz-intro h2 {
        font-size: 1.5rem;
    }

    #questionContainer h3 {
        font-size: 1.2rem;
    }

    .quiz-navigation {
        flex-direction: column;
    }

    .recommendation-details {
        grid-template-columns: 1fr;
    }

    /* Attention mapping mobile styles */
    #attention-section .pathway-grid {
        grid-template-columns: 1fr !important;
    }

    #attention-section table {
        font-size: 0.85rem;
    }

    #attention-section table th,
    #attention-section table td {
        padding: 0.5rem;
    }

    /* Make tradition details more compact on mobile */
    #traditionDetails .meta {
        grid-template-columns: 1fr !important;
    }

    /* Improve button spacing on mobile */
    .controls button,
    #toggleTableRows {
        margin-top: 0.5rem;
    }

    /* Header tagline */
    header p {
        font-size: 0.9rem;
    }

    /* Ensure touch targets are large enough */
    nav button {
        min-height: 44px;
    }

    /* Attention pathway boxes on mobile */
    #attention-section [style*="grid-template-columns: 200px"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #attention-section [style*="grid-template-columns: 200px"] > div {
        width: 100% !important;
    }
}

/* Medium screens (tablets) */
@media (min-width: 769px) and (max-width: 1024px) {
    .visualization-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .visualization-grid > div:last-child {
        grid-column: 1 / -1;
    }
}

/* Explore section tabs */
.explore-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.explore-tab {
    padding: 0.75rem 1.5rem;
    border: 2px solid #e0e0e0;
    background: white;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    border-radius: 8px;
}

.explore-tab:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

.explore-tab.active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.explore-content {
    display: none;
}

.explore-content.active {
    display: block;
}

@media (max-width: 768px) {
    .explore-tabs {
        flex-wrap: wrap;
    }

    .explore-tab {
        flex: 1;
        min-width: 100px;
        text-align: center;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-close:hover {
    color: var(--primary);
}

/* Auth styles */
.auth-button {
    background: transparent !important;
    border: 2px solid rgba(255,255,255,0.5) !important;
    color: white !important;
}

.auth-button:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: white !important;
}

/* Profile dropdown */
.profile-dropdown {
    position: relative;
}

.profile-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
}

.profile-dropdown-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.profile-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.profile-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
}

.profile-dropdown.open .profile-dropdown-menu {
    display: block;
}

.profile-dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.15s;
}

.profile-dropdown-menu a:hover {
    background: #f5f5f5;
}

.profile-dropdown-menu hr {
    margin: 0;
    border: none;
    border-top: 1px solid #eee;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: white;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--secondary);
    color: white;
}

.auth-tab:hover:not(.active) {
    background: #f5f5f5;
}

/* Google sign-in button */
.google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.google-button:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Auth divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
    color: #999;
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.auth-divider span {
    padding: 0 1rem;
}

/* Danger button */
.danger-button {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-button:hover {
    background: #e74c3c;
    color: white;
}

/* Notifications */
.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.notification-success {
    background: var(--success);
}

.notification-error {
    background: var(--accent);
}

.notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* Practice cards */
.practice-group {
    margin-bottom: 2rem;
}

.practice-group h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.practice-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.practice-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    transition: box-shadow 0.2s;
}

.practice-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.practice-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.practice-card h4 {
    margin: 0;
    color: var(--primary);
}

.practice-origin {
    font-size: 0.85rem;
    color: #666;
    margin: 0.25rem 0 0.75rem 0;
}

.practice-notes {
    font-size: 0.9rem;
    color: #555;
    margin: 0.75rem 0 0 0;
    font-style: italic;
}

.effectiveness-badge {
    display: inline-block;
    background: #e8f4f8;
    color: var(--secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background: #f8f9fa;
    border-radius: 10px;
    color: #666;
}

.empty-state a {
    color: var(--secondary);
}

/* Practice resource link */
.practice-resource {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--secondary);
    text-decoration: none;
}

.practice-resource:hover {
    text-decoration: underline;
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

@media (max-width: 768px) {
    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }

    .notification {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .practice-cards {
        grid-template-columns: 1fr;
    }
}
