:root {
    --primary-color: #10b981; /* Emerald */
    --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: #064e3b; /* Deep emerald */
    --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: 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);
}

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(16, 185, 129, 0.3);
}

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

/* スライダー・トグル部 */
.input-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);
}

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

.highlight-value {
    color: #fff;
    font-size: 1.6rem;
    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: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border: 4px solid var(--primary-color);
}

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

.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-btn small {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.8;
}

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


/* 天秤アニメーション部 */
.visual-section {
    margin-bottom: 24px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    border-bottom: 4px solid #475569;
    height: 280px;
    position: relative;
    overflow: hidden;
}

.scale-wrapper {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 支点 */
.fulcrum {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 40px solid #94a3b8;
    position: relative;
    z-index: 5;
    margin-top: -10px; /* 棒の下にめり込ませる */
}

/* 棒 */
.beam {
    width: 280px;
    height: 8px;
    background-color: #cbd5e1;
    border-radius: 4px;
    position: absolute;
    bottom: 30px; /* 支点の上に乗る位置 */
    left: 20px;
    transform-origin: center center;
    /* CSS変数でJSから角度制御 */
    transform: rotate(var(--beam-angle));
    /* ドスゥン！と激しく傾くtransition */
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 4;
}

/* 皿の共通 */
.pan {
    position: absolute;
    top: 8px; /* 棒からぶら下がる基準点 */
    width: 60px;
    /* 皿自体は常に水平を保つため、親(beam)の逆回転をかける */
    transform-origin: top center;
    transform: rotate(calc(-1 * var(--beam-angle)));
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pan-left {
    left: 10px;
}

.pan-right {
    right: 10px;
}

/* 皿の紐とベース */
.pan-line {
    width: 2px;
    height: 60px;
    background-color: #cbd5e1;
    position: absolute;
    top: 0;
}
.pan-line-1 { left: 10px; transform: rotate(15deg); transform-origin: top center; }
.pan-line-2 { right: 10px; transform: rotate(-15deg); transform-origin: top center; }

.pan-base {
    width: 70px;
    height: 6px;
    background-color: #94a3b8;
    border-radius: 3px;
    margin-top: 58px;
    position: relative;
}

/* 皿に乗る重り（お金） */
.weight-item {
    position: absolute;
    bottom: 6px; /* pan-baseの上に乗せる */
    text-align: center;
    font-weight: 700;
    line-height: 1.1;
    border-radius: 6px;
    color: #fff;
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.3);
}

.cost-item {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #64748b 0%, #334155 100%);
    font-size: 0.75rem;
}
.cost-item .minus { color: #fca5a5; font-size: 0.6rem; }
.cost-item .weight-val { font-size: 1rem; }

.gain-item {
    width: 80px;
    /* heightはJSで動的 */
    background: linear-gradient(135deg, #fce7f3 0%, #fbbf24 40%, #d97706 100%);
    font-size: 0.9rem;
    padding: 8px 4px;
    opacity: 0; /* JSで落下させるまで隠す */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.gain-item .plus { color: #fed7aa; font-size: 0.75rem; }
.gain-item .weight-val { font-size: 1.4rem; font-weight: 900; }

/* 落下アニメーション用クラス */
.gain-item.dropping {
    animation: drop-gold 0.5s ease-in forwards;
}

@keyframes drop-gold {
    0% { transform: translateY(-300px) scale(1.1); opacity: 0; }
    30% { opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}


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

.profit-card {
    background: rgba(6, 78, 59, 0.4); /* 暗いエメラルド */
    border: 2px solid #10b981;
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

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

.profit-value {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 16px;
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    font-variant-numeric: tabular-nums;
}
.profit-value .sign { font-size: 2rem; margin-right: 4px; color: #6ee7b7; }
.profit-value .unit { font-size: 1.2rem; color: #a7f3d0; margin-left: 4px;}

.breakdown-box {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    text-align: left;
}

.bd-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
}
.bd-row:last-child { margin-bottom: 0; padding-bottom: 0; }
.text-green { color: #6ee7b7; }
.text-red { color: #fca5a5; }
.text-gray { color: #cbd5e1; }
.bd-row strong { font-size: 1.1rem; }

/* 内訳 */
.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;
}
