:root {
  --bg: #f4f6f3;
  --card: #fff;
  --text: #1c2420;
  --muted: #66716b;
  --border: #dfe4e0;
  --accent: #1f8a5b;
  --accent-text: #fff;
  --danger: #c0392b;
  --green-bg: #e2f4ea; --green: #1d6f47;
  --amber-bg: #fff2d6; --amber: #8a5a00;
  --red-bg: #fde4e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --card: #1b201d; --text: #e6ebe8; --muted: #9aa59f; --border: #2c3430;
    --accent: #3cb37e; --accent-text: #08130d; --danger: #ef6b5b;
    --green-bg: #183326; --green: #7fd6a8; --amber-bg: #3a2e12; --amber: #f2c46b; --red-bg: #3a1c18;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Noto Sans HK", sans-serif;
}
a { color: var(--accent); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card.warn { border-color: var(--amber); }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 16px 0 8px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.notes { background: var(--bg); padding: 10px; border-radius: 8px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; }
dt { color: var(--muted); }
dd { margin: 0; }

.form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: .9rem; }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 16px; }
.row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
legend { font-size: .9rem; padding: 0 4px; }
input, select, textarea, button, .button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; width: 100%;
}
input[type=radio] { width: auto; }
button, .button { cursor: pointer; width: auto; text-decoration: none; display: inline-block; text-align: center; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; width: 100%; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { padding: 4px 10px; font-size: .85rem; }
.button.wa { background: #25d366; color: #062b14; border-color: #25d366; font-weight: 600; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.flash { padding: 10px 14px; border-radius: 10px; background: var(--red-bg); }
.flash.ok { background: var(--green-bg); color: var(--green); }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }
.tag.green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.tag.amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.tag.red { background: var(--red-bg); color: var(--danger); border-color: transparent; }

.people { margin: 0; padding-left: 1.6em; }
.people li { padding: 3px 0; }
.people li.me { font-weight: 700; }
.people-table { width: 100%; border-collapse: collapse; }
.people-table td { border-top: 1px solid var(--border); padding: 8px 4px; vertical-align: top; }
.people-table td:first-child { color: var(--muted); width: 2em; }
.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline; }

