:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --primary-color: #0d1b2a; /* ダークネイビー */
    --accent-color-start: #f0f2f5;
    --accent-color-end: #e6e9ee;
    --card-bg: #f8f9fa;
    --border-color: #dee2e6;
    --gold-color: #c9a46de0;
    --turquoise-color: #40e0d0;
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: var(--primary-color);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Page Transitions --- */
#app-root {
    transition: opacity 0.2s ease-in-out;
}

#app-root.fade-out {
    opacity: 0;
}

/* --- Popular Ranking Section --- */
#popular-ranking-section {
    background: transparent;
    margin: 40px 0;
    padding: 40px 0;
    border-radius: 20px;
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#popular-ranking-section .section-title {
    text-align: center;
    margin-bottom: 40px;
    width: 100%;
    max-width: 1200px;
}

#popular-ranking-section .section-title h2 {
    font-size: 2.2rem;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#popular-ranking-section .section-title p {
    color: #374151;
    font-size: 1.1rem;
    font-weight: 500;
}

.popular-ranking {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    justify-content: center;
}

.popular-item {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    width: 100%;
    max-width: 500px;
}

.popular-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #4f46e5;
}

.popular-item:nth-child(1) {
    border-left: 5px solid #ffd700;
    background: var(--card-bg);
}

.popular-item:nth-child(2) {
    border-left: 5px solid #c0c0c0;
    background: var(--card-bg);
}

.popular-item:nth-child(3) {
    border-left: 5px solid #cd7f32;
    background: var(--card-bg);
}

.popular-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.popular-rank {
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
}

.popular-item:nth-child(1) .popular-rank {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
}

.popular-item:nth-child(2) .popular-rank {
    background: linear-gradient(45deg, #c0c0c0, #e5e5e5);
    color: #333;
}

.popular-item:nth-child(3) .popular-rank {
    background: linear-gradient(45deg, #cd7f32, #daa520);
    color: white;
}

.popular-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.popular-details {
    flex: 1;
    min-width: 0;
}

.popular-details h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    line-height: 1.4;
    color: var(--primary-color);
}

.popular-details p {
    font-size: 0.9rem;
    color: #374151;
    margin-bottom: 8px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-weight: 500;
}

.popular-category {
    display: inline-block;
    background: #e0e7ff;
    color: #4338ca;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-popular {
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    color: white !important;
    border: none;
    padding: 8px 16px;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-popular:hover {
    background: linear-gradient(45deg, #6366f1, #8b5cf6) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

/* --- Responsive Design for Popular Ranking --- */
@media (max-width: 768px) {
    .popular-ranking {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .popular-item {
        padding: 15px;
    }

    .popular-info {
        gap: 10px;
    }

    .popular-rank {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .popular-details h3 {
        font-size: 1rem;
    }

    .popular-details p {
        font-size: 0.85rem;
    }

    .btn-popular {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    #popular-ranking-section .section-title h2 {
        font-size: 1.8rem;
    }

    #popular-ranking-section .section-title p {
        font-size: 1rem;
    }
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    text-align: center;
}

.back-btn {
    font-size: 14px !important;
    padding: 8px 20px !important;
    border-radius: 25px !important;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color) !important;
    color: var(--primary-color) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.back-btn:hover {
    background: var(--primary-color) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background-color: #4f46e5;
    color: #ffffff !important;
    border: 2px solid #4f46e5;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    margin: 0 8px 8px 0;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.share-btn-x {
    background: #000000;
    color: #ffffff;
}

.share-btn-x:hover {
    background: #333333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.share-btn-line {
    background: #00B900;
    color: #ffffff;
}

.share-btn-line:hover {
    background: #009900;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 185, 0, 0.3);
}

.share-btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary:hover {
    background-color: #6366f1 !important;
    color: #ffffff !important;
    border-color: #6366f1 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* --- Header & Footer --- */
.main-header {
    padding: 20px 0;
    position: absolute;
    width: 100%;
    z-index: 10;
}
.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo, #history-link {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}
#history-link {
    font-size: 16px;
}
.logo:hover, #history-link:hover {
    color: var(--turquoise-color);
}

.main-footer {
    background: var(--primary-color);
    color: #fff;
    padding: 30px 0;
    text-align: center;
}

/* --- General Section Styling --- */
.page-section {
    padding: 80px 0;
    min-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.section-title {
    text-align: center;
    margin-bottom: 60px;
}
.section-title h2 {
    font-size: 36px;
    position: relative;
    display: inline-block;
    padding-bottom: 10px;
}
.section-title h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--primary-color);
}

/* --- Home Page --- */
#home-hero {
    height: 100vh;
    min-height: 700px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(45deg, var(--accent-color-start), var(--accent-color-end));
    padding-top: 60px;
}
.hero-content h1 {
    font-size: 48px;
    margin-bottom: 16px;
}
.hero-content p {
    font-size: 18px;
    margin-bottom: 32px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.random-btn-container {
    margin-top: 20px;
}

/* --- Diagnostic Cards --- */
.diag-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}
.diag-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}
.diag-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
}
.diag-card .icon {
    font-size: 48px;
    margin-bottom: 20px;
}
.diag-card h3 {
    font-size: 22px;
    margin-bottom: 10px;
}
.diag-card p {
    font-size: 15px;
    margin-bottom: 20px;
    flex-grow: 1;
    min-height: 45px;
}

