/* Gauge: a ruler, a marker, a crowd */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #E8F3EE;
  --card: #FFFFFF;
  --ink: #132620;
  --muted: #557068;
  --line: #CFE0D8;
  --track: #DDEBE4;
  --band: #B4D6C7;
  --mark: #FF6B35;
  --good: #1E9E63;
  --ok: #C98F00;
  --bad: #D9483B;
  --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: #0F1A16; --card: #172520; --ink: #E8F3EE; --muted: #95ADA4; --line: #2A3B35; --track: #22332D; --band: #36574A; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); line-height: 1.45; min-height: 100vh; }
a { color: inherit; }
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 560px; 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; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; 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.95rem; }

.card { background: var(--card); border-radius: 22px; padding: 22px 18px; box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(19, 38, 32, .5); }
.card + .card { margin-top: 14px; }
.kicker { margin: 0; color: var(--muted); font-weight: 600; }
.go { width: 100%; border: 0; border-radius: 16px; padding: 15px; background: var(--ink); color: var(--card); font-weight: 800; font-size: 1.15rem; cursor: pointer; }
.go:disabled { opacity: .35; cursor: default; }
.go.alt { background: var(--mark); color: #fff; }
.fine { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 10px 0 0; }
.detail { margin: 0 0 14px; color: var(--muted); }

/* the scale: a tall hit area around a thin track */
.scale { position: relative; height: 92px; touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; border-radius: 12px; }
.scale.small { height: 54px; }
.track { position: absolute; left: 14px; right: 14px; bottom: 22px; height: 10px; border-radius: 5px; background: var(--track); }
.scale.small .track { bottom: 22px; }
.track::before, .track::after { content: ""; position: absolute; top: -5px; width: 2px; height: 20px; background: var(--line); }
.track::before { left: -1px; }
.track::after { right: -1px; }
.thumb { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 3px var(--line); transition: background-color .15s, box-shadow .15s; }
.scale.set .thumb { background: var(--mark); box-shadow: 0 2px 8px rgba(255, 107, 53, .45); }
.scale:focus-visible { outline-offset: 0; }
.ticks { position: absolute; left: 14px; right: 14px; top: 0; bottom: 40px; pointer-events: none; }
.tick { position: absolute; bottom: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.tick span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.tick i { width: 2px; height: 10px; background: var(--muted); opacity: .6; margin-top: 2px; }
.tick.up i { height: 26px; }
.ends { display: flex; justify-content: space-between; font-family: var(--display); font-size: 1.15rem; margin: -6px 2px 16px; }

.play .count { margin: 0; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.play .word { font-family: var(--display); font-size: clamp(2.4rem, 11vw, 3.4rem); line-height: 1.05; margin: 6px 0 2px; text-align: center; overflow-wrap: anywhere; }
.play .from { margin: 0 0 4px; min-height: 1.3em; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* results */
.big { font-family: var(--display); font-size: 3.2rem; line-height: 1; margin: 6px 0 6px; }
.big small { font-size: 1.1rem; color: var(--muted); margin-left: 2px; }
.grade { display: inline-block; vertical-align: middle; font-family: var(--ui); font-weight: 850; font-size: 1.1rem; padding: 3px 10px; border-radius: 8px; background: var(--ink); color: var(--card); margin-left: 6px; }
.rows-ends { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 0 44px 0 92px; }
.rows { list-style: none; padding: 0; margin: 4px 0 8px; }
.rows li { display: grid; grid-template-columns: 84px 1fr 36px; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .w { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .w small { display: block; font-weight: 500; color: var(--muted); font-size: 0.7rem; }
.mini { position: relative; height: 20px; }
.mini::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 4px; border-radius: 2px; background: var(--track); }
.mini .band { position: absolute; top: 5px; height: 10px; border-radius: 5px; background: var(--band); }
.mini .crowd { position: absolute; top: 1px; width: 3px; height: 18px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.mini .you { position: absolute; top: 3px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--mark); box-shadow: 0 0 0 2px var(--card); }
.rows .pts { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.pts.good { color: var(--good); }
.pts.ok { color: var(--ok); }
.pts.bad { color: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; color: var(--muted); font-size: 0.8rem; margin: 0 0 14px; }
.legend i { display: inline-block; vertical-align: -2px; margin-right: 5px; }
.lg-you { width: 11px; height: 11px; border-radius: 50%; background: var(--mark); }
.lg-crowd { width: 3px; height: 13px; border-radius: 2px; background: var(--ink); }
.lg-band { width: 18px; height: 9px; border-radius: 5px; background: var(--band); }

/* suggestion */
.next-scale { font-family: var(--display); font-size: 1.7rem; line-height: 1.15; margin: 2px 0 8px; }
#sug-word { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 1.1rem; }
#sug-word:focus { outline: none; border-color: var(--mark); }
.err { color: var(--bad); font-size: 0.85rem; min-height: 1.3em; margin: 4px 2px 0; }

/* 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(8, 18, 14, .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; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; background: var(--bg); border-radius: 10px; padding: 10px; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (max-width: 380px) {
  .rows li { grid-template-columns: 70px 1fr 32px; }
  .rows-ends { padding: 0 40px 0 78px; }
}
.mini .in { animation: pop-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.mini .you.in { animation-name: you-in; }
@keyframes pop-in { from { opacity: 0; transform: scaleY(.2); } }
@keyframes you-in { from { opacity: 0; transform: scale(.4); } }
@media (prefers-reduced-motion: reduce) { .thumb, .toast { transition: none; } .mini .in { animation: none; } }
