:root {
    --safe-color: #0ea5e9; /* Sky blue */
    --safe-dark: #0369a1;
    --danger-color: #ef4444; /* Red */
    --danger-dark: #991b1b;
    --card-bg: rgba(20, 25, 30, 0.85);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #000000;
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    background-color: #0f172a;
    position: relative;
    overflow-x: hidden;
}

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 100;
    transition: background 0.3s;
}

.back-link:hover {
    background: rgba(255,255,255,0.2);
}

.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    z-index: -1;
    transition: opacity 0.5s ease;
}

.app-container {
    width: 100%;
    max-width: 800px;
    z-index: 10;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.05em;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* スライダー */
.slider-section {
    margin-bottom: 24px;
    background: rgba(0,0,0,0.3);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.input-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 1rem;
}

.highlight-value {
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

input[type="range"] {
    width: 100%;
    height: 14px;
    background: #334155;
    border-radius: 8px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 5px rgba(0,0,0,0.2);
    border: 4px solid #94a3b8;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* 比較セクション */
.visual-section {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    position: relative;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.3);
    font-style: italic;
    width: 40px;
}

/* パネル共通 */
.house-panel {
    flex: 1;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.house-panel.safe-zone {
    border-top: 4px solid var(--safe-color);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.05) 0%, rgba(0,0,0,0) 100%);
}

.house-panel.danger-zone {
    border-top: 4px solid var(--danger-color);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.05) 0%, rgba(0,0,0,0) 100%);
    /* 血走ったような赤い影 */
    box-shadow: inset 0 0 40px rgba(153, 27, 27, 0.2);
}

.panel-header {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 16px;
    line-height: 1.4;
    height: 60px;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-top: 8px;
    color: white;
}
.badge.safe { background: var(--safe-dark); }
.badge.danger { background: var(--danger-dark); }

/* 家アイコンとアニメーション */
.house-wrapper {
    height: 150px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.house-icon {
    font-size: 4rem;
    line-height: 1;
    /* JSで transform: scale(x) を使ってサイズを変える */
    transform-origin: bottom center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 2;
}

.house-icon.safe {
    filter: drop-shadow(0 0 15px rgba(14, 165, 233, 0.4));
}

.house-icon.danger {
    filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.6));
    animation: danger-shake 0.4s cubic-bezier(.36,.07,.19,.97) infinite;
}

/* 常にギリギリで揺れる危険な家 */
@keyframes danger-shake {
    0% { transform: scale(var(--scale-factor, 1)) rotate(0); }
    25% { transform: scale(var(--scale-factor, 1)) rotate(-2deg); }
    50% { transform: scale(var(--scale-factor, 1)) rotate(1deg) translateY(-2px); }
    75% { transform: scale(var(--scale-factor, 1)) rotate(-1deg); }
    100% { transform: scale(var(--scale-factor, 1)) rotate(0); }
}

/* 炎エフェクト */
.fire-effect {
    position: absolute;
    bottom: 20px;
    font-size: 5rem;
    z-index: 1;
    opacity: 0.8;
    filter: blur(1px);
    animation: burn 1s infinite alternate;
}
.fire-effect.hidden { display: none; }

@keyframes burn {
    0% { transform: scale(1) translateY(0); opacity: 0.6; }
    100% { transform: scale(1.1) translateY(-10px); opacity: 0.9; }
}

/* 金額表示部 */
.price-box {
    background: rgba(0,0,0,0.5);
    width: 100%;
    padding: 16px 8px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.price-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}

.price-value {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.blue-text { color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.3); }
.red-text { color: #f87171; text-shadow: 0 0 10px rgba(248, 113, 113, 0.3); }

.monthly-payment {
    font-size: 0.85rem;
    color: #cbd5e1;
}

.monthly-payment strong {
    font-size: 1.2rem;
    color: #fff;
}

/* 生活ステータス */
.life-status {
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
}

.safe-status {
    background: rgba(14, 165, 233, 0.1);
    color: #bae6fd;
}

.danger-status {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-weight: 700;
}


/* メタファーカード */
.metaphor-card {
    background: rgba(20, 20, 20, 0.8);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.metaphor-icon {
    font-size: 2rem;
}

.metaphor-text {
    flex: 1;
}

.metaphor-text h3 {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fbbf24;
    margin-bottom: 4px;
}

.metaphor-text p {
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .visual-section {
        flex-direction: column;
    }
    .vs-divider {
        width: 100%;
        height: 30px;
    }
}
