*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --c-bg: #ffffff;
  --c-bg2: #f5f5f5;
  --c-bg3: #ebebeb;
  --c-border: #e0e0e0;
  --c-border2: #d0d0d0;
  --c-text: #1a1a1a;
  --c-text2: #666;
  --c-text3: #999;
  --c-blue: #185FA5;
  --c-blue-bg: #E6F1FB;
  --c-red: #993C1D;
  --c-red-bg: #FAECE7;
  --c-green: #0F6E56;
  --c-green-bg: #EAF3DE;
  --c-amber: #BA7517;
  --c-amber-bg: #FAEEDA;
  --c-birdie: #5DCAA5;
  --c-eagle: #1D9E75;
  --c-bogey-bg: #FAECE7;
  --c-bogey: #712B13;
  --c-double: #D85A30;
  --radius: 10px;
  --radius-sm: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #1a1a1a; --c-bg2: #242424; --c-bg3: #2e2e2e;
    --c-border: #333; --c-border2: #444;
    --c-text: #f0f0f0; --c-text2: #aaa; --c-text3: #666;
    --c-blue-bg: #1a2e42; --c-red-bg: #2e1a14;
    --c-green-bg: #1a2e24; --c-amber-bg: #2e2414;
    --c-bogey-bg: #2e1a14; --c-bogey: #e07050;
  }
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--c-bg); color: var(--c-text); font-size: 14px; min-height: 100vh; }
.app { max-width: 680px; margin: 0 auto; padding: 0 12px 80px; }

/* Header */
.app-header { padding: 16px 0 12px; border-bottom: 1px solid var(--c-border); margin-bottom: 12px; }
.app-title { font-size: 20px; font-weight: 600; }
.app-sub { font-size: 12px; color: var(--c-text2); margin-top: 2px; }
.score-header { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; font-weight: 500; }

/* Round nav */
.round-nav { display: flex; gap: 6px; padding: 8px 0; flex-wrap: wrap; margin-bottom: 4px; }
.round-btn { padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--c-border); background: var(--c-bg2); color: var(--c-text2); line-height: 1.3; text-align: center; transition: all 0.15s; }
.round-btn.active { background: var(--c-text); color: var(--c-bg); border-color: var(--c-text); }
.round-btn div:first-child { font-weight: 600; }
.round-btn div:last-child { font-size: 10px; opacity: 0.7; }

