/* Dot Game - clean, golf-themed, big tap targets. Safe inside an iframe (no fixed full-viewport tricks, transparent-friendly). */
:root {
  --green: #1f5f3a; --green-d: #154329; --green-l: #e8f3ec; --sand: #f6f3ea; --ink: #1d2a22; --mute: #5c6b62; --line: #d6ddd7; --bad: #b3261e; --warn: #8a5a00;
  --st4: #f4b0b0; --st3: #fcd5a0; --st2: #c6e0b4; --st1: #ddebf7; --st5: #e4d6f2; --st0: transparent;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* installed (standalone) app on a phone with a notch / rounded corners: keep content inside the safe area; the status-bar strip is green */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body::before { content: ''; position: fixed; z-index: 60; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--green); }
@media print { body::before { display: none; } }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--sand); }
h1, h2 { margin: 0 0 .4rem; line-height: 1.2; } h2 { font-size: 1.15rem; }
p { margin: .3rem 0; }
.boot { padding: 2rem; text-align: center; color: var(--mute); }
.small { font-size: .85rem; color: var(--mute); }
a { color: var(--green); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }

/* ---------- header / tabs ---------- */
.demo-bar { background: #fff3cd; color: #664d03; text-align: center; font-size: .85rem; padding: .35rem .6rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; background: var(--green); color: #fff; padding: .55rem .9rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.3rem; font-weight: 700; letter-spacing: .02em; }
.flag { font-size: 1.5rem; }
.who { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.who a { color: #cfe8d8; }
.who-email { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: #ffffff33; border-radius: 99px; padding: .05rem .55rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.badge.admin { background: #ffd34d; color: #3a2d00; }
.tabs { display: flex; gap: .25rem; padding: .5rem .6rem 0; background: var(--green-d); overflow-x: auto; }
.tab { flex: 1 0 auto; min-height: 46px; padding: .5rem 1rem; border: 0; border-radius: 10px 10px 0 0; background: #ffffff1f; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.tab.on { background: var(--sand); color: var(--green-d); }
.main { padding: .7rem; max-width: 1100px; margin: 0 auto; }

/* ---------- cards, buttons, fields ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin-bottom: .7rem; box-shadow: 0 1px 2px #0000000d; }
.btn { min-height: 46px; padding: .55rem 1rem; border: 1.5px solid var(--green); border-radius: 10px; background: #fff; color: var(--green-d); font: inherit; font-weight: 700; letter-spacing: .02em; cursor: pointer; }
.btn:hover { background: var(--green-l); } .btn:focus-visible, .inp:focus-visible, .tab:focus-visible { outline: 3px solid #f2b705; outline-offset: 1px; }
.btn-primary { background: var(--green); color: #fff; } .btn-primary:hover { background: var(--green-d); }
.btn-danger { border-color: var(--bad); color: var(--bad); } .btn-danger:hover { background: #fdecea; }
.btn.on { background: var(--green-l); }
.btn.big { width: 100%; margin-top: .6rem; font-size: 1.05rem; }
.btn.link, button.link { border: 0; background: none; color: var(--green); text-decoration: underline; min-height: 40px; padding: .3rem; font-weight: 500; cursor: pointer; font: inherit; }
button.link { text-align: left; min-height: 0; padding: 0; color: inherit; }
.small-btn { min-height: 36px; padding: .25rem .7rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .1rem 0 .7rem; }
.actions .btn { flex: 1 1 8rem; }
.actions .post { flex: 2 1 10rem; font-size: 1.2rem; }
.actions #index-search { flex: 2 1 14rem; min-width: 10rem; min-height: 44px; }
.inp { width: 100%; min-height: 44px; padding: .45rem .6rem; border: 1.5px solid #b9c4bc; border-radius: 9px; background: #fff; font: inherit; color: inherit; }
.inp.big { min-height: 52px; font-size: 1.15rem; } .inp.code { letter-spacing: .3em; text-align: center; font-size: 1.5rem; }
.fld { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .6rem; font-size: .85rem; color: var(--mute); }
.chk { display: flex; align-items: center; gap: .5rem; min-height: 40px; }
.chk input { width: 22px; height: 22px; }
.lbl { display: block; margin-top: .6rem; font-size: .85rem; color: var(--mute); }
.msg { min-height: 1.4em; font-size: .9rem; color: var(--mute); } .msg.bad { color: var(--bad); font-weight: 600; }
.datewarn { grid-column: 1 / -1; margin: 0; background: #fdecea; border: 1px solid var(--bad); color: var(--bad); padding: .5rem .7rem; border-radius: 8px; font-size: .92rem; font-weight: 600; }
.datewarn[hidden] { display: none; }
.btn-primary.blocked { background: #8b8f8c; border-color: #8b8f8c; }
.warnbox { background: #fff3cd; border: 1px solid #f0d27a; color: #664d03; padding: .5rem .7rem; border-radius: 8px; font-size: .9rem; }
.demo-note { background: #fff3cd; border: 1px solid #f0d27a; color: #664d03; padding: .5rem .7rem; border-radius: 8px; font-size: .9rem; margin-bottom: .6rem; }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding: 1.2rem .8rem; }
.login { width: 100%; max-width: 26rem; } .login .brand { color: var(--green-d); margin-bottom: .6rem; } .lead { font-size: 1rem; }

.login-switch { margin-top: .85rem; text-align: center; }
.login-switch .btn.link { font-weight: 400; font-size: .9rem; color: var(--mute); }
.login-switch .btn.link:hover { color: var(--green); }
.msg.ok { color: var(--green); font-weight: 600; }
.pw-panel { max-width: 28rem; }

/* ---------- public Player Index (no sign-in) ---------- */
.pub-index-wrap { display: flex; justify-content: center; padding: 1.2rem .7rem 2rem; }
.pub-index { width: 100%; max-width: 36rem; }
.pub-index .brand { color: var(--green-d); margin-bottom: .4rem; }
.pub-index h2 { margin: .2rem 0 .4rem; }
.pub-tools { display: flex; flex-wrap: wrap; gap: .45rem; align-items: stretch; margin: .5rem 0 .7rem; }
.pub-tools .inp { flex: 1 1 12rem; min-height: 44px; }
.pub-tools .btn { min-height: 44px; }
.pub-tablewrap { max-height: none; overflow: visible; }
.pub-table { width: 100%; font-size: 1rem; }
.pub-table th, .pub-table td { padding: .6rem .65rem; border-bottom: 1px solid #e1e7e2; vertical-align: middle; }
.pub-table thead th { position: sticky; top: 0; }
.pub-table td.pname { font-weight: 600; }
.pub-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.pub-index .back-link { display: inline-block; margin-top: .2rem; font-size: 1rem; color: var(--green); }
.pub-index .back-link:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .pub-index-wrap { padding: .8rem .5rem 1.6rem; }
  .pub-table { font-size: 1.02rem; }
  .pub-table th, .pub-table td { padding: .7rem .55rem; }
}

/* ---------- Daily Game ---------- */
.ctrl { display: grid; gap: .6rem; grid-template-columns: 1fr; } .ctrl .fld { margin: 0; }
.date-row { display: flex; gap: .4rem; align-items: stretch; }
.date-row #g-date { flex: 0 0 10.5rem; min-width: 9.5rem; }
.date-row #btn-change-date { flex: 0 0 auto; white-space: nowrap; min-height: 44px; }
.date-row #g-saved { flex: 1; min-width: 0; }
@media (max-width: 520px) {
  .date-row { flex-wrap: wrap; }
  .date-row #g-date { flex: 1 1 auto; min-width: 9rem; }
  .date-row #btn-change-date { flex: 0 0 auto; }
  .date-row #g-saved { flex: 1 1 100%; }
}
@media (min-width: 640px) { .ctrl { grid-template-columns: minmax(16rem, 1.3fr) 1fr 1fr; } }
.grid { padding: .4rem; }
.grow { display: grid; grid-template-columns: 1.8rem 1.7fr .8fr .9fr; grid-template-areas: "num player player player" ". tee idx ph" ". score score score"; gap: .3rem .5rem; align-items: center; padding: .55rem .3rem; border-bottom: 1px solid #edf0ed; }
.grow:last-child { border-bottom: 0; }
.grow.ghead { display: none; }
.gnum { grid-area: num; color: var(--mute); font-size: .85rem; text-align: center; }
.gplayer { grid-area: player; position: relative; display: grid; grid-template-columns: 1fr 44px; gap: .3rem; }
.gplayer .flag-note { grid-column: 1 / -1; font-size: .78rem; color: var(--warn); display: none; } .gplayer .flag-note.on { display: block; }
.gcell { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.grow .gcell.tee { grid-area: tee; } .grow .gcell:nth-child(4) { grid-area: idx; } .grow .gcell:nth-child(5) { grid-area: ph; } .grow .gcell:nth-child(6) { grid-area: score; }
.gcell .cap { font-size: .68rem; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.gidx, .gph { min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 9px; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.gph { background: var(--green-l); color: var(--green-d); font-size: 1.3rem; } .gph:empty, .gidx:empty { background: transparent; }
.x { min-height: 44px; min-width: 44px; padding: 0; border-color: var(--line); color: var(--mute); }
.gscore { text-align: center; font-size: 1.2rem; font-weight: 700; }
.gtee { padding-left: .3rem; padding-right: .2rem; }
@media (min-width: 720px) {
  .grow { grid-template-columns: 2.2rem minmax(14rem, 2.4fr) minmax(8rem, 1.2fr) 7rem 7rem 6.5rem; grid-template-areas: "num player tee idx ph score"; padding: .35rem .4rem; }
  .grow.ghead { display: grid; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); border-bottom: 2px solid var(--line); }
  .grow.ghead .gcell { align-items: center; }
  .gcell .cap { display: none; }
  .gidx, .gph { min-height: 40px; }
}
.hint { margin: .2rem .3rem 1rem; }

/* ENTER SCORES: the Total Score column is hidden until the button is pressed */
.noscores .gscorecell { display: none; }
.noscores .grow { grid-template-areas: "num player player player" ". tee idx ph"; }
@media (min-width: 720px) {
  .noscores .grow { grid-template-columns: 2.2rem minmax(14rem, 2.4fr) minmax(8rem, 1.2fr) 7rem 7rem; grid-template-areas: "num player tee idx ph"; }
}
#btn-scores.on { background: var(--green); color: #fff; }

/* ---------- status colours (Calculated Index) ---------- */
.st4 { background: var(--st4); } .st3 { background: var(--st3); } .st2 { background: var(--st2); } .st1 { background: var(--st1); } .st5 { background: var(--st5); }
.chip { display: inline-block; min-width: 3.4rem; text-align: center; padding: .12rem .4rem; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: .5rem .7rem; font-size: .85rem; margin: .4rem 0 .6rem; box-shadow: none; }
.lg { display: inline-flex; align-items: center; gap: .35rem; } .sw { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px; } .sw.bd { border: 1px solid var(--line); }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; max-height: 75vh; padding: 0; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
th, td { padding: .35rem .5rem; border-bottom: 1px solid #edf0ed; white-space: nowrap; }
thead th { position: sticky; top: 0; background: #eef3ef; z-index: 3; text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--mute); }
.dtable .sticky { position: sticky; background: #fff; z-index: 2; } .dtable thead .sticky { z-index: 4; background: #eef3ef; }
.dtable .c1 { left: 0; min-width: 5.2rem; } .dtable .c2 { left: 5.2rem; min-width: 11rem; box-shadow: 2px 0 0 #e1e7e2; font-weight: 600; }
.dtable th.rd { height: 5.2rem; vertical-align: bottom; padding: .3rem .1rem; min-width: 2.2rem; text-align: center; }
.dtable th.rd span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; }
.dtable th.seed, .dtable td.seed { background: var(--st5); }
.dtable td.diff, .dtable th.diffh { background: #f5f5f5; } .dtable td.seed.diff { background: var(--st5); }
.dtable td.rc, .ctable tr.rc { cursor: pointer; } .dtable td.rc:hover, .ctable tr.rc:hover td { background: #fff7d6; }
@media (max-width: 600px) { .dtable .c2 { min-width: 8.5rem; } .dtable .c1 { min-width: 4.4rem; } .dtable .c2 { left: 4.4rem; } .who-email { max-width: 9rem; } }
.addrow { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-top: .5rem; } @media (min-width: 640px) { .addrow { grid-template-columns: 1fr 8rem auto; } }
.utable td.em { font-weight: 600; } .utable select { min-width: 6.5rem; min-height: 38px; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(94vw, 30rem); max-height: 90vh; box-shadow: 0 10px 40px #0005; }
dialog::backdrop { background: #0006; }
dialog.dlg-print { width: min(98vw, 60rem); }
.dlg-form { display: flex; flex-direction: column; max-height: 90vh; }
.dlg-title { margin: 0; padding: .8rem 1rem; background: var(--green); color: #fff; font-size: 1.05rem; border-radius: 14px 14px 0 0; }
.dlg-warn .dlg-title { background: #8a5a00; } .dlg-error .dlg-title { background: var(--bad); }
.dlg-body { padding: .8rem 1rem; overflow: auto; } .dlg-line { margin: .1rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dlg-input { width: 100%; min-height: 48px; margin-top: .6rem; padding: .4rem .6rem; font: inherit; font-size: 1.1rem; border: 1.5px solid #b9c4bc; border-radius: 9px; }
.dlg-buttons { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; padding: .6rem 1rem .9rem; } .dlg-buttons .btn { min-width: 6rem; }

/* ---------- print ---------- */
.print-only { display: none; }
.psheet h1 { font-size: 1.15rem; margin: 0 0 .35rem; } .pmeta { display: flex; flex-wrap: wrap; gap: .7rem 1rem; margin-bottom: .45rem; font-weight: 600; font-size: .85rem; }
.ptable { width: 100%; border-collapse: collapse; table-layout: fixed; } .ptable th, .ptable td { border: 1px solid #888; padding: .22rem .28rem; } .ptable th { background: #eee; font-size: .68rem; position: static; text-transform: none; color: #000; line-height: 1.15; white-space: normal; word-break: break-word; }
.ptable .pn { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ptable .ptee { font-size: .72rem; text-align: center; }
.ptable .pph { font-weight: 700; text-align: center; font-size: 1rem; } .ptable .psc { text-align: center; }
.ptable .pwrite { text-align: center; min-height: 1.35em; } /* blank write-in boxes (Front / Back / Total / Dots) */
.ptable td:nth-child(1), .ptable td:nth-child(4), .ptable td:nth-child(5), .ptable td:nth-child(6) { text-align: center; }
/* Front / Back / Total are ~2/3 of their previous 10.5% width (7% each); the freed 10.5% goes to Dots (21%). */
.ptable th:nth-child(1), .ptable td:nth-child(1) { width: 4%; }    /* # */
.ptable th:nth-child(2), .ptable td:nth-child(2) { width: 20%; }   /* Player */
.ptable th:nth-child(3), .ptable td:nth-child(3) { width: 10%; }   /* Tees */
.ptable th:nth-child(4), .ptable td:nth-child(4) { width: 7%; }    /* Index */
.ptable th:nth-child(5), .ptable td:nth-child(5) { width: 8%; }    /* Playing HC */
.ptable th:nth-child(6), .ptable td:nth-child(6) { width: 9%; }    /* Total Score */
.ptable th:nth-child(7), .ptable td:nth-child(7),
.ptable th:nth-child(8), .ptable td:nth-child(8),
.ptable th:nth-child(9), .ptable td:nth-child(9) { width: 7%; }    /* Front Back Total */
.ptable th:nth-child(10), .ptable td:nth-child(10) { width: 21%; } /* Dots */
.ptable .pnarrow { width: 7%; } .ptable .pdots { width: 21%; }
/* handwritten team boxes: 2 rows of 3, 5 lines each; stay together if they overflow to page 2 */
.pteams { margin-top: .4rem; page-break-inside: avoid; break-inside: avoid; }
.pteams-title { font-size: .75rem; font-weight: 700; margin: 0 0 .25rem; }
.pteams-row { display: flex; gap: .4rem; margin: 0 0 .35rem; }
.pteam { flex: 1; border: 1px solid #888; padding: .15rem .25rem .12rem; }
.pteam h3 { font-size: .72rem; margin: 0 0 .08rem; text-align: center; font-weight: 700; }
.pteam .pline { border-bottom: 1px solid #bbb; height: 1.05em; margin-top: .08rem; }
.print-preview { overflow: auto; }
@media print {
  @page { size: letter portrait; margin: 0.35in; }
  body.printing #app > *:not(#print-root), body.printing dialog, body.printing .demo-bar { display: none !important; }
  body.printing { background: #fff; } body.printing #print-root { display: block !important; }
  body:not(.printing) #app { display: none; }
  .psheet h1 { font-size: 11pt; margin-bottom: .2rem; } .pmeta { font-size: 8pt; gap: .25rem .6rem; margin-bottom: .2rem; }
  .ptable th { font-size: 7pt; padding: .08rem .1rem; } .ptable td { padding: .08rem .1rem; font-size: 8pt; }
  .ptable .pn { font-size: 8pt; } .ptable .ptee { font-size: 7pt; } .ptable .pph { font-size: 9pt; }
  .ptable .pwrite { min-height: 1.15em; height: 1.15em; }
  .pteams { margin-top: .28rem; } .pteams-title { font-size: 8pt; margin-bottom: .15rem; }
  .pteams-row { gap: .28rem; margin-bottom: .22rem; }
  .pteam { padding: .08rem .16rem .08rem; } .pteam h3 { font-size: 7.5pt; }
  .pteam .pline { height: 0.18in; margin-top: .06rem; }
}

/* Data-tab roster + rounds print (portrait). No Dot Game Index. */
.psheet-data { color: #111; background: #fff; }
.psheet-data h1 { font-size: 1.15rem; margin: 0 0 .15rem; }
.psheet-data h2, .psheet-data .pdata-h { font-size: 1rem; margin: .85rem 0 .3rem; page-break-after: avoid; break-after: avoid; }
.dptable { width: 100%; border-collapse: collapse; }
.dptable th, .dptable td { border: 1px solid #888; padding: .22rem .35rem; font-size: .82rem; text-align: left; vertical-align: top; }
.dptable th { background: #eee; font-weight: 700; color: #000; text-transform: none; position: static; line-height: 1.2; }
.dptable .num { text-align: right; font-variant-numeric: tabular-nums; }
.dptable .flag { text-align: center; }
.dptable .empty { color: #555; font-style: italic; }
.dptable tr.seed td { background: #f4eef9; }
.dptable tr.in-ix td { background: #f3f8f4; }
.pdata-roster { margin-bottom: .4rem; }
.pdata-player { margin: 0 0 .7rem; page-break-inside: avoid; break-inside: avoid; }
.pdata-player h3 { font-size: .92rem; margin: 0 0 .25rem; }
.pdata-sub { font-weight: 500; font-size: .8rem; color: #333; }
.dlg-print .print-preview { max-height: 70vh; overflow: auto; background: #fff; padding: .5rem .6rem; border: 1px solid #d6ddd7; -webkit-overflow-scrolling: touch; }
.dlg-print .print-preview { overflow-x: auto; }
.dlg-print .psheet-data { width: 40rem; max-width: none; } /* readable columns; swipe to see the rest on a phone */
@media print {
  .psheet-data h1 { font-size: 13pt; margin-bottom: .12rem; }
  .psheet-data h2, .psheet-data .pdata-h { font-size: 11pt; margin: .28in 0 .12rem; }
  .psheet-data .pmeta { font-size: 8pt; }
  .dptable th, .dptable td { font-size: 8pt; padding: .05rem .12rem; }
  .pdata-player { margin-bottom: .28rem; }
  .pdata-player h3 { font-size: 9pt; }
  .pdata-sub { font-size: 8pt; }
}

/* ---------- "Install this app" tip (sign-in screen) ---------- */
.install-tip { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; padding: .6rem .7rem; border: 1px dashed var(--line); border-radius: 10px; background: var(--green-l); font-size: .88rem; color: var(--ink); }
.install-tip .ic { font-size: 1.3rem; line-height: 1.2; }
.install-tip .tx { flex: 1; } .install-tip b { color: var(--green-d); }
.install-tip button { border: 0; background: transparent; color: var(--mute); font-size: 1.2rem; line-height: 1; padding: .1rem .4rem; cursor: pointer; border-radius: 6px; min-width: 2rem; min-height: 2rem; }
.install-tip button:hover { background: #d3e6d9; }
@media print { .install-tip { display: none; } }

/* ---------- public Data-tab view (no sign-in) ---------- */
.pub-page { width: 100%; max-width: 72rem; margin: 0 auto; padding: 1rem .7rem 2.2rem; box-sizing: border-box; }
.pub-page .pub-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.pub-page .brand { color: var(--green-d); margin: 0; }
.pub-page h1 { font-size: 1.35rem; margin: .5rem 0 .25rem; }
.pub-page .lead { margin: 0 0 .6rem; }
.pub-page .back-link { color: var(--green); font-size: 1rem; }
.pub-page .back-link:hover { text-decoration: underline; }
.pub-page .login-switch { margin: .2rem 0; }
.pub-page .legend { margin-top: .5rem; }
.pub-page #index-search { flex: 1 1 12rem; min-height: 44px; min-width: 10rem; }
@media (max-width: 600px) {
  .pub-page { padding: .7rem .4rem 1.6rem; }
}

/* First / last name fields in Add Player and Edit player */
.name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .7rem; }
.name-grid .dlg-input, .name-grid .inp { margin-top: .25rem; width: 100%; box-sizing: border-box; min-height: 44px; }
@media (max-width: 520px) {
  .name-grid { grid-template-columns: 1fr; }
}
