:root {
    --primary-color: #059669; /* 에메랄드 그린 */
    --primary-light: #34d399;
    --primary-dark: #047857;
    --primary-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --secondary-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-main: #1f2937;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --font-base: 'Noto Sans KR', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-base);
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #d1fae5, #f3f4f6 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

/* 앱 컨테이너 (모바일 중심) */
#app {
    max-width: 480px; /* 모바일에 더 적합한 너비 */
    margin: 0 auto;
    background-color: var(--card-bg);
    min-height: 100vh;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow-x: hidden;
}

/* 화면 전환 기본 설정 */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 공통 헤더 */
header {
    background: var(--primary-gradient);
    color: white;
    padding: 24px 20px;
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    flex: 1;
    letter-spacing: -0.5px;
}

.content {
    padding: 24px 20px;
    flex: 1;
    overflow-y: auto;
}

/* 폼 요소 */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
}

input[type="text"], input[type="date"], input[type="password"] {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    background-color: #f9fafb;
    transition: all 0.2s ease;
}

input[type="text"]:focus, input[type="date"]:focus, input[type="password"]:focus {
    border-color: var(--primary-color);
    background-color: #fff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.radio-group {
    display: flex;
    gap: 12px;
}

.radio-group label {
    flex: 1;
    background: #f9fafb;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.radio-group input[type="radio"] {
    display: none;
}

.radio-group input[type="radio"]:checked + label,
.radio-group label:has(input[type="radio"]:checked) {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* 버튼 스타일 */
.btn {
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    text-align: center;
    font-family: var(--font-base);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(5, 150, 105, 0.39);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.23);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--primary-dark);
    border: 1.5px solid var(--primary-color);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.39);
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    margin-top: 10px;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.95rem;
}

.btn-icon {
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 히스토리 섹션 */
.divider {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 30px 0;
}

.section-title {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 16px;
    font-weight: 700;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-item:active {
    transform: scale(0.98);
}

.history-info {
    flex: 1;
}

.history-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.history-desc {
    font-size: 0.85rem;
    color: var(--text-light);
}

.empty-history {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    background: #f9fafb;
    border-radius: 12px;
    font-size: 0.95rem;
}

/* 설정 섹션 */
.settings-section details {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 30px;
}

.settings-section summary {
    font-weight: 700;
    cursor: pointer;
    color: var(--text-main);
    outline: none;
}

/* 스코어 기록 화면 */
.par-selector {
    background: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.par-selector span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.par-selector .radio-group label {
    padding: 8px 16px;
    font-size: 1rem;
}

.player-scores-container {
    padding-bottom: 80px; /* 하단 버튼 가림 방지 */
}

.player-score-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.player-score-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary-gradient);
}

.player-name-row {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    color: var(--text-main);
}

.score-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

.btn-score {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f3f4f6;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    transition: background-color 0.1s;
}

.btn-score:active {
    background-color: #e5e7eb;
}

.btn-score.minus {
    color: var(--danger-color);
}

.btn-score.plus {
    color: var(--primary-color);
}

.current-score {
    font-size: 2.5rem;
    font-weight: 800;
    min-width: 60px;
    text-align: center;
    color: var(--primary-dark);
    font-variant-numeric: tabular-nums;
}

.bottom-actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.bottom-actions .btn-large {
    margin-top: 0;
}

/* 결과 테이블 */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

#scorecard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    min-width: 400px;
    background: white;
}

#scorecard-table th, #scorecard-table td {
    border: 1px solid var(--border-color);
    padding: 14px 10px;
    font-size: 1.05rem;
}

#scorecard-table th {
    background: #f9fafb;
    color: var(--text-main);
    font-weight: 700;
}

#scorecard-table tfoot th {
    background: #f3f4f6;
    color: var(--primary-dark);
    font-weight: 800;
}

.score-cell {
    font-weight: 700;
}

/* 스코어 하이라이팅 (프리미엄 룩을 위해 부드러운 배경색 사용) */
.under-par { color: #2563eb; background-color: #eff6ff; } /* 파란색: 버디 */
.par { color: #059669; }       /* 초록색: 파 */
.over-par { color: #dc2626; background-color: #fef2f2; }  /* 빨간색: 보기 */

.ocr-group {
    background: #eef2ff;
    padding: 16px;
    border-radius: 12px;
    border: 1px dashed #6366f1;
}

.ocr-group label {
    color: #4338ca;
}

.ocr-group .btn-secondary {
    width: 100%;
    padding: 14px;
    background: white;
    border-color: #6366f1;
    color: #4338ca;
}

/*  ˾ Ÿ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}
.modal-header {
    background: var(--primary-gradient);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}
.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
}
.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}
.form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    background-color: #f9fafb;
    outline: none;
    transition: border-color 0.2s;
}
.form-select:focus {
    border-color: var(--primary-color);
}
.course-list-container {
    flex: 1;
    overflow-y: auto;
}
.course-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.course-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.course-item:hover {
    background-color: #f0fdf4;
    border-color: var(--primary-color);
}
.course-item-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}
.course-item-desc {
    font-size: 0.9rem;
    color: var(--text-light);
}
.empty-list {
    text-align: center;
    color: var(--text-light);
    padding: 20px 0;
}
