/* ===== 색과 기본값 ===== */
:root {
  --forest: #0f3b28;      /* 깊은 숲색 (머리글, 홀 카드) */
  --forest-2: #17543a;
  --fairway: #2c8a57;     /* 강조 초록 */
  --flag: #d9a521;        /* 깃발 금색 (배판, 니어리스트) */
  --bg: #f4f2ea;          /* 스코어카드 종이색 */
  --card: #fffdf8;
  --sunk: #ece9df;        /* 입력칸·버튼 바탕 */
  --text: #17201a;
  --muted: #6a7268;
  --line: #e1ddd0;
  --plus: #1d7a45;
  --minus: #c2412d;
  --on-dark: #f4f2ea;
  --shadow: 0 1px 2px rgba(20, 30, 20, .06), 0 4px 14px rgba(20, 30, 20, .05);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --forest: #0d2a1d; --forest-2: #143b29; --fairway: #4cc583; --flag: #f0c040;
    --bg: #0e1411; --card: #161e19; --sunk: #1e2822; --text: #e9eee9; --muted: #95a29a; --line: #26312a;
    --plus: #5fd896; --minus: #ff7d68; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.5; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--fairway); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ===== 머리글 ===== */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--forest); color: var(--on-dark);
}
.top h1 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  background: rgba(255,255,255,.1); border: 0; border-radius: 50%; color: var(--on-dark); font-size: 24px; line-height: 1; padding: 0 2px 3px 0;
}
.mode { font-size: 12px; font-weight: 600; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
main { padding: 16px; max-width: 560px; margin: 0 auto; }

/* ===== 카드와 글자 ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.02em; }
.card h2 .muted { font-weight: 500; }
.muted { color: var(--muted); font-size: 14px; }
.plus { color: var(--plus); } .minus { color: var(--minus); }

/* ===== 입력 ===== */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--sunk);
  border: 1px solid transparent; border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
input:focus, select:focus { border-color: var(--fairway); background: var(--card); outline: none; }
input::placeholder { color: var(--muted); opacity: .8; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 500; color: var(--text); margin: 8px 0; padding: 6px 0; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--fairway); }
input[type="range"] { accent-color: var(--fairway); padding: 0; background: none; }

/* ===== 버튼 ===== */
.btn {
  display: block; width: 100%; font: inherit; font-weight: 700; font-size: 16px; border: 0; border-radius: 14px;
  padding: 16px; min-height: 54px; background: var(--forest); color: var(--on-dark); margin-top: 12px;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--sunk); color: var(--text); }
.btn.small { display: inline-flex; align-items: center; justify-content: center; width: auto; min-height: 40px; padding: 8px 14px; margin: 0; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .4; }
.file-btn { text-align: center; }
@media (prefers-color-scheme: dark) { .btn { background: var(--fairway); color: #06140c; } }

/* ===== 처음 화면 ===== */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 26px 20px 20px; margin-bottom: 16px;
  color: var(--on-dark);
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.045) 0 22px, rgba(255,255,255,0) 22px 44px),
    radial-gradient(120% 90% at 100% 0%, var(--forest-2) 0%, var(--forest) 60%);
}
.hero .flag { position: absolute; right: 18px; top: 16px; width: 54px; height: 70px; opacity: .9; }
.hero .kicker { font-size: 13px; font-weight: 600; opacity: .7; letter-spacing: .02em; }
.hero h2 { font-size: 26px; line-height: 1.25; margin: 4px 0 6px; font-weight: 800; letter-spacing: -0.03em; }
.hero p { margin: 0 0 18px; font-size: 14px; opacity: .78; max-width: 26em; }
.hero .btn { background: var(--flag); color: #1c1503; margin: 0; }
.join { display: flex; gap: 8px; margin-top: 10px; }
.join input { flex: 1; background: rgba(255,255,255,.1); color: var(--on-dark); text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.join input::placeholder { color: rgba(244,242,234,.55); letter-spacing: 0; font-weight: 500; }
.join input:focus { background: rgba(255,255,255,.16); border-color: var(--flag); }
.join .btn { width: auto; margin: 0; padding: 0 18px; background: rgba(255,255,255,.14); color: var(--on-dark); }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 22px 4px 8px; letter-spacing: .02em; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; min-height: 64px;
  font: inherit; text-align: left; color: var(--text); text-decoration: none;
  background: none; border: 0; border-top: 1px solid var(--line);
}
.list-item:first-child { border-top: 0; }
.list-item:active { background: var(--sunk); }
.list-item .ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--sunk); color: var(--fairway); }
.list-item .ico svg { width: 20px; height: 20px; }
.list-item .txt { flex: 1; min-width: 0; }
.list-item .txt b { display: block; font-weight: 600; font-size: 15px; }
.list-item .txt span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .chev { color: var(--muted); font-size: 20px; }
.list-item .date { font-size: 13px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin: 14px 6px; }

