:root {
  color-scheme: light;
  --forest: #244f37;
  --green: #2f7652;
  --green-soft: #e8f1eb;
  --lime: #b9c58b;
  --cream: #f7f5eb;
  --ink: #17211b;
  --muted: #68736c;
  --line: #dce3de;
  --danger: #a43a3a;
  --warning: #8b6019;
  --shadow: 0 10px 30px rgba(20, 48, 32, .09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body { margin: 0; min-height: 100vh; background: linear-gradient(#fff 0 190px, var(--cream) 390px); color: var(--ink); }
button, input, select { font: inherit; }
button { touch-action: manipulation; }

.app-header {
  position: sticky; top: 0; z-index: 20; min-height: 76px; padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  display: grid; grid-template-columns: 48px 1fr 48px 48px; gap: 8px; align-items: center;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.wordmark { display: block; width: min(250px, 100%); height: 54px; margin: auto; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--forest); font-size: 27px; font-weight: 700; }
.icon-button[hidden] { display: none; }
.camera-button svg { display:block; width:23px; height:23px; margin:auto; fill:currentColor; }
.app-main { width: min(760px, 100%); min-height: calc(100vh - 80px); margin: 0 auto; padding: 14px 12px calc(108px + env(safe-area-inset-bottom)); }

h1 { margin: 0 0 10px; font-size: clamp(1.75rem, 8vw, 2.5rem); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin: 0 0 10px; font-size: 1.3rem; }
h3 { margin: 0; font-size: 1rem; }
p { line-height: 1.5; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.stack { display: grid; gap: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.card { background: rgba(255,255,255,.98); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.hero-card { margin-bottom: 18px; padding: 24px; overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -82px; top: -86px; background: var(--green-soft); }
.tournament-card { width: 100%; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 16px; text-align: left; color: var(--ink); }
.tournament-card:active { transform: translateY(1px); }
.tournament-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: .86rem; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; background: var(--green-soft); color: var(--forest); font-size: .75rem; font-weight: 750; }
.badge.warning { background: #fff1cf; color: var(--warning); }
.badge.approved { background: #e3efe7; color: var(--green); }

label { display: block; margin: 14px 0 6px; font-size: .88rem; font-weight: 750; }
input, select { width: 100%; min-height: 48px; border: 1px solid #bdc8c0; border-radius: 12px; background: #fff; color: var(--ink); padding: 10px 12px; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(47,118,82,.25); outline-offset: 2px; border-color: var(--green); }
.search-box { position: sticky; top: 86px; z-index: 5; background: var(--cream); padding: 6px 0 10px; }
.player-option { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.player-option:last-child { border-bottom: 0; }
.player-option button { min-width: 74px; }
.selected-player { display: grid; grid-template-columns: 1fr 94px 38px; align-items: end; gap: 9px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.selected-player label { margin-top: 0; }
.remove-button { width: 38px; height: 48px; border: 0; background: transparent; color: var(--danger); font-size: 24px; }
.guest-card { margin-top: 14px; }
.guest-fields { display: grid; grid-template-columns: minmax(0,1fr) minmax(110px,.45fr); gap: 10px; }
.guest-fields label { margin-top: 4px; }

.primary-button, .secondary-button, .danger-button, .small-button {
  min-height: 50px; border-radius: 999px; padding: 11px 20px; font-weight: 800; cursor: pointer;
}
.primary-button { width: 100%; border: 0; background: var(--green); color: #fff; box-shadow: 0 8px 18px rgba(47,118,82,.2); }
.secondary-button { border: 1px solid var(--green); background: #fff; color: var(--green); }
.danger-button { border: 1px solid #dbaaaa; background: #fff; color: var(--danger); }
.small-button { min-height: 38px; padding: 6px 14px; border: 1px solid var(--green); background: #fff; color: var(--green); }
button:disabled { opacity: .48; cursor: not-allowed; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.button-row.compact { grid-template-columns: 1fr; }
.sidegame-notice { background:#eef3ef; color:var(--forest); border:1px solid #c7d7cc; }
.sidegame-entry { margin-top:12px; }
.sidegame-measure { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.sidegame-saved { margin-top:14px; border-top:1px solid var(--line); padding-top:8px; }
.sidegame-saved>div,.sidegame-result>div { display:flex; justify-content:space-between; gap:12px; padding:8px 0; border-bottom:1px solid var(--line); }
.sidegame-result { margin-top:14px; padding:12px; border-radius:12px; background:#f1f3f1; }
.sidegame-result h3 { margin:0 0 5px; }
.sidegame-tab-list { display:grid; gap:12px; }
.sidegame-tab-card { margin:0; padding:15px; border:1px solid var(--line); border-radius:16px; background:#fff; box-shadow:var(--shadow); }
.sidegame-tab-card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:8px; }
.sidegame-tab-card h2 { margin:0; font-size:1.08rem; }
.sidegame-hole { flex:0 0 auto; padding:5px 9px; border-radius:999px; background:var(--green-soft); color:var(--forest); font-size:.76rem; font-weight:850; }
.sidegame-tab-row { display:grid; grid-template-columns:34px minmax(0,1fr) auto; gap:9px; align-items:center; padding:10px 0; border-top:1px solid var(--line); }
.sidegame-tab-row .side-place { width:30px; height:30px; display:grid; place-items:center; border-radius:50%; background:#eef2ee; color:var(--forest); font-weight:850; }
.sidegame-tab-row.winner .side-place { background:#efd77a; color:#4e3b00; }
.sidegame-tab-row.winner .side-player::after { content:'Foreløbig vinder'; display:block; margin-top:2px; color:var(--green); font-size:.7rem; font-weight:750; }
.sidegame-tab-row .side-distance { color:var(--forest); font-weight:850; white-space:nowrap; }
.sidegame-empty { margin:0; padding:10px 0 2px; color:var(--muted); }
.result-tabs { display:grid; grid-template-columns:1fr 1fr; gap:5px; margin:0 0 12px; padding:4px; border:1px solid var(--line); border-radius:14px; background:#eef2ee; }
.result-tabs button { min-height:44px; border:0; border-radius:10px; background:transparent; color:var(--muted); font-weight:800; }
.result-tabs button.active { background:#fff; color:var(--forest); box-shadow:0 3px 10px rgba(20,55,35,.1); }
.result-panel[hidden] { display:none; }

.score-top { position: sticky; top: 76px; z-index: 7; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 6px; margin: -4px -4px 8px; padding: 5px 4px; background: rgba(247,245,235,.96); backdrop-filter: blur(10px); }
.hole-nav { border: 1px solid var(--line); background: #fff; border-radius: 50%; width: 44px; height: 44px; color: var(--forest); font-size: 24px; }
.hole-title { text-align: center; }
.hole-title strong { display: block; font-size: 1.25rem; }
.hole-title span { color: var(--muted); font-size: .85rem; }
.score-players.stack { gap: 7px; }
.score-player { border: 2px solid transparent; border-radius: 14px; padding: 9px 10px; }
.score-player.complete { border-color: #9fc4aa; }
.score-player-head { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.score-points { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--green-soft); color: var(--forest); font-weight: 850; }
.score-entry-row { display: grid; grid-template-columns: minmax(0,1fr) 76px; gap: 7px; margin-top: 7px; }
.score-controls { min-width:0; }
.score-input { min-height: 44px; height: 44px; padding: 2px; text-align: center; font-size: 1.5rem; font-weight: 850; }
.score-input { appearance:textfield; -moz-appearance:textfield; }
.score-input::-webkit-inner-spin-button,.score-input::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
.pickup { width: 100%; border: 1px solid #d5adad; border-radius: 10px; background: #fff; color: var(--danger); min-height: 44px; padding: 4px; font-size: .76rem; font-weight: 750; }
.pickup.selected { background: #f8e9e9; font-weight: 750; }
.score-action { position: sticky; bottom: 84px; z-index: 8; margin-top: 8px; padding-top: 8px; background: linear-gradient(transparent, var(--cream) 25%); }

.leader-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.leader-row:last-child { border-bottom: 0; }
.place { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--forest); font-weight: 850; }
.pace { font-size: 1.25rem; color: var(--forest); font-weight: 850; text-align: right; }
.leader-score { margin-top:2px; color:var(--forest); }
.leader-entry { border-bottom: 1px solid var(--line); }
.leader-entry:last-child { border-bottom: 0; }
.leader-entry .leader-row { border-bottom: 0; }
.leader-name-button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--ink); padding: 2px 0; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: #9fc4aa; text-underline-offset: 3px; }
.leader-name-button span { color: var(--green); transition: transform .18s ease; }
.leader-name-button[aria-expanded="true"] span { transform: rotate(180deg); }
.mobile-scorecard-slot { margin: 0 0 13px 48px; padding: 11px; border: 1px solid #cbdcd0; border-radius: 14px; background: var(--green-soft); }
.mobile-scorecard-slot[hidden] { display: none; }
.mobile-scorecard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.scorecard-total { text-align: right; white-space: nowrap; }
.mobile-scorecard-scroll { overflow-x: auto; margin-top: 8px; border-radius: 10px; box-shadow: 0 2px 8px rgba(20,48,32,.05); }
.mobile-scorecard-table { width: 100%; min-width: 540px; border-collapse: collapse; background: #fff; font-size: .72rem; }
.mobile-scorecard-table th, .mobile-scorecard-table td { min-width: 42px; border: 1px solid var(--line); padding: 6px 4px; text-align: center; }
.mobile-scorecard-table thead th { background: var(--green); color: #fff; font-weight: 850; }
.mobile-scorecard-table th:first-child { position: sticky; left: 0; z-index: 1; min-width: 56px; background: #fff; color: var(--ink); text-align: left; }
.mobile-scorecard-table thead th:first-child { background: var(--green); color: #fff; }
.mobile-scorecard-table .nine-total { background: #f3f7f4; font-weight: 850; }
.gross-double { background: #0b4773 !important; color: #fff !important; }
.gross-bogey { background: #4b95df !important; color: #fff !important; }
.gross-par { background: #fff !important; color: var(--ink) !important; }
.gross-birdie { background: #d9534f !important; color: #fff !important; }
.gross-eagle { background: #f2cb45 !important; color: #352b00 !important; }
.gross-albatross { background: #ef8a32 !important; color: #271400 !important; }
.scorecard-legend { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.scorecard-legend span { padding: 3px 7px; border: 1px solid rgba(0,0,0,.1); border-radius: 999px; font-size: .67rem; }
.scorecard-loading { padding: 10px; }
.score-grid { width: 100%; border-collapse: collapse; font-size: .82rem; }
.score-grid th, .score-grid td { border-bottom: 1px solid var(--line); padding: 8px 5px; text-align: center; }
.score-grid th:first-child, .score-grid td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.table-scroll { overflow-x: auto; }

.bottom-nav { position: fixed; z-index: 18; bottom: 0; left: 0; right: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
.bottom-nav[hidden] { display: none; }
.bottom-nav button { border: 0; background: transparent; color: var(--muted); min-height: 52px; border-radius: 12px; font-size: .76rem; font-weight: 750; }
.bottom-nav button span { display: block; color: var(--green); font-size: 20px; }
.bottom-nav button.active { background: var(--green-soft); color: var(--forest); }

.network-status { position: fixed; z-index: 50; top: calc(78px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(92%, 520px); padding: 9px 14px; border-radius: 0 0 12px 12px; background: #fff1cf; color: #664813; text-align: center; font-size: .85rem; box-shadow: var(--shadow); }
.toast { position: fixed; z-index: 80; bottom: calc(90px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(90%, 480px); padding: 13px 16px; border-radius: 12px; background: var(--ink); color: #fff; text-align: center; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }
.loading-card { min-height: 260px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.spinner { width: 38px; height: 38px; margin: auto; border: 4px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.help-dialog { width: min(92%, 560px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.help-dialog::backdrop { background: rgba(10,23,15,.55); }
.help-dialog form { padding: 24px; }
.help-dialog li { margin: 9px 0; line-height: 1.4; }
.dialog-close { float: right; border: 0; background: transparent; font-size: 28px; }
.help-note { background: var(--green-soft); border-radius: 12px; padding: 13px; line-height: 1.45; }
.visually-hidden { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
.photo-dialog-body { padding:24px; }
.photo-dialog-body h2 { font-size:1.45rem; }
.photo-preview { display:block; width:100%; max-height:52vh; margin:14px 0; border-radius:14px; background:#edf1ee; object-fit:contain; }
.location-choice { display:grid; grid-template-columns:24px 1fr; gap:10px; align-items:start; margin:14px 0; padding:12px; border:1px solid var(--line); border-radius:12px; background:var(--green-soft); }
.location-choice input { width:20px; min-height:20px; margin:2px 0 0; }
.location-choice small { display:block; margin-top:3px; color:var(--muted); font-weight:500; line-height:1.35; }
.photo-progress { min-height:22px; margin:8px 0; color:var(--forest); font-size:.86rem; font-weight:700; }

.login-page { display: grid; place-items: center; padding: 24px 16px; }
.login-shell { width: min(440px,100%); }
.login-logo { display: block; width: 300px; max-width: 90%; margin: 0 auto 18px; }
.login-card { padding: 26px; }
.login-card .primary-button { margin-top: 20px; }
.text-link { display: block; margin-top: 18px; color: var(--green); text-align: center; font-weight: 700; }
.error-message { border-radius: 10px; background: #f9e4e4; color: var(--danger); padding: 10px; }
.alert { border-radius: 13px; padding: 13px 14px; line-height: 1.45; }
.alert.info { background: var(--green-soft); color: var(--forest); }
.alert.warning { background: #fff1cf; color: #694b15; }
.alert.danger { background: #f9e4e4; color: var(--danger); }

@media (min-width: 700px) {
  .app-main { padding-top: 34px; }
  .score-players { grid-template-columns: repeat(2,1fr); display: grid; gap: 14px; }
  .score-players .card { margin: 0; }
}
@media (max-width: 480px) {
  .app-header { grid-template-columns:44px 1fr 44px 44px; padding-inline:10px; gap:5px; }
  .wordmark { height:46px; }
  .guest-fields { grid-template-columns: 1fr; }
  .mobile-scorecard-slot { margin-left: 0; }
}
