/* =============================================
   파크골프 스코어카드 - 전체 디자인 시스템
   참고 이미지: pill 형태 스코어, 아이보리 배경
   ============================================= */

/* 색상 및 디자인 변수 */
:root {
    /* 메인 컬러 - 골프 그린 */
    --primary-color: #2d8a4e;
    --primary-light: #4caf72;
    --primary-dark: #1a5e34;
    --primary-gradient: linear-gradient(135deg, #2d8a4e 0%, #4caf72 100%);

    /* 보조 컬러 */
    --secondary-color: #f59e0b;
    --danger-color: #ef4444;

    /* 배경 - 아이보리/크림 톤 */
    --bg-color: #faf8ee;
    --card-bg: #ffffff;

    /* 텍스트 */
    --text-main: #2c3e50;
    --text-light: #8e9aaa;
    --text-muted: #adb5bd;

    /* 테두리 */
    --border-color: #ede9d8;

    /* 그림자 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10);

    /* 폰트 */
    --font-base: 'Noto Sans KR', sans-serif;

    /* 스코어 pill 색상 */
    --color-eagle: #155d35;        /* 이글 이하: 매우 진한 초록 */
    --color-birdie: #2d8a4e;       /* 버디: 초록 */
    --color-par: #f5e06e;          /* 파: 연한 노란색 */
    --color-par-text: #7a6500;     /* 파 텍스트: 어두운 노란 */
    --color-bogey: #f9d44a;        /* 보기: 노란색 */
    --color-bogey-text: #6b5000;   /* 보기 텍스트 */
    --color-double: #b07d10;       /* 더블보기 이상: 올리브/갈색 */
}

/* =============================================
   기본 리셋 & 전역 스타일
   ============================================= */
* {
    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 20% 80%, rgba(45, 138, 78, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(76, 175, 114, 0.05) 0%, transparent 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(--bg-color);
    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.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active {
    display: flex;
}

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

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

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

/* =============================================
   컨텐츠 영역
   ============================================= */
.content {
    padding: 20px 16px;
    flex: 1;
    overflow-y: auto;
}

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

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

input[type="text"],
input[type="date"],
input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 10px;
    background-color: #ffffff;
    font-family: var(--font-base);
    color: var(--text-main);
    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 3px rgba(45, 138, 78, 0.12);
}

/* =============================================
   라디오 그룹 (홀 선택, Par 선택)
   ============================================= */
.radio-group {
    display: flex;
    gap: 10px;
}

.radio-group label {
    flex: 1;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0;
}

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

.radio-group label:has(input[type="radio"]:checked) {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(45, 138, 78, 0.3);
    transform: translateY(-1px);
}

/* =============================================
   버튼 스타일
   ============================================= */
.btn {
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.18s ease;
    text-align: center;
    font-family: var(--font-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

/* 메인 버튼 */
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(45, 138, 78, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(45, 138, 78, 0.45);
    transform: translateY(-1px);
}

/* 보조 버튼 */
.btn-secondary {
    background: white;
    color: var(--primary-dark);
    border: 1.5px solid var(--primary-color);
}

.btn-secondary:hover {
    background: #f0faf4;
}

/* 위험(삭제) 버튼 */
.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* 큰 버튼 */
.btn-large {
    width: 100%;
    padding: 17px;
    font-size: 1.1rem;
    margin-top: 8px;
    border-radius: 16px;
}

/* 작은 버튼 */
.btn-small {
    padding: 8px 14px;
    font-size: 0.88rem;
    border-radius: 10px;
}

/* 아이콘 버튼 (이전/다음 홀) */
.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.4rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 헤더 가운데 영역 - 홀 타이틀 + 중단하기 버튼을 세로로 배치 */
.header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* 중단하기 버튼 - 헤더 안에 작게 표시 */
.btn-stop-round {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-base);
    transition: all 0.15s ease;
}

.btn-stop-round:hover {
    background: rgba(255, 255, 255, 0.25);
}

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


/* =============================================
   구분선
   ============================================= */
.divider {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 24px 0;
}

/* =============================================
   섹션 타이틀
   ============================================= */
.section-title {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 14px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

/* =============================================
   히스토리 목록
   ============================================= */
.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 각 히스토리 카드 */
.history-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.history-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: #c8e6d5;
}

.history-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 10px;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
    /* 긴 텍스트 줄임 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* 기록 없을 때 */
.empty-history {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    background: #f8f9fa;
    border-radius: 14px;
    font-size: 0.9rem;
}

/* =============================================
   설정 섹션 (AI 비전 안내 등)
   ============================================= */
.settings-section details {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: 20px;
}

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

/* =============================================
   스코어 기록 화면 - Par 선택 바
   ============================================= */
.par-selector {
    background: white;
    padding: 14px 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: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
}

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

/* =============================================
   플레이어 스코어 카드 (기록 화면)
   ============================================= */
.player-scores-container {
    padding-bottom: 90px; /* 하단 버튼 가림 방지 */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-score-card {
    background: white;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 10px 14px;    /* 패딩 축소 */
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

/* 왼쪽 컬러 바 */
.player-score-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 5px; height: 100%;
    background: var(--primary-gradient);
    border-radius: 5px 0 0 5px;
}

.player-name-row {
    font-size: 0.95rem;     /* 이름 폰트 축소 */
    font-weight: 700;
    margin-bottom: 6px;     /* 마진 축소 */
    text-align: center;
    color: var(--text-main);
    padding-left: 10px;
}

.score-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;         /* 좌우 패딩 축소 */
}

/* 스코어 조절 버튼 (+/-) */
.btn-score {
    width: 42px;            /* 버튼 크기 축소 */
    height: 42px;
    border-radius: 50%;
    font-size: 1.6rem;      /* 아이콘 크기 축소 */
    font-weight: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f3f4f6;
    color: var(--text-main);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.15s ease;
    border: none;
    cursor: pointer;
    line-height: 1;
}

.btn-score:active {
    transform: scale(0.92) !important;
}

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

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

/* 현재 스코어 숫자 */
.current-score {
    font-size: 2.2rem;      /* 숫자 크기 축소 */
    font-weight: 800;
    min-width: 55px;
    text-align: center;
    color: var(--primary-dark);
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
}

/* =============================================
   하단 고정 액션 버튼
   ============================================= */
.bottom-actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 12px 16px 16px;
    background: rgba(250, 248, 238, 0.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

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

/* =============================================
   결과 화면 - 골프장명/날짜 정보 바
   ============================================= */
.result-info-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
    background: rgba(45, 138, 78, 0.07);
    border-bottom: 1px solid rgba(45, 138, 78, 0.15);
    flex-wrap: wrap;    /* 긴 이름이면 줄바깔 */
}

.result-info-course {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-dark);
}

.result-info-date {
    font-size: 0.88rem;
    color: var(--text-light);
    font-weight: 500;
}

/* =============================================
   스코어카드 테이블
   참고 이미지: 테두리 없이 깔끔하고 pill 스타일 셀
   ============================================= */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 20px;
    /* 테이블 자체에 배경과 그림자를 줌 */
    background: white;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

#scorecard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    min-width: 360px;
    background: white;
    border-radius: 20px;
    overflow: hidden;
}

/* 셀 기본 - 테두리 없이 */
#scorecard-table th,
#scorecard-table td {
    border: none;
    padding: 10px 8px;
    font-size: 0.95rem;
}