/* Tabs */
.tab-bar { display: flex; border-bottom: 1px solid var(--c-border); margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn { padding: 10px 14px; font-size: 13px; cursor: pointer; border: none; background: none; color: var(--c-text2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: all 0.15s; }
.tab-btn.active { color: var(--c-text); border-bottom-color: var(--c-text); font-weight: 500; }

/* Panels */
.panel { display: none; }
.panel.active { display: block; }

/* Cards */
.card { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.section-label { font-size: 11px; font-weight: 600; color: var(--c-text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; margin-top: 16px; }
.section-label:first-child { margin-top: 0; }

/* Notices */
.notice { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; display: flex; align-items: flex-start; gap: 8px; }
.notice-blue { background: var(--c-blue-bg); color: var(--c-blue); }
.notice-green { background: var(--c-green-bg); color: var(--c-green); }
.notice-amber { background: var(--c-amber-bg); color: var(--c-amber); }
.notice-red { background: var(--c-red-bg); color: var(--c-red); }

/* Badges */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; display: inline-block; white-space: nowrap; }
.badge-a { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-b { background: var(--c-red-bg); color: var(--c-red); }
.badge-admin { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-group { background: var(--c-green-bg); color: var(--c-green); }
.badge-skins { background: var(--c-green-bg); color: var(--c-green); }
.badge-fourball { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-scramble { background: #f3e8ff; color: #7c3aed; }
.badge-singles { background: var(--c-red-bg); color: var(--c-red); }
.badge-split { background: var(--c-amber-bg); color: var(--c-amber); }

/* Buttons */
.btn { padding: 8px 16px; font-size: 13px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; border: none; transition: all 0.15s; }
.btn-primary { background: var(--c-text); color: var(--c-bg); }
.btn-secondary { background: none; color: var(--c-text); border: 1px solid var(--c-border2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: none; color: var(--c-red); border: 1px solid var(--c-red); }

/* Metrics */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr)); gap: 8px; margin-bottom: 12px; }
.metric { background: var(--c-bg2); border-radius: var(--radius-sm); padding: 10px 12px; }
.metric-label { font-size: 10px; color: var(--c-text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.metric-value { font-size: 20px; font-weight: 600; }

/* Access bar */
.access-bar { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; background: var(--c-bg2); border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 12px; }

/* PIN screen */
.pin-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; min-height: 300px; }
.pin-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.pin-sub { font-size: 13px; color: var(--c-text2); margin-bottom: 20px; text-align: center; }
.pin-dots { display: flex; gap: 14px; margin-bottom: 8px; }
.pin-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--c-border2); background: none; transition: all 0.12s; }
.pin-dot.filled { background: var(--c-text); border-color: var(--c-text); }
.pin-error { font-size: 12px; color: var(--c-red); height: 18px; margin-bottom: 12px; text-align: center; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 68px); gap: 10px; }
.pin-key { height: 56px; font-size: 22px; font-weight: 500; background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-sm); cursor: pointer; color: var(--c-text); transition: all 0.1s; }
.pin-key:active { transform: scale(0.94); background: var(--c-bg3); }
.pin-key.del { font-size: 16px; color: var(--c-text2); }

/* Leaderboard */
.lb-row { display: grid; grid-template-columns: 24px 1fr 44px 44px 44px 44px 48px 64px; gap: 4px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--c-border); font-size: 13px; overflow-x: auto; }
.lb-row:last-child { border-bottom: none; }
.lb-row.hdr { font-size: 11px; color: var(--c-text2); font-weight: 600; padding-bottom: 6px; }
/* On mobile, hide individual round columns — show rank, name, total, prize only */
@media (max-width: 480px) {
  .lb-row { grid-template-columns: 24px 1fr 48px 64px; font-size: 12px; }
  .lb-row > div:nth-child(3),
  .lb-row > div:nth-child(4),
  .lb-row > div:nth-child(5),
  .lb-row > div:nth-child(6) { display: none; }
  .lb-row.hdr > div:nth-child(3),
  .lb-row.hdr > div:nth-child(4),
  .lb-row.hdr > div:nth-child(5),
  .lb-row.hdr > div:nth-child(6) { display: none; }
}
.rank { text-align: center; font-size: 12px; color: var(--c-text2); }
.rank.gold { color: #BA7517; font-weight: 700; }
.rank.silver { color: #5F5E5A; font-weight: 600; }
.rank.bronze { color: var(--c-red); font-weight: 600; }
.skin-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-eagle); display: inline-block; margin-right: 3px; }

/* Score entry */
.player-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.player-chip-btn { padding: 5px 10px; font-size: 12px; border-radius: 20px; cursor: pointer; border: 1px solid var(--c-border); background: none; color: var(--c-text); display: inline-flex; align-items: center; gap: 4px; transition: all 0.12s; }
.player-chip-btn.active { background: var(--c-text); color: var(--c-bg); border-color: var(--c-text); }
.dot-sc { width: 7px; height: 7px; border-radius: 50%; background: var(--c-eagle); flex-shrink: 0; }
.dot-sp { width: 7px; height: 7px; border-radius: 50%; background: var(--c-amber); flex-shrink: 0; }
.dot-se { width: 7px; height: 7px; border-radius: 50%; background: var(--c-border2); flex-shrink: 0; }

/* Scorecard */
.scorecard-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scorecard-grid { display: grid; gap: 3px; min-width: 420px; }
.sc-cell { text-align: center; font-size: 12px; padding: 3px 2px; }
.sc-label { font-size: 11px; color: var(--c-text2); text-align: center; padding: 2px; }
.sc-total { background: var(--c-bg2); border-radius: 3px; text-align: center; font-size: 13px; font-weight: 600; padding: 3px 4px; }
.sc-input { width: 100%; text-align: center; padding: 4px 2px; font-size: 14px; border: 1px solid var(--c-border); border-radius: 4px; background: var(--c-bg); color: var(--c-text); -moz-appearance: textfield; }
.sc-input::-webkit-outer-spin-button, .sc-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.sc-input:focus { outline: none; border-color: var(--c-blue); }
.sc-net { font-size: 12px; padding: 3px 2px; border-radius: 3px; text-align: center; }
.split-line { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.split-line-bar { flex: 1; height: 1px; background: var(--c-border); }
.split-line-txt { font-size: 11px; color: var(--c-text2); font-weight: 500; white-space: nowrap; }
.course-strip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--c-bg2); border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 12px; flex-wrap: wrap; }

