:root {
  --green: #1f6f43;
  --green-dark: #155232;
  --green-light: #e8f3ec;
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #1d2a22;
  --muted: #6a786f;
  --line: #dde6e0;
  --under: #d0342c;
  --over: #2c64c9;
  --warn: #c77700;
  --radius: 14px;
  --tabs-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--green); text-decoration: none; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.3; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
small { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--green); color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; }
.sync-badge {
  border: 0; border-radius: 999px; padding: 4px 12px; font-size: 13px;
  background: rgba(255, 255, 255, 0.18); color: #fff;
}
.sync-badge.busy { background: #f0b429; color: #3d2c00; }
.sync-badge.err { background: #e55a4e; }

.view { max-width: 720px; margin: 0 auto; padding: 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
}
.tabs a span { font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: 0.7; }
.tabs a.active { color: var(--green); font-weight: 700; }
.tabs a.active span { filter: none; opacity: 1; }

.card {
  display: block; background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: inherit;
}
.card.alert { background: #fff6e0; color: #6b4a00; font-weight: 700; }
.card.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card-head select { width: auto; margin: 0; padding: 6px 10px; }
.card .table + h3 { margin-top: 18px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.page-head h2 { margin: 0; }
.hello { margin: 4px 0 14px; }
.big { font-size: 18px; font-weight: 700; margin: 4px 0; }
.muted { color: var(--muted); font-size: 14px; }
.pre { white-space: pre-wrap; }
.center { text-align: center; }
.error { color: var(--under); font-size: 14px; min-height: 1em; margin: 6px 0; }
.notice { background: #fff6e0; color: #6b4a00; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); border-color: transparent; }
.stack > * + * { margin-top: 4px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--under); border-color: #f1c9c6; background: #fff; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.disabled, .btn:disabled { opacity: 0.4; pointer-events: none; }
.actions { display: flex; gap: 10px; margin-bottom: 14px; }
.actions > * { flex: 1; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: #eef1ef; color: var(--muted); margin-left: 4px; white-space: nowrap;
}
.badge.live { background: var(--green-light); color: var(--green); }
.badge.err { background: #fde8e6; color: var(--under); }
.badge.att-yes { background: var(--green-light); color: var(--green); }
.badge.att-no { background: #fde8e6; color: var(--under); }
.badge.att-maybe { background: #fff2d6; color: var(--warn); }

.seg { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.seg > button, .seg > a, .seg > label {
  flex: 1; min-height: 42px; margin: 0; padding: 8px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 700; text-align: center; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg > label { position: relative; }
.seg > label input { position: absolute; opacity: 0; pointer-events: none; }
.seg .on, .seg > label:has(input:checked) { background: var(--green); border-color: var(--green); color: #fff; }
.seg .on.att-no { background: var(--under); border-color: var(--under); }
.seg .on.att-maybe { background: var(--warn); border-color: var(--warn); }
.seg.small > button { min-height: 32px; padding: 4px 8px; font-size: 12px; flex: none; }
.seg.filter { margin-bottom: 12px; }

.list-item, .list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-top: 1px solid var(--line); color: inherit;
}
.list-item:first-of-type, .list-row:first-of-type { border-top: 0; }
.card h3 + .list-item, .card h3 + .list-row, .card-head + .list-item, .card-head + .list-row { border-top: 0; }
.list-item small, .list-row small { display: block; }
.list-item .right { text-align: right; flex-shrink: 0; }
.list-row > span:first-child small { display: inline; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--green); }
.stat span { font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.table td:first-child, .table th:first-child { text-align: left; }
.table th a { color: var(--muted); }
.table th a.on { color: var(--green); font-weight: 800; }
.table tr.me td { background: var(--green-light); }
.table .under { color: var(--under); font-weight: 700; }
.table .over { color: var(--over); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.money { text-align: right !important; font-weight: 700; white-space: nowrap; }
.money.plus { color: var(--green); }
.money.minus { color: var(--under); }
.bar { height: 6px; background: #eef1ef; border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--green); }

.card-table { min-width: 520px; margin-bottom: 10px; }
.card-table th, .card-table td { padding: 6px 2px; }
.card-table .name { font-weight: 700; white-space: nowrap; padding-right: 8px; }
.card-table .par-row td { background: #f5f8f6; color: var(--muted); }
.sc { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; }
.sc.birdie { border: 1.5px solid var(--under); border-radius: 50%; color: var(--under); }
.sc.eagle { border: 3px double var(--under); border-radius: 50%; color: var(--under); }
.sc.bogey { border: 1.5px solid var(--over); color: var(--over); }
.sc.double { border: 3px double var(--over); color: var(--over); }

.subtabs { display: flex; background: #e4ebe6; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.subtabs a { flex: 1; text-align: center; padding: 8px; border-radius: 9px; color: var(--muted); font-weight: 700; font-size: 14px; }
.subtabs a.active { background: #fff; color: var(--green); }

.hole-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.hole-title { text-align: center; }
.hole-title b { display: block; font-size: 22px; }
.hole-title select { display: inline-block; width: auto; margin: 0; padding: 2px 6px; }
.hole-dots { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-bottom: 12px; }
.hole-dots a {
  text-align: center; padding: 5px 0; border-radius: 8px; font-size: 13px; font-weight: 700;
  background: #fff; color: var(--muted); border: 1px solid var(--line);
}
.hole-dots a.done { background: var(--green-light); color: var(--green); border-color: transparent; }
.hole-dots a.cur { background: var(--green); color: #fff; border-color: var(--green); }

.player-card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player-top small { display: block; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  font-size: 24px; font-weight: 700; color: var(--green); cursor: pointer;
}
.stepper button:disabled { opacity: 0.35; }
.stepper .val { width: 62px; text-align: center; font-size: 28px; font-weight: 800; line-height: 1.1; }
.stepper .val small { display: block; font-size: 11px; font-weight: 700; }
.val.under, .val.under small { color: var(--under); }
.val.over, .val.over small { color: var(--over); }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; }
.chip {
  flex: 1 0 auto; min-width: 42px; min-height: 36px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #f7f9f8; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chip:disabled { opacity: 0.4; }

.slot { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.slot-no {
  width: 28px; height: 28px; margin-top: 12px; border-radius: 50%; background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
.slot select { flex: 1; margin-top: 4px; }
.slot .guest { display: flex; gap: 6px; width: 100%; padding-left: 36px; }
.slot .guest input { margin: 0; }
.slot .guest input[name^="gh"] { width: 90px; flex: none; }
.par-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-bottom: 12px; }
.par-cell { margin: 0; text-align: center; font-size: 11px; color: var(--muted); }
.par-cell select { margin-top: 2px; padding: 6px 0; text-align: center; text-align-last: center; font-size: 14px; }

.games legend { font-weight: 800; padding: 0 4px; }
fieldset.card { border: 0; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-weight: 600; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; }
.games .sub { padding-left: 28px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.games .sub input[type="number"] { display: inline-block; width: 90px; margin: 0; padding: 6px 8px; }
.games .sub select { display: inline-block; width: auto; margin: 0; padding: 6px 8px; }
.games .sub .check { margin: 0; font-weight: 400; }

.ppopgi { border: 2px solid #f0d78a; background: #fffcf2; }
.pair-options { display: grid; gap: 6px; }
.pair {
  min-height: 42px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: 14px; font-weight: 700; text-align: left; cursor: pointer;
}
.pair.on { background: var(--green); border-color: var(--green); color: #fff; }
.pair:disabled { opacity: 0.6; }
select.compact { width: auto; max-width: 60%; margin: 0; padding: 6px 8px; font-size: 13px; }
.done-text { color: var(--green); }
.nowrap { white-space: nowrap; }
.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.logo-preview { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.round-kind { margin: -8px 0 10px; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.dist-row { display: grid; grid-template-columns: 84px 1fr 70px; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.dist-row > span:last-child { text-align: right; }
.dist-row .under { color: var(--under); }
.dist-row .over { color: var(--over); }
.bar i.under { background: var(--under); }
.bar i.over { background: var(--over); }
.grid-table { min-width: 460px; }
.grid-table th, .grid-table td { padding: 3px 1px; }
.grid-table input {
  width: 36px; margin: 0 auto; padding: 6px 0; text-align: center; font-size: 16px; font-weight: 700;
  -moz-appearance: textfield;
}
.grid-table input::-webkit-outer-spin-button, .grid-table input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grid-table .grid-par { background: #f5f8f6; color: var(--muted); font-weight: 600; }
.inline-num { display: inline-block; width: 70px; margin: 0 0 0 4px; padding: 4px 8px; }
form .sub.muted { padding-left: 28px; margin-bottom: 12px; }

.transfer {padding: 8px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.total-card { border: 2px solid var(--green-light); }

.member-row { padding: 12px 0; border-top: 1px solid var(--line); }
.member-row:first-of-type { border-top: 0; }
.stats-toggle { margin: 6px 0 0; font-size: 13px; font-weight: 600; }
.stats-toggle input { width: 18px; height: 18px; }
.member-actions {display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.member-actions label { display: flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; }
.member-actions input { width: 64px; margin: 0; padding: 6px 8px; }

.auth { max-width: 420px; margin: 24px auto 0; }
.auth h1 { text-align: center; font-size: 22px; margin-bottom: 18px; }
.auth-logo { text-align: center; font-size: 48px; }
.server-box summary { cursor: pointer; font-weight: 700; }
details.card summary { cursor: pointer; font-weight: 700; }
details.card[open] summary { margin-bottom: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 20px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%); max-width: 90%;
  background: rgba(20, 30, 24, 0.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
}

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stepper button { width: 40px; height: 40px; }
}

/* 골프장 */
.search { margin: 0 0 12px; }
.nine-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nine-pick label { margin-bottom: 8px; }
.small-link { margin: 0 0 4px; }
.nine-block + .nine-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.par-grid.nine { margin-bottom: 4px; }
.nine-sum { margin: 0 0 8px; text-align: right; }
.nine-table { font-size: 13px; }
.nine-table td, .nine-table th { padding: 6px 1px; }
.nine-table td.name { padding-right: 4px; white-space: nowrap; }
.page-head h2 small { font-size: 14px; }
.tabs a { font-size: 11px; }
.link-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.link-row select { margin: 0; padding: 7px 8px; font-size: 14px; }
.link-row small { display: block; }

/* 핸디캡 */
.hcp-box { background: var(--green-light); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.hcp-box b { display: block; font-size: 18px; color: var(--green); }
.hcp-line { width: 100%; font-size: 14px; }
.hcp-input { width: 64px; margin: 0; padding: 6px 8px; text-align: center; }

.warn { color: var(--warn); font-weight: 700; }

.danger-zone { border: 2px solid #f1c9c6; }
.danger-zone summary { color: var(--under); }
