/* Pretty Sure: layout and components. All colours, fonts and outline sizes come from the
 * theme file (theme-sticker.css) as CSS variables. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.6px, transparent 1.6px);
  background-size: 18px 18px;
  color: var(--ink);
  font: 500 16px/1.45 var(--font);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app { max-width: 520px; margin: 0 auto; padding: 14px 16px 32px; }
.stack { display: grid; gap: 14px; }

/* header */
.top { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px; }
.brand {
  display: flex; align-items: center; gap: 8px;
  background: var(--yellow); color: var(--on-bright);
  border: var(--bw) solid var(--border); border-radius: 999px;
  padding: 6px 14px; box-shadow: 3px 3px 0 var(--shadow-c);
}
.brand h1 { font-size: 1rem; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.theme { margin-left: auto; min-height: 44px; padding: 0 8px; }
.back { margin-left: auto; min-height: 44px; padding: 0 8px; display: inline-flex; align-items: center; }
.back + .theme { margin-left: 0; }
.back, .theme { white-space: nowrap; }
/* Narrow phones: links share the first row, the Pretty Sure badge gets its own row below. */
@media (max-width: 400px) {
  .top { flex-wrap: wrap; row-gap: 0; }
  .back { order: 1; margin-left: 0; }
  .theme { order: 2; margin-left: auto !important; }
  .brand { order: 3; flex: 0 0 100%; max-width: max-content; }
}

/* level chooser (Kid / Teen / Adult) */
.levels { margin: 0 0 14px; }
.level-labels { display: grid; grid-template-columns: repeat(3, 1fr); }
.lv {
  appearance: none; min-height: 44px; padding: 0; border: 0; background: transparent;
  color: var(--muted, var(--ink)); font: 800 0.95rem var(--font); cursor: pointer;
}
.lv.on { color: var(--ink); text-decoration: underline 3px var(--pink); text-underline-offset: 5px; }
/* thumb centres line up with the label columns: 1/6, 1/2, 5/6 of the width */
.level-slider {
  display: block; box-sizing: border-box; height: 44px; margin: 0 0 0 calc(100% / 6 - 22px);
  width: calc(100% * 2 / 3 + 44px);
  background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
}
.level-slider::-webkit-slider-runnable-track {
  height: 12px; border-radius: 999px; border: var(--bw) solid var(--border); background: var(--card);
}
.level-slider::-moz-range-track {
  height: 12px; box-sizing: border-box; border-radius: 999px; border: var(--bw) solid var(--border); background: var(--card);
}
.level-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 44px; height: 44px; margin-top: -19px;
  border-radius: 50%; background: var(--pink); border: var(--bw) solid var(--on-bright); box-shadow: 2px 2px 0 var(--on-bright);
}
.level-slider::-moz-range-thumb {
  box-sizing: border-box; width: 44px; height: 44px;
  border-radius: 50%; background: var(--pink); border: var(--bw) solid var(--on-bright); box-shadow: 2px 2px 0 var(--on-bright);
}
.level-slider:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 999px; }

.card {
  background: var(--card);
  border: var(--bw) solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--hs) var(--hs) 0 var(--shadow-c);
  padding: 18px;
}

h2 { font-size: 1.5rem; line-height: 1.12; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 12px; text-wrap: pretty; }
.sect { font-size: 1.1rem; font-weight: 800; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.eyebrow { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mascot { display: inline-block; line-height: 0; }
.intro-mascot { float: right; margin: -6px -4px 6px 10px; }
.intro-mascot svg { width: 100px; height: auto; }
.rules { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-weight: 500; }
.rules li { margin-bottom: 6px; }

/* buttons */
.btn {
  appearance: none;
  border: var(--bw) solid var(--border);
  background: var(--card);
  color: var(--ink);
  font: 800 1.05rem var(--font);
  min-height: 54px;
  padding: 0 20px;
  border-radius: 18px;
  box-shadow: 4px 4px 0 var(--shadow-c);
  cursor: pointer;
  width: 100%;
}
.btn.primary { background: var(--blue); color: var(--on-blue); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow-c); }
.btn:focus-visible, .link:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 3px;
}
.link { background: none; border: none; padding: 4px; color: var(--ink); font: 700 0.9rem var(--font); text-decoration: underline; cursor: pointer; }
.foot .link { color: var(--muted); }
a { color: var(--ink); font-weight: 700; }