/* 행 구분선 (얇게) */
#scorecard-table tbody tr {
    border-bottom: 1px solid #f5f0e0;
}

#scorecard-table tbody tr:last-child {
    border-bottom: none;
}

/* 헤더 행 */
#scorecard-table thead th {
    background: white;
    color: var(--text-light);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 14px 8px 10px;
    /* 헤더 하단 경계선 */
    border-bottom: 2px solid var(--border-color) !important;
}

/* 홀 번호 컬럼 */
.col-hole {
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
    width: 36px;
}

/* Par 컬럼 */
.col-par {
    width: 44px;
}

/* 합계 행 (footer) */
#scorecard-table tfoot tr {
    border-top: 2px solid var(--border-color);
}

#scorecard-table tfoot th {
    background: #f9faf5;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 1rem;
    padding: 14px 8px;
}

/* =============================================
   스코어 pill (핵심 디자인 - 참고 이미지 기반)
   ============================================= */
.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 최소 가로 48px, 높이 40px의 둥근 pill */
    min-width: 48px;
    height: 40px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
    padding: 0 10px;
    transition: transform 0.1s;
    /* 기본: Par와 동일 (연한 노란) */
    background-color: #fef3a3;
    color: var(--color-par-text);
}

/* 이글 이하 (2언더~): 진한 초록 */
.score-pill.eagle {
    background-color: var(--color-eagle);
    color: white;
    box-shadow: 0 2px 8px rgba(21, 93, 53, 0.35);
}

