:root {
    --primary-color: #ef4444; /* Red for debt/danger */
    --primary-dark: #b91c1c;
    --card-bg: rgba(20, 20, 20, 0.85);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bg-gradient-start: #1e1b4b; /* Deep extremely dark purple/blue */
    --bg-gradient-end: #450a0a;  /* Very dark red */
}

* {
    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: #000;
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

/* 点滅アニメーション - クリティカル用 */
body.pulse-red {
    animation: danger-pulse 1.5s infinite;
}

@keyframes danger-pulse {
    0% { background-color: #000; }
    50% { background-color: #450a0a; }
    100% { background-color: #000; }
}

.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, opacity 0.5s ease;
}

.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, border-color 0.5s ease;
}

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

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

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

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

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

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

.highlight-value {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

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(239, 68, 68, 0.8), inset 0 0 5px rgba(0,0,0,0.2);
    border: 4px solid var(--primary-color);
    transition: transform 0.1s;
}

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

.warning-badge {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

/* ビジュアルセクション (テキストとグラフの2カラム) */
.visual-section {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stats-panel {
    flex: 6;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-box.danger {
    background: rgba(127, 29, 29, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

.stat-box.total {
    background: rgba(15, 23, 42, 0.5);
}

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

.stat-box.danger .stat-label {
    color: #fca5a5;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.stat-value.red-glow {
    color: #f87171;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.sub-text {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.7;
}

/* 棒グラフパネル */
.chart-panel {
    flex: 4;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 250px;
    border-left: 1px dashed rgba(255, 255, 255, 0.1);
    padding-left: 20px;
}

.bar-container {
    width: 80px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: height 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.bar-interest {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
    box-shadow: inset 0 2px 10px rgba(255,255,255,0.3);
}

.bar-interest::after {
    /* 縞模様のエフェクト */
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.1),
        rgba(0,0,0,0.1) 10px,
        transparent 10px,
        transparent 20px
    );
}

.bar-principal {
    background: linear-gradient(180deg, #64748b 0%, #334155 100%);
}

.bar-label {
    position: relative;
    z-index: 2;
    font-size: 0.75rem;
    font-weight: 900;
    color: white;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#interest-percent {
    font-size: 1.1rem;
}

/* クリティカル警告 (一生返せない状態) */
.critical-warning {
    background: #7f1d1d;
    border: 2px solid #ef4444;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.critical-warning.hidden {
    display: none;
}

.skull-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.critical-warning h3 {
    color: #fca5a5;
    font-size: 1.4rem;
    font-weight: 900;
    margin-bottom: 12px;
}

.critical-warning p {
    font-size: 0.95rem;
    color: #fee2e2;
    line-height: 1.5;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* メタファーカード */
.metaphor-card {
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s;
}

.metaphor-icon {
    font-size: 2.5rem;
    line-height: 1;
    text-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.metaphor-text {
    flex: 1;
    text-align: left;
}

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

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

@media (max-width: 480px) {
    .visual-section {
        flex-direction: column;
    }
    .chart-panel {
        border-left: none;
        border-top: 1px dashed rgba(255, 255, 255, 0.1);
        padding-left: 0;
        padding-top: 20px;
        height: 120px;
    }
    .bar-container {
        width: 100%;
        height: 60px;
        flex-direction: row;
    }
    .bar {
        height: 100% !important;
        transition: width 0.6s ease-out;
    }
    .bar-interest { height: 100%; }
    .bar-principal { height: 100%; }
}
