:root {
    /* 深みのあるプレミアムな色彩設計 */
    --bg-color: #080a12;
    --bg-gradient: radial-gradient(circle at top right, #161b2e 0%, #080a12 100%);
    --card-bg: rgba(28, 34, 58, 0.7);
    --header-bg: rgba(22, 27, 46, 0.8);
    --accent: #4facfe;
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --accent-hover: #00f2fe;
    --text-main: #f8f9fa;
    --text-muted: #94a3b8;
    --success: #00e676;
    --border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --layered-shadow: 0 1px 1px rgba(0, 0, 0, 0.11),
        0 2px 2px rgba(0, 0, 0, 0.11),
        0 4px 4px rgba(0, 0, 0, 0.11),
        0 8px 8px rgba(0, 0, 0, 0.11),
        0 16px 16px rgba(0, 0, 0, 0.11);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background: var(--bg-color);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* フェードインアニメーション */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 20px;
}

.logo {
    font-weight: 700;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* グラスモーフィズムカード */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid var(--border);
    box-shadow: var(--glass-shadow), var(--layered-shadow);
    margin-bottom: 24px;
}

.view-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.view-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-btn.active {
    background: white;
    color: #080a12;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.preview-area {
    width: 100%;
    min-height: 280px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    overflow: hidden;
    position: relative;
    transition: border-color 0.3s;
}

.preview-area:hover {
    border-color: var(--accent);
}

.preview-area img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.default-msg {
    text-align: center;
    color: var(--text-muted);
}

.default-msg .icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

button {
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.primary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    padding: 18px;
    border-radius: 16px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.primary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.analyze-btn {
    background: var(--accent-gradient);
    border: none;
    color: #080a12;
    padding: 20px;
    border-radius: 16px;
    font-size: 17px;
    box-shadow: 0 10px 20px rgba(79, 172, 254, 0.3);
}

.analyze-btn:disabled {
    background: #1e253a;
    color: #4a5578;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.analyze-btn:not(:disabled):hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px rgba(79, 172, 254, 0.5);
}

.analyze-btn:not(:disabled):active {
    transform: translateY(-1px);
}

/* Comparison Layout */
.comparison-container {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.comp-card {
    flex: 1;
    min-width: 0;
    padding: 16px !important;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.comp-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.preview-area.small {
    height: 180px !important;
    min-height: 180px !important;
}

#resultImage {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    /* 画像の鮮明度を上げる */
}

/* Loading Overlay 高級感アップ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 10, 18, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(79, 172, 254, 0.1);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
    margin: 0 auto 24px;
    filter: drop-shadow(0 0 10px var(--accent));
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Result Section */
.report-wrapper {
    background: #000;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    margin-bottom: 30px;
}

.secondary-btn {
    background: var(--success);
    color: #080a12;
    text-align: center;
    padding: 18px;
    border-radius: 16px;
    text-decoration: none;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 10px 20px rgba(0, 230, 118, 0.2);
    transition: all 0.3s;
}

.secondary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(0, 230, 118, 0.4);
}

/* ログイン画面専用調整 */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-left: 4px;
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 16px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 4px rgba(79, 172, 254, 0.1);
}

/* Footer 高級感 */
footer {
    opacity: 0.6;
    transition: opacity 0.3s;
}

footer:hover {
    opacity: 1;
}

/* Responsive Mobile */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .card {
        padding: 24px 20px;
        border-radius: 32px 32px 0 0;
        margin-bottom: 0;
    }

    h1 {
        font-size: 24px;
    }

    .report-wrapper {
        margin-left: -20px;
        margin-right: -20px;
        border-radius: 0;
    }
}

/* 印刷用最適化（Phase 21） */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    header,
    .view-selector,
    .view-btn,
    .actions,
    footer,
    .guide-control,
    #singleModeArea .actions,
    .secondary-btn,
    .comparison-slider .slider-input,
    .slider-handle::after,
    #downloadBtn,
    .primary-btn,
    .analyze-btn {
        display: none !important;
    }

    .card {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        backdrop-filter: none !important;
    }

    .result-section {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .report-wrapper {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    #resultImage {
        width: 100% !important;
        max-height: 250mm;
        /* A4に収める */
        object-fit: contain;
    }

    .result-card {
        page-break-inside: avoid;
        border-left: 3px solid #000 !important;
    }

    /* 印刷時のヘッダー追加 */
    .container::before {
        content: "シセビズ ｜ AI 姿勢解析診断書";
        display: block;
        text-align: center;
        font-size: 24px;
        font-weight: bold;
        margin-bottom: 20px;
    }
}

/* 比較スライダー（Phase 20） */
.comparison-slider {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    border-radius: 16px;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: #000;
}

.comparison-slider .after-img {
    display: block;
    width: 100%;
    height: auto;
}

.comparison-slider .before-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.comparison-slider .before-img img {
    height: 100% !important;
    width: auto !important;
    object-fit: cover;
    display: block;
}

.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.slider-handle::after {
    content: "↔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: white;
    color: #080a12;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    z-index: 30;
    margin: 0;
}

.comp-badge {
    position: absolute;
    top: 15px;
    padding: 6px 12px;
    background: rgba(8, 10, 18, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    z-index: 25;
}

.badge-before {
    left: 15px;
    border-left: 2px solid var(--accent);
}

.badge-after {
    right: 15px;
    border-right: 2px solid var(--success);
}