/* ===== 홀 카드 ===== */
.holebar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  background: var(--forest); color: var(--on-dark); border-radius: 22px; padding: 14px 12px;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.04) 0 18px, rgba(255,255,255,0) 18px 36px);
}
.holebar button {
  width: 44px; height: 44px; flex: none; font-size: 24px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.1); color: var(--on-dark);
}
.holebar button:disabled { opacity: .25; }
.holebar .now { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; }
.holebar .no { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.holebar .meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.holebar .meta .lbl { font-size: 12px; opacity: .65; font-weight: 600; letter-spacing: .04em; }
.holebar .meta .par { font-size: 17px; font-weight: 700; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--flag); color: #1c1503; }

.chips { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-bottom: 14px; }
.chips button {
  font: inherit; font-size: 13px; font-weight: 600; height: 34px; padding: 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.chips button.done { background: color-mix(in srgb, var(--fairway) 14%, var(--card)); color: var(--plus); border-color: transparent; }
.chips button.cur { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 800; }

/* ===== 타수 입력 ===== */
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.player:first-of-type { border-top: 0; padding-top: 2px; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff; background: var(--c, var(--fairway));
}
.player.me .avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--c, var(--fairway)); }
.player .who { flex: 1; min-width: 0; }
.player .who b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.me .who b::after { content: "나"; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--sunk); color: var(--muted); vertical-align: 2px; }
.player .who span { font-size: 13px; font-weight: 600; }
.player .who span.muted { font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--sunk); border-radius: 16px; padding: 4px; }
.stepper button { width: 44px; height: 44px; font-size: 22px; border-radius: 12px; border: 0; background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.stepper .val { width: 46px; text-align: center; font-size: 24px; font-weight: 800; line-height: 1.05; }
.stepper .val small { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: 0; }

/* 벌금 (OB, 해저드) */
.ev { flex-basis: 100%; display: flex; gap: 6px; padding-left: 52px; }
.evb { display: inline-flex; border-radius: 99px; overflow: hidden; background: var(--sunk); }
.evb button { font: inherit; font-size: 13px; font-weight: 600; min-height: 32px; padding: 4px 12px; border: 0; background: none; color: var(--muted); }
.evb button + button { border-left: 1px solid var(--line); padding: 4px 10px; }
.evb.on { background: color-mix(in srgb, var(--minus) 14%, var(--card)); }
.evb.on button { color: var(--minus); font-weight: 800; }

/* 니어리스트 · 롱기스트 */
.special { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 14px; margin-top: 4px; border-top: 1px dashed var(--line); }
.special .muted { margin-right: 4px; font-weight: 600; }
.special button { font: inherit; font-size: 14px; font-weight: 600; min-height: 36px; padding: 6px 14px; border-radius: 99px; border: 0; background: var(--sunk); color: var(--text); }
.special button.on { background: var(--flag); color: #1c1503; }

.code { font-size: 26px; font-weight: 800; letter-spacing: .18em; }
.code-card { display: flex; flex-direction: column; gap: 4px; }

/* ===== 거리 ===== */
.dist { text-align: center; }
.dist .big { font-size: 76px; font-weight: 800; line-height: 1; margin: 8px 0 4px; letter-spacing: -0.04em; }
.dist .big small { font-size: 22px; font-weight: 700; margin-left: 2px; letter-spacing: 0; color: var(--muted); }
.dist .club { display: inline-block; font-size: 15px; margin: 6px 0 2px; padding: 6px 14px; border-radius: 99px; background: color-mix(in srgb, var(--fairway) 14%, var(--card)); color: var(--plus); }
.dist .three { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dist .three div { background: var(--sunk); border-radius: 14px; padding: 10px; }
.dist .three div b { display: block; font-size: 26px; font-weight: 800; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row3 button { font: inherit; font-weight: 700; min-height: 52px; border-radius: 14px; border: 0; background: var(--sunk); color: var(--text); }
.row3 button.set { background: color-mix(in srgb, var(--fairway) 16%, var(--card)); color: var(--plus); }
.row3 button:disabled { opacity: .4; }

/* ===== 정산 ===== */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 11px 4px; text-align: right; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .02em; }
table.money td, table.money th { font-size: 14px; }
table.money td:last-child { font-size: 15px; }
.transfer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 16px; }
.transfer:first-of-type { border-top: 0; }
.transfer .arrow { color: var(--muted); margin: 0 6px; }
.transfer b { font-size: 17px; }

table.sc { font-size: 13px; table-layout: fixed; margin-bottom: 14px; }
table.sc th, table.sc td { padding: 7px 0; text-align: center; }
table.sc th:first-child, table.sc td:first-child { width: 3.4em; text-align: left; white-space: nowrap; overflow: hidden; font-weight: 600; }
table.sc th:last-child, table.sc td:last-child { width: 2.4em; }
table.sc tr.par td { color: var(--muted); background: var(--sunk); }
table.sc td span { display: inline-block; min-width: 22px; line-height: 20px; }
table.sc .under { border: 1.5px solid var(--plus); border-radius: 50%; color: var(--plus); font-weight: 700; }
table.sc .bogey { border: 1.5px solid var(--minus); border-radius: 3px; }
table.sc .double { background: var(--minus); color: #fff; border-radius: 3px; }
table.sc [data-goto] { cursor: pointer; }

/* ===== 클럽 · 핸디 · 프리셋 ===== */
.club-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.club-row:first-of-type { border-top: 0; }
.club-row span:first-child { flex: 1; font-weight: 500; }
.club-row input { width: 96px; flex: none; text-align: right; }
.prow { display: flex; gap: 8px; margin-bottom: 8px; }
.prow .pname { flex: 1; }
.prow .phandi { width: 80px; flex: none; text-align: center; }
.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.presets button { font: inherit; font-weight: 700; font-size: 15px; min-height: 52px; padding: 6px 0; border-radius: 12px; border: 0; background: var(--sunk); color: var(--text); }
.presets button small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.presets button.on { background: var(--forest); color: var(--on-dark); }
.presets button.on small { color: inherit; opacity: .7; }
@media (prefers-color-scheme: dark) { .presets button.on { background: var(--fairway); color: #06140c; } }

/* ===== 아래 탭 ===== */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; max-width: 536px; margin: 0 auto; padding: 6px;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: inherit; font-size: 12px; font-weight: 700; padding: 8px 0; border: 0; border-radius: 16px; background: none; color: var(--muted);
}
.tabs button svg { width: 22px; height: 22px; }
.tabs button.on { background: var(--forest); color: var(--on-dark); }
@media (prefers-color-scheme: dark) { .tabs button.on { background: var(--fairway); color: #06140c; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 9;
  width: max-content; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; text-align: center; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

/* 타수 줄 정리: 이름 / 이번 홀 / 누적 */
.player .who span { display: block; line-height: 1.35; }
.player .who .sum { font-size: 12.5px; }
.ev { padding-left: 52px; margin-top: -2px; }
.list-item .txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) {
  .stepper button { width: 40px; height: 40px; }
  .stepper .val { width: 40px; }
  .avatar { width: 34px; height: 34px; font-size: 14px; }
  .ev { padding-left: 46px; }
}

/* ===== 사진 배너 ===== */
.hero.photo {
  min-height: 460px; display: flex; align-items: flex-end; padding: 0; margin: -16px -16px 16px; border-radius: 0 0 28px 28px;
  background: #0f3b28 url("img/hero.jpg") center 38% / cover no-repeat;
}
@media (min-width: 600px) { .hero.photo { background-image: url("img/hero-wide.jpg"); margin: 0 0 16px; border-radius: 28px; } }
.hero.photo::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,22,14,.45) 0%, rgba(8,22,14,0) 22%, rgba(8,22,14,.25) 42%, rgba(8,22,14,.78) 66%, rgba(8,22,14,.92) 100%);
}
.hero-in { position: relative; padding: 22px 20px 22px; width: 100%; }
.hero.photo h2 { font-size: 30px; text-shadow: 0 2px 16px rgba(0,0,0,.35); }
.hero.photo p { opacity: .9; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.hero.photo .join input { background: rgba(255,255,255,.14); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hero.photo .join .btn { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.top { transition: background .2s; }

/* ===== 바로가기 ===== */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.quick > * {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0; padding: 14px 4px 12px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text); text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); cursor: pointer;
}
.quick svg { width: 24px; height: 24px; color: var(--fairway); }
.quick > *:active { transform: scale(.97); }

/* ===== 요약 카드 ===== */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-h { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.stat-h svg { width: 18px; height: 18px; color: var(--fairway); }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); padding: 4px 0; }
.stat-row b { color: var(--text); font-size: 16px; }
.stat-big { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; padding: 2px 0 4px; }
.rmoney { font-size: 14px; font-weight: 700; white-space: nowrap; }

/* ===== 순위표 ===== */
.board-h { display: flex; justify-content: space-between; align-items: baseline; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.board-row:nth-child(2) { border-top: 0; }
.board-row .rank { position: relative; width: 22px; text-align: center; font-weight: 800; font-size: 17px; color: var(--muted); }
.board-row .crown { position: absolute; left: 50%; top: -15px; width: 18px; height: 18px; transform: translateX(-50%); color: var(--flag); }
.board-row .bn { flex: 1; min-width: 0; }
.board-row .bn b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .bn span { font-size: 12.5px; }
.board-row .bamt { font-size: 19px; font-weight: 800; white-space: nowrap; }
.board-row.me .avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--c); }
.board-row:nth-child(2) .rank { color: var(--flag); }
.hero.photo .kicker { display: inline-block; padding: 4px 10px; border-radius: 99px; background: rgba(217,165,33,.92); color: #1c1503; opacity: 1; font-weight: 700; }
