/* ───── 토큰 ─────
   어르신 사용 기준: 본문 18px 이상, 터치 영역 64px 이상, 명암비 7:1 이상.
   햇빛 아래 야외에서 쓰므로 다크모드를 쓰지 않고 흰 바탕으로 고정한다. */
:root {
  --green: #0f5132;        /* 흰 글씨 기준 8.6:1 */
  --green-dark: #0a3a24;
  --green-soft: #e3f0e8;
  --bg: #f2f4f2;
  --surface: #ffffff;
  --text: #121a14;         /* 17:1 */
  --text-dim: #42504a;     /* 8.1:1 */
  --line: #c4cec8;
  --line-strong: #8d9a93;
  --under: #0d47a1;        /* 버디 등 언더파 8.6:1 */
  --over: #a01b13;         /* 보기 등 오버파 7.4:1 */
  --radius: 16px;
  --tap: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* 글자 크기 3단계 — 본문이 전부 rem이라 이 값만 바뀌면 함께 커진다 */
html { font-size: 16px; }
html[data-scale="l"] { font-size: 18px; }
html[data-scale="xl"] { font-size: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 클래스의 display가 UA의 [hidden] 규칙을 이기므로 한 번에 눌러둔다 */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
               "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 1.15rem;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }

/* ───── 화면 전환 ───── */
.screen { display: none; height: 100%; flex-direction: column; }
.screen.is-active { display: flex; }

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px calc(20px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.scroll--play { padding: 10px 8px calc(20px + var(--safe-b)); }

/* ───── 헤더 ───── */
.top {
  position: relative;
  background: var(--green);
  color: #fff;
  /* 오른쪽은 회사 로고 자리 — 긴 제목이 로고를 타고 올라가지 않게 비워둔다 */
  padding: calc(16px + env(safe-area-inset-top, 0px)) 104px 16px 16px;
}
/* 회사 로고 — 밝은 하늘색이라 진초록 위에서 그대로 읽힌다 */
.brand {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: 16px;
  height: 26px; width: auto;
  opacity: 0.95;
}
.top__title { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.top__sub { margin: 4px 0 0; font-size: 1.05rem; opacity: 0.95; }

.top--play {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 10px;
}
.holehead { flex: 1; text-align: center; font-size: 1.75rem; font-weight: 800; line-height: 1.15; }
.holehead__cs {
  display: block; font-style: normal;
  font-size: 0.56em; font-weight: 700;
  color: rgba(255,255,255,0.88); letter-spacing: 0.02em;
}

.topbtn {
  flex: 0 0 auto;
  min-width: 78px; min-height: var(--tap);
  padding: 0 10px;
  border: 2px solid rgba(255,255,255,0.65); border-radius: 12px;
  background: transparent; color: #fff;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
}
.topbtn:active { background: rgba(255,255,255,0.25); }
.topbtn.is-off { opacity: 0.6; border-style: dashed; }

/* ───── 카드 ───── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  margin-bottom: 12px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--par { border-color: var(--line-strong); }
.card__title {
  margin: 0 0 12px;
  font-size: 1.15rem; font-weight: 800;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card__badge {
  font-size: 0.95rem; font-weight: 700;
  color: #fff; background: var(--green);
  padding: 4px 11px; border-radius: 999px;
}
.card__note { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); }
.hint { margin: 12px 0 0; font-size: 1rem; color: var(--text-dim); }
.hint--warn { color: var(--over); font-weight: 700; }
.hint--center { text-align: center; }

/* ───── 입력 ───── */
.field--row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.field__label { font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.field--row input[type="range"] { flex: 1; height: 40px; accent-color: var(--green); }

input[type="text"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}
input[type="text"]::placeholder { color: var(--text-dim); }
input[type="text"]:focus { outline: 3px solid var(--green); outline-offset: -1px; }

.seg { display: flex; gap: 8px; }
.seg__btn {
  flex: 1; min-height: var(--tap);
  border: 2px solid var(--line-strong); border-radius: 12px;
  background: var(--surface);
  font-size: 1.1rem; font-weight: 800;
  cursor: pointer;
}
.seg__btn.is-on {
  background: var(--green); border-color: var(--green); color: #fff;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35);
}
.seg--par .seg__btn { min-height: 72px; font-size: 1.3rem; }

.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__box {
  flex: 0 0 62px; width: 62px; height: 36px;
  border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background 0.15s;
}
.switch__box::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch__box { background: var(--green); }
.switch input:checked + .switch__box::after { transform: translateX(26px); }
.switch__text { font-size: 1.1rem; font-weight: 700; }
.switch__text em { display: block; font-style: normal; font-weight: 500; font-size: 1rem; color: var(--text-dim); margin-top: 2px; }

/* ───── 경기 종류 고르기 ───── */
.card--mode { border-color: var(--line-strong); border-width: 3px; }
.seg--mode .seg__btn { min-height: 76px; font-size: 1.25rem; }

/* 코스 A~F — 치는 순서대로 누른다. 누른 자리에 순서 번호가 뜬다 */
.sublabel {
  margin: 18px 0 8px; font-size: 1.1rem; font-weight: 800;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.seg--course { flex-wrap: wrap; gap: 8px; }
.seg--course .seg__btn {
  flex: 0 0 calc(33.333% - 6px);
  min-height: 60px; font-size: 1.25rem;
  position: relative;
}
.seg__ord:not(:empty) {
  position: absolute; top: 4px; right: 6px;
  min-width: 22px; height: 22px; line-height: 22px;
  border-radius: 999px; background: #fff; color: var(--green);
  font-size: 0.85rem; font-weight: 800;
}
.coursepick {
  margin: 12px 0 0; padding: 12px 14px;
  border: 2px dashed var(--line-strong); border-radius: 12px;
  font-size: 1.05rem; font-weight: 700; color: var(--text-dim);
  text-align: center; word-break: keep-all;
}
.coursepick.is-set {
  border-style: solid; border-color: var(--green);
  background: var(--green-soft); color: var(--green);
  font-size: 1.15rem; font-weight: 800;
}
#btn-course-clear { margin-top: 10px; }

/* ───── 대회 참가 ───── */
.joinrow { display: flex; gap: 10px; }
.joinrow input {
  flex: 1; min-width: 0;
  font-size: 1.5rem; font-weight: 800;
  letter-spacing: 0.22em; text-align: center; text-transform: uppercase;
}
.joinrow .btn { flex: 0 0 auto; padding: 0 22px; }

/* 대회 중에만 보이는 띠 — 심판이 전송 상태를 늘 볼 수 있어야 한다 */
.meetbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px;
  background: #0b3f27; color: #fff;
  font-size: 0.95rem; font-weight: 700;
}
.meetbar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meetbar__sync { flex: 0 0 auto; padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,0.18); }
.meetbar__sync.is-ok { background: #1f7a4d; }
.meetbar__sync.is-wait { background: #8a6a12; }
.meetbar__sync.is-err { background: #a01b13; }

/* ───── 홀 확정 ───── */
.srow.is-locked { border-color: var(--line-strong); background: #f6f8f6; }
.srow.is-locked .chip,
.srow.is-locked .penflag { opacity: 0.45; pointer-events: none; }
.lockdone {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--green); border-radius: 14px;
  background: var(--green-soft); color: var(--green);
  padding: 14px; margin-bottom: 14px;
  font-size: 1.05rem; font-weight: 800;
}
.lockdone small { display: block; font-weight: 600; color: var(--text-dim); }
.lockdone--warn { border-color: var(--over); background: #f9e9e7; color: var(--over); }

/* ───── 설치 안내 ───── */
.card--install {
  border-color: var(--green);
  border-width: 3px;
  background: var(--green-soft);
}
.card--install .card__title { color: var(--green); }
.install__desc {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.5;
}

/* ───── 내 기록 ───── */
.merow { display: flex; gap: 10px; }
.merow input { flex: 1; min-width: 0; }
.merow input#in-me-pin {
  flex: 0 0 42%;
  text-align: center; letter-spacing: 0.3em; font-weight: 800;
}
.me-who { margin: 0 0 14px; font-size: 1.1rem; }
.me-who b { font-size: 1.3rem; }
.me-who span { display: block; color: var(--text-dim); font-size: 1rem; font-weight: 600; margin-top: 2px; }

/* 최근 흐름 — 타수가 적을수록 막대가 짧다 */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.trend__bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.trend__fill { background: var(--green); border-radius: 6px 6px 0 0; min-height: 4px; }
.trend__fill.is-best { background: var(--under); }
.trend__num {
  font-size: 0.8rem; font-weight: 800; text-align: center;
  color: var(--text-dim); margin-bottom: 3px;
}

/* 파별 평균 — 막대가 길수록 파보다 많이 친다 */
.bypar { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bypar li {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: var(--surface);
}
.bypar b { flex: 0 0 62px; font-size: 1.15rem; }
.bypar .bar { flex: 1; height: 14px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bypar .bar i { display: block; height: 100%; }
.bypar .num { flex: 0 0 auto; font-size: 1rem; font-weight: 800; }
.bypar .num small { font-weight: 600; color: var(--text-dim); }

/* ───── 오늘 친 경기 ───── */
.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.games button {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); text-align: left; cursor: pointer;
}
.games button:active { background: var(--green-soft); }
.games__when { flex: 0 0 auto; font-size: 1.05rem; font-weight: 800; color: var(--green); }
.games__who { flex: 1; min-width: 0; font-size: 1.05rem; font-weight: 700; }
.games__who small { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-dim); }
.games__go { flex: 0 0 auto; font-size: 1.2rem; color: var(--text-dim); }

/* ───── 사람 목록 ───── */
.players { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.players li { display: flex; gap: 10px; align-items: center; }
.players input { flex: 1; }
.players .del {
  flex: 0 0 var(--tap); min-height: var(--tap);
  border: 2px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); color: var(--over);
  font-size: 1.1rem; font-weight: 800; cursor: pointer;
}
.players .del:active { background: #f7e3e1; }
.players .del[disabled] { opacity: 0.35; }

/* ───── 스코어 입력 ───── */
.scores { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; }
.srow {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px 12px;
}
.srow.is-done { border-color: var(--green); }
.srow__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 10px; padding: 0 2px;
}
.srow__name { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.srow__meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.srow__term { font-size: 1.1rem; font-weight: 800; }
.srow__total { font-size: 0.95rem; color: var(--text-dim); font-weight: 700; }
.srow__total b { font-size: 1rem; }

/* 1타부터 고른다. 한 줄에 5개씩 두 줄. */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  flex: 0 0 calc((100% - 20px) / 5);
  min-width: 0; min-height: 62px;
  border: 2px solid var(--line-strong); border-radius: 12px;
  background: var(--surface);
  font-size: 1.45rem; font-weight: 800;
  cursor: pointer;
}
.chip:active { background: var(--green-soft); }
.chip.is-on {
  background: var(--green); border-color: var(--green); color: #fff;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35);
}
.chip--more { font-size: 1.1rem; letter-spacing: 0.05em; }

/* 벌타 — 타수는 건드리지 않고 '있었다'만 표시한다 */
.penflag {
  display: block; width: 100%; min-height: 54px;
  margin-top: 9px;
  border: 2px dashed var(--line-strong); border-radius: 12px;
  background: var(--surface);
  font-size: 1.05rem; font-weight: 800; color: var(--text-dim);
  cursor: pointer;
}
.penflag:active { background: #f7e3e1; }
.penflag.is-on {
  border-style: solid; border-color: var(--over);
  background: #f9e9e7; color: var(--over);
}

/* 파를 고르고 나면 한 줄로 접어 자리를 돌려준다 */
.parset { display: flex; align-items: center; gap: 12px; }
.parset__now { flex: 1; font-size: 1.15rem; font-weight: 700; }
.parset__now b { font-size: 1.35rem; color: var(--green); }
.parset .btn { flex: 0 0 auto; min-height: 56px; font-size: 1rem; }

.t-under { color: var(--under); }
.t-over { color: var(--over); }
.t-par { color: var(--green); }

/* ───── 결과 ───── */
.rank { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.rank li {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 14px 14px;
}
.rank li:first-child { border-color: var(--green); background: var(--green-soft); }
.rank__pos {
  flex: 0 0 38px; height: 38px; line-height: 34px; text-align: center;
  border: 2px solid var(--line-strong); border-radius: 50%;
  font-size: 1.1rem; font-weight: 800; color: var(--text-dim);
}
.rank li:first-child .rank__pos { border-color: var(--green); color: var(--green); }
.rank__name { flex: 1; font-size: 1.25rem; font-weight: 800; }
.rank__score { font-size: 1.15rem; font-weight: 800; text-align: right; }
.rank__score small { display: block; font-size: 0.95rem; font-weight: 700; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rtable { border-collapse: collapse; width: 100%; font-size: 1.05rem; }
.rtable th, .rtable td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px; text-align: center;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rtable tbody th {
  text-align: left; padding-left: 14px;
  font-weight: 800; background: var(--surface);
}
/* 옆으로 밀어도 이름 칸만 붙어 있게 한다. 홀 번호 칸까지 붙으면 서로 겹친다 */
.rtable tbody tr > th:first-child {
  position: sticky; left: 0;
  border-right: 1px solid var(--line);
}
.rtable .sum { font-weight: 800; background: var(--green-soft); }

/* 코스 한 칸 — 머리 두 줄(코스·홀 번호 / 파) 아래에 사람마다 한 줄.
   thead 는 운영본부 화면(board.html)이 쓴다 — 같이 챙긴다 */
.rtable thead th,
.rtable .hd th { background: var(--green); color: #fff; font-weight: 800; text-align: center; }
.rtable thead .sum { background: var(--green-dark); }
.rtable .hd th.csname { text-align: left; letter-spacing: 0.02em; border-right-color: rgba(255,255,255,0.3); }
.rtable .hd .sum { background: var(--green-dark); }
.rtable .csec + .csec .hd th { border-top: 10px solid var(--surface); }
/* 안 친 칸 — 빈칸과 헷갈리지 않게 옅게 덮어둔다 */
.rtable .pad { background: var(--bg); border-bottom-color: var(--bg); }
.rtable .hd .pad { background: var(--green); }
.rtable .csec--tot td { color: var(--text-dim); font-weight: 700; }

/* 코스를 골랐으면 한 칸이 9홀이라, 칸 사이를 좁혀 폰 너비에 들어가게 한다.
   칸 너비를 못 박지 않고 글자에 맞춰 늘어나게 둔다 — 10타가 넘어도 안 잘린다. */
.rtable--cs th, .rtable--cs td { padding-left: 3px; padding-right: 3px; }
.rtable--cs tr > :first-child { padding-left: 10px; padding-right: 6px; }

/* 결과표만 화면 양끝까지 늘린다. 9홀 한 줄이 폰에 그대로 들어가도록 */
.card--bleed {
  margin-left: -12px; margin-right: -12px;
  border-left: 0; border-right: 0; border-radius: 0;
}

/* ───── 버튼 ───── */
.bottom {
  padding: 12px 12px calc(12px + var(--safe-b));
  background: var(--surface);
  border-top: 2px solid var(--line);
}
.bottom--nav { display: flex; gap: 10px; }
.bottom--nav .btn { flex: 1; }
.bottom--nav .btn--primary { flex: 1.4; }

.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border: 2px solid transparent; border-radius: 14px;
  font-size: 1.15rem; font-weight: 800;
  cursor: pointer;
}
.btn--block { display: block; width: 100%; }
/* 링크를 버튼처럼 쓸 때 — 글자가 가운데에 오게 */
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.btn--lg { min-height: 72px; font-size: 1.35rem; }
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:active { background: var(--green-dark); }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); }
.btn--ghost:active { background: var(--green-soft); }
/* 사람 추가 — 한 명으로 시작하니 이 버튼이 눈에 잘 띄어야 한다 */
.btn--add {
  min-height: 72px;
  font-size: 1.3rem;
  background: var(--green-soft);
  border: 3px solid var(--green);
  color: var(--green);
}
.btn--add:active { background: #d3e7da; }

.btn--danger { background: var(--surface); border-color: var(--over); color: var(--over); }
.btn--danger:active { background: #f7e3e1; }
.btn[disabled] { opacity: 0.35; }
.btn--spaced { margin-top: 10px; }

/* 저장이 막힌 기기에서 이미지를 직접 꾹 눌러 저장하도록 보여준다 */
.shot {
  width: 100%; height: auto; display: block;
  border: 2px solid var(--line); border-radius: 12px;
  margin-bottom: 14px;
}

/* ───── 대화상자 ───── */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 20, 14, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal__card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 20px;
  padding: 20px 16px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.modal__title { margin: 0 0 10px; font-size: 1.3rem; font-weight: 800; }
.modal__body {
  font-size: 1.1rem; color: var(--text-dim); margin-bottom: 18px;
  white-space: pre-wrap; max-height: 46vh; overflow-y: auto;
}
.modal__actions { display: grid; gap: 10px; }
.modal__num {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 18px;
}
.modal__num button {
  flex: 0 0 72px; min-height: 72px;
  border: 2px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); font-size: 2rem; font-weight: 800; cursor: pointer;
}
.modal__num span {
  flex: 1; text-align: center;
  font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums;
}

/* ───── 저작권 표기 ───── */
.legal {
  margin: 22px 4px 4px;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.legal strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 3px;
}
/* 개인정보처리방침 — 스토어가 앱 안에서 닿을 수 있기를 요구한다 */
.legal a {
  display: inline-block;
  margin-top: 6px; padding: 6px 4px;
  color: var(--green); font-weight: 700;
}

/* ───── 토스트 ───── */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b));
  transform: translateX(-50%);
  max-width: 88vw;
  background: #121a14; color: #fff;
  padding: 14px 20px; border-radius: 999px;
  font-size: 1.05rem; font-weight: 700;
  z-index: 50;
}
