:root {
    --rent-color: #ef4444; /* Alert red */
    --base-color: #64748b; /* Neutral slate */
    --free-color: #3b82f6; /* Safe blue */
    --card-bg: rgba(15, 23, 42, 0.9);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    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; /* Solid background initially */
    transition: background-color 0.4s ease;
}

body.danger-mode {
    background-color: #450a0a; /* Dark blood red */
}

.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);
}

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

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
    overflow: hidden;
}

.glass-card.fatal {
    border-color: #ef4444;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.5);
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
}

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

/* スライダー */
.slider-section {
    margin-bottom: 32px;
}

.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.2);
}

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 2px 5px rgba(0,0,0,0.5);
    border: 4px solid var(--base-color);
}

/* 圧迫される帯グラフ */
.bar-section {
    margin-bottom: 32px;
    padding: 0 10px;
}

.ratio-bar-container {
    width: 100%;
    height: 80px;
    display: flex;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.5);
    background: #000;
}

.bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: flex-basis 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.bar-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap;
}

.bar-label .small-text {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* 各セグメントの色 */
.rent-bar {
    background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
    box-shadow: 3px 0 10px rgba(0,0,0,0.5);
    z-index: 3;
}
.base-bar {
    background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
    box-shadow: 3px 0 10px rgba(0,0,0,0.5);
    z-index: 2;
}
.free-bar {
    background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
    z-index: 1;
}

.free-bar.critical {
    /* もしゆとりがゼロやマイナスになったら見えなくなるが、わずかに残る場合の色 */
    background: linear-gradient(180deg, #fca5a5 0%, #b91c1c 100%);
}

#free-amount {
    font-size: 1.2rem;
    display: block;
    margin-top: 2px;
}

/* 警告パネル */
.warning-panel {
    background: #7f1d1d;
    border: 2px solid #ef4444;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
    animation: flash 1s infinite alternate;
}
.warning-panel.hidden {
    display: none;
}
.warning-panel h3 {
    color: #fca5a5;
    margin-bottom: 8px;
    font-size: 1.2rem;
    font-weight: 900;
}
.warning-panel p {
    font-size: 0.9rem;
    color: #fee2e2;
}

@keyframes flash {
    0% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
    100% { box-shadow: 0 0 30px rgba(239, 68, 68, 0.8); }
}

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

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

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

.metaphor-text p {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 24px;
    padding: 0 10px;
}

@media (max-width: 480px) {
    .ratio-bar-container {
        height: 60px;
    }
    .bar-label {
        font-size: 0.7rem;
    }
    #free-amount {
        font-size: 1rem;
    }
}