/* 버디 (1언더): 초록 */
.score-pill.under-par {
    background-color: var(--color-birdie);
    color: white;
    box-shadow: 0 2px 8px rgba(45, 138, 78, 0.3);
}

/* 파 (0): 연한 노란색 */
.score-pill.par {
    background-color: #fef3a3;
    color: var(--color-par-text);
}

/* 보기 (1오버): 노란색 */
.score-pill.bogey {
    background-color: #fde047;
    color: var(--color-bogey-text);
}

/* 더블 보기 이상 (2오버~): 올리브/갈색 */
.score-pill.double-bogey {
    background-color: var(--color-double);
    color: white;
    box-shadow: 0 2px 8px rgba(176, 125, 16, 0.35);
}

/* 합계 스코어 표시 */
.total-score {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-dark);
}

/* Par 전용 pill - 사각형(둥근 모서리) 모양으로 타수 pill(타원)과 구별 */
/* 타수 pill은 border-radius: 20px (타원), par-pill은 border-radius: 8px (사각형) */
.par-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border-radius: 8px;          /* 사각형에 가까운 둥근 모서리 */
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0 8px;
    background-color: #e8f5e9;   /* 연한 초록 배경 */
    color: #1b5e20;               /* 진한 초록 텍스트 */
    border: 1.5px solid #a5d6a7; /* 초록 테두리 */
    letter-spacing: 0;
}

/* =============================================
   결과 화면 - 액션 버튼 영역
   ============================================= */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 4px 20px;
}

/* =============================================
   OCR (AI 스코어카드 인식) 섹션
   ============================================= */
.ocr-group {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    padding: 16px;
    border-radius: 16px;
    border: 1.5px dashed #818cf8;
}

.ocr-group label {
    color: #3730a3;
    font-weight: 700;
}

/* OCR 버튼 - 충분한 패딩으로 두께감 복원 */
.ocr-group .btn-secondary {
    background: white;
    border-color: #818cf8;
    color: #3730a3;
    font-weight: 700;
    padding: 14px 10px;   /* 위아래 패딩을 충분히 줘서 두께 확보 */
    font-size: 0.95rem;
    min-height: 52px;     /* 최소 높이 보장 */
}

.ocr-group .btn-secondary:hover {
    background: #f5f3ff;
}

/* =============================================
   골프장 검색 모달
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(6px);
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    box-shadow: 0 20px 50px 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.1rem;
    font-weight: 700;
    margin: 0;
}

.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

/* 지역 선택 드롭다운 */
.form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--border-color);
    font-size: 1rem;
    font-family: var(--font-base);
    background-color: #f9fafb;
    outline: none;
    transition: border-color 0.2s;
    color: var(--text-main);
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.1);
}

.course-list-container {
    flex: 1;
    overflow-y: auto;
}

.course-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.course-item {
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.course-item:hover {
    background-color: #f0fdf4;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.course-item-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 3px;
}

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

.empty-list {
    text-align: center;
    color: var(--text-light);
    padding: 20px 0;
    font-size: 0.9rem;
}

/* =============================================
   반응형 - 아주 작은 화면 대응
   ============================================= */
@media (max-width: 360px) {
    .score-pill {
        min-width: 40px;
        height: 36px;
        font-size: 0.9rem;
    }

    #scorecard-table th,
    #scorecard-table td {
        padding: 8px 4px;
    }
}