* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --green-deep: #0a5c36;
  --green: #0e7a46;
  --green-light: #e8f2ea;
  --green-line: #cfe0d3;
  --gold: #c9a227;
  --ink: #1c2b22;
  --ink-soft: #5c6f63;
  --paper: #f2f5ef;
  --card: #ffffff;
  --red: #d40d24;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 40, 26, 0.10), 0 4px 14px rgba(16, 40, 26, 0.06);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.noscript-msg { padding: 20px; text-align: center; }
.card-pad.tight-bottom { padding-bottom: 0; }
.tight-bottom .card-title { margin-bottom: 0; }
.min0 { min-width: 0; }
.empty-note.no-pad { padding: 0; }
.empty-note.pad-top { padding-top: 12px; }
.btn-primary.no-top { margin-top: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

button { font: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input { font: inherit; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 2px 10px rgba(10, 60, 34, 0.25);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; flex: 0 0 auto; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; opacity: 0.75; }

.topbar-slim { justify-content: flex-end; padding-top: calc(env(safe-area-inset-top) + 10px); padding-bottom: 10px; }

.topbar-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.topbar-btn:active { background: rgba(255, 255, 255, 0.28); }

.content {
  flex: 1;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-pad { padding: 18px; }

.card-title { font-size: 13px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 14px; }

.name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.name-field { position: relative; }
.name-field input {
  width: 100%;
  padding: 13px 14px 13px 38px;
  border: 1.5px solid var(--green-line);
  border-radius: 11px;
  background: var(--green-light);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.name-field input:focus { border-color: var(--green); background: #fff; }
.name-field input::placeholder { color: #93a89a; font-weight: 500; }
.name-num {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.start-opt {
  padding: 12px;
  border: 1.5px solid var(--green-line);
  border-radius: 11px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}
.start-opt.on { background: var(--green); border-color: var(--green); color: #fff; }

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

.btn-primary {
  width: 100%;
  margin-top: 14px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 3px 10px rgba(10, 92, 54, 0.35);
}
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; }

.btn-ghost {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1.5px solid var(--green-line);
  color: var(--green-deep);
  font-size: 15px;
  font-weight: 700;
  background: #fff;
}
.btn-ghost:active { background: var(--green-light); }

.scoring-key { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key-item { text-align: center; padding: 10px 4px; border-radius: 10px; background: var(--green-light); }
.key-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.key-pts { font-size: 12px; font-weight: 700; color: var(--green-deep); margin-top: 2px; }

.resume-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.resume-info { min-width: 0; }
.resume-title { font-size: 16px; font-weight: 700; }
.resume-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-btn { flex: 0 0 auto; padding: 11px 18px; border-radius: 999px; background: var(--green); color: #fff; font-size: 14px; font-weight: 700; }

.hole-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hole-arrow {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-deep);
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hole-arrow:disabled { opacity: 0.25; }
.hole-arrow:active:not(:disabled) { background: var(--green-line); }
.hole-center { text-align: center; }
.hole-label { font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--ink-soft); }
.hole-num { font-size: 30px; font-weight: 800; color: var(--green-deep); line-height: 1.1; }
.hole-dots { display: flex; gap: 3px; justify-content: center; margin-top: 5px; padding: 7px 10px; margin-left: -10px; margin-right: -10px; cursor: pointer; border-radius: 999px; }
.hole-dots:active { background: var(--green-light); }
.hole-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green-line); }
.hole-dot.done { background: var(--green); }
.hole-dot.now { background: var(--gold); }

.nine-ask { padding: 14px; background: #fffaf0; border: 1.5px solid #f0dfae; }
.nine-title { font-size: 15px; font-weight: 700; text-align: center; margin-bottom: 11px; }
.nine-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nine-btn { padding: 13px 8px; border-radius: 11px; font-size: 15px; font-weight: 700; }
.nine-btn.end { background: var(--green-deep); color: #fff; }
.nine-btn.go { background: #fff; border: 1.5px solid var(--green-line); color: var(--green-deep); }
.nine-btn:active { transform: scale(0.985); }

.player-card { padding: 14px 14px 12px; }
.player-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.player-name { font-size: 17px; font-weight: 700; }
.player-total { font-size: 15px; font-weight: 800; color: var(--green-deep); }
.player-total span { font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-left: 3px; }

.outcome-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.outcome-btn {
  padding: 10px 2px 9px;
  border-radius: 11px;
  border: 1.5px solid var(--green-line);
  background: #fff;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}
.outcome-btn .o-label { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.outcome-btn .o-pts { font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.outcome-btn.sel .o-label { color: #fff; }
.outcome-btn.sel .o-pts { color: rgba(255, 255, 255, 0.85); }
.outcome-btn.sel.chip { background: var(--green-deep); border-color: var(--green-deep); }
.outcome-btn.sel.one { background: #2e9c62; border-color: #2e9c62; }
.outcome-btn.sel.two { background: #d3e9da; border-color: #c2ddcb; }
.outcome-btn.sel.two .o-label { color: var(--green-deep); }
.outcome-btn.sel.two .o-pts { color: rgba(10, 92, 54, 0.75); }
.outcome-btn.sel.miss { background: var(--red); border-color: var(--red); }
.outcome-btn:active { border-color: var(--green); }

.leader-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.leader-chip {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  background: #f4f7f3;
  border: 1px solid #dfe7e0;
  border-radius: 11px;
  box-shadow: 0 1px 2px rgba(16, 40, 26, 0.05);
  padding: 10px 6px 9px;
}
.leader-chip .lc-name { font-size: 12px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-chip .lc-pts { font-size: 23px; font-weight: 800; color: var(--green-deep); line-height: 1.15; }
.leader-chip .lc-zeros {
  display: inline-block;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--red);
  background: #ffe4e7;
  border-radius: 999px;
  padding: 2px 8px;
}

.sc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 8px; margin-bottom: 12px; }
.sc-tile { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 6px; text-align: center; }
.sc-tile.lead { background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%); box-shadow: 0 3px 10px rgba(10, 60, 34, 0.28); }
.sc-name { font-size: 12px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-pts { font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1.15; }
.sc-z { font-size: 10.5px; font-weight: 700; color: var(--red); margin-top: 1px; }
.sc-tile.lead .sc-name { color: rgba(255, 255, 255, 0.82); }
.sc-tile.lead .sc-pts { color: #fff; }
.sc-tile.lead .sc-z { color: #ff8a94; }

.table-wrap { overflow-x: auto; }
table.scorecard { border-collapse: collapse; width: 100%; font-size: 13px; table-layout: fixed; }
.scorecard th, .scorecard td { padding: 2px 4px; text-align: center; }
.scorecard th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--green-light);
  position: sticky;
  top: 0;
  padding: 7px 4px;
  overflow-wrap: anywhere;
  line-height: 1.25;
  vertical-align: bottom;
}
.scorecard th.hcol, .scorecard td.h { width: 42px; }
.scorecard td.h { font-weight: 700; color: var(--ink-soft); background: #fafcf9; font-size: 12px; }
.scorecard tr.subtotal td { font-weight: 800; background: var(--green-light); color: var(--green-deep); padding: 5px 4px; }
.scorecard tr.total td { font-weight: 800; background: var(--green-deep); color: #fff; font-size: 15px; padding: 6px 4px; }
.scorecard tr.now td { background: #fdf7e3; }
.scorecard tr.clickable { cursor: pointer; }

.sc-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  height: 23px;
  border-radius: 7px;
  font-weight: 800;
  font-size: 12.5px;
}
.sc-chip { background: var(--green-deep); color: #fff; }
.sc-one { background: #2e9c62; color: #fff; }
.sc-two { background: #d3e9da; color: var(--green-deep); }
.sc-miss { background: var(--red); color: #fff; }
.sc-none { color: #c4cfc6; font-weight: 600; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 26, 18, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--paper);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.sheet-title { font-size: 17px; font-weight: 800; }
.sheet-close { width: 34px; height: 34px; border-radius: 50%; background: var(--green-line); font-size: 16px; font-weight: 700; color: var(--ink); }
.sheet-body { overflow-y: auto; padding: 0 14px calc(env(safe-area-inset-bottom) + 20px); }

.history-item { padding: 9px 18px 13px; border-bottom: 1px solid #edf2ee; cursor: pointer; }
.history-item:first-of-type { border-top: 1px solid #edf2ee; }
.history-item:last-child { border-bottom: 0; }
.hist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.history-date { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.hist-row { display: flex; align-items: baseline; gap: 8px; padding: 2px 0; font-size: 14px; color: var(--ink-soft); }
.hist-row.win {
  color: var(--green-deep);
  font-weight: 800;
  background: var(--green-light);
  border-radius: 9px;
  padding: 5px 9px;
  margin: 0 -9px 3px;
  font-size: 15px;
}
.hist-row.win .hr-pts { color: var(--green-deep); }
.hr-mark { flex: 0 0 18px; font-size: 12px; }
.hr-name { flex: 1; min-width: 0; white-space: nowrap; }
.hr-pts { flex: 0 0 34px; text-align: right; font-weight: 800; color: var(--ink); }
.hr-z { flex: 0 0 30px; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--red); }
.history-del {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -6px -6px -6px 0;
  border-radius: 9px;
  color: #9aa8a0;
}
.history-del svg { width: 17px; height: 17px; }
.history-del:active { background: #f1f4f0; }
.history-del.arm { background: var(--red); color: #fff; }

.empty-note { text-align: center; padding: 22px 16px; color: var(--ink-soft); font-size: 14px; }

.results-hero { text-align: center; padding: 30px 18px 24px; }
.results-trophy { font-size: 46px; }
.results-winner { font-size: 26px; font-weight: 800; color: var(--green-deep); margin-top: 8px; }
.results-sub { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.standings { padding: 0 18px 18px; }
.standing-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid #edf2ee; font-size: 16px; font-weight: 600; }
.standing-row:last-child { border-bottom: 0; }
.standing-pos { color: var(--ink-soft); font-weight: 700; width: 28px; }
.standing-name { flex: 1; }
.standing-zeros { font-size: 12px; font-weight: 700; color: var(--red); margin-right: 12px; }
.standing-pts { font-weight: 800; color: var(--green-deep); }

.danger-zone { text-align: center; }
.danger-btn { font-size: 13px; font-weight: 700; color: var(--red); padding: 12px 18px; border-radius: 10px; }
.danger-btn.arm { background: var(--red); color: #fff; }

.fade-in { animation: fadeIn 0.18s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
