:root {
    --primary-color: #f43f5e; /* Red danger */
    --card-bg: rgba(15, 20, 30, 0.9);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bg-gradient-start: #2a111a; /* Dark blood red */
    --bg-gradient-end: #020617;
}

* {
    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;
}

.app-container {
    width: 100%;
    max-width: 650px;
    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), 0 0 40px rgba(0,0,0,0.5) inset;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(244, 63, 94, 0.4);
}

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

/* スライダー部 */
.input-section {
    margin-bottom: 32px;
    background: rgba(0,0,0,0.4);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

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

.input-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.highlight-value {
    color: #fff;
    font-size: 1.5rem;
    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;
    margin-top: 8px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border: 4px solid #64748b;
}


/* タイムライン演出セクション */
.visual-section {
    margin-bottom: 32px;
    padding: 30px 10px 60px 10px; /* アイコン等のためのスペース確保 */
}

.timeline-container {
    position: relative;
    width: 100%;
    height: 24px;
    /* 50歳を超える場合はバーが右端に張り付くなどして overflow-x */
}

/* 背景となるレール */
.timeline-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 24px;
    background: #1e293b;
    border-radius: 12px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

/* メモリ線 */
.tick-mark {
    position: absolute;
    top: 30px;
    width: 2px;
    height: 6px;
    background: #475569;
    transform: translateX(-50%);
}
.tick-mark span {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
}

/* 借金のプログレスバー */
.debt-bar {
    position: absolute;
    top: 0;
    /* JSで left を currentAge基準、width を payoffAge基準で指定 */
    height: 24px;
    background-color: #9f1239; /* Dark red */
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(159, 18, 57, 0.8);
    transition: width 1s cubic-bezier(0.25, 0.8, 0.25, 1), left 0.3s;
    overflow: hidden;
    z-index: 2; /* イベントマーカーより下にしたいが重なり次第 */
}

/* 不気味に動くストライプ模様 */
.debt-stripes {
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.2),
        rgba(0,0,0,0.2) 10px,
        transparent 10px,
        transparent 20px
    );
    animation: move-stripes 2s linear infinite;
}

@keyframes move-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 28px 0; }
}

/* ライフイベントマーカー */
.event-marker {
    position: absolute;
    top: -45px; /* バーの上 */
    transform: translateX(-50%);
    text-align: center;
    width: 50px;
    z-index: 5;
    transition: filter 0.5s, transform 0.5s;
    /* デフォルトは綺麗な色 */
    filter: grayscale(0%);
}

.ev-emoji {
    font-size: 1.8rem;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.ev-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

/* 借金に飲まれた時の鎖マーク(初期は非表示) */
.ev-chain {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    opacity: 0;
    transition: opacity 0.5s;
}

/* JS付与クラス: 借金バーに被弾(侵食)した場合 */
.event-marker.devoured {
    filter: grayscale(100%) sepia(50%) hue-rotate(300deg); /* 絶望的な赤黒いセピア */
    transform: translateX(-50%) scale(0.9);
}

.event-marker.devoured .ev-chain {
    opacity: 1;
    text-shadow: 0 0 10px rgba(255,0,0,0.5);
}


/* 結果アラートパネル */
.result-section {
    margin-bottom: 24px;
}

.hell-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #be123c;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 0 20px rgba(159, 18, 57, 0.2);
    /* デンジャー演出ベース */
}

.hell-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fda4af;
    margin-bottom: 8px;
}

.payoff-age {
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 25px rgba(225, 29, 72, 0.8);
}

.payoff-unit {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 16px;
}

.hell-text {
    font-size: 0.85rem;
    color: #cbd5e1;
    background: rgba(159, 18, 57, 0.2);
    padding: 12px;
    border-radius: 8px;
    border: 1px dashed rgba(244, 63, 94, 0.4);
    font-weight: 600;
    line-height: 1.5;
}

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

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

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

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