:root {
    --main: #007aff;
    --accent: #5856d6;
    --spare: #ff9500;
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --text: #1d1d1f;
    --sub: #86868b;
    --border: rgba(0,0,0,0.08);
    --input-bg: #ffffff;
    --success-bg: #e8f5e9;
    --success-text: #2e7d32;
    --warning-bg: #fffde7;
    --warning-text: #5d4037;
    --info-bg: #e3f2fd;
    --info-text: #1976d2;
    --neutral-bg: #f5f5f5;
    --neutral-text: #757575;
}

:root[data-theme='dark'] {
    --main: #0a84ff;
    --accent: #5e5ce6;
    --spare: #ff9f0a;
    --bg: #121212;
    --card-bg: #1c1c1e;
    --text: #ffffff;
    --sub: #8e8e93;
    --border: rgba(255,255,255,0.15);
    --input-bg: #2c2c2e;
    --success-bg: rgba(46, 125, 50, 0.2);
    --success-text: #81c784;
    --warning-bg: rgba(251, 192, 45, 0.15);
    --warning-text: #ffd54f;
    --info-bg: rgba(25, 118, 210, 0.2);
    --info-text: #64b5f6;
    --neutral-bg: rgba(255, 255, 255, 0.1);
    --neutral-text: #bdbdbd;
}

/* 全てのサイズ計算を内側に固定 */
*, *::before, *::after { 
    box-sizing: border-box !important; 
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Noto Sans JP', -apple-system, sans-serif;
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 10px 24px 50px 24px; 
}

h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    letter-spacing: -1px;
}

/* 💡 ガイドエリア */
.guide {
    position: relative;
    padding: 20px 30px 20px 60px;
    background: var(--card-bg);
    border-radius: 16px;
    border-left: 6px solid var(--main);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    margin-bottom: 25px;
    font-size: 0.9rem;
    color: var(--text);
}

.guide::before {
    content: "💡";
    position: absolute;
    left: 22px;
    top: 18px;
    font-size: 1.4rem;
}

/* 💳 メインカード */
.card {
    background: var(--card-bg);
    border-radius: 20px;
    margin-bottom: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-h {
    background: rgba(0,0,0,0.02);
    padding: 18px 40px; 
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--sub);
    border-bottom: 1px solid var(--border);
}

[data-theme='dark'] .card-h {
    background: rgba(255,255,255,0.02);
}

.card-body {
    padding: 40px 50px !important; 
}

.form-group {
    margin-bottom: 30px;
}

.label-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.form-label {
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
}

/* 🏷️ 数値バッジ */
.badge { 
    background: var(--accent); 
    color: white; 
    padding: 3px 12px; 
    border-radius: 20px; 
    font-size: 0.75rem; 
    font-weight: bold; 
}
.badge.spare { 
    background: var(--spare); 
}

/* 入力要素 */
select {
    width: 100% !important;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text);
    cursor: pointer;
}

input[type="range"] { 
    appearance: none;
    -webkit-appearance: none; 
    width: 100%; 
    height: 8px; 
    background: #eee; 
    border-radius: 5px; 
    outline: none; 
    margin: 15px 0; 
}

input[type="range"]::-webkit-slider-thumb { 
    appearance: none;
    -webkit-appearance: none; 
    width: 22px; 
    height: 22px; 
    background: var(--main); 
    border-radius: 50%; 
    cursor: pointer; 
    border: 3px solid var(--card-bg); 
    box-shadow: 0 2px 6px rgba(0,0,0,0.1); 
}

/* 🚀 計算実行ボタン */
.btn {
    background: linear-gradient(135deg, var(--main), var(--accent));
    color: white;
    border: none;
    padding: 16px 50px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    font-size: 1.1rem;
    width: 100%;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* 📊 計算結果エリア */
.res-card { 
    background: rgba(88, 86, 214, 0.05); 
    border-radius: 16px; 
    padding: 30px; 
    border: 1px solid var(--border); 
    margin-top: 40px; 
}

.res-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 15px 0; 
    border-bottom: 1px dotted #d1d1d6; 
    align-items: center; 
}

.res-val { 
    font-weight: 800; 
    color: var(--main); 
    font-size: 1.4rem; 
}

.res-row:last-of-type { 
    border-bottom: none; 
}

.cond-tag { 
    background: var(--main); 
    color: white; 
    padding: 6px 15px; 
    border-radius: 8px; 
    font-size: 0.85rem; 
    font-weight: bold; 
    display: inline-block; 
    margin-bottom: 25px; 
}

/* ⚠️ エラーメッセージ */
.error-msg { 
    color: #ff3b30; 
    background: #fff1f0; 
    padding: 18px; 
    border-radius: 12px; 
    border: 1px solid #ffa39e; 
    margin-top: 25px; 
    font-weight: bold; 
}

/* サイト紹介文 */
.site-intro { 
    color: var(--sub); 
    font-size: 0.9rem;
    max-width: 700px; 
    margin: 0 auto; 
    line-height: 1.6; 
    font-weight: 500; 
    text-align: left;
}

/* 📱 モバイル対応（画面幅650px以下） */
@media (max-width: 650px) {
    .container {
        padding: 10px 12px 30px 12px; /* 外側の余白を半分にしてカードを広げる */
    }
    
    .card-body {
        padding: 25px 15px !important; /* カード内部の左右余白を詰める */
    }
    
    .card-h {
        padding: 12px 15px;
    }

    h1 {
        font-size: 1.5rem;
        margin-left: 5px;
    }

    .guide {
        padding: 15px 20px 15px 50px;
        font-size: 0.85rem;
    }
    
    .guide::before {
        left: 15px;
    }

    .btn {
        font-size: 1rem;
        padding: 14px;
    }

    .res-val {
        font-size: 1.2rem;
    }

    .site-intro { 
        font-size: 0.85rem;
        line-height: 1.5;
    }
}