/* Ryder Cup */
.ryder-board { display: flex; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.ryder-side { flex: 1; padding: 14px; text-align: center; }
.ryder-side.a { background: var(--c-blue-bg); }
.ryder-side.b { background: var(--c-red-bg); }
.ryder-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.ryder-side.a .ryder-name { color: var(--c-blue); }
.ryder-side.b .ryder-name { color: var(--c-red); }
.ryder-pts { font-size: 40px; font-weight: 700; line-height: 1; }
.ryder-side.a .ryder-pts { color: var(--c-blue); }
.ryder-side.b .ryder-pts { color: var(--c-red); }
.ryder-mid { padding: 0 10px; background: var(--c-bg2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--c-text2); }
.ryder-round-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.rtab { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--c-border); background: none; color: var(--c-text2); transition: all 0.12s; white-space: nowrap; }
.rtab.active { background: var(--c-text); color: var(--c-bg); border-color: var(--c-text); }
.match-row { display: grid; grid-template-columns: 1fr 16px 1fr 96px; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--c-border); }
.match-row:last-child { border-bottom: none; }
.match-row.hdr { font-size: 11px; color: var(--c-text2); font-weight: 600; padding-bottom: 5px; }

/* Player chips for ryder picks */
.pick-chip { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 20px; font-size: 12px; cursor: pointer; border: 1px solid var(--c-border); background: var(--c-bg2); margin: 2px; user-select: none; transition: all 0.1s; }
.pick-chip.sel-a { background: var(--c-blue-bg); border-color: var(--c-blue); color: var(--c-blue); }
.pick-chip.sel-b { background: var(--c-red-bg); border-color: var(--c-red); color: var(--c-red); }
.pick-chip.used { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* Skins table */
.skins-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.skins-tbl th { font-size: 11px; color: var(--c-text2); font-weight: 600; padding: 5px 6px; border-bottom: 1px solid var(--c-border); text-align: center; }
.skins-tbl td { padding: 6px; border-bottom: 1px solid var(--c-border); text-align: center; }
.skins-tbl tr:last-child td { border-bottom: none; }
.skins-winner { font-weight: 600; color: var(--c-green); }

/* Admin */
.group-card { border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.group-card-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.player-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 12px; background: var(--c-bg2); border: 1px solid var(--c-border); margin: 2px; }

/* Save bar */
.save-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--c-bg); border-top: 1px solid var(--c-border); padding: 10px 16px; display: flex; justify-content: flex-end; gap: 8px; z-index: 100; max-width: 680px; margin: 0 auto; }

/* Toast */
/* ── PLAYER PROFILE MODAL ── */
#player-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; align-items: flex-end; justify-content: center;
}
#player-modal-overlay.open { display: flex; }
#player-modal {
  background: var(--c-bg); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; padding: 0 0 24px;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
#player-modal-header {
  position: sticky; top: 0; background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
#toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--c-eagle); color: white; padding: 10px 20px; border-radius: 20px; font-size: 13px; font-weight: 500; display: none; z-index: 999; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.25); transition: opacity 0.3s; max-width: 90vw; text-align: center; }
#toast.toast-eagle  { background: #c8a000; }
#toast.toast-birdie { background: var(--c-birdie); }
#toast.toast-match  { background: var(--c-blue); }
#toast.toast-pin    { background: var(--c-text); }
#toast.toast-recap  { background: #6b48c8; }
#toast.toast-info   { background: var(--c-eagle); }

/* Sync indicator */
#sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-border2); display: inline-block; margin-left: 6px; transition: background 0.3s; }
#sync-dot.syncing { background: var(--c-amber); }
#sync-dot.synced { background: var(--c-eagle); }
#sync-dot.error { background: var(--c-red); }

input[type=text], input[type=number], select { font-size: 13px; background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 5px 8px; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── PWA INSTALL PROMPT ── */
#pwa-banner {
  display: none;
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 656px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  z-index: 998;
  display: none;
  align-items: center;
  gap: 12px;
}
#pwa-banner.show { display: flex; }
#pwa-banner-icon { font-size: 28px; flex-shrink: 0; }
#pwa-banner-text { flex: 1; }
#pwa-banner-title { font-size: 13px; font-weight: 600; margin-bottom: 1px; }
#pwa-banner-sub   { font-size: 11px; color: var(--c-text2); }
#pwa-banner-btns  { display: flex; gap: 6px; flex-shrink: 0; }

/* ── PWA iOS MODAL ── */
#pwa-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1001;
  align-items: flex-end;
  justify-content: center;
}
#pwa-modal-overlay.open { display: flex; }
#pwa-modal {
  background: var(--c-bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 680px;
  padding: 20px 20px 36px;
  animation: slideUp 0.25s ease-out;
}
#pwa-modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
#pwa-modal p  { font-size: 13px; color: var(--c-text2); margin-bottom: 20px; line-height: 1.5; }
.pwa-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
}
.pwa-step:last-of-type { border-bottom: none; }
.pwa-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-green);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pwa-step-text { font-size: 13px; line-height: 1.6; }
.pwa-step-text strong { font-weight: 600; }
.pwa-step-icon { font-size: 20px; margin-left: auto; flex-shrink: 0; }
