:root {
    --primary: #1F4E79;
    --primary-hover: #163858;
    --primary-light: #2E75B6;
    --bg-color: #F8F9FA;
    --card-bg: #FFFFFF;
    --text-primary: #1C1C1E;
    --text-secondary: #757575;
    --border-color: #E0E0E0;
    --highlight-green: #E2EFDA;
    --accent-green-text: #2E7D32;
    --accent-orange-bg: #FFF3E0;
    --accent-orange-text: #E65100;
    --radius-card: 16px;
    --radius-btn: 12px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-header: 0 2px 10px rgba(31, 78, 121, 0.2);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --card-bg: #1E1E1E;
        --text-primary: #FFFFFF;
        --text-secondary: #AAAAAA;
        --border-color: #333333;
        --highlight-green: #1B382B;
        --accent-green-text: #81C784;
        --accent-orange-bg: #3E2723;
        --accent-orange-text: #FFB74D;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* 안드로이드 / iOS 스크린 매칭 컨테이너 */
.app-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    min-height: 100vh;
}

/* Top App Bar */
.app-bar {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 18px 16px;
    text-align: center;
    box-shadow: var(--shadow-header);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-bar h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

/* 카드 UI */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-card);
    padding: 18px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 입력 폼 그리드 */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-group input {
    width: 100%;
    min-width: 0;
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
    text-align: right;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary-light);
}

/* 인원 스태퍼(Stepper) 버튼 스타일링 */
.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.stepper input {
    border: none;
    background: transparent;
    text-align: center;
    padding: 10px 0;
}

.btn-step {
    background: var(--border-color);
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 800;
    width: 36px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    user-select: none;
}

.btn-step:hover {
    background: var(--primary-light);
    color: white;
}

.btn-step:active {
    transform: scale(0.95);
}

.btn-calc {
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    border: none;
    border-radius: var(--radius-btn);
    background: var(--primary);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(31, 78, 121, 0.25);
    transition: background-color 0.2s, transform 0.1s;
}

.btn-calc:hover {
    background: var(--primary-hover);
}

.btn-calc:active {
    transform: scale(0.98);
}

/* 시나리오 탭 */
.tab-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
    box-shadow: 0 4px 10px rgba(46, 117, 182, 0.2);
}

/* 시나리오 헤더 카드 */
.scenario-header-card {
    background: var(--highlight-green);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    border: 1px solid rgba(46, 117, 182, 0.15);
}

.scenario-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
}

.scenario-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 등수별 리스트 */
.rank-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rank-card {
    background: var(--card-bg);
    border-radius: var(--radius-btn);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.rank-card.worst {
    background: var(--accent-orange-bg);
    border-color: rgba(230, 81, 0, 0.3);
}

.rank-card.best {
    background: var(--highlight-green);
    border-color: rgba(46, 125, 50, 0.3);
}

.rank-name {
    font-size: 14px;
    font-weight: 700;
}

.rank-card.worst .rank-name { color: var(--accent-orange-text); }
.rank-card.best .rank-name { color: var(--accent-green-text); }

.rank-amt-group {
    text-align: right;
}

.rank-amt {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
}

.rank-diff {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* 총합계 배지 카드 */
.total-card {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-btn);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(31, 78, 121, 0.3);
    margin-top: 4px;
}

.total-label {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.total-val {
    font-size: 18px;
    font-weight: 800;
}

.error-card {
    background: #FFEBEE;
    color: #C62828;
    padding: 14px;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}