/* progress */
.progress { height: 18px; background: var(--card); border: var(--bw) solid var(--border); border-radius: 99px; overflow: hidden; box-shadow: 3px 3px 0 var(--shadow-c); }
.progress-bar { height: 100%; width: 0; background: var(--pink); border-right: var(--bw) solid var(--border); transition: width 0.3s ease; }

/* question card */
.qcard { padding: 0; overflow: hidden; }
.banner { height: 96px; border-bottom: var(--bw) solid var(--border); background: var(--yellow); }
.banner-art, .banner-art svg { display: block; height: 96px; width: 100%; }
.qbody { padding: 14px 18px 8px; }
.qbody h2 { font-size: 1.6rem; margin: 0 0 6px; }

/* the form panel */
.panel { background: var(--yellow); color: var(--on-bright); }
.sentence { font-weight: 700; margin-bottom: 8px; }
.inputs { display: flex; align-items: center; gap: 8px; }
.field { flex: 1; min-width: 0; }
.and { font-weight: 700; }
input[type="text"] {
  width: 100%;
  min-height: 54px;
  font: 800 1.45rem var(--font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 8px;
  border: var(--bw) solid var(--on-bright);
  border-radius: 14px;
  background: var(--field-bg);
  color: var(--on-bright);
}
input[type="text"]::placeholder { color: #6A6A80; font-weight: 600; }
input[type="text"]:disabled { opacity: 1; background: #F3EBD0; -webkit-text-fill-color: var(--on-bright); }
.unit { margin: 6px 0 0; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.hint { margin: 2px 0 8px; font-size: 0.85rem; font-weight: 600; }
.helper { font-size: 0.92rem; font-weight: 700; min-height: 1.4em; margin-bottom: 4px; }
.error { color: var(--bad-ink); font-size: 0.92rem; font-weight: 700; min-height: 1.4em; margin-bottom: 8px; }
.panel .error { color: #8A0F32; }

/* drag-range input: two native range inputs layered over one track, so keyboards and screen readers work */
.ranger { --lo: 0; --hi: 1; --tw: 44px; position: relative; height: 56px; margin-top: 8px; }
.ranger-track { position: absolute; left: calc(var(--tw) / 2); right: calc(var(--tw) / 2); top: 25px; height: 6px; background: var(--on-bright); border-radius: 3px; }
.ranger-ticks { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; top: 19px; width: 3px; height: 18px; margin-left: -1.5px; background: var(--on-bright); left: calc(var(--tw) / 2 + (100% - var(--tw)) * var(--f)); }
.ranger-band {
  position: absolute; top: 9px; height: 38px;
  left: calc(var(--tw) / 2 + (100% - var(--tw)) * var(--lo));
  width: calc((100% - var(--tw)) * (var(--hi) - var(--lo)));
  background: var(--pink); border: var(--bw) solid var(--on-bright); border-radius: 12px;
}
.tick.minor { top: 22px; height: 12px; width: 2px; margin-left: -1px; }
.ticklabels { position: relative; height: 20px; margin-bottom: 4px; font-size: 0.75rem; font-weight: 800; }
.tl.minor { font-weight: 600; color: var(--muted); }
.tl { position: absolute; top: 0; transform: translateX(-50%); left: calc(22px + (100% - 44px) * var(--f)); white-space: nowrap; }
.slider {
  position: absolute; left: 0; top: 0; width: 100%; height: 56px; margin: 0;
  background: transparent; pointer-events: none;
  -webkit-appearance: none; appearance: none;
}
.slider::-webkit-slider-runnable-track { background: transparent; height: 56px; }
.slider::-moz-range-track { background: transparent; height: 56px; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: grab;
  width: 44px; height: 44px; margin-top: 6px; border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='18' viewBox='0 0 14 18'%3E%3Cpath d='M4 2V16M10 2V16' stroke='%231A1A2E' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px 18px no-repeat;
  border: var(--bw) solid var(--on-bright); box-shadow: 2px 2px 0 var(--on-bright);
}
.slider::-moz-range-thumb {
  pointer-events: auto; cursor: grab; box-sizing: border-box;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='18' viewBox='0 0 14 18'%3E%3Cpath d='M4 2V16M10 2V16' stroke='%231A1A2E' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px 18px no-repeat;
  border: var(--bw) solid var(--on-bright); box-shadow: 2px 2px 0 var(--on-bright);
}
.slider:focus-visible { outline: none; }
.slider:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--blue); outline-offset: 3px; }
.slider:focus-visible::-moz-range-thumb { outline: 3px solid var(--blue); outline-offset: 3px; }
.slider:disabled::-webkit-slider-thumb { cursor: default; }
.slider:disabled::-moz-range-thumb { cursor: default; }

/* after locking in, the form collapses to what was chosen and the feedback card takes over */
.panel.locked .hint, .panel.locked .helper, .panel.locked .error { display: none; }

/* feedback after locking in */
.fb-title { font-weight: 800; font-size: 1.1rem; margin-bottom: 4px; }
.fb-title.good { color: var(--good-ink); }
.fb-title.bad { color: var(--bad-ink); }
.fb-answer { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.fb-chart { margin-bottom: 10px; }
.fb-why { font-weight: 700; }
.fb-points { font-weight: 800; margin-bottom: 8px; }

/* final */
.verdict-card { background: var(--pink); color: var(--on-bright); text-align: center; }
.verdict-card .eyebrow { color: var(--on-bright); }
.verdict-card h2 { font-size: 2.3rem; margin: 2px 0 8px; }
.verdict-card p { font-weight: 700; margin: 0 auto; max-width: 30ch; text-wrap: balance; }
.mascots { min-height: 152px; display: flex; justify-content: center; }
.squares { display: flex; gap: 8px; justify-content: center; margin: 4px 0 0; }
.tile {
  width: 48px; height: 48px; display: grid; place-items: center;
  border: var(--bw) solid var(--border); border-radius: 12px;
  font-size: 1.4rem; font-weight: 900; line-height: 1;
}
.tile.hit { background: var(--mint); color: var(--on-bright); }
.tile.hit::before { content: "\2713"; }
.tile.miss { background: var(--miss-bg); color: var(--miss-ink); }
.tile.miss::before { content: "\2715"; }
.score { font-size: 1.15rem; font-weight: 800; text-align: center; margin: 0; }
.rows { display: grid; gap: 16px; margin: 0 0 8px; }
.row-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 0.95rem; margin-bottom: 6px; }
.row-pts { color: var(--muted); font-weight: 700; white-space: nowrap; }
.track { position: relative; height: 18px; background: var(--track); border: 2px solid var(--border); border-radius: 99px; }
.range { position: absolute; top: -2px; bottom: -2px; border: 2px solid var(--border); border-radius: 99px; }
.range.hit { background: var(--mint); }
.range.miss { background: var(--pink); }
.truth { position: absolute; top: -8px; bottom: -8px; width: 5px; margin-left: -2.5px; background: var(--ink); border: 1px solid var(--card); border-radius: 3px; }
.row-cap { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-top: 6px; }
.legend { margin-top: 4px; }
.actions { display: grid; gap: 12px; margin-top: 4px; }
.toast { min-height: 1.4em; margin: 4px 0 0; text-align: center; font-weight: 800; font-size: 0.92rem; }

.foot { text-align: center; margin-top: 22px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
  .btn:active { transform: none; }
}
