/* Heaven Halo camera sizer. Light only, to match the shop. */
:root {
  --bg: #FBFAF6;
  --ink: #2E2B28;
  --body: #4A453E;
  --mute: #6A645B;
  --gold: #B68A2E;
  --gold-deep: #80601E;
  --gold-soft: #F6EFDD;
  --gold-fill: #E8CA7E;
  --line: #E9E1CF;
  --warn: #8A3B12;
  --live: #FFD778;
  --pfs: clamp(17px, 1.0625rem, 22px);
  --plh: 1.25;
  --prows: 3;
  color-scheme: light;
  /* One screen: type and spacing follow the visible height, so nothing needs a scroll. dvh where supported. */
  --vh: 1vh;
  --fs: clamp(14px, calc(var(--vh) * 2.2), 17px);
  --fs-sm: clamp(13px, calc(var(--vh) * 1.9), 15px);
  --h1: clamp(22px, min(calc(var(--vh) * 4.2), 8.6vw), 34px);
  --h2: clamp(17px, min(calc(var(--vh) * 2.9), 5.4vw), 20px);
  --gap: clamp(6px, calc(var(--vh) * 1.5), 14px);
  --btn: clamp(46px, calc(var(--vh) * 7.2), 56px);
  --pic: clamp(44px, calc(var(--vh) * 11), 96px);
}
@supports (height: 1dvh) { :root { --vh: 1dvh; } }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font: 400 var(--fs)/1.42 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.defs { position: absolute; }