.mine-item { display: grid; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.mine-item:first-of-type { border-top: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form button { white-space: nowrap; }
.copy { display: flex; gap: 8px; }
.copy input { font-size: .8rem; }
.copy button { flex: none; white-space: nowrap; }
textarea.share { font-family: ui-monospace, monospace; font-size: .85rem; }
details summary { cursor: pointer; margin: 14px 0 10px; color: var(--accent); }

@media (max-width: 420px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row label:first-child { grid-column: 1 / -1; }
  .actions { white-space: normal; }
}

button.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: inherit; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.button.google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; font-weight: 600; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 14px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.inline-form { flex-wrap: wrap; }
.inline-form input { flex: 1 1 140px; }
.list form.inline { display: inline; margin-left: 8px; }
.buttons > .button, .buttons > button { flex: 1 1 auto; width: auto; }
.code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .12em; background: var(--bg); padding: 1px 6px; border-radius: 6px; }
.code-form label { margin-bottom: 6px; }
.code-form input { text-transform: uppercase; letter-spacing: .1em; font-family: ui-monospace, monospace; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
label.check input { width: auto; margin-top: 4px; }
.events li { padding: 0; }
.event-card { display: flex; gap: 12px; align-items: center; padding: 9px 0; color: var(--text); text-decoration: none; }
.event-card:hover b { color: var(--accent); }
.event-icon { font-size: 1.6rem; }
.event-main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.event-card .tag { flex: none; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
details.filters > summary { margin: 0; font-weight: 600; color: var(--text); }
details.filters[open] > summary { margin-bottom: 12px; }
.tag { white-space: nowrap; }
.people-table td:nth-child(3) { width: 1%; }
.actions form + form { margin-left: 4px; }
.page-title { margin: 4px 0 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--card); color: var(--text); text-decoration: none; white-space: nowrap; font-size: .9rem; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: grid; gap: 2px; }
.stat b { font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .8rem; }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.admin-row { display: grid; gap: 8px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-actions form { display: inline; }
.small-button { padding: 4px 10px; font-size: .85rem; }
.flash.warn { background: var(--amber-bg); color: var(--amber); }
.log li { font-size: .9rem; }
.foot { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; text-align: center; font-size: .9rem; }
.foot a { color: var(--muted); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
a.stat.link { text-decoration: none; color: var(--text); border-color: var(--amber); }
.reply { background: var(--green-bg); color: var(--green); padding: 8px 10px; border-radius: 8px; margin: 6px 0 0; }
.feedback-edit { gap: 8px; }
.flash { white-space: pre-line; }
.friends-form { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.friends-form h3 { margin: 0; font-size: 1rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.person .admin-actions { flex: none; }
h3 { font-size: .95rem; margin: 16px 0 6px; }
form[action="/friends/reset-link"] { margin-top: 10px; }
.setting { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.setting code { color: var(--muted); }
.sticky-save { position: sticky; bottom: 0; padding: 10px 0 14px; background: linear-gradient(transparent, var(--bg) 30%); }
button[disabled] { opacity: .5; cursor: not-allowed; }
.setting label > .tag { justify-self: start; }
.card p code { word-break: break-all; }
dt code { white-space: nowrap; }
/* Tabs */
.tabbar { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 5; padding: 8px 0; margin-bottom: 6px; background: var(--bg); }
/* iOS-style segmented control: grey track, white thumb that slides to the chosen tab (app.js adds .thumb). */
.seg { --seg-track: rgba(118, 118, 128, .12); --seg-thumb: #fff; --seg-line: rgba(60, 60, 67, .18);
  position: relative; display: flex; padding: 2px; border-radius: 9px; background: var(--seg-track);
  overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a { position: relative; z-index: 1; flex: 1 0 auto; padding: 6px 12px; border-radius: 7px; text-align: center;
  color: var(--text); text-decoration: none; white-space: nowrap; font-size: .9rem; font-weight: 500;
  -webkit-tap-highlight-color: transparent; transition: opacity .15s; }
.seg a:active { opacity: .6; }
.seg a.active { font-weight: 600; }
/* Without the sliding thumb (no JS yet) the chosen tab gets the white background itself. */
.seg:not(.has-thumb) a.active, .seg .thumb { background: var(--seg-thumb);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.seg .thumb { position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 0; border-radius: 7px; pointer-events: none; }
.seg.animate .thumb { transition: transform .28s cubic-bezier(.3, .7, .3, 1), width .28s cubic-bezier(.3, .7, .3, 1); }
/* Hairline dividers between tabs, hidden next to the chosen one. */
.seg a + a::before { content: ''; position: absolute; left: 0; top: 25%; bottom: 25%; width: 1px; background: var(--seg-line);
  transition: opacity .2s; }
.seg a.active::before, .seg a.active + a::before { opacity: 0; }
.seg a .count { opacity: .55; font-size: .8rem; margin-left: 4px; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .seg { --seg-track: rgba(118, 118, 128, .24); --seg-thumb: #636366; --seg-line: rgba(235, 235, 245, .16); }
}
@media (prefers-reduced-motion: reduce) { .seg.animate .thumb { transition: none; } }
.tabpanel > .card:last-child { margin-bottom: 14px; }
.page-head { margin: 4px 0 6px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.seg .badge { background: var(--amber); }
/* 2FA */
.steps { padding-left: 1.3em; display: grid; gap: 14px; }
.qr { width: 200px; max-width: 70vw; margin: 10px 0; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border); }
.qr svg { display: block; width: 100%; height: auto; }
.code.secret { font-size: .95rem; letter-spacing: .08em; word-break: normal; display: inline-block; line-height: 1.8; }
input.otp { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-codes code { display: block; text-align: center; font-size: 1rem; padding: 8px; background: var(--bg); border-radius: 8px; letter-spacing: .06em; }
.locked { background: var(--bg); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.locked p { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }
.card .tabbar { background: var(--card); }
.foot { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.donate h1 { margin-bottom: 8px; }
.donate-fps { display: grid; gap: 6px; margin: 14px 0; }
.donate-links { display: grid; gap: 10px; margin: 14px 0; }
.donate-btn { width: 100%; font-weight: 600; padding: 12px; }
.location-bar { display: grid; gap: 10px; }
.location-bar > span { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.location-bar form.inline-form select { flex: 1 1 160px; }
.location-bar p { margin: 0; }
.distance { color: var(--accent); font-weight: 600; }
.venue-position { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Skill level */
.level-fit { margin: 0; padding: .5rem .75rem; border-radius: 8px; font-size: .9rem; }
.level-fit.ok { background: #e8f6ec; color: #1d6b34; }
.level-fit.warn { background: #fff4e0; color: #8a5300; }
.level-guide { margin: .5rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; }
.level-guide dt { font-weight: 600; }
.level-guide dd { margin: 0; }
@media (prefers-color-scheme: dark) {
  .level-fit.ok { background: #16351f; color: #9be0ad; }
  .level-fit.warn { background: #3a2a10; color: #f3c27a; }
}

/* Install page */
.install h1 { display: flex; align-items: center; gap: 12px; }
.install-icon { border-radius: 12px; }
.steps { padding-left: 1.4em; margin: .5rem 0; }
.steps li { margin: .4rem 0; }
@media (display-mode: standalone) { .install-link { display: none; } }

/* Directions to the venue: one button, then a menu of maps apps */
.directions { position: relative; margin: 6px 0 0; }
.directions > summary { list-style: none; display: inline-block; text-align: center; cursor: pointer; }
.directions > summary::-webkit-details-marker { display: none; }
.maps-menu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); overflow: hidden; }
.maps-menu p { margin: 0; padding: 10px 14px 6px; text-align: center; }
.maps-menu a { display: block; padding: 13px 14px; text-align: center; text-decoration: none; font-size: 1.05rem;
  border-top: 1px solid var(--border); color: var(--accent); }
.maps-menu a:active { background: var(--bg); }

/* Profile photos */
.avatar { display: inline-block; flex: none; border-radius: 50%; object-fit: cover; vertical-align: middle; background: var(--border); }
.avatar.initial { width: var(--size); height: var(--size); line-height: var(--size); text-align: center; color: #fff;
  font-size: calc(var(--size) * .45); font-weight: 700; background: hsl(var(--hue) 45% 46%); }
.nav-me { display: inline-flex; align-items: center; gap: 6px; }
.with-avatar { display: flex; align-items: center; gap: 12px; }
.who { display: inline-flex; align-items: center; gap: 10px; }
.people li .avatar { margin-right: 4px; }
.avatar-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.avatar-actions label.button { cursor: pointer; margin: 0; width: auto; flex: none; }
.avatar-actions p { flex-basis: 100%; margin: 0; }
.avatar-edit.busy { opacity: .6; pointer-events: none; }

/* iOS-style chrome: translucent top bar and bottom tab bar */
:root { --top-h: 52px; --tabbar-h: 56px; --bar-bg: rgba(249, 249, 249, .82); --bar-line: rgba(0, 0, 0, .14); --tab-idle: #8e8e93; }
@media (prefers-color-scheme: dark) { :root { --bar-bg: rgba(29, 29, 31, .82); --bar-line: rgba(255, 255, 255, .14); --tab-idle: #8e8e93; } }
.top { position: sticky; top: 0; z-index: 30; padding-top: env(safe-area-inset-top); background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: .5px solid var(--bar-line); }
.top-inner { max-width: 640px; height: var(--top-h); margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 7px; }
.top nav { display: flex; align-items: center; gap: 12px; }
.bar-icon { font-size: 1.15rem; text-decoration: none; }
.nav-me { display: inline-flex; border-radius: 50%; }
/* Language: a tiny segmented control */
.langs { display: inline-flex; padding: 2px; border-radius: 8px; background: rgba(118, 118, 128, .12); font-size: .78rem; font-weight: 600; }
.langs > * { padding: 3px 9px; border-radius: 6px; text-decoration: none; color: var(--text); }
.langs b { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
@media (prefers-color-scheme: dark) { .langs { background: rgba(118, 118, 128, .24); } .langs b { background: #636366; } }

.tabbar-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom); background: var(--bar-bg); border-top: .5px solid var(--bar-line);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.tabbar-bottom a { flex: 1 1 0; max-width: 128px; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--tab-idle); text-decoration: none; font-size: .66rem; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.tabbar-bottom a.active { color: var(--accent); }
.tabbar-bottom a.active svg { stroke-width: 2.3; }
.tabbar-bottom a:active { opacity: .6; }
/* Keep the end of every page clear of the tab bar. */
body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
form.inline { display: inline; }

/* Site admin: a classic desktop website layout (no iOS bars) */
body.desktop { padding-bottom: 0; --top-h: 56px; }
body.desktop main { max-width: 1240px; padding: 20px 24px 48px; }
body.desktop .top { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 1px solid var(--border); }
body.desktop .top-inner { max-width: 1240px; padding: 0 24px; }
body.desktop .top nav { gap: 18px; font-size: .92rem; }
body.desktop .top nav a { color: var(--accent); text-decoration: none; }
body.desktop .brand .tag { font-size: .7rem; vertical-align: middle; }
body.desktop .me { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
body.desktop .foot { max-width: 1240px; }
.admin-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-side { position: sticky; top: calc(var(--top-h) + 20px); }
.admin-nav { display: grid; gap: 2px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .95rem; }
.admin-nav a:hover { background: var(--card); }
.admin-nav a.active { background: var(--green-bg); color: var(--green); font-weight: 600; }
.admin-main .page-title { margin: 0 0 16px; }
.admin-main .stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:hover { background: var(--bg); }
table.data .num { text-align: right; }
table.data .nowrap { white-space: nowrap; }
table.data .admin-actions { justify-content: flex-end; flex-wrap: nowrap; }
/* Desktop tabs: underlined, not the iOS segmented control */
body.desktop .tabbar { background: var(--bg); padding: 0; margin-bottom: 14px; }
body.desktop .seg { background: none; padding: 0; border-radius: 0; gap: 4px; border-bottom: 1px solid var(--border); }
body.desktop .seg .thumb { display: none; }
body.desktop .seg a { flex: none; border-radius: 0; padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); }
body.desktop .seg a.active, body.desktop .seg:not(.has-thumb) a.active { background: none; box-shadow: none; color: var(--accent); border-bottom-color: var(--accent); }
body.desktop .seg a + a::before { display: none; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; gap: 12px; }
  .admin-side { position: static; }
  .admin-nav { display: flex; overflow-x: auto; gap: 4px; }
  .admin-nav a { white-space: nowrap; }
  body.desktop main { padding: 16px; }
}
body.desktop .top nav > * { white-space: nowrap; }
table.data { min-width: 760px; }
@media (max-width: 860px) { .admin-shell { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  body.desktop .wide-only { display: none; }
  body.desktop .top-inner { padding: 0 12px; }
  body.desktop .top nav { gap: 12px; }
}
.level-filter { display: grid; gap: 4px; }
.level-filter .label { font-size: .95rem; }
.level-filter p { margin: 0; }
.my-levels { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.my-levels legend { font-weight: 600; margin-bottom: 4px; }
.levels-table input { width: 100%; margin: 2px 0; }
.levels-table td:nth-child(2) { width: 32%; }
pre.sample { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
ul.import-errors { padding-left: 1.4em; }
.venue-hint { margin-top: -6px; }
.sport-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sport-row .icon-input { width: 3.2em; text-align: center; font-size: 1.2rem; padding: 4px; }
.sport-row .sport-names { display: flex; gap: 6px; flex: 1 1 280px; }
.sport-row .sport-names input { flex: 1; min-width: 0; }
.sport-row .sort-input { width: 4.5em; }
.sport-row .check { margin: 0; }
.sports-table td { padding: 10px 6px; }
.sports-table tr.muted input { opacity: .6; }
.preset-list { display: flex; flex-wrap: wrap; gap: 8px; }
/* Proof of payment */
.proof-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.proof-upload label.button { margin: 0; width: auto; cursor: pointer; }
.proof-upload.busy { opacity: .6; pointer-events: none; }
.proof-thumb { display: inline-block; margin-top: 6px; }
.proof-thumb img { display: block; width: 48px; height: 48px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); }
.flash.amber-note { background: var(--amber-bg); color: var(--amber); }
.level-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: center; gap: 10px; margin: 0; }
.level-row select { margin: 0; }
.my-levels { gap: 8px; }
details h3 { font-size: .95rem; margin: 12px 0 4px; }
details.card.more > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.card.more[open] > summary { margin-bottom: 10px; }
/* Home: one compact top card, three-line game cards */
.top-card h1 { margin: 0 0 10px; }
.top-card .code-form { margin-top: 10px; }
.location-pick { display: flex; gap: 8px; align-items: center; }
.location-pick .inline-form { flex: 1; display: flex; gap: 6px; margin: 0; }
.location-pick select { flex: 1; min-width: 0; margin: 0; }
.location-pick button { margin: 0; white-space: nowrap; width: auto; }
.top-card .location-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.top-card .location-bar form { margin: 0; }
.one-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-main { min-width: 0; }
/* Organizer list: icon buttons on one line */
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 9px; font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.people-table td.actions { white-space: nowrap; width: 1%; }
.people-table td.pay { white-space: nowrap; }
.people-table .proof-thumb { margin: 0 0 0 4px; vertical-align: middle; }
.people-table .proof-thumb img { width: 40px; height: 40px; }
.actions form + form { margin-left: 3px; }
/* Admin on a wide screen: settings in two columns, level rows on one line */
body.desktop .settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); column-gap: 28px; }
body.desktop .settings-grid .setting:nth-child(2) { border-top: 0; }
.levels-table td { padding: 6px 4px; }
.levels-table td:nth-child(2), .levels-table td:nth-child(3) { width: 16%; }
.people-table .icon-btn, .people-table .icon-btn.primary { width: 34px; min-width: 34px; flex: none; margin: 0; }
.people-table td.name { max-width: 0; width: 100%; }
.people-table td.name .who { display: flex; min-width: 0; }
.people-table td.name .one-line { min-width: 0; line-height: 1.3; }
.people-table td { vertical-align: middle; }
.admin-search { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-search input { flex: 1 1 220px; margin: 0; }
.admin-search select, .admin-search button { flex: 0 0 auto; width: auto; margin: 0; }
table.data .admin-actions button, table.data .admin-actions .button { white-space: nowrap; }
/* Keep names readable next to the receipt and buttons on a phone */
.people-table td.name { max-width: none; width: auto; min-width: 6.5em; }
.people-table td.pay .tag { font-size: .72rem; padding: 1px 6px; }
.people-table .proof-thumb img { width: 34px; height: 34px; }
.people-table .icon-btn { width: 32px; min-width: 32px; height: 32px; }
.people-table td { padding: 8px 3px; }
@media (max-width: 420px) {
  .people-table td:first-child { display: none; }
}
.people-table td.name .one-line { white-space: normal; overflow-wrap: anywhere; }
/* Calendar */
.top-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.top-card-head h1 { margin: 0; }
.top-card-head .button { width: auto; margin: 0; white-space: nowrap; }
.cal-head h1 { margin: 0 0 8px; }
.cal-selected { margin: 0; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.week-nav .button { width: 40px; margin: 0; font-size: 1.2rem; }
.center { text-align: center; }
.cal-days { list-style: none; margin: 0; padding: 0; }
.cal-day { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.cal-day.today .cal-date { color: var(--accent); font-weight: 700; }
.cal-day.past { opacity: .6; }
.cal-date { font-size: .85rem; padding-top: 4px; }
.cal-events { display: grid; gap: 4px; min-width: 0; }
.cal-event { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px; background: var(--bg); color: var(--text); text-decoration: none; font-size: .88rem; min-width: 0; }
.cal-event.closed { opacity: .6; }
.cal-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8rem; }
.cal-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event .tag { font-size: .7rem; padding: 1px 6px; }
/* Wide screens: seven columns */
@media (min-width: 760px) {
  main:has(.cal-week) { max-width: 1100px; }
  .cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .cal-day { grid-template-columns: 1fr; border-top: 0; border-left: 1px solid var(--border); padding: 4px 6px; align-content: start; min-height: 160px; }
  .cal-day:first-child { border-left: 0; }
  .cal-date { text-align: center; padding: 0 0 4px; border-bottom: 1px solid var(--border); }
  .cal-event { display: grid; grid-template-columns: 1fr auto; row-gap: 2px; align-items: center; }
  .cal-time { grid-row: 1; grid-column: 1; }
  .cal-event .tag { grid-row: 1; grid-column: 2; justify-self: end; }
  .cal-title { grid-row: 2; grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; }
}
/* Level line in calendar chips, and ✔ / ⚠ fit marks */
.cal-event { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 6px; row-gap: 1px; }
.cal-level { grid-column: 2 / -1; font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fit { font-size: .8rem; font-weight: 700; }
.fit.ok { color: var(--green); }
.fit.warn { color: var(--amber); }
@media (min-width: 760px) {
  .cal-event { grid-template-columns: 1fr auto; }
  .cal-level { grid-row: 3; grid-column: 1 / -1; white-space: normal; }
}
.event-card .tags { display: grid; gap: 4px; justify-items: end; }
.event-card.closed { opacity: .65; }
/* Calendar on a phone: a date heading per day, then the same cards as the home page */
.cal-day { display: block; }
.cal-date { font-weight: 600; padding: 2px 0; }
.cal-none { font-weight: 400; margin-left: 6px; }
.cal-cards { margin: 0; }
.cal-cards li:first-child { border-top: 0; }
.cal-events { display: none; }
@media (min-width: 760px) {
  .cal-day { display: grid; }
  .cal-cards { display: none; }
  .cal-events { display: grid; }
  .cal-none { display: block; margin: 4px 0 0; }
}
@media (max-width: 759px) {
  .cal-day.empty { padding: 3px 0; }
  .cal-day.empty .cal-date { font-weight: 500; color: var(--muted); font-size: .85rem; }
  .cal-week .week-nav { margin-bottom: 4px; }
  .cal-week > p.center { margin: 0 0 6px; }
  .cal-cards .event-card { padding: 6px 0; }
}
.sport-chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.sport-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--border); background: var(--card); color: var(--text); text-decoration: none; font-size: .85rem; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* Friends on a game: small overlapping photos before their names. */
.friend-faces { display: inline-flex; vertical-align: middle; margin-right: 6px; }
.friend-faces .avatar { border: 2px solid var(--card, #fff); border-radius: 50%; }
.friend-faces .avatar + .avatar { margin-left: -6px; }
.friends-going { margin: 0 0 10px; }

/* "Copy a past game" picker above the new-game form. */
.copy-picker { margin: 0 0 12px; }
.copy-picker select { width: 100%; }
.sport-row .per-court { display: inline-flex; align-items: center; gap: 4px; margin: 0; white-space: nowrap; }
.courts-now { margin: -4px 0 10px; }

/* Friend picker: a dropdown with a search box and a scrolling list. */
.picker { position: relative; margin: 10px 0; }
.picker > summary { list-style: none; margin: 0; padding: 10px 36px 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--muted); position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker > summary::-webkit-details-marker { display: none; }
.picker > summary::after { content: '▾'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.picker[open] > summary::after { content: '▴'; }
.picker.picked > summary { color: var(--text); font-weight: 600; }
.picker-panel { margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.picker-panel input[type=search] { width: 100%; margin: 0 0 6px; }
.picker-list { max-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; margin: 0; }
.picker-item[hidden] { display: none; }
.picker-item:hover, .picker-item:has(input:checked) { background: var(--bg); }
.picker-item input { width: auto; margin: 0; flex: none; }
.picker-list [data-picker-none] { margin: 8px 6px; }

/* Home: choose a sport first. */
.sport-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.sport-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 8px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); color: var(--text); text-decoration: none; text-align: center; }
.sport-tile:hover, .sport-tile:focus-visible { border-color: var(--accent); }
.sport-tile:active { background: var(--bg); }
.sport-tile-icon { font-size: 2rem; line-height: 1.2; }

/* Top bar: log in / sign up, or log out. */
.top .bar-link { background: none; border: 0; padding: 0; color: var(--accent); font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.top .bar-btn { padding: 5px 12px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.top .bar-link.active { text-decoration: underline; }
@media (max-width: 360px) { .top nav { gap: 8px; } .top .brand { font-size: .95rem; } }
