:root {
    --green: #0b5d2a;
    --green-dark: #063d1b;
    --fairway: #008822;
    --ink: #1a1a1a;
    --muted: #666;
    --line: #d6d6d6;
    --paper: #ffffff;
    --bg: #f2f4f1;
    --t1: #1d4ed8;
    --t2: #b91c1c;
    --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg) center top / cover no-repeat fixed;
    line-height: 1.35;
}
a { color: inherit; }
button, input, select { font: inherit; }
button {
    cursor: pointer;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    background: var(--green);
    color: #fff;
    font-weight: 600;
}
button.secondary { background: #e4e7e3; color: var(--ink); }
button.danger { background: #fbe4e4; color: #9b1c1c; }
button.small { padding: 6px 10px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
input, select {
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 16px; /* prevents iOS zoom on focus */
    max-width: 100%;
}
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 15px; margin: 6px 14px 6px 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.card {
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 16px;
    margin: 16px 0;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 0 1 auto; }
.grow { flex: 1 1 200px; }

/* ---- Top bar ---- */
.topbar {
    background: var(--green-dark);
    color: #fff;
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 52px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.topbar .brand { font-weight: 700; font-size: 18px; text-decoration: none; margin-right: auto; }
.topbar a, .topbar button.link { color: #fff; font-size: 15px; }
button.link { background: none; padding: 0; font-weight: 500; text-decoration: underline; }

/* ---- Landing hero ---- */
.hero {
    background: var(--fairway) center / cover no-repeat;
    color: #fff;
    text-align: center;
    padding: 40px 16px 32px;
    position: relative;
}
.hero.has-image::before { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.hero > * { position: relative; }
.hero h1 { margin: 0; font-size: clamp(28px, 7vw, 52px); letter-spacing: .5px; }
.hero p { margin: 6px 0 0; font-size: 18px; opacity: .9; }
.hero .vs { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 18px; font-weight: 700; }
.hero .vs img {
    --size: min(192px, 36vw);   /* 3x the original 64px, shrinks to fit phones */
    width: var(--size); height: var(--size);
    /* % padding would be relative to the page width, not the logo, so derive it from the size */
    object-fit: contain; background: rgba(255,255,255,.9); border-radius: 50%; padding: calc(var(--size) * .06);
}
.hero .vs .tname { display: block; margin-top: 4px; font-size: 15px; }

.hero .vs a { color: inherit; text-decoration: none; }
.hero .vs a:hover img { transform: scale(1.04); }
.hero .vs img { transition: transform .15s; }

/* ---- Team page ---- */
.team-hero { padding: 28px 16px; }
.team-hero .team-logo {
    --size: min(360px, 75vw);
    width: var(--size); height: var(--size);
    object-fit: contain; background: rgba(255,255,255,.9); border-radius: 50%; padding: calc(var(--size) * .05);
}
.team-hero h1 { margin-top: 14px; }
.team-pts { margin-top: 10px; font-size: clamp(30px, 8vw, 44px); font-weight: 800; }
.team-pts small { display: block; font-size: 15px; font-weight: 400; opacity: .9; }
table.roster th.num, table.roster td.num { text-align: right; white-space: nowrap; }
table.roster td, table.roster th { padding: 12px 14px; }
table.roster td.pts-col { font-size: 20px; font-weight: 800; }
table.roster .live { display: block; font-size: 13px; margin-top: 4px; text-decoration: none; color: var(--muted); }
table.roster .live .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e11; margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
a.lb-team { text-decoration: none; display: block; }

/* ---- Login / PIN ---- */
.login { max-width: 360px; margin: 24px auto; }
.login input[type=password] { font-size: 28px; letter-spacing: 8px; text-align: center; width: 100%; }
.login select { width: 100%; }
.login button[type=submit] { width: 100%; margin-top: 14px; padding: 14px; font-size: 18px; }
.error { color: #b00020; min-height: 1.2em; margin-top: 8px; }

/* ---- Leaderboard ---- */
.lb-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-radius: var(--radius); overflow: hidden; margin-top: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.lb-team {
    color: #fff;
    padding: 16px 12px;
    text-align: center;
    background-size: cover;
    background-position: center;
    position: relative;
    min-height: 170px;
}
.lb-team.has-image::before { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.lb-team > * { position: relative; }
.mrow.tbd { opacity: .65; box-shadow: none; border: 1px dashed var(--line); }
.lb-team h2 { margin: 6px 0 2px; font-size: clamp(17px, 4.5vw, 26px); }
.lb-team .captains { font-size: 13px; opacity: .95; }
.lb-team .pts { font-size: clamp(44px, 12vw, 72px); font-weight: 800; line-height: 1; margin-top: 8px; }
.lb-team .proj { font-size: 13px; opacity: .9; }
.lb-towin { text-align: center; color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.lb-round { margin-top: 20px; }
.lb-round h3 { margin: 0 0 6px; font-size: 16px; }
.lb-round h3 small { font-weight: 400; color: var(--muted); }
.mrow {
    display: grid;
    grid-template-columns: 1fr minmax(92px, auto) 1fr;
    align-items: stretch;
    background: #fff;
    border-radius: 8px;
    margin: 6px 0;
    text-decoration: none;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,.07);
}
.mrow .side { padding: 10px; font-size: 15px; display: flex; flex-direction: column; justify-content: center; }
.mrow .side.t1 { text-align: left; border-left: 5px solid var(--t1); }
.mrow .side.t2 { text-align: right; border-right: 5px solid var(--t2); }
.mrow .side small { color: var(--muted); font-size: 12px; }
.mrow .side.lead { font-weight: 700; }
.mrow .stat {
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 6px 8px; font-weight: 700; font-size: 14px; color: var(--ink); background: #eef0ed;
}
.mrow .stat.final { color: #fff; }
.mrow .stat.live { color: #fff; opacity: .85; }
.my-matches .mrow { border: 2px solid var(--green); }

/* ---- Scorecard ---- */
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.status-chip { font-weight: 800; font-size: 20px; padding: 6px 14px; border-radius: 999px; background: #eef0ed; }
/* Green frame outside the scroller, so scrolled cells never pass over the margin. */
.sc-frame { background: var(--fairway); border-radius: var(--radius); padding: 6px; }
.sc-scroll { overflow-x: auto; background: var(--fairway); }
table.sc { border-collapse: separate; border-spacing: 0; font-size: 15px; min-width: 900px; width: 100%; }
table.sc th, table.sc td {
    border: .5px solid #000;
    background: #fff;
    text-align: center;
    padding: 0;
    height: 34px;
    min-width: 34px;
    position: relative;
}
table.sc .name { text-align: left; padding: 0 8px; min-width: 120px; position: sticky; left: 0; z-index: 1; white-space: nowrap; }
table.sc .sum { font-weight: 700; }
table.sc tr.par td { background: #bbbbbb; }
table.sc tr.hdcp td { background: #333; color: #fff; }
table.sc td.edit { cursor: pointer; }
table.sc td.edit:hover, table.sc td.active { outline: 3px solid red; outline-offset: -3px; }
table.sc td .dots { position: absolute; top: 2px; right: 3px; line-height: 0; }
table.sc td .dots i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #000; margin-left: 1px; }
table.sc td.best { font-weight: 800; }
table.sc td.best::after { content: ""; position: absolute; inset: 4px; border: 1.5px solid currentColor; border-radius: 50%; pointer-events: none; }
table.sc td.pickup { color: var(--muted); }
table.sc tr.match td { font-size: 12px; font-weight: 700; }
table.sc tr.player td.name { border-left: 6px solid var(--team, #000); }
.tee-chip {
    font-size: 12px; padding: 2px 4px; margin-left: 6px; border: 1px solid #888; border-radius: 4px;
    color: #000; vertical-align: middle;
}
select.tee-chip { cursor: pointer; }

/* ---- Score keypad ---- */
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; box-shadow: 0 -4px 20px rgba(0,0,0,.25);
    border-radius: 16px 16px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    max-width: 560px; margin: 0 auto;
}
.sheet .who { font-weight: 700; font-size: 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet .who small { font-weight: 400; color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.keypad button { padding: 16px 0; font-size: 22px; background: #eef0ed; color: var(--ink); }
.keypad button.par { background: var(--green); color: #fff; }
.keypad button.wide { grid-column: span 2; font-size: 16px; }
.sheet .nav { display: flex; gap: 8px; margin-top: 10px; }
.sheet .nav button { flex: 1; }

/* ---- Admin ---- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 16px; }
.tabs button { background: #e4e7e3; color: var(--ink); border-radius: 8px 8px 0 0; }
.tabs button.on { background: var(--paper); }
.tab-body { background: var(--paper); border-radius: 0 var(--radius) var(--radius) var(--radius); padding: 16px; }
table.list { border-collapse: collapse; width: 100%; font-size: 15px; }
table.list th, table.list td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
table.list th { font-size: 13px; color: var(--muted); font-weight: 600; }
.holes-grid { overflow-x: auto; }
.holes-grid table { border-collapse: collapse; }
.holes-grid th, .holes-grid td { padding: 2px; text-align: center; font-size: 13px; }
.holes-grid input { width: 46px; padding: 6px 2px; text-align: center; font-size: 15px; }
.holes-grid input.wide { width: 100px; text-align: left; padding: 6px; }
.img-slot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.img-slot img { max-height: 70px; max-width: 220px; border: 1px solid var(--line); border-radius: 6px; background: #fafafa; }
.match-edit { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0; }
.match-edit .vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.match-edit select { width: 100%; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef0ed; }
.toast {
    position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 100;
    background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 15px;
    max-width: calc(100vw - 32px);
}
.toast.err { background: #b00020; }

@media (max-width: 560px) {
    .mrow .side { font-size: 14px; padding: 8px; }
    .lb-team { min-height: 140px; padding: 12px 6px; }
}