/* The page itself never scrolls. #app is exactly the visible screen; a screen scrolls inside itself only as a last resort. */
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
@supports (-webkit-touch-callout: none) and (not (height: 1dvh)) { #app { height: -webkit-fill-available; } }
.screen { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 520px; max-height: 940px; margin: auto; padding: max(8px, env(safe-area-inset-top)) clamp(14px, 4.5vw, 20px) max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
/* Spacers rather than auto margins: they hold the content in place whichever children are hidden. */
.screen:not(.flow)::before, .step-body::before { content: ""; flex: 1 1 0; }
.screen:not(.flow)::after, .step-body::after { content: ""; flex: 2 1 0; }
.center { align-items: center; text-align: center; gap: var(--gap); }
.center .eyebrow, .center h1, .center .lead { margin: 0; }
.back { align-self: flex-start; color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); text-decoration: none; font-weight: 600; padding: 10px 0; min-height: 44px; display: inline-flex; align-items: center; }
.eyebrow { margin: 0 0 2px; color: var(--gold-deep); font-weight: 700; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
h1 { font: 300 var(--h1)/1.14 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; margin: 0 0 var(--gap); color: var(--gold-deep); }
h1:focus { outline: none; }
h2 { font: 400 var(--h2)/1.3 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; margin: var(--gap) 0 6px; color: var(--ink); }
p { margin: 0 0 var(--gap); }
.lead { font-size: var(--fs); color: var(--body); }
.preview { background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; font-size: var(--fs-sm); color: var(--gold-deep); font-weight: 600; }

/* Setup diagram: card, then hand, then phone above, on a loop. */
#setup { margin: 0; }
#setup svg { display: block; width: 100%; height: calc(var(--vh) * 22); max-height: 240px; }
.s-table { fill: #F1E9D8; stroke: #E2D7BF; stroke-width: 6; }
.s-card rect { fill: var(--gold-deep); }
.s-card .s-stripe { fill: #5F4714; }
.s-hand-f { fill: #fff; }
.s-hand-l { fill: none; stroke: var(--gold-deep); stroke-width: 9; }
.s-gold { fill: var(--gold-fill); }
.s-ph-body { fill: rgba(46, 43, 40, .88); }
.s-ph-screen { fill: rgba(246, 239, 221, .22); stroke: rgba(255, 255, 255, .45); stroke-width: 5; }
.s-ph-lens { fill: #15130F; stroke: var(--gold-fill); stroke-width: 8; }
.s-frust path { fill: none; stroke: var(--gold); stroke-width: 2; stroke-dasharray: 3 6; }
.s-card { animation: s-card 7s ease-out infinite; }
.s-hand { animation: s-hand 7s ease-out infinite; }
.s-phone { animation: s-phone 7s ease-out infinite; }
.s-frust { animation: s-frust 7s linear infinite; }
@keyframes s-card { 0% { opacity: 0; transform: translateY(-110px); } 10%, 88% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes s-hand { 0%, 16% { opacity: 0; transform: translateY(190px); } 30%, 88% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes s-phone { 0%, 38% { opacity: 0; transform: translateY(-70px); } 54%, 88% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes s-frust { 0%, 52% { opacity: 0; } 62%, 88% { opacity: 1; } 96%, 100% { opacity: 0; } }
@supports selector(:has(*)) {
  #intro:has(#hRight:checked) .s-flip { transform: translate(900px, 0) scale(-1, 1); }
}
.tips { margin: var(--gap) 0 0; padding: 0; list-style: none; color: var(--body); font-size: var(--fs-sm); }
.tips li { padding: 4px 0 4px 20px; position: relative; }
.tips li::before { content: ""; position: absolute; left: 2px; top: .75em; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* Hand first, no default: choosing a hand reveals the finger picture. */
.hands { display: flex; gap: 10px; }
.hands label { flex: 1; min-width: 0; position: relative; cursor: pointer; }
.hands input, .fingers input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hand-card { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 0; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; }
.hand-card svg { height: var(--pic); width: auto; fill: #F4EEDF; }
.ic-line { fill: none; stroke: var(--gold-deep); stroke-width: 14; }
.hand-card b { font: 500 var(--fs)/1.2 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--ink); }
.hands input:checked + .hand-card { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.hands input:checked + .hand-card svg { fill: var(--gold-fill); }
.hands input:focus-visible + .hand-card { outline: 3px solid var(--gold); outline-offset: 2px; }
@supports selector(:has(*)) {
  #handPicker:has(#hRight:checked) .pick-mirror { transform: translate(900px, 0) scale(-1, 1); }
  #handPicker:has(#hRight:checked) .ft { left: calc(100% - var(--x) - var(--w)); }
  #handPicker:has(#fIndex:checked) .pf-index, #handPicker:has(#fMiddle:checked) .pf-middle, #handPicker:has(#fRing:checked) .pf-ring { display: inline; }
  #handPicker:has(#fIndex:checked) .pick-mirror .band-index, #handPicker:has(#fMiddle:checked) .pick-mirror .band-middle, #handPicker:has(#fRing:checked) .pick-mirror .band-ring { display: inline; }
}
.consequence { margin: var(--gap) 0 0; color: var(--body); font-size: var(--fs-sm); }
.finger-pic { position: relative; width: min(100%, calc(var(--vh) * 24), 240px); margin: 2px auto 6px; }
@media (max-height: 700px) { .finger-pic { display: none; } }
.finger-pic svg { display: block; width: 100%; height: auto; }
.ph-fill { fill: #FDFBF5; stroke: none; }
.ph-line { fill: none; stroke: var(--gold-deep); stroke-width: 6; }
.pf { fill: var(--gold-fill); display: none; }
.pick-mirror .band { display: none; }
.pick-mirror .band rect { fill: var(--gold-deep); stroke: #fff; stroke-width: 4; }
.ft { position: absolute; top: 2%; left: var(--x); width: var(--w); height: 46%; --w: 18%; cursor: pointer; }
.ft-index { --x: 50%; } .ft-middle { --x: 32%; } .ft-ring { --x: 14%; }

.fingers { display: flex; gap: 8px; }
.fingers label { flex: 1; min-width: 0; cursor: pointer; }
.fingers:not(.ring-fingers) label:first-child { flex: 1.7; }
.fingers span, .opts span, .band-card b, .m-text b { overflow-wrap: anywhere; hyphens: auto; }
.fingers span { display: flex; min-height: 46px; align-items: center; justify-content: center; text-align: center; padding: 6px; border: 1.5px solid var(--line); border-radius: 12px; color: var(--ink); -webkit-text-fill-color: var(--ink); font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; background: #fff; }
.fingers input:checked + span { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); }
.fingers input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

.privacy { margin-top: 0; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-size: var(--fs-sm); line-height: 1.38; color: var(--body); }
.privacy p { margin: 0 0 4px; }
.privacy p:last-child { margin: 0; }
.privacy a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 0; color: var(--gold-deep); font-weight: 600; }
.inapp, .warn { margin: 0 0 var(--gap); padding: 8px 12px; border-radius: 12px; background: #FBEDE3; color: var(--warn); font-size: var(--fs-sm); line-height: 1.3; font-weight: 600; }

.adult { display: flex; gap: 10px; align-items: flex-start; margin: var(--gap) 0 0; font-weight: 600; font-size: var(--fs-sm); line-height: 1.32; color: var(--ink); -webkit-text-fill-color: var(--ink); min-height: 44px; cursor: pointer; }
.adult input { width: 24px; height: 24px; accent-color: var(--gold-deep); flex: none; margin: 1px 0 0; }

.preprompt { margin: 4px 0 0; text-align: center; font-weight: 600; font-size: var(--fs-sm); line-height: 1.3; color: var(--body); }
.dlnote { margin: 2px 0 0; text-align: center; font-size: 13px; line-height: 1.3; color: var(--mute); }

.primary, .link { display: block; width: 100%; text-align: center; font: inherit; text-decoration: none; cursor: pointer; }
.primary { background: var(--gold-deep); color: #fff; -webkit-text-fill-color: #fff; font-weight: 700; border: 0; border-radius: 14px; padding: 8px 16px; min-height: var(--btn); display: flex; align-items: center; justify-content: center; line-height: 1.2; }
/* Disabled buttons keep dark, readable words. iOS paints disabled controls from the text-fill colour, so set both. */
.primary:disabled { background: #E3DCCB; color: #4A453E; -webkit-text-fill-color: #4A453E; opacity: 1; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); font-weight: 600; font-size: var(--fs-sm); line-height: 1.25; padding: 4px 8px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.link:disabled { color: #6A645B; -webkit-text-fill-color: #6A645B; opacity: 1; cursor: not-allowed; }
.primary:focus-visible, .link:focus-visible, .back:focus-visible, #cancel:focus-visible, #stageKit:focus-visible, #stagePhoto:focus-visible, #kitNow:focus-visible, .method:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.spin { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Laptop visitors: move to the phone. */
.qr { display: flex; gap: 14px; align-items: center; margin: 0 0 var(--gap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.qr h2 { margin: 0 0 4px; }
.qr p { margin: 0; font-size: var(--fs-sm); color: var(--body); }
#qrCode { flex: none; width: calc(var(--vh) * 12); height: calc(var(--vh) * 12); min-width: 84px; min-height: 84px; max-width: 112px; max-height: 112px; }
#qrCode > * { display: block; width: 100%; height: 100%; }
.qr .link { width: auto; padding: 10px 0; min-height: 44px; text-align: left; }
@media (max-width: 359px) { .qr { flex-direction: column; align-items: flex-start; } }

/* In-app browser escape. */
#escape .primary { margin-bottom: var(--gap); }
#escapeOpen:not([hidden]) ~ #escapeCopy { background: none; color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); border: 1.5px solid var(--gold); }
.urlfield { display: block; margin: 8px 0 12px; }
.urlfield input { width: 100%; min-height: 48px; padding: 10px 12px; font: 400 15px/1.3 ui-monospace, Menlo, monospace; color: var(--body); background: #fff; border: 1.5px solid var(--line); border-radius: 12px; }

/* ---------- camera stage ---------- */
#stage { position: fixed; inset: 0; background: #000; overflow: hidden; }
#video, #guide { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { object-fit: cover; }
#guide { pointer-events: none; }

/* Hand outline. Searching: white dashes, gold finger, band. Aligned: one solid line that fades. Locked: gone. */
.h-halo { fill: none; stroke: rgba(0, 0, 0, .45); stroke-width: 9; stroke-linejoin: round; }
.h-line { fill: none; stroke: #fff; stroke-width: 5; stroke-linejoin: round; stroke-dasharray: 18 14; opacity: .95; transition: opacity 1.1s ease .5s; }
.fg { fill: var(--live); opacity: .55; display: none; transition: opacity .3s; }
#handOutline .band { display: none; }
#handOutline .band rect { fill: #FFF2CC; stroke: #6B4F12; stroke-width: 4; }
#guide:not([data-finger]) .fg-index, #guide[data-finger=index] .fg-index,
#guide[data-finger=middle] .fg-middle, #guide[data-finger=ring] .fg-ring,
#guide:not([data-finger]) #handOutline .band-index, #guide[data-finger=index] #handOutline .band-index,
#guide[data-finger=middle] #handOutline .band-middle, #guide[data-finger=ring] #handOutline .band-ring { display: inline; }
#guide[data-hand=right] #handOutline { transform: translate(900px, 0) scale(-1, 1); }
#handOutline[data-state=aligned] .h-line { stroke: #FFE29C; stroke-dasharray: none; opacity: .3; }
#handOutline[data-state=aligned] .h-halo { display: none; }
#handOutline[data-state=aligned] .fg { opacity: .16; }
#handOutline[data-state=aligned] .band rect { fill: none; stroke: #FFE29C; }
#handOutline[data-state=locked] { display: none; }

/* Card box: the same three states. */
#guide .g { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 18 14; opacity: .95; }
#guide .card { stroke: #FFE29C; }
.g-halo { fill: none; stroke: rgba(0, 0, 0, .45); stroke-width: 9; }
#cardOutline[data-state=aligned] .g-halo, #cardOutline[data-state=locked] .g-halo { display: none; }
#guide text { fill: #FFE29C; stroke: rgba(0, 0, 0, .6); stroke-width: 6; paint-order: stroke; font: 500 34px 'Jost', system-ui, sans-serif; }
#cardOutline[data-state=aligned] .card, #cardOutline[data-state=locked] .card { stroke: var(--live); stroke-dasharray: none; opacity: 1; }
#cardOutline[data-state=aligned] text, #cardOutline[data-state=locked] text { display: none; }
#cardOutline[data-state=locked] .card { stroke-width: 9; fill: rgba(255, 215, 120, .16); }
.c-tick { fill: none; stroke: var(--live); stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; display: none; }
#cardOutline[data-state=locked] .c-tick { display: inline; }
#cardFound { fill: rgba(255, 215, 120, .22); stroke: var(--live); stroke-width: 3; vector-effect: non-scaling-stroke; }
#ringSpot { fill: none; stroke: var(--live); stroke-width: 3; vector-effect: non-scaling-stroke; }

/* The ring: thin while searching, closes clockwise as progress, tick when done. */
#guide { --rx: 497; --ry: 779; }
#guide[data-finger=middle] { --rx: 400; --ry: 744; }
#guide[data-finger=ring] { --rx: 302; --ry: 771; }
#guide[data-hand=right] { --rx: 403; }
#guide[data-hand=right][data-finger=middle] { --rx: 500; }
#guide[data-hand=right][data-finger=ring] { --rx: 598; }
#ringProgress { transform: translate(calc(var(--rx) * 1px), calc(var(--ry) * 1px)); transition: transform .12s linear; }
.rp-track { fill: none; stroke: #fff; stroke-width: 4; opacity: .9; }
.rp-arc { fill: none; stroke: var(--live); stroke-width: 16; stroke-dasharray: 100; stroke-dashoffset: calc((1 - var(--p, 0)) * 100px); transition: stroke-dashoffset .12s linear; }
.rp-tick { fill: none; stroke: #fff; stroke-width: 15; stroke-linecap: round; stroke-linejoin: round; display: none; }
#ringProgress[data-state=searching] .rp-arc { opacity: 0; }
#ringProgress[data-state=aligned] .rp-track { stroke: #FFE29C; stroke-width: 6; }
#ringProgress[data-state=locked] .rp-arc { --p: 1; }
#ringProgress[data-state=locked] .rp-track { opacity: 0; }
#ringProgress[data-state=locked] .rp-tick { display: inline; }

.topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: flex-end; align-items: flex-start; gap: 8px; }
#cancel { flex: none; font: inherit; font-size: 15px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); border: 0; border-radius: 22px; padding: 10px 14px; min-height: 44px; }

/* Prompt box: one fixed height, whatever the message. Sized in lines so it holds the longest prompt. */
.prompt { position: absolute; left: 12px; right: 12px; bottom: calc(max(6px, env(safe-area-inset-bottom)) + 50px); height: calc(var(--pfs) * var(--plh) * var(--prows) + 40px); padding: 12px 14px 12px; background: rgba(20, 18, 15, .78); color: #fff; border-radius: 16px; text-align: center; display: flex; flex-direction: column; overflow: hidden; }
.prompt p { flex: 1; min-height: 0; margin: 0; font-size: var(--pfs); font-weight: 700; line-height: var(--plh); display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
.meter { flex: none; height: 5px; margin-top: 8px; background: rgba(255, 255, 255, .22); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--live); transition: width .12s linear; }
#dlProgress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255, 255, 255, .18); }
#dlProgress i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--live); }
.stage-help { position: absolute; left: 12px; right: 12px; bottom: calc(max(6px, env(safe-area-inset-bottom)) + 50px + var(--pfs) * var(--plh) * var(--prows) + 52px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#stageTip { margin: 0; padding: 8px 14px; border-radius: 12px; background: rgba(20, 18, 15, .78); color: #fff; font-weight: 600; font-size: 15px; text-align: center; }
#stageKit { pointer-events: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: 22px; background: rgba(20, 18, 15, .78); color: var(--live); font-weight: 700; font-size: 15px; text-decoration: none; text-align: center; }
@media (max-width: 300px) { :root { --prows: 4; } }

#debug { position: absolute; bottom: 150px; left: 8px; right: 8px; margin: 0; color: #9FFFA0; background: rgba(0, 0, 0, .6); font: 11px/1.35 ui-monospace, Menlo, monospace; padding: 6px; white-space: pre-wrap; pointer-events: none; }
#resultDebug { background: #fff; border: 1px solid var(--line); border-radius: 10px; font: 12px/1.4 ui-monospace, Menlo, monospace; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Result headline: three tiers. Strong gets the ring; a range stays plain; a rough figure is visibly weaker. */
#resultHead { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 var(--gap); color: var(--gold-deep); }
#tierText { font: 300 var(--h1)/1.15 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; }
.size { font-weight: 400; }
#resultOk:not([data-tier]) .size, #resultOk[data-tier=strong] .size { display: flex; align-items: center; justify-content: center; width: clamp(72px, calc(var(--vh) * 15), 128px); height: clamp(72px, calc(var(--vh) * 15), 128px); margin-top: 4px; border: 6px solid var(--gold-fill); border-radius: 50%; font: 400 clamp(34px, calc(var(--vh) * 7), 62px)/1 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--gold-deep); }
#resultOk[data-tier=between] .size { font: 400 clamp(32px, calc(var(--vh) * 6.5), 56px)/1.05 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; }
#resultOk[data-tier=rough] #resultHead { color: var(--body); }
#resultOk[data-tier=rough] #tierText { font-size: clamp(20px, calc(var(--vh) * 3.4), 26px); }
#resultOk[data-tier=rough] .size { padding-bottom: 8px; border-bottom: 2px dashed var(--line); font: 300 clamp(26px, calc(var(--vh) * 5), 40px)/1.1 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--body); }
.fine { margin: var(--gap) 0 0; font-size: 13px; line-height: 1.35; color: var(--mute); }
#photoSecond { margin: 14px 0 4px; font-weight: 600; }
#again[data-prompted] { background: var(--gold-soft); border-radius: 14px; }

/* Failure: room for per-error steps; after the second failure the kit leads. */
.steps { margin: 0 0 var(--gap); padding: 0 0 0 22px; color: var(--body); font-size: var(--fs-sm); }
.steps li { margin: 3px 0; }
#fail:not([data-kit-first]) #failKitTop { display: none; }
#fail[data-kit-first] #failKit { display: none; }
#fail[data-kit-first] #failKitTop { margin-bottom: 4px; }
#fail[data-kit-first] #retry { background: none; color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); font-weight: 600; padding: 4px 8px; min-height: 44px; }

/* ---------- ring mode, chooser, checklist (Package F) ---------- */
button.back { background: none; border: 0; font-family: inherit; font-size: inherit; cursor: pointer; }
.how { margin: var(--gap) 0 0; padding: 0; list-style: none; counter-reset: how; color: var(--ink); }
.how li { counter-increment: how; position: relative; padding: 0 0 clamp(4px, calc(var(--vh) * 1), 9px) 34px; line-height: 1.34; }
.how li::before { content: counter(how); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--gold-deep); color: #fff; font-size: 14px; font-weight: 700; line-height: 24px; text-align: center; }
.tips li:empty { display: none; }

/* Details behind a tap: the short tips stay above, nothing is lost. */
.more { margin: 0; }
.more summary { min-height: 44px; display: flex; align-items: center; color: var(--gold-deep); font-weight: 600; cursor: pointer; list-style: revert; }
.more summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.more[open] { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.more p { font-size: var(--fs-sm); color: var(--body); }

/* Chooser: three equal tiles, ring first. */
.methods { list-style: none; margin: 0 0 4px; padding: 0; display: grid; grid-auto-rows: 1fr; gap: clamp(6px, calc(var(--vh) * 1.2), 10px); }
.methods li { display: flex; min-width: 0; }
.method { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: clamp(6px, calc(var(--vh) * 1.4), 14px) 14px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); -webkit-text-fill-color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.method:hover { border-color: var(--gold); }
.method svg { flex: none; width: clamp(34px, calc(var(--vh) * 6), 48px); height: clamp(34px, calc(var(--vh) * 6), 48px); }
.m-ring { fill: none; stroke: var(--gold-fill); stroke-width: 7; }
.m-hand { fill: #F4EEDF; }
.m-box { fill: var(--gold-soft); stroke: var(--gold-deep); stroke-width: 2; }
.m-box-l { fill: none; stroke: var(--gold-deep); stroke-width: 2; }
.m-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.m-text b { font: 500 clamp(16px, calc(var(--vh) * 2.5), 19px)/1.2 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--ink); }
.m-tag { font-size: 13px; line-height: 1.2; font-weight: 700; color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); }
.m-need { font-size: 13px; line-height: 1.2; color: var(--mute); -webkit-text-fill-color: var(--mute); }

/* Ring questions. */
.ring-which { margin-top: 8px; padding: 12px 14px; border-radius: 12px; background: var(--gold-soft); font-size: 15px; color: var(--body); }
.ring-which p:last-child { margin: 0; }
.ring-which b { color: var(--ink); }
.q { border: 0; margin: var(--gap) 0 0; padding: 0; min-width: 0; }
.q legend { padding: 0; margin: 0 0 6px; font: 400 var(--h2)/1.3 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--ink); }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opts-fit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts-fit .fit-yes { grid-column: 1 / -1; }
.opts-fit label:not(.fit-yes) span { justify-content: center; text-align: center; padding: 8px 6px; }
.opts label, .bands label { position: relative; cursor: pointer; }
.opts input, .bands input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opts span { display: flex; align-items: center; min-height: 46px; height: 100%; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); -webkit-text-fill-color: var(--ink); font-weight: 600; font-size: var(--fs-sm); line-height: 1.25; }
.opts input:checked + span { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-deep); -webkit-text-fill-color: var(--gold-deep); }
.opts input:focus-visible + span, .bands input:focus-visible + .band-card { outline: 3px solid var(--gold); outline-offset: 2px; }
.ring-fingers { flex-wrap: wrap; }
.ring-fingers label { flex: 1 1 40%; position: relative; }
.bands { display: flex; gap: 8px; }
.bands label { flex: 1; min-width: 0; }
.band-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; height: 100%; padding: 6px 4px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; text-align: center; }
.band-card b { font-weight: 600; font-size: 13px; line-height: 1.2; color: var(--ink); -webkit-text-fill-color: var(--ink); }
.band-card svg { width: clamp(30px, calc(var(--vh) * 6), 46px); height: auto; }
.band-q i { font: 300 clamp(24px, calc(var(--vh) * 5), 40px)/1 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; font-style: normal; color: var(--gold-deep); }
.bd-fill { fill: var(--gold-fill); }
.bd-hole { fill: #fff; stroke: var(--gold-deep); stroke-width: 2; }
.bd-line { fill: none; stroke: var(--gold-deep); stroke-width: 2; }
.bands input:checked + .band-card { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.stop { margin: var(--gap) 0 0; padding: 10px 12px; border-radius: 12px; background: #FBEDE3; color: var(--warn); font-weight: 600; font-size: var(--fs-sm); }
.stop p { margin: 0 0 6px; }
#ringSetup { margin: 0; }
#ringSetup svg, #elbowPic svg { display: block; width: 100%; height: auto; }
#ringSetup svg { height: calc(var(--vh) * 19); max-height: 210px; }
#elbowPic { margin: 10px 0 0; }
#elbowPic svg { max-height: 170px; }
.rs-card rect { fill: var(--gold-deep); }
.rs-card .s-stripe { fill: #5F4714; }
.rs-ring { fill: none; stroke: var(--gold-fill); stroke-width: 14; }
.s-frust-flat { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; }
.ep-table { stroke: #E2D7BF; stroke-width: 6; stroke-linecap: round; }
.ep-arm { fill: none; stroke: var(--gold-deep); stroke-width: 18; stroke-linecap: round; }
.ep-hand { fill: none; stroke: var(--gold-deep); stroke-width: 14; stroke-linecap: round; }
.ep-elbow { fill: var(--gold-fill); stroke: var(--gold-deep); stroke-width: 3; }
.ep-phone { fill: var(--ink); }
.ep-view { fill: none; stroke: var(--gold); stroke-width: 2; stroke-dasharray: 3 6; }
.ep-subj { stroke: var(--gold-fill); stroke-width: 10; stroke-linecap: round; }

/* Ring result. */
#resultRing h1, #resultRingOut h1 { font-size: var(--h1); }
.ring-sizes { margin: 0 0 var(--gap); font: 400 clamp(19px, calc(var(--vh) * 3.2), 26px)/1.25 'Jost', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; color: var(--gold-deep); }

.copy-box { flex: none; width: 100%; max-width: 520px; margin: 0 auto; padding: 0 20px 8px; }

/* Ring stage: the circle replaces the hand and the progress ring runs on it. A zone only, never a measurement. */
#stage[data-mode=ring] #handOutline { display: none; }
#stage:not([data-mode=ring]) #ringOutline { display: none; }
#stage[data-mode=ring] #guide { --rx: 450; --ry: 800; }
#stage[data-mode=ring] #ringProgress { transform: translate(calc(var(--rx) * 1px), calc(var(--ry) * 1px)) scale(1.1); }
#stage[data-mode=ring] .rp-track { display: none; }
#stage[data-mode=ring] .rp-arc { stroke-width: 9; }
.rz-halo { fill: none; stroke: rgba(0, 0, 0, .45); stroke-width: 9; }
.rz-line { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 18 14; opacity: .95; }
.rz-ring { fill: none; stroke: #FFE29C; stroke-width: 10; opacity: .6; }
#ringOutline[data-state=aligned] .rz-halo, #ringOutline[data-state=locked] .rz-halo,
#ringOutline[data-state=aligned] .rz-ring, #ringOutline[data-state=locked] .rz-ring,
#ringOutline[data-state=aligned] text, #ringOutline[data-state=locked] text { display: none; }
#ringOutline[data-state=aligned] .rz-line, #ringOutline[data-state=locked] .rz-line { stroke: #FFE29C; stroke-dasharray: none; opacity: .3; }

/* Checklist: four independent items, each with its own state. Shape as well as colour. */
#checklist { flex: 1 1 0; min-width: 0; max-width: 300px; margin: 0 auto 0 0; padding: 7px 6px 5px; display: flex; gap: 2px; list-style: none; background: rgba(20, 18, 15, .78); border-radius: 14px; color: #fff; }
#checklist li { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; line-height: 1.15; }
#checklist i { position: relative; display: block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); }
#checklist li[data-state=on] i { background: #66D17F; border-color: #66D17F; }
#checklist li[data-state=on] i::after { content: ""; position: absolute; left: 3px; top: 0; width: 5px; height: 9px; border: solid #14120F; border-width: 0 2px 2px 0; transform: rotate(40deg); }
#checklist li[data-state=amber] i { border-color: var(--live); background: linear-gradient(90deg, var(--live) 50%, transparent 50%); }
.chk-ring { display: none; }
#stage[data-mode=ring] .chk-finger { display: none; }
#stage[data-mode=ring] .chk-ring { display: inline; }

/* The kit route, always on the stage, and the 45 s rung beside the trouble link. */
.stage-help-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#stagePhoto { pointer-events: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border: 0; border-radius: 22px; background: rgba(20, 18, 15, .78); color: var(--live); font: inherit; font-weight: 700; font-size: 15px; text-align: center; cursor: pointer; }
#kitNow { position: absolute; left: 12px; right: 12px; bottom: max(6px, env(safe-area-inset-bottom)); min-height: 44px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 600; text-decoration: underline; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
#kitNow:empty { display: none; }
/* From 45 s the kit link has joined the help row, so the prompt and the help stack move down into its place. */
#stage[data-trouble] .prompt { bottom: calc(max(6px, env(safe-area-inset-bottom)) + 8px); }
#stage[data-trouble] .stage-help { bottom: calc(max(6px, env(safe-area-inset-bottom)) + 8px + var(--pfs) * var(--plh) * var(--prows) + 52px); }
/* 75 s, or the second failure: the kit is the main button here too. */
#stage[data-kit-first] .stage-help { gap: 10px; }
#stage[data-kit-first] .stage-help-row { flex-direction: column; align-items: stretch; width: 100%; }
#stage[data-kit-first] #stageKit { justify-content: center; min-height: 56px; background: var(--gold-deep); color: #fff; font-size: 17px; }
#stage[data-kit-first] #stagePhoto { justify-content: center; min-height: 44px; }
/* Short phones: at the 45 s rung the two buttons replace the tip, so the help stack clears the ring circle. */
@media (max-height: 620px) {
  .stage-help { gap: 4px; }
  .stage-help-row { gap: 4px; }
  .stage-help:has(#stagePhoto:not([hidden])) #stageTip { display: none; }
}

/* ---------- one screen, short steps ---------- */
.flow-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flow-progress { margin: 0; color: var(--mute); font-size: 13px; font-weight: 600; white-space: nowrap; }
.step { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* The body takes the room and centres in it; it only scrolls inside itself if the user has opened a disclosure. */
.step-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.step-foot { flex: none; padding-top: 6px; }
.foot-hint { display: none; margin: 3px 0 0; text-align: center; font-size: 13px; line-height: 1.25; color: var(--mute); }
.primary:disabled:not([hidden]) + .foot-hint { display: block; }
.foot-links { display: flex; gap: 4px; }
.foot-links .link { flex: 1 1 0; min-width: 0; padding: 2px 4px; }
/* Short phones: the lead already says to tick the box, so the hint gives way to the consent text. */
@media (max-height: 620px) {
  #ringConsent .foot-hint, #fingerConsent .foot-hint { display: none !important; }
  .dlnote { font-size: 12px; }
  #resultHead { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  #resultOk:not([data-tier]) .size, #resultOk[data-tier=strong] .size { margin-top: 0; flex: none; }
  #result .link { min-height: 40px; }
  #result p { margin-bottom: 4px; font-size: var(--fs-sm); line-height: 1.32; }
  #result .fine { font-size: 12px; margin-top: 2px; }
  #result .warn { padding: 6px 10px; }
}

/* Tablets and laptops: the buttons sit with the content, in a centred column, not at the bottom edge. */
@media (min-width: 700px) {
  .step { justify-content: center; }
  .step-body { flex: 0 1 auto; }
  .step-body::before, .step-body::after { display: none; }
  .step-foot { padding-top: var(--gap); }
}

/* The safety net: only the links that work without a script stay. */
.boot-fail { margin: 0 0 var(--gap); padding: 10px 12px; border-radius: 12px; background: #FBEDE3; color: var(--warn); font-weight: 600; font-size: var(--fs-sm); }
.boot-fail p { margin: 0; }
.sizer-failed li.needs-js, .sizer-failed #chooser .lead { display: none; }

/* Very short views (a small phone with Safari's bars, or a phone on its side): the tick box must stay in view. */
@media (max-height: 500px) {
  #ringConsent .lead, #fingerConsent .lead, .dlnote { display: none; }
  .privacy a { min-height: 32px; }
  .foot-hint { display: none !important; }
}

/* Phone on its side: no pictures, a wider column, foot buttons in a row. Internal scroll is allowed here only. */
@media (orientation: landscape) and (max-height: 500px) {
  .screen { max-width: 760px; }
  #setup, #ringSetup, .finger-pic, .eyebrow { display: none; }
  .step-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
  .step-foot .primary { flex: 1 1 40%; width: auto; }
  .foot-hint, .preprompt, .dlnote { flex: 1 1 100%; }
  .methods { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .method { min-height: 0; }
  .hand-card { flex-direction: row; justify-content: center; }
}

/* Reduced motion: no sweep, no sliding. The ring steps through opacity instead. */
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; border-color: var(--gold); }
  .meter i, .h-line, .fg, #ringProgress, .rp-arc { transition: none; }
  .s-card, .s-hand, .s-phone, .s-frust { animation: none; opacity: 1; transform: none; }
  #ringProgress:not([data-state=searching]) .rp-arc {
    stroke-dasharray: none;
    opacity: calc(.15 + .2 * clamp(0, (var(--p, 0) - .24) * 1000, 1) + .2 * clamp(0, (var(--p, 0) - .49) * 1000, 1) + .22 * clamp(0, (var(--p, 0) - .74) * 1000, 1) + .23 * clamp(0, (var(--p, 0) - .99) * 1000, 1));
  }
}
