.container {
    max-width: 600px;
    margin: 20px auto;
    padding: 0 15px;
}

h1 {
    /* clampを使って、画面幅に合わせて文字サイズを適切に調整します */
    /* 最小 1.1rem、推奨 4.5vw（画面幅の4.5%）、最大 1.6rem */
    font-size: clamp(1.1rem, 4.5vw, 1.6rem);
    
    color: #333;
    margin: 20px 0;
    text-align: center;
    font-weight: bold;

    /* --- ここからが2行にしないための重要設定 --- */
    white-space: nowrap;     /* 文字を折り返さない */
    overflow: hidden;        /* はみ出た分を隠す */
    text-overflow: ellipsis; /* もし入り切らないほど狭ければ末尾を「...」にする */
    
    /* 左右に少しだけ余白を持たせて、画面端に密着するのを防ぐ */
    padding: 0 5px;
    box-sizing: border-box;
}

/* モード切替ボタン */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
    border: 1px solid #4364f7;
    border-radius: 8px;
    overflow: hidden;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: #fff;
    color: #4364f7;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.mode-btn.active {
    background: #4364f7;
    color: #fff;
}

.calculator-card, .result-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    text-align: left;
}

.input-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #ddd;
}

.input-group:last-child {
    border-bottom: none;
}

.input-group h3 {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 10px;
    border-left: 4px solid #4364f7;
    padding-left: 8px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 1fr 1fr 1fr と同義ですが、より簡潔です */
    gap: 10px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.input-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.input-field label {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #444;
}

.input-field input, .input-field select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box; /* これを追加: paddingとborderを幅に含める */
    width: 100%; /* これを追加: 親要素の幅いっぱいに広げる */
}

.input-field input:focus {
    outline: none;
    border-color: #4364f7;
    box-shadow: 0 0 0 2px rgba(67, 100, 247, 0.1);
}

/* 結果表示エリア */
.result-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0f4ff 100%);
    border: 2px solid #4364f7;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-sizing: border-box; /* はみ出し防止 */
}

.total-eval {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* 狭い時に上下に逃げられるようにする */
    gap: 10px;
    padding: 10px 0;
}

.total-eval .label {
    font-weight: bold;
    color: #4364f7;
    font-size: 1rem;
    white-space: nowrap;
}

.total-eval .value {
    font-size: clamp(1.5rem, 8vw, 2.5rem); /* 最小1.5rem、画面幅の8%、最大2.5rem */
    font-weight: 800;
    color: #333;
    line-height: 1;
}

.target-scores h3 {
    font-size: 0.9rem;
    margin: 15px 0 10px;
    color: #555;
}

.target-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: clamp(0.9rem, 4vw, 1rem); /* 文字サイズを微調整 */
}

.needed-score {
    font-weight: bold;
    color: #e63946;
    text-align: right;
}



/* 属性カラー設定 */
.label-vo { color: #ff4d4d !important; } /* 赤 */
.label-da { color: #4d79ff !important; } /* 青 */
.label-vi { color: #ffbc00 !important; } /* 黄（見やすく調整） */

/* 評価値表示のレイアウト調整 */
.eval-display {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 1; /* 親に合わせて縮むように設定 */
}

/* ランクバッジのデザイン */
.rank-badge {
    background-color: #4364f7;
    color: white;
    padding: 2px 12px;
    border-radius: 4px;
    font-weight: bold;
    font-size: clamp(1rem, 5vw, 1.3rem);
    min-width: 60px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* スマホ用微調整：さらに狭い画面（iPhone SE等）の場合 */
@media screen and (max-width: 400px) {
    .result-card {
        padding: 15px 10px; /* 内側の余白を削る */
    }
    .total-eval {
        justify-content: center; /* 中央寄せにして安定させる */
        text-align: center;
    }
}

.param-total-display {
    margin-top: 10px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: bold;
    color: #666;
}

#preTotal {
    color: #4364f7; /* メインカラーに合わせて青色に */
    font-size: 1.1rem;
    margin-left: 5px;
}