/* --- Category Tabs --- */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}
.tab {
    padding: 10px 25px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.tab:hover, .tab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* --- Diagnosis Start/Question/Result Page --- */
.diag-page-container {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}
.diag-page-container h1 {
    font-size: 42px;
    margin-bottom: 15px;
}
.diag-page-container .description {
    font-size: 18px;
    max-width: 550px;
    margin: 0 auto 40px;
}
.diag-visual {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #5c677d);
    margin: 0 auto 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 60px;
    box-shadow: 0 10px 25px rgba(13, 27, 42, 0.2);
}

/* --- Question Screen --- */
.progress-bar {
    width: 100%;
    background-color: var(--border-color);
    border-radius: 10px;
    height: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}
.progress-bar-inner {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 10px;
    transition: width 0.5s ease;
}
.progress-text {
    text-align: right;
    margin-bottom: 40px;
    font-family: 'Montserrat', sans-serif;
    color: #777;
}
.question-text {
    font-size: 28px;
    font-weight: 400;
    margin-bottom: 50px;
}
.answer-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
}
.answer-option {
    padding: 25px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}
.answer-option:hover {
    border-color: var(--primary-color);
    background: var(--card-bg);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* --- Result Screen --- */
.result-text .detail {
    max-width: 600px;
    margin: 20px auto 40px;
    text-align: left;
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    border-left: 5px solid var(--primary-color);
}
.share-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 60px;
}
.share-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 20px;
    transition: all 0.3s ease;
}
.share-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* --- History Page --- */
.history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.history-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}
.history-card .icon {
    font-size: 36px;
    margin-bottom: 15px;
}
.history-card h4 {
    font-size: 18px;
    margin-bottom: 5px;
}
.history-card .date {
    font-size: 13px;
    color: #777;
    font-family: 'Montserrat', sans-serif;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overflow-y: auto;
    padding: 20px 0;
}
.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    text-align: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.modal-overlay.visible .modal-content {
    transform: scale(1);
}
.modal-content h3 {
    margin-bottom: 30px;
}
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.modal-close-btn:hover {
    background: #ff3742;
    transform: scale(1.1);
}

/* --- History Page Styles --- */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.history-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.history-item-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.history-item-icon {
    font-size: 32px;
    margin-right: 15px;
}

.history-item-info {
    flex: 1;
}

.history-item-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.history-item-date {
    font-size: 14px;
    color: #666;
}

.history-item-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.history-item-delete:hover {
    opacity: 1;
    transform: scale(1.1);
}

.history-item-result {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
}

.history-item-summary {
    width: 100%;
}

.history-item-summary h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.history-item-summary p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.history-item-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 10px 16px;
    font-size: 14px;
}

/* History Modal Styles */
.history-modal {
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    text-align: left;
    overflow-y: auto;
}

.history-detail-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.history-detail-header .history-item-icon {
    margin: 0 0 15px 0;
}

.history-detail-header h3 {
    margin-bottom: 10px;
}

.history-detail-date {
    color: #666;
    font-size: 14px;
}

