:root {
    --primary-color: #3b82f6; /* Blue for Rent */
    --secondary-color: #ef4444; /* Red for Buy */
    --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: #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;
}

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

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

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

header p {
    font-size: 0.85rem;
    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 {
    margin-bottom: 20px;
}
.input-group:last-child {
    margin-bottom: 0;
}

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

.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: 12px;
    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: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border: 4px solid #fff;
    transition: transform 0.1s;
}

/* 各スライダーのカラー */
#rent-slider::-webkit-slider-thumb { border-color: var(--primary-color); }
#buy-slider::-webkit-slider-thumb { border-color: var(--secondary-color); }
#years-slider::-webkit-slider-thumb { border-color: #8b5cf6; }

/* 勝敗表示部 */
.winner-display {
    text-align: center;
    background: rgba(0,0,0,0.5);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.winner-label {
    display: block;
    font-size: 1.2rem;
    font-weight: 900;
    margin-bottom: 4px;
}

.diff-value {
    font-size: 2.5rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

/* レンタルの勝ち（持ち家のコスト大） */
.winner-display.rent {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.1);
}
.winner-display.rent .winner-label, .winner-display.rent .diff-value {
    color: var(--primary-color);
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

/* 持ち家の勝ち（レンタルのコスト大） */
.winner-display.buy {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
}
.winner-display.buy .winner-label, .winner-display.buy .diff-value {
    color: var(--secondary-color);
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* シーソーUI */
.visual-section {
    padding: 40px 0 20px 0;
    position: relative;
    overflow: hidden;
}

.seesaw-container {
    position: relative;
    width: 100%;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* 支点 (三角) */
.fulcrum {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 50px solid #64748b; /* slate-500 */
    position: absolute;
    bottom: 0px;
    z-index: 1;
}

/* 板ラッパー (ここで回転させる) */
.seesaw-board-wrapper {
    position: absolute;
    bottom: 50px; /* 支点の上に配置 */
    width: 90%;
    height: 12px;
    transform-origin: center center;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
}

.board-line {
    position: absolute;
    width: 100%;
    height: 12px;
    background: linear-gradient(90deg, #94a3b8, #cbd5e1);
    border-radius: 6px;
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
}

/* 重りボックス */
.weight-box {
    position: absolute;
    bottom: 12px; /* 板の直上 */
    width: 130px;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    /* 重り自体が変に回転しないよう、逆転させるハックは今回はせず自然に傾かせる */
}

.left-rent {
    left: 10px;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    border: 2px solid #60a5fa;
}

.right-buy {
    right: 10px;
    background: linear-gradient(135deg, #7f1d1d, #ef4444);
    border: 2px solid #f87171;
}

.box-title {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #f8fafc;
    opacity: 0.9;
}

.box-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
}


/* 内訳説明 */
.breakdown-section {
    margin-top: 10px;
}

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

.formula-block {
    background: rgba(255,255,255,0.05);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #e2e8f0;
    border-left: 4px solid;
}

.rent-formula { border-color: var(--primary-color); }
.buy-formula { border-color: var(--secondary-color); }

.formula-block strong { font-size: 0.95rem; }

.cost-hint {
    margin-top: 12px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
}
