:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fcfcfb;
  --surface-2: #f0ede6;
  --border: #e3dfd5;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8880;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --p1: #2a78d6;
  --p2: #eb6834;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --grid: #e8e5dd;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8d85;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --p1: #3987e5;
    --p2: #d95926;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --grid: #2a2a27;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* Header */
.hero {
  background: linear-gradient(160deg, #0f766e 0%, #0e7490 55%, #f59e0b 140%);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 0 22px;
}
.hero .top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.hero .eyebrow { font-size: 13px; opacity: 0.85; letter-spacing: 0.04em; text-transform: uppercase; }
.hero h1 { font-size: 26px; margin-top: 2px; }
.countdown { text-align: right; }
.countdown .num { font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown .lbl { font-size: 12px; opacity: 0.9; }
.daybar { margin-top: 14px; height: 6px; background: rgb(255 255 255 / 0.25); border-radius: 99px; overflow: hidden; }
.daybar > div { height: 100%; background: #fff; border-radius: 99px; }
.daymeta { display: flex; justify-content: space-between; font-size: 12px; opacity: 0.9; margin-top: 6px; }

main { padding-top: 16px; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }
.card h2 .sub { font-weight: 400; color: var(--muted); }

/* Leader banner */
.leader { display: flex; align-items: center; gap: 14px; }
.leader .trophy { font-size: 36px; }
.leader .who { font-size: 20px; font-weight: 700; }
.leader .why { color: var(--text-2); font-size: 14px; }
.scorebar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin-top: 14px; gap: 2px; background: var(--surface); }
.scorebar > div { height: 100%; }
.scorelabels { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; color: var(--text-2); }
.scorelabels b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Player cards */
.players { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
@media (min-width: 640px) { .players { grid-template-columns: 1fr 1fr; } }
.players .card { margin: 0; border-top: 4px solid var(--pc); }
.pname { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pname h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); display: inline-block; flex: none; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.good { color: var(--good); }
.pill.warn { color: var(--warn); }
.big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big small { font-size: 15px; font-weight: 500; color: var(--text-2); }
.meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; position: relative; }
.progress > .fill { height: 100%; background: var(--pc); border-radius: 99px; }
.progress > .pace { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: 0.5; }
.row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; }
.stat .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--text-2); }
.weekdots { display: flex; gap: 6px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.weekdots span.w { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--pc); }
.weekdots span.w.on { background: var(--pc); }
.weekdots span.w.extra { border-style: dashed; }
.weekdots .lbl { font-size: 13px; color: var(--text-2); margin-left: 4px; }

/* Categories */
.cats { list-style: none; margin: 0; padding: 0; }
.cats li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.cats li:last-child { border-bottom: 0; }
.cats .w { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.cats .none { color: var(--muted); font-weight: 400; }

/* Chart */
.chartbox { position: relative; height: 240px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ln { width: 16px; height: 2px; background: var(--pc); }
.legend .ln.dash { background: none; border-top: 2px dashed var(--muted); height: 0; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 28px 0; }

/* Week grid */
.weekgrid { display: grid; grid-template-columns: 64px repeat(10, 1fr); gap: 4px; align-items: center; font-size: 12px; }
.weekgrid .hd { color: var(--muted); text-align: center; }
.weekgrid .nm { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.weekgrid .cell {
  aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 0;
}
.weekgrid .cell.hit { background: var(--pc); color: #fff; }
.weekgrid .cell.miss { box-shadow: inset 0 0 0 2px var(--pc); color: var(--text); }
.weekgrid .cell.current { outline: 2px solid var(--text); outline-offset: 1px; }
.weekgrid .cell.future { opacity: 0.45; }

/* Forms */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
label.f { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 4px; }
input[type='number'], input[type='text'], input[type='tel'], input[type='email'], input[type='date'], input[type='password'], select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 17px;
  min-height: 48px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.weightinput { font-size: 34px !important; font-weight: 800; text-align: center; letter-spacing: 0.02em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips button { border: 1px solid var(--border); background: var(--surface); padding: 9px 14px; border-radius: 99px; cursor: pointer; font-size: 15px; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); min-height: 50px;
}
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.small { width: auto; padding: 8px 14px; min-height: 0; font-size: 14px; }
.btn:disabled { opacity: 0.6; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* History */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist li:last-child { border-bottom: 0; }
.hist .main { flex: 1; min-width: 0; }
.hist .t { font-weight: 600; }
.hist .s { font-size: 13px; color: var(--text-2); }
.hist .del { border: 0; background: none; color: var(--muted); font-size: 20px; padding: 6px 10px; cursor: pointer; }
.datehdr { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 12px 0 2px; }

/* Bottom nav */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button { border: 0; background: none; padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
nav.tabs button .ic { font-size: 22px; line-height: 1; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; transition: all 0.25s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; text-align: center; padding: 28px 22px; }
.login h1 { font-size: 24px; margin: 8px 0 4px; }
.login p { color: var(--text-2); margin: 0 0 20px; }
.login .err { color: var(--bad); font-size: 14px; margin-bottom: 12px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--border); }
details summary { cursor: pointer; color: var(--text-2); font-size: 13px; margin-top: 10px; }

/* Photos */
.photodrop {
  display: grid; place-items: center; min-height: 160px; margin-bottom: 14px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 14px; background: var(--surface-2); color: var(--text-2);
  overflow: hidden; text-align: center; padding: 8px;
}
.photodrop img { max-width: 100%; max-height: 340px; border-radius: 10px; display: block; }
.photo-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.photo-status a { color: var(--accent); font-weight: 600; text-decoration: none; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.compare:last-child { margin-bottom: 0; }
.compare .who { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.shot { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); aspect-ratio: 3 / 4; cursor: pointer; border: 0; padding: 0; display: block; width: 100%; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 12px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.65));
}
.shot.empty { display: grid; place-items: center; color: var(--muted); font-size: 13px; cursor: default; }
.gweek { margin-bottom: 14px; }
.gweek:last-child { margin-bottom: 0; }
.gweek h3 { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.gweek h3 span { color: var(--muted); font-weight: 400; }
.grow { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.shot .tag { position: absolute; top: 6px; left: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 2px #fff; }
.lightbox { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; color: #fff; }
.lb-info { flex: 1; font-size: 14px; }
.lb-btn { border: 0; background: rgb(255 255 255 / 0.15); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.lightbox img { flex: 1; min-height: 0; width: 100%; object-fit: contain; padding-bottom: env(safe-area-inset-bottom); }
.btn.google {
  display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
}
.btn.google[hidden] { display: none; }
