@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/Inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/Inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/Inter-700.woff2") format("woff2"); }

:root {
  --bg: #f3f4f8; --surface: #ffffff; --fg: #1c1f2b; --muted: #5d6275; --line: #e1e3ec; --accent: #3f6af2;
  --accent-fg: #ffffff; --coins: #9a6d00; --good: #1a7f46; --bad: #b3261e; --warn: #a35a00; --soft: #eef1fb;
  --star: #e3a008; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c; --surface: #1b1e29; --fg: #eef0f7; --muted: #a3a8bb; --line: #2c3040; --accent: #7d9cff;
    --accent-fg: #0e1220; --coins: #f0bf3a; --good: #4cc884; --bad: #ff8a80; --warn: #f0a24a; --soft: #232838;
    --star: #f5c542; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.5 "Inter", system-ui, -apple-system, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 0.85rem; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top h1 { font-size: 1.25rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { font-size: 2rem; line-height: 1; border: 0; background: none; padding: 0 8px 4px 0; cursor: pointer; color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 48px; display: grid; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--soft); border-radius: 12px; padding: 10px; min-width: 0; }
.stat b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 0.75rem; color: var(--muted); display: block; line-height: 1.3; }
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.coins { color: var(--coins); font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: 0.8rem; padding: 2px 9px; border-radius: 999px; }
.tag { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.approved { color: var(--good); }
.tag.returned { color: var(--bad); }
.tag.pending { color: var(--warn); }

button.primary, button.secondary, button.ghost, button.danger {
  border-radius: 12px; padding: 11px 16px; font-weight: 600; cursor: pointer; border: 1px solid transparent; min-height: 44px;
}
button.primary { background: var(--accent); color: var(--accent-fg); }
button.secondary { background: var(--soft); border-color: var(--line); }
button.ghost { background: none; color: var(--accent); padding: 8px 10px; min-height: 0; }
button.danger { background: none; color: var(--bad); border-color: var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label.field { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; color: var(--fg);
}
textarea { min-height: 70px; resize: vertical; }
form { display: grid; gap: 12px; }
.error { color: var(--bad); font-size: 0.9rem; }

.tabs { display: flex; gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 8px; font-size: 0.92rem; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { display: grid; gap: 6px; }
.photo button { padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--soft); cursor: zoom-in; aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .gone { aspect-ratio: 4 / 3; display: grid; place-items: center; border-radius: 12px; background: var(--soft); color: var(--muted); font-size: 0.8rem; text-align: center; padding: 8px; }
.photo p { font-size: 0.9rem; }

.stars { display: flex; gap: 2px; }
.stars button { border: 0; background: none; font-size: 1.9rem; line-height: 1; padding: 2px 4px; cursor: pointer; color: var(--line); min-width: 44px; min-height: 44px; }
.stars button[aria-checked="true"] { color: var(--star); }
.rating { display: grid; gap: 2px; }
.rating > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.ledger { display: grid; }
.ledger div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.ledger div:last-child { border-bottom: 0; }
.plus { color: var(--good); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.minus { color: var(--bad); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal span { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 0.75rem; background: var(--soft); color: var(--muted); }
.cal .h { background: none; font-weight: 600; aspect-ratio: auto; }
.cal .ok { background: var(--good); color: #fff; }
.cal .freeze { background: #4aa3df; color: #fff; }
.cal .miss { background: color-mix(in srgb, var(--bad) 25%, var(--soft)); color: var(--fg); }
.cal .off { background: none; border: 1px dashed var(--line); }
.cal .pending { background: color-mix(in srgb, var(--warn) 30%, var(--soft)); color: var(--fg); }
.cal .today { outline: 2px solid var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; }

.code { font: 700 2rem/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; text-align: center; padding: 14px; background: var(--soft); border-radius: 12px; user-select: all; }
pre { background: var(--soft); padding: 10px 12px; border-radius: 10px; overflow-x: auto; font-size: 0.85rem; margin: 0; }

.viewer { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.9); display: grid; place-items: center; padding: 16px; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer button { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; font-size: 1rem; background: rgb(255 255 255 / 0.15); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 30; max-width: calc(100% - 32px); }
.login { max-width: 400px; width: 100%; margin: 8vh auto 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
@media (prefers-reduced-motion: no-preference) { .card { transition: border-color 0.15s; } }

label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.week { display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.week.games { grid-template-columns: minmax(84px, auto) repeat(2, minmax(0, 1fr)); }
.week .hours { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 0 0 8px 32px; }
.week .hours input { flex: 1; }
.week .h { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.week input[type=number], .week input[type=time] { padding: 9px 6px; min-width: 0; text-align: center; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=time] { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; color: var(--fg); }
fieldset.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.days legend { padding: 0; margin-bottom: 6px; }
fieldset.days label { position: relative; }
fieldset.days input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
fieldset.days span { display: inline-block; min-width: 44px; padding: 8px 6px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); font-size: 0.85rem; font-weight: 600; color: var(--muted); }
fieldset.days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
fieldset.days input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
