:root {
  --ink: #15322A;
  --ink-2: #23463A;
  --ground: #F3F1EA;
  --card: #FFFFFF;
  --line: #DAD6CA;
  --line-2: #ECE9E0;
  --muted: #5E665F;
  --faint: #8A918B;
  --accent: #1F5C47;
  --accent-soft: #E3EDE7;
  --penalty: #B4471F;
  --penalty-text: #9C3A17;
  --penalty-line: #E6C3B4;
  --sand-bg: #F1E6CC;
  --sand-text: #6E4A12;
  --wait-bg: #F6E3C7;
  --wait-text: #6E4A12;
  --sans: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* layout */
.screen { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.title { font-size: 24px; font-weight: 900; margin: 0; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.label { font-size: 12px; font-weight: 700; color: var(--muted); }
.label small { font-weight: 400; }
.h2 { font-size: 15px; font-weight: 700; margin: 0; }
.iconbtn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: flex-start; background: none; border: 0; padding: 0; color: inherit; text-decoration: none; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.card.tight { gap: 8px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line-2); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: 11px; font-weight: 700; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 21px; font-weight: 600; }
.stat .s { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.stat.pen { border-color: var(--penalty-line); }
.stat.pen .k, .stat.pen .v { color: var(--penalty-text); }
.stat.sand { background: var(--sand-bg); border-color: transparent; }
.stat.sand .k { color: var(--sand-text); }
.stat.sand .v { color: #4A320B; }
.low { opacity: .5; }

/* buttons */
.btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 700; font-size: 15px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); min-height: 56px; border-radius: 14px; font-size: 17px; }
.btn-danger { color: var(--penalty-text); border-color: var(--penalty-line); }
.btn:disabled { opacity: .45; }
.key { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-family: var(--mono); font-size: 14px; font-weight: 600; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key.on, .chip.on, .seg .on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500; }
.chip.on { font-weight: 700; }
.chip.sm { min-height: 36px; border-radius: 8px; padding: 0 10px; font-size: 13px; }
.chip.pen { border-color: var(--penalty-line); color: var(--penalty-text); }
.chip.pen.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.dir { height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 12px; line-height: 1.15; padding: 0 2px; }
.dir.center { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.dir.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { flex: 1; min-height: 40px; border: 0; background: transparent; font-family: var(--mono); font-weight: 600; font-size: 13px; }
.seg .on { background: var(--ink); }

/* inputs */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.input, select.input, textarea.input { min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; font-size: 16px; color: var(--ink); width: 100%; }
textarea.input { padding: 12px; min-height: 64px; resize: vertical; }
.input:focus, .key:focus-visible, .chip:focus-visible, .dir:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bigin { height: 52px; border: 2px solid var(--accent); border-radius: 10px; display: flex; align-items: center; padding: 0 12px; background: var(--card); }
.bigin input { border: 0; outline: 0; width: 100%; font-family: var(--mono); font-size: 24px; font-weight: 600; background: transparent; min-width: 0; }
.bigin span { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 0; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 4px; background: #1F7A55; display: inline-block; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-wait { background: var(--wait-bg); color: var(--wait-text); }
.badge-err { background: #F6DCCB; color: var(--penalty-text); }

/* hole header */
.holehead { background: var(--ink); color: #fff; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 5; }
.holehead .iconbtn { color: #fff; }
.holehead .hole-title { min-width: 0; height: 44px; padding: 0; border: 0; background: none; color: inherit; display: flex; flex-direction: column; justify-content: center; gap: 2px; text-align: left; }
.holehead .meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 10px; line-height: 14px; color: #B9CCC2; }
.holehead .hno { font-size: 20px; font-weight: 900; line-height: 24px; white-space: nowrap; }
.holehead .hole-chevron { font-size: 12px; opacity: .7; }
.holehead .hole-total { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: flex-end; color: inherit; text-decoration: none; }
.holehead .tot { font-family: var(--mono); font-size: 20px; font-weight: 600; white-space: nowrap; }
.holehead .tot small { font-size: 12px; color: #F2B79C; }
.holehead [data-sync-badge] { min-width: 0; max-width: 100px; }
.holehead .badge { max-width: 100%; min-height: 44px; padding: 4px 6px; gap: 4px; border-radius: 10px; font-size: 10px; line-height: 14px; white-space: normal; }
.holehead .badge .dot { flex: none; width: 6px; height: 6px; }
.holehead-details { background: var(--ink); color: #fff; padding: 0 16px 8px; display: flex; flex-direction: column; gap: 6px; }
.holehead-details [data-act="nine"] { min-width: 0; min-height: 44px !important; overflow-wrap: anywhere; }
.holehead-details .parsel { flex-wrap: wrap; }
.holehead-details .parsel button { min-height: 44px; }
.minicard { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; text-align: center; font-family: var(--mono); }
.minicard button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border-radius: 8px; border: 1px solid #2E4E43; background: transparent; color: #8FA89C; font-size: 11px; min-height: 44px; justify-content: center; }
.minicard button b { font-size: 15px; font-weight: 600; color: #fff; }
.minicard button.done { background: var(--ink-2); border-color: var(--ink-2); color: #B9CCC2; }
.minicard button.over b { color: #F2B79C; }
.minicard button.cur { background: #fff; border-color: #fff; color: var(--ink); font-weight: 600; }
.minicard button.cur b { color: var(--ink); }
.parsel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #B9CCC2; }
.parsel button { min-height: 32px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid #3E6153; background: transparent; color: #fff; font-size: 13px; }
.parsel button.on { background: #fff; color: var(--ink); border-color: #fff; font-weight: 700; }

/* shot list */
.shotrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; text-align: left; width: 100%; }
.shotrow.editing { background: var(--accent-soft); }
.seqdot { width: 28px; height: 28px; border-radius: 14px; background: var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 13px; font-weight: 600; flex: none; }
.tag { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.sand { background: var(--sand-bg); color: var(--sand-text); }
.tag.pen { background: #F6DCCB; color: var(--penalty-text); }
.tag.ok { background: var(--accent-soft); color: var(--accent); }

.putts { padding: 12px; border-radius: 12px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; }
.putts .k2 { height: 44px; border-radius: 10px; border: 1px solid #B9CCC2; background: #fff; font-weight: 700; font-size: 15px; }
.switch { width: 52px; height: 30px; border-radius: 15px; border: 0; background: #C9C4B6; padding: 3px; display: flex; align-items: center; flex: none; }
.switch i { width: 24px; height: 24px; border-radius: 12px; background: #fff; display: block; transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(22px); }
.panel { padding: 10px 12px; border-radius: 10px; background: #F7F5EF; }

.footbar { position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--ground); border-top: 1px solid var(--line); z-index: 4; }
/* Keep the compact footer and scroll clearance local to shot entry. */
.holehead ~ .footbar { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 0; box-shadow: inset 0 1px var(--line); }
.holehead ~ .footbar .btn { min-height: 48px !important; height: 48px; }
.holehead ~ .screen #dist, .holehead ~ .screen .penalty-choices { scroll-margin-top: calc(64px + env(safe-area-inset-top)); scroll-margin-bottom: calc(72px + env(safe-area-inset-bottom)); }
body:has(.holehead) #toast { bottom: calc(72px + env(safe-area-inset-bottom)); }

/* scorecard */
.sc { display: grid; grid-template-columns: 40px repeat(9, minmax(0, 1fr)); row-gap: 6px; align-items: center; text-align: center; font-family: var(--mono); font-size: 13px; }
.sc .rl { font-family: var(--sans); font-size: 11px; color: var(--muted); text-align: left; }
.sc .cell { display: flex; justify-content: center; position: relative; }
.sc .box { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.sc .b1 { border: 1.5px solid var(--ink); }
.sc .b2 { background: var(--penalty); color: #fff; }
.sc .bm { border: 1.5px solid var(--accent); border-radius: 13px; }
.sc .pdot { position: absolute; top: -3px; right: 2px; width: 7px; height: 7px; border-radius: 4px; background: var(--penalty); }
.sc .y { color: var(--accent); }
.sc .n { color: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }

/* stats */
.tabs { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.tabs button { min-height: 36px; padding: 0 12px; border: 0; background: transparent; font-size: 13px; }
.tabs button.on { background: var(--ink); color: #fff; font-weight: 700; }
.bars { display: grid; gap: 6px; align-items: end; height: 140px; }
.bars .bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-family: var(--mono); font-size: 10px; }
.bars .bar i { width: 100%; border-radius: 6px 6px 0 0; background: #C9D6CF; display: block; }
.bars .bar.best i { background: #1F7A55; }
.bars .bar.last i { background: var(--ink); }
.split { display: flex; height: 40px; border-radius: 10px; overflow: hidden; font-size: 13px; font-weight: 700; }
.split span { display: flex; align-items: center; justify-content: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.cross { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 3px; font-family: var(--mono); font-size: 12px; font-weight: 600; text-align: center; flex: none; }
.cross span { border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.hbar { display: flex; align-items: center; gap: 8px; }
.hbar .t { width: 36px; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.hbar .track { flex: 1; height: 12px; background: var(--line-2); border-radius: 6px; display: flex; }
.hbar .track i { height: 12px; border-radius: 6px; background: var(--accent); display: block; }
.hbar .n { width: 64px; text-align: right; font-family: var(--mono); font-size: 12px; }

/* bag & misc */
.clubrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.clubrow .lab { width: 44px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 13px; font-weight: 600; flex: none; }
.clubrow.off .lab { background: var(--line-2); color: var(--faint); }
.mini { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.roundrow { text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.roundrow .big { font-family: var(--mono); font-size: 26px; font-weight: 600; }
.topar { font-family: var(--mono); font-size: 12px; color: var(--penalty); }
.notice { padding: 12px; border-radius: 12px; background: var(--wait-bg); color: var(--wait-text); font-size: 13px; line-height: 1.5; }
.empty { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }
.holegrid { display: grid; grid-template-columns: 34px repeat(9, minmax(0, 1fr)); gap: 3px; align-items: center; font-size: 12px; }
.holegrid input { width: 100%; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 6px; text-align: center; font-family: var(--mono); font-size: 14px; padding: 0; background: var(--card); }
.holegrid .rl { font-size: 11px; color: var(--muted); }
.holegrid .hn { text-align: center; font-family: var(--mono); color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 14px; display: flex; gap: 12px; align-items: center; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; width: max-content; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast span { white-space: nowrap; }
#toast .toast-action { background: none; border: 0; color: #F2B79C; font-weight: 700; min-height: 32px; white-space: nowrap; }

.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px; }
.brand { font-size: 32px; font-weight: 900; margin: 0; }
.dialog { position: fixed; inset: 0; background: rgba(21, 50, 42, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.dialog .sheet { width: 100%; max-width: 520px; background: var(--ground); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 90dvh; overflow: auto; }

/* Landing and save controls: touch targets and next-step guidance. */
[data-act="land"], [data-act="pen"], [data-act="drop"] { min-height: 44px; }
.penalty-choices { border: 1px solid transparent; border-radius: 12px; padding: 6px; scroll-margin-bottom: 100px; }
.penalty-choices.pending { border-color: var(--accent); }
.putt-landings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.putt-landings .chip { min-height: 64px; font-size: 20px; border-radius: 14px; }