.history-detail-result h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* --- Related Diagnostics Section --- */
.related-diagnostics-section {
    margin: 40px 0 30px;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.related-diagnostics-section h3 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 600;
}

.related-diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.related-diag-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}

.related-diag-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: var(--turquoise-color);
    text-decoration: none;
    color: inherit;
}

.related-diag-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--turquoise-color), var(--gold-color));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.related-diag-card:hover::before {
    transform: scaleX(1);
}

.related-diag-card .diag-icon {
    font-size: 36px;
    text-align: center;
    margin-bottom: 15px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.related-diag-card .diag-content {
    flex: 1;
}

.related-diag-card .diag-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-diag-card .diag-category {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.related-diag-card .diag-description {
    font-size: 14px;
    color: #777;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .related-diagnostics-section {
        margin: 30px 0 20px;
        padding: 20px 0;
    }
    
    .related-diagnostics-section h3 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .related-diag-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-top: 20px;
    }
    
    .related-diag-card {
        padding: 18px;
    }
    
    .related-diag-card .diag-icon {
        font-size: 32px;
        height: 50px;
        margin-bottom: 12px;
    }
    
    .related-diag-card .diag-title {
        font-size: 15px;
    }
    
    .related-diag-card .diag-description {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .related-diagnostics-section {
        margin: 25px 0 15px;
        padding: 15px 0;
    }
    
    .related-diag-card {
        padding: 15px;
    }
    
    .related-diag-card .diag-icon {
        font-size: 28px;
        height: 45px;
        margin-bottom: 10px;
    }
}

.result-summary {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
    color: #555;
}

.result-detail {
    line-height: 1.7;
    margin-bottom: 30px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-detail p {
    margin-bottom: 15px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-detail ul {
    margin: 15px 0;
    padding-left: 20px;
}

.result-detail li {
    margin-bottom: 8px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Mobile specific improvements */
@media (max-width: 768px) {
    .result-detail {
        font-size: 15px;
        line-height: 1.8;
        margin-bottom: 25px;
    }
    
    .result-detail p {
        margin-bottom: 18px;
        hyphens: auto;
        -webkit-hyphens: auto;
        -moz-hyphens: auto;
    }
    
    .result-detail ul {
        padding-left: 15px;
        margin: 18px 0;
    }
    
    .result-detail li {
        margin-bottom: 12px;
        line-height: 1.7;
    }
}

@media (max-width: 480px) {
    .result-detail {
        font-size: 14px;
        line-height: 1.9;
        padding: 0 5px;
    }
    
    .result-detail p {
        margin-bottom: 20px;
    }
    
    .result-detail li {
        margin-bottom: 15px;
        line-height: 1.8;
    }
}

.history-detail-actions {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Image Share Modal Styles --- */
.image-share-modal {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.image-share-content {
    text-align: center;
}

.username-input-section {
    margin: 20px 0;
    text-align: left;
}

.username-input-section label {
    font-weight: 600;
    color: #555;
    display: block;
    margin-bottom: 8px;
}

.image-preview-section {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px 0;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 2px dashed #ddd;
}

.image-share-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.btn-image-share {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-image-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    color: white;
    text-decoration: none;
}

.share-instructions {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
    text-align: left;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 768px) {
    .image-share-modal {
        width: 95vw !important;
        max-height: 90vh !important;
        padding: 15px !important;
    }
    
    .image-preview-section canvas {
        max-width: 250px !important;
    }
    
    .image-share-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-image-share {
        width: 100%;
        text-align: center;
    }
}

/* --- Purpose Buttons --- */
.purpose-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 600px;
    margin: 40px auto 0;
    padding: 0 20px;
}

.purpose-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-color);
}

.purpose-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.purpose-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.purpose-btn h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.purpose-btn p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* --- Category Tabs --- */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    padding: 0 15px;
}

.category-tab {
    padding: 12px 24px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.category-tab:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.category-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* --- Responsive Design (Overhauled) --- */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.8;
    }

    .container {
        padding: 0 20px;
    }

    .page-section {
        padding: 60px 0;
    }

    #category-section {
        overflow-x: hidden;
    }

    /* --- Header & Footer --- */
    .main-header {
        padding: 15px 0;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(10px);
        position: sticky;
        top: 0;
    }
    .logo {
        font-size: 20px;
    }
    #history-link {
        font-size: 14px;
    }

    /* --- Home Page --- */
    #home-hero {
        height: auto;
        min-height: 90vh;
        padding: 120px 0 60px 0;
    }
    .hero-content h1 {
        font-size: 36px;
        line-height: 1.3;
    }
    .hero-content p {
        font-size: 16px;
    }
    .purpose-buttons {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-top: 30px;
        padding: 0;
    }
    .purpose-btn {
        display: flex;
        align-items: center;
        text-align: left;
        padding: 20px;
    }
    .purpose-icon {
        font-size: 32px;
        margin-right: 20px;
        margin-bottom: 0;
    }
    .purpose-btn h3 {
        font-size: 18px;
    }
    .purpose-btn p {
        font-size: 14px;
    }

    /* --- Category Tabs --- */
    .category-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        padding: 5px 20px;
        margin-left: -20px;
        margin-right: -20px;
        scrollbar-width: none; /* Firefox */
    }
    .category-tabs::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }
    .category-tab {
        flex: 0 0 auto;
        padding: 10px 22px;
        font-size: 15px;
        white-space: nowrap;
    }

    /* --- Diagnostic Cards --- */
    .diag-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    .diag-card {
        padding: 25px;
    }
    .diag-card:hover {
        transform: none;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    }
    .diag-card .icon {
        font-size: 40px;
        margin-bottom: 15px;
    }
    .diag-card h3 {
        font-size: 20px;
    }
    .diag-card p {
        font-size: 15px;
        min-height: auto;
    }
    .btn {
        padding: 14px 24px;
        font-size: 16px;
    }

    /* --- Diagnosis Pages --- */
    .diag-page-container h1 {
        font-size: 28px;
    }
    .diag-page-container .description {
        font-size: 16px;
    }
    .diag-visual {
        width: 120px;
        height: 120px;
        font-size: 50px;
    }
    .question-text {
        font-size: 20px;
        margin-bottom: 40px;
    }
    .answer-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .answer-option {
        padding: 20px;
        font-size: 16px;
    }
    .answer-option:hover {
        transform: none;
    }
    .result-text .detail {
        padding: 20px;
    }

    /* --- History Page --- */
    .history-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .history-item {
        padding: 20px;
    }
}

