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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
    overflow-x: hidden;
}

:root {
    --primary-color: #18A195;
    --secondary-color: #4298b4;
    --accent-color: #33a474;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --background: #f5f7fa;
    --card-background: #ffffff;
    --border-color: #e1e8ed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    position: relative;
}

/* タイトルバナー */
.title-banner {
    width: 100%;
    margin: 0;
    padding: 0;
    background: var(--primary-color);
}

/* 結果画面表示時はタイトルバナーを非表示 */
#result-screen.active ~ .title-banner,
body:has(#result-screen.active) .title-banner {
    display: none;
}

.title-banner-image {
    width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

#start-screen h1 {
    display: none;
}

#start-screen .subtitle {
    display: none;
}

h1 {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.subtitle {
    text-align: center;
    font-size: 1.1em;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-weight: 400;
}

.intro-text {
    background: var(--card-background);
    padding: 32px;
    border-radius: 8px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.intro-text p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 1em;
}

.intro-text p:last-child {
    margin-bottom: 0;
}

.intro-text .important-notice {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 16px;
    margin-top: 20px;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.95em;
}

.intro-text .important-notice strong {
    color: #f57c00;
}

.btn-primary, .btn-secondary {
    display: block;
    width: 100%;
    padding: 16px 32px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

.btn-primary:focus, .btn-secondary:focus {
    outline: none;
}

.btn-primary:active, .btn-secondary:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    margin-top: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--border-color);
}

/* ホバーはマウスがあるデバイスのみ */
@media (hover: hover) {
    .btn-primary:hover {
        background: #158d82;
        transform: translateY(-2px);
        box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
    }

    .btn-secondary:hover {
        background: #f8f9fa;
        transform: translateY(-2px);
        box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
        border-color: var(--primary-color);
    }
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    width: 0%;
}

.question-counter {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.95em;
    font-weight: 500;
}

.question-text {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.4;
}

.answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-btn {
    padding: 20px 24px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    color: var(--text-primary);
    font-weight: 500;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

/* ホバーはマウスがあるデバイスのみ */
@media (hover: hover) {
    .answer-btn:hover {
        border-color: var(--primary-color);
        background: #fafbfc;
    }
}

.answer-btn:focus {
    outline: none;
    border-color: var(--border-color);
}

.answer-btn:focus-visible {
    outline: none;
}

.answer-btn:active {
    transform: scale(0.98);
    background: #f0f4f8;
    border-color: var(--primary-color);
}

/* 戻るボタン */
.btn-back {
    display: block;
    width: 100%;
    padding: 12px 24px;
    margin-top: 16px;
    font-size: 0.9em;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    background: transparent;
    color: var(--text-secondary);
    outline: none;
}

@media (hover: hover) {
    .btn-back:hover {
        color: var(--primary-color);
        background: rgba(24, 161, 149, 0.05);
    }
}

.btn-back:focus {
    outline: none;
}

.btn-back:active {
    transform: scale(0.98);
    color: var(--primary-color);
}

/* 結果画面 */
.result-header {
    margin-bottom: 24px;
}

.result-header-image {
    width: 100%;
    height: auto;
    max-height: 300px;
    display: block;
    object-fit: contain;
    object-position: center;
    background: var(--primary-color);
}

/* モバイルで結果画像を全幅表示 */
@media (max-width: 768px) {
    .result-header {
        width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        margin-bottom: 24px;
    }

    .result-header-image {
        width: 100%;
    }
}

.type-name {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.type-subtitle {
    font-size: 1.2em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 500;
}

.type-description {
    font-size: 1.05em;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* 情報セクション */
.result-sections {
    display: grid;
    gap: 16px;
}

.result-section {
    background: var(--card-background);
    padding: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.result-section h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1.2em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.result-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.result-section ul {
    list-style: none;
    padding-left: 0;
}

.result-section li {
    padding: 10px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 24px;
    position: relative;
}

.result-section li:before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2em;
    position: absolute;
    left: 0;
}

/* スコア表示 */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.score-item {
    background: var(--background);
    padding: 16px;
    border-radius: 6px;
}

.score-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.score-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* 中央から左右に伸びるスコアバー */
.score-bar-container {
    display: flex;
    align-items: center;
    height: 8px;
    margin-bottom: 4px;
}

.score-bar-half {
    flex: 1;
    height: 100%;
    background: var(--border-color);
    overflow: hidden;
}

.score-bar-left {
    border-radius: 4px 0 0 4px;
    display: flex;
    justify-content: flex-end;
}

.score-bar-right {
    border-radius: 0 4px 4px 0;
    display: flex;
    justify-content: flex-start;
}

.score-bar-center {
    width: 2px;
    height: 12px;
    background: var(--text-secondary);
    flex-shrink: 0;
}

.score-fill-left {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px 0 0 4px;
    transition: width 0.5s ease;
}

.score-fill-right {
    height: 100%;
    background: var(--primary-color);
    border-radius: 0 4px 4px 0;
    transition: width 0.5s ease;
}

.score-value {
    font-size: 0.85em;
    color: var(--text-secondary);
    text-align: right;
}

/* タグ */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tag {
    background: var(--background);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

/* タイプ一覧画面 */
.type-list-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 480px) {
    .type-list-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.type-list-item {
    background: var(--card-background);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--border-color);
}

@media (hover: hover) {
    .type-list-item:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        border-color: var(--primary-color);
    }
}

.type-list-item:active {
    transform: scale(0.98);
}

.type-list-image {
    width: 100%;
    height: auto;
    display: block;
    background: var(--primary-color);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
    }

    .title-banner-image {
        /* スマホ用画像は横幅100%、高さ自動で全体表示 */
    }

    .result-header-image {
        max-height: 150px;
    }

    h1 {
        font-size: 2em;
    }

    .question-text {
        font-size: 1.25em;
    }

    .answer-btn {
        padding: 16px 20px;
        font-size: 16px;
    }

    .result-header {
        padding: 32px 24px;
    }

    .type-name {
        font-size: 2em;
    }

    .type-subtitle {
        font-size: 1.1em;
    }

    .result-section {
        padding: 20px;
    }

    .scores-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75em;
    }

    .intro-text {
        padding: 24px;
    }
}

/* 診断中モーダル */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

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

.modal-content {
    background: var(--card-background);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    color: var(--text-primary);
    font-size: 1.5em;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* スピナーアニメーション */
.analyzing-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 広告スペース */
.ad-space {
    margin-top: 24px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.ad-placeholder {
    color: var(--text-secondary);
    font-size: 0.9em;
}
