:root {
    --primary-color: #f59e0b; /* Amber */
    --card-bg: rgba(20, 25, 30, 0.9);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bg-gradient-start: #1e1b4b; /* Indigo deep */
    --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: background 1s ease; /* JSで危険時に赤く染める用 */
}

/* 危険状態の背景オーラ（JSで付与） */
.bg-layer.danger-mode {
    background: linear-gradient(135deg, #450a0a 0%, #000000 100%);
}

.app-container {
    width: 100%;
    max-width: 600px;
    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);
    transition: box-shadow 0.5s ease;
}

/* 危険時のカードのエフェクト */
.glass-card.danger-mode {
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.2), inset 0 0 20px rgba(220, 38, 38, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

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

header h1 {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

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

.flex-row {
    display: flex;
    gap: 16px;
    margin-top: 24px;
}
.flex-half {
    flex: 1;
}

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

.highlight-value {
    color: #fff;
    font-size: 1.8rem;
    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;
    appearance: none;
    cursor: pointer;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 8px;
}

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);
    border: 4px solid var(--primary-color);
    transition: transform 0.1s;
}

/* トグル行 */
.toggle-container {
    display: flex;
    gap: 4px;
}

.toggle-container input[type="radio"] {
    display: none;
}

.toggle-btn {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 8px 4px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.2;
}

.toggle-container input[type="radio"]:checked + .toggle-btn {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

/* 結果パネル (不足額) */
.result-section {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.deficit-card {
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid #334155;
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.5s ease;
}

.deficit-card.danger {
    border-color: #ef4444;
    background: rgba(30, 10, 10, 0.8);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

/* 炎のアニメーション（2000万超え等で発動） */
.deficit-card.danger::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(239,68,68,0.1) 0%, transparent 60%);
    animation: rotateGlow 5s linear infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.deficit-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.deficit-body {
    position: relative;
    z-index: 1;
}

.slot-number {
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 5px 15px rgba(0,0,0,0.8);
    transition: color 0.3s;
    line-height: 1;
    display: inline-block;
}

.slot-number.shaking {
    /* カウントアップ中のアニメーション */
    animation: slot-shake 0.05s infinite alternate;
}
@keyframes slot-shake {
    0% { transform: translateY(-2px); }
    100% { transform: translateY(2px); }
}

.unit {
    font-size: 1.5rem;
    font-weight: 700;
    color: #94a3b8;
    margin-left: 4px;
}

/* 危険状態のテキストカラー（2000万超え） */
.deficit-card.danger .slot-number {
    color: #f87171;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8), 0 5px 15px rgba(0,0,0,0.8);
}

/* 今すぐ必要な貯金パネル */
.action-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}
.action-card p {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 8px;
}

.monthly-hl {
    color: #fca5a5;
    font-size: 2rem;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.5);
    font-variant-numeric: tabular-nums;
}

/* 内訳 */
.breakdown-card {
    background: rgba(0,0,0,0.4);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.breakdown-card h3 {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin-bottom: 12px;
    text-align: center;
}

.cost-hint-list {
    list-style: none;
}

.cost-hint-list li {
    font-size: 0.8rem;
    color: #e2e8f0;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
    line-height: 1.5;
}