/* --- [ADDITION] Interactive Elements: Active State --- */
.btn:active,
.answer-option:active,
.category-tab:active,
.purpose-btn:active,
.share-btn:active,
.back-btn:active {
    transform: translateY(1px) scale(0.99);
    filter: brightness(0.95);
}

/* --- [ADDITION] Scroll-reveal Animation --- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- [ADDITION] Dark Mode Support --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0d1b2a;
        --text-color: #e6e9ee;
        --primary-color: #ffffff;
        --accent-color-start: #12233a;
        --accent-color-end: #1a2f4a;
        --card-bg: #1e293b;
        --border-color: #3a4a5f;
    }

    .main-header {
        background: rgba(13, 27, 42, 0.7);
    }

    .back-btn {
        background: var(--card-bg) !important;
        border-color: var(--border-color) !important;
        color: var(--primary-color) !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    .back-btn:hover {
        background: var(--primary-color) !important;
        color: var(--bg-color) !important;
    }

    .category-tab {
        background: var(--card-bg);
        border-color: var(--border-color);
    }

    .category-tab:hover {
        border-color: var(--primary-color);
        background: var(--primary-color);
        color: var(--bg-color);
    }

    .category-tab.active {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: var(--bg-color);
    }

    .answer-option:hover {
        border-color: var(--primary-color);
        background: var(--card-bg);
    }

    .diag-card:hover {
        box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    }

    .modal-content {
        background: var(--card-bg);
        width: 95vw;
        max-height: 90vh;
        margin: 5vh auto;
        padding: 20px;
        overflow-y: auto;
    }

    .history-modal {
        width: 95vw !important;
        max-height: 90vh !important;
        padding: 15px !important;
    }

    .history-detail-header {
        margin-bottom: 20px !important;
        padding-bottom: 15px !important;
    }

    .modal-close-btn {
        color: var(--text-color);
        top: 10px;
        right: 10px;
        font-size: 24px;
        z-index: 1001;
    }

    .main-footer {
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
    }
}