/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #06c755;
    --primary-dark: #05a648;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f5f5;
    --white: #fff;
    --border-color: #ddd;
    --error-color: #e74c3c;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Container */
.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 24px 20px;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main */
.main {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.5;
}

.step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 400;
    width: 100%;
    margin-top: 2px;
    padding-left: 34px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
    cursor: pointer;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}

.form-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-input-wrapper .form-input {
    flex: 1;
    min-width: 0;
}

.form-unit {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Radio Group */
.form-radio-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.form-radio {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.form-radio:hover {
    border-color: #bbb;
}

.form-radio:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(6, 199, 85, 0.08);
}

.form-radio input {
    accent-color: var(--primary-color);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.form-radio span {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    background: var(--primary-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 8px;
    -webkit-tap-highlight-color: transparent;
}

.btn-submit:hover {
    background: var(--primary-dark);
}

.btn-submit:active {
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.footer {
    padding: 16px 20px 24px;
    text-align: center;
    flex-shrink: 0;
}

.note {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Modal */
.modal {
    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;
    padding: 20px;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: modalIn 0.3s ease;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.result-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 20px;
    text-align: center;
}

.result-header h2 {
    font-size: 1.25rem;
}

.result-body {
    padding: 32px 24px;
    text-align: center;
}

.result-label {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.result-amount {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

#result-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-unit {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.result-note {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.8;
}

.result-actions {
    padding: 20px 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

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

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

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

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

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

/* Utility */
.hidden {
    display: none !important;
}

/* Loading */
.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ================================
   Responsive - Tablet
   ================================ */
@media (min-width: 481px) {
    .header {
        padding: 32px 24px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .main {
        padding: 32px 28px;
    }

    .form {
        gap: 32px;
    }

    .form-label {
        font-size: 1.05rem;
    }

    .form-select,
    .form-input {
        padding: 18px;
        font-size: 1.05rem;
    }

    .form-radio {
        padding: 16px 14px;
    }

    .btn-submit {
        padding: 20px;
        font-size: 1.15rem;
    }
}

/* ================================
   Responsive - Desktop
   ================================ */
@media (min-width: 769px) {
    body {
        padding: 40px 20px;
        background: linear-gradient(135deg, #e8f5e9 0%, #f5f5f5 100%);
    }

    .container {
        min-height: auto;
        border-radius: 24px;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
        overflow: hidden;
    }

    .header {
        padding: 40px 32px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .main {
        padding: 40px 36px;
    }

    .form {
        gap: 36px;
    }

    .form-label {
        font-size: 1.1rem;
    }

    .step {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .form-hint {
        font-size: 0.85rem;
        padding-left: 36px;
    }

    .form-select,
    .form-input {
        padding: 18px 20px;
        font-size: 1.05rem;
        border-radius: 12px;
    }

    .form-radio-group {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .form-radio {
        padding: 16px 12px;
        border-radius: 12px;
    }

    .btn-submit {
        padding: 20px;
        font-size: 1.2rem;
        border-radius: 12px;
        margin-top: 12px;
    }

    .footer {
        padding: 20px 36px 32px;
    }

    .note {
        font-size: 0.85rem;
    }

    .modal-content {
        border-radius: 24px;
    }

    .result-body {
        padding: 40px 32px;
    }

    #result-value {
        font-size: 3.5rem;
    }

    .result-unit {
        font-size: 1.5rem;
    }

    .result-note {
        font-size: 0.9rem;
    }

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

    .btn-primary,
    .btn-secondary {
        padding: 18px;
        font-size: 1.05rem;
        border-radius: 12px;
    }
}

/* ================================
   Responsive - Small Mobile
   ================================ */
@media (max-width: 360px) {
    html {
        font-size: 14px;
    }

    .header {
        padding: 20px 16px;
    }

    .main {
        padding: 20px 16px;
    }

    .form {
        gap: 24px;
    }

    .form-radio-group {
        grid-template-columns: 1fr;
    }

    .form-radio {
        justify-content: flex-start;
        padding: 14px 16px;
    }

    .result-body {
        padding: 24px 20px;
    }

    #result-value {
        font-size: 2.5rem;
    }

    .result-actions {
        padding: 16px 20px 24px;
    }
}

/* ================================
   Safe Area (iPhone X+)
   ================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .result-actions {
        padding-bottom: calc(28px + env(safe-area-inset-bottom));
    }
}

/* ================================
   Result Steps (Contact Form)
   ================================ */
.result-step {
    animation: fadeIn 0.3s ease;
}

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

/* Consult Header */
.consult-header {
    margin-bottom: 24px;
}

.consult-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
}

.consult-desc {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.7;
}

/* Contact Form */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.contact-group {
    text-align: left;
}

.contact-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
}

.contact-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.contact-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}

.contact-input::placeholder {
    color: #bbb;
}

.contact-note {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Text Button */
.btn-text {
    width: 100%;
    padding: 14px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: underline;
    -webkit-tap-highlight-color: transparent;
}

.btn-text:hover {
    color: var(--text-color);
}

/* Complete Step */
.complete-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--primary-color);
    color: var(--white);
    font-size: 2rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.complete-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 12px;
}

.complete-desc {
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 24px;
}

.result-summary {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ================================
   High Contrast / Accessibility
   ================================ */
@media (prefers-contrast: high) {
    .form-select,
    .form-input,
    .form-radio,
    .contact-input {
        border-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* 診断完了画面 */
.complete-screen {
    text-align: center;
    padding: 60px 20px;
}
.complete-screen .complete-icon {
    width: 80px;
    height: 80px;
    background: #4CAF50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: white;
    margin: 0 auto 24px;
}
.complete-screen h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: #333;
}
.complete-screen p {
    color: #666;
    line-height: 1.8;
}
