/* Tap Tally: a red enamel hand counter with rolling digit wheels */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #E6E9F0;
  --card: #FFFFFF;
  --ink: #1D2230;
  --muted: #5D6474;
  --line: #CDD2DC;
  --red: #C8302E;
  --red-dark: #9C1F1E;
  --steel: #B8BFCB;
  --me: #FCE7A8;
  --display: "Young Serif", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171E; --card: #1E222C; --ink: #E6E9F0; --muted: #9AA1B0; --line: #2E3442; --me: #4A3F1C; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); line-height: 1.45; min-height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

.wrap { max-width: 520px; margin: 0 auto; padding: 0 14px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 0; }
.back { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.icon-btn:hover { background: var(--card); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4px 0 12px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; margin: 0; line-height: 1; }
.sub { margin: 0; color: var(--muted); font-size: 0.9rem; text-align: right; }

/* ---------- the counter ---------- */
.counter { background: radial-gradient(120% 90% at 30% 10%, #E04A45 0%, var(--red) 45%, var(--red-dark) 100%); border-radius: 38px; padding: 26px 22px 28px; display: flex; flex-direction: column; align-items: center; box-shadow: inset 0 2px 0 rgba(255,255,255,.25), inset 0 -6px 0 rgba(0,0,0,.18), 0 18px 34px -22px rgba(60, 10, 10, .7); }
.window { display: flex; gap: 3px; background: #11141C; border-radius: 12px; padding: 8px 10px; box-shadow: inset 0 3px 8px rgba(0,0,0,.6), 0 0 0 4px var(--steel); }
.wheel { width: 0.72em; height: 1.15em; overflow: hidden; font: 700 2.7rem/1.15 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #F4F5F7; background: linear-gradient(#0B0D12, #2A2F3B 50%, #0B0D12); border-radius: 4px; }
.wheel span { display: block; transition: transform .12s ease-out; }
.wheel span i { display: block; font-style: normal; height: 1.15em; text-align: center; }
.label { margin: 8px 0 18px; color: #FBE3E1; font-size: 0.9rem; }
.plunger { width: 168px; height: 168px; border-radius: 50%; border: 0; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle at 38% 30%, #FFFFFF 0%, #DDE1E8 35%, #A9B0BD 100%);
  box-shadow: 0 10px 0 #7D8492, 0 14px 22px rgba(0,0,0,.35), inset 0 -4px 10px rgba(0,0,0,.15);
  font-family: var(--display); font-size: 1.9rem; color: #3A404D; transition: transform .05s, box-shadow .05s; }
.plunger.down, .plunger:active { transform: translateY(8px); box-shadow: 0 2px 0 #7D8492, 0 4px 8px rgba(0,0,0,.3), inset 0 -4px 10px rgba(0,0,0,.15); }

.nums { display: flex; justify-content: space-between; margin: 16px 2px 0; gap: 10px; }
.nums p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.nums p:last-child { text-align: right; }
.nums b { display: block; color: var(--ink); font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fine { color: var(--muted); font-size: 0.82rem; text-align: center; margin: 8px 0 0; min-height: 1.2em; }

/* ---------- leaderboards ---------- */
.card { background: var(--card); border-radius: 20px; padding: 14px 14px 12px; box-shadow: 0 1px 0 var(--line); }
.board { margin-top: 16px; }
.tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.tab { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 700; cursor: pointer; color: var(--muted); }
.tab.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.rows { list-style: none; margin: 10px 0 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 2.2em 1fr auto; align-items: baseline; padding: 7px 8px; border-radius: 9px; font-variant-numeric: tabular-nums; }
.rows li:nth-child(odd) { background: color-mix(in srgb, var(--bg) 45%, transparent); }
.rows li.me { background: var(--me); font-weight: 700; }
.rows .rk { color: var(--muted); }
.rows .ct { font-weight: 700; }
.rows li.gap { display: block; text-align: center; color: var(--muted); padding: 2px; background: none; }

.go { width: 100%; border: 0; border-radius: 16px; padding: 14px; background: var(--ink); color: var(--card); font-weight: 800; font-size: 1.1rem; cursor: pointer; }

/* ads */
.ad-inline { margin-top: 26px; }
.ad-slot { display: block; margin: 0 auto; overflow: hidden; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-slot.placeholder { border: 1.5px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.ad-slot.placeholder::before { content: "Ad space " attr(data-size); }
.ad-slot.collapsed { min-height: 0; }
.ad-slot ins[data-ad-status="unfilled"] { display: none !important; }
.ad-label { font-size: 11px; color: var(--muted); text-align: center; margin: 0 0 4px; }

.foot { display: flex; justify-content: center; gap: 22px; padding: 26px 0 40px; color: var(--muted); font-size: 0.9rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dlg { border: 0; border-radius: 16px; padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(10, 12, 18, .5); }
.dlg h2 { font-family: var(--display); font-weight: 400; margin: 0 0 10px; font-size: 1.6rem; }
.dlg p { color: var(--muted); }
.dlg .x { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); width: 40px; height: 40px; }
@media (prefers-reduced-motion: reduce) { .wheel span, .plunger, .toast { transition: none; } }
@media (max-width: 360px) { .wheel { font-size: 2.2rem; } .plunger { width: 140px; height: 140px; } }
