/* The page stays neutral white and grey around the plates. Blue is for controls only. */
:root { --white: #fff; --ink: #1c2530; --soft: #55606d; --hair: #d5dae0; --scale: #858f9a; --blue: #1a55a8; --blue-deep: #143f7f; --blue-tint: #edf3fb;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; font: 17px/1.5 var(--sans); color: var(--ink); background: var(--white); font-variant-numeric: tabular-nums; }
h1, h2, h3, p, ul, ol { margin: 0; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
#masthead { display: flex; align-items: center; justify-content: center; gap: 10px; height: 60px; border-bottom: 1px solid var(--hair); }
.mark { width: 32px; height: 32px; display: block; }
#masthead h1 { font-size: 1.2rem; font-weight: 400; letter-spacing: -.01em; }
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
button { font: inherit; cursor: pointer; }
.solid, .line { display: block; width: 100%; min-height: 54px; padding: 10px 20px; border-radius: 8px; font-weight: 500; }
.solid { background: var(--blue); color: #fff; border: 1px solid var(--blue); }
.line { background: #fff; color: var(--blue-deep); border: 1px solid var(--blue); }
.text { display: block; min-height: 44px; padding: 8px 12px; margin: 0 auto; background: none; border: 0; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .solid:hover { background: var(--blue-deep); } .line:hover { background: var(--blue-tint); } }

/* Start */
#screen-start { padding: 24px 0 32px; }
.instrument { display: block; width: 132px; height: 132px; margin: 0 auto 18px; fill: none; stroke: var(--scale); stroke-width: 1; }
.instrument .pupil { fill: var(--blue); stroke: none; }
.lede { font-size: 1.5rem; line-height: 1.3; letter-spacing: -.01em; margin-bottom: 22px; }
.actions { display: grid; gap: 10px; }
#start-disclaimer { margin-top: 26px; padding-left: 14px; border-left: 3px solid var(--blue); }
#brightness-note { margin-top: 14px; color: var(--soft); }

/* Play */
#screen-play { padding: 12px 0 16px; display: flex; flex-direction: column; align-items: center; }
#round-label { font-size: 1.05rem; font-weight: 400; color: var(--soft); }
.ruler { width: 100%; max-width: 480px; height: 7px; margin: 8px 0 12px; border-bottom: 1px solid var(--scale); position: relative; }
.ruler i { position: absolute; left: 0; bottom: -2px; height: 3px; width: calc(var(--progress, 0) * 100%); background: var(--blue); }
.stage { position: relative; }
#plate-canvas { display: block; width: clamp(220px, min(100vw - 40px, 100dvh - 410px), 460px); height: auto; aspect-ratio: 1 / 1; }
#options { width: 100%; max-width: 480px; margin-top: 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#options button { min-height: 54px; padding: 4px; background: #fff; color: var(--ink); border: 1px solid var(--scale); border-radius: 8px; font-size: 1.1rem; }
#options button:last-child { grid-column: 1 / -1; font-size: 1.05rem; color: var(--soft); min-height: 48px; }
@media (hover: hover) { #options button:hover { border-color: var(--blue); color: var(--blue-deep); } }
#btn-quit { margin-top: 2px; }
.play-note { font-size: .88rem; color: var(--soft); }

/* Results */
#screen-results { padding: 26px 0 32px; }
#results-title { font-size: 1.7rem; font-weight: 400; line-height: 1.2; letter-spacing: -.01em; }
#results-disclaimer { margin-top: 14px; padding-left: 14px; border-left: 3px solid var(--blue); }
#results-body { margin-top: 14px; }
#results-breakdown { margin-top: 14px; padding: 0; list-style: none; }
#results-breakdown li, #history-list li { padding: 9px 0; border-top: 1px solid var(--hair); }
.res-side { margin-top: 24px; }
.res-side h3 { font-size: .8rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); margin: 22px 0 8px; }
.res-side h3:first-child { margin-top: 0; }
textarea { display: block; width: 100%; font: .95rem/1.4 ui-monospace, Menlo, monospace; color: var(--ink); padding: 10px; margin-bottom: 8px; border: 1px solid var(--scale); border-radius: 8px; resize: vertical; }
#share-status { display: block; min-height: 1.5em; margin-top: 4px; color: var(--soft); }
#history-empty { color: var(--soft); }
#history-list { padding: 0; list-style: none; font-size: .95rem; }
#btn-clear-history { margin: 6px 0 12px; padding-left: 0; }

@media (min-width: 840px) {
  #masthead { height: 72px; } #masthead h1 { font-size: 1.5rem; } .mark { width: 40px; height: 40px; }
  #screen-start { display: grid; grid-template-columns: 300px 1fr; gap: 64px; align-items: center; padding-top: 72px; }
  .instrument { width: 300px; height: 300px; margin: 0; }
  .lede { font-size: 2rem; }
  .actions { grid-template-columns: 1fr 1fr; }
  #screen-play { padding-top: 16px; }
  #plate-canvas { width: clamp(280px, 100dvh - 350px, 500px); }
  /* Graduated scales either side of the plate, neutral grey only. */
  .stage::before, .stage::after { content: ""; position: absolute; top: 0; bottom: 0; width: 14px;
    background: repeating-linear-gradient(0deg, var(--scale) 0 1px, transparent 1px 12.5%) ; border-block: 1px solid var(--scale); }
  .stage::before { left: -90px; border-left: 1px solid var(--scale); }
  .stage::after { right: -90px; border-right: 1px solid var(--scale); }
  #options { max-width: 640px; grid-template-columns: repeat(4, 1fr) 1.4fr; }
  #options button:last-child { grid-column: auto; min-height: 54px; }
  #screen-results { display: grid; grid-template-columns: 1fr 380px; column-gap: 64px; padding-top: 48px; }
  #screen-results > :not(.res-side) { grid-column: 1; }
  .res-side { grid-column: 2; grid-row: 1 / span 8; margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { :not(.help-frames *), *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 840px) { #options button { font-size: 1.3rem; } }

.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 22px; margin: 0; padding: 0; list-style: none; }
.foot-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--blue-deep); text-underline-offset: 3px; }
.brand { display: flex; align-items: center; gap: inherit; color: inherit; text-decoration: none; }
.prose ol, .prose ul { margin: .7em 0 0; padding-left: 1.3em; }
.prose li + li { margin-top: .5em; }
.prose { overflow-wrap: break-word; }
.prose h1 { margin: 0; }
.prose h3 { margin: 1.2em 0 0; }
.prose table { width: 100%; margin-top: .8em; border-collapse: collapse; }
.prose th, .prose td { padding: .4em 0; text-align: left; }
.prose th:last-child, .prose td:last-child { text-align: right; }
.play-link a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Content pages */
.wordmark { font-size: 1.2rem; font-weight: 400; letter-spacing: -.01em; }
.site-note { max-width: 40rem; margin: 0 auto; padding: 20px 0 28px; color: var(--soft); text-align: center; }
.site-note a, .prose a { color: var(--blue-deep); text-underline-offset: 3px; }
#site-footer { padding: 12px 16px 16px; border-top: 1px solid var(--hair); font-size: .9rem; color: var(--soft); text-align: center; }
.prose { max-width: 40rem; margin: 0 auto; padding: 28px 0 40px; }
.prose h1 { font-size: 1.9rem; font-weight: 400; line-height: 1.15; letter-spacing: -.01em; }
.prose h2 { margin-top: 1.7em; font-size: 1.25rem; font-weight: 500; line-height: 1.25; }
.prose h3 { font-size: 1.02rem; font-weight: 500; line-height: 1.3; }
.prose p { margin-top: .8em; }
.prose .lede { font-size: 1.2rem; line-height: 1.4; }
.prose .callout { margin-top: 1em; padding-left: 14px; border-left: 3px solid var(--blue); }
.prose .updated { color: var(--soft); }
.play-link { margin-top: 2em; }
@media (min-width: 840px) { .wordmark { font-size: 1.5rem; } }

/* Challenges, scores and sharing */
#challenge-note { margin: 12px 0 0; padding-left: 12px; border-left: 3px solid var(--blue); color: var(--soft); }
#challenge-banner { max-width: 34rem; margin: 16px auto 0; padding: 14px 16px; text-align: center; background: var(--blue-tint); border: 1px solid var(--hair); border-radius: 8px; }
#challenge-banner h2 { font-size: 1.3rem; font-weight: 500; }
#challenge-detail { color: var(--soft); }
#challenge-disclaimer { margin: 6px 0 12px; font-size: .95rem; }
#results-score { font-size: 2rem; line-height: 1.2; font-weight: 500; }
#results-note:empty { display: none; }
#results-note, #countdown-line { color: var(--soft); }
#vs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 10px 0; padding: 12px; border: 1px solid var(--hair); border-radius: 8px; text-align: center; }
#vs span { display: block; font-size: 1.5rem; }
#vs small { color: var(--soft); }
#vs-line, #vs-note { grid-column: 1 / -1; }
#vs-note { font-size: .92rem; color: var(--soft); }
#screen-results label[for="challenge-name"] { display: block; margin-top: 12px; color: var(--soft); font-size: .95rem; }
#challenge-name { display: block; width: 100%; min-height: 48px; font: inherit; padding: 6px 10px; margin: 2px 0 8px; border: 1px solid var(--scale); border-radius: 6px; }
#share-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.share-opt { flex: 1 1 30%; min-height: 48px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--blue); border-radius: 8px; color: var(--blue-deep); font: inherit; text-decoration: none; cursor: pointer; }
#start-stats { margin-top: 14px; border-top: 1px solid var(--hair); padding-top: 4px; }
#start-stats summary { min-height: 44px; display: flex; align-items: center; color: var(--blue-deep); cursor: pointer; }
#start-stats h3 { margin: 12px 0 4px; font-size: 1rem; font-weight: 500; }
#start-stats ol, #start-stats ul { padding-left: 20px; }
.mini { margin: 0; }
.mini div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--hair); }
.mini dd { margin: 0; }
.fine { font-size: .9rem; color: var(--soft); margin-top: 4px; }
#code-box { width: 100%; font: .85rem/1.3 ui-monospace, monospace; border: 1px solid var(--scale); border-radius: 6px; padding: 6px; }
.code-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.code-actions .text { margin: 0; }
#code-status:empty { display: none; }

:root { --h-bg:#fff;--h-ink:#1c2530;--h-btn:#1a55a8;--h-btn-ink:#fff;--h-radius:8px;--h-font:var(--sans); }
/* First-visit walkthrough. Only transform and opacity animate. */
.help-btn { position: fixed; z-index: 6; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 44px; height: 44px; min-width: 0; min-height: 0; padding: 0; border-radius: 50%; border: 1px solid var(--h-ink); background: var(--h-bg); color: var(--h-ink); font: 600 20px/1 var(--h-font); cursor: pointer; }
.help-card, .help-strip { position: fixed; z-index: 7; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; background: var(--h-bg); color: var(--h-ink); border: 1px solid var(--h-ink); border-radius: var(--h-radius); box-shadow: 0 6px 22px rgba(0,0,0,.28); font: 15px/1.35 var(--h-font); }
.help-card { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; align-items: center; padding: 10px; }
.help-card.help-top { top: max(8px, env(safe-area-inset-top)); bottom: auto; right: 60px; }
.help-text { margin: 0; font: 15px/1.35 var(--h-font); color: var(--h-ink); }
.help-row { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.help-ok { flex: 1; min-height: 44px; min-width: 0; width: auto; padding: 0 18px; border: 1px solid var(--h-btn); border-radius: var(--h-radius); background: var(--h-btn); color: var(--h-btn-ink); font: 600 16px/1.2 var(--h-font); cursor: pointer; }
.help-link { min-height: 44px; min-width: 44px; width: auto; padding: 0 8px; border: 0; background: none; color: var(--h-ink); font: 15px/1.2 var(--h-font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.help-link:hover, .help-ok:hover { background: none; color: var(--h-ink); }
.help-ok:hover { background: var(--h-btn); color: var(--h-btn-ink); }
.help-strip { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 0 8px; }
.help-x { width: 44px; height: 44px; min-width: 0; padding: 0; border: 0; background: none; color: var(--h-ink); font-size: 22px; cursor: pointer; }
.help-demo { --s: 1; --freeze: 0s; --d: 5s; position: relative; width: calc(130px * var(--s)); height: calc(110px * var(--s)); overflow: hidden; border-radius: var(--h-radius); }
.help-frame { position: absolute; left: 0; top: 0; width: 130px; height: 110px; transform: scale(var(--s)); transform-origin: 0 0; }
.help-frame svg { display: block; width: 130px; height: 110px; }
.help-frame svg * { transform-box: fill-box; transform-origin: center; }
.help-tick { position: absolute; width: 0; height: 0; animation: help-tick var(--d) linear var(--loops) both; }
.help-paused * { animation-play-state: paused !important; }
.help-frames { --s: .5; width: 130px; height: 55px; }
.help-frames .help-frame:nth-child(2) { left: 65px; }
.help-frames * { animation-delay: var(--freeze) !important; animation-play-state: paused !important; animation-iteration-count: 1 !important; }
.help-dialog { width: min(92vw, 420px); max-height: 92dvh; overflow: auto; padding: 18px; border: 1px solid var(--h-ink); border-radius: var(--h-radius); background: var(--h-bg); color: var(--h-ink); }
.help-dialog::backdrop { background: rgba(0,0,0,.5); }
.help-dialog .help-demo { --s: 1.8; margin: 0 auto; }
.help-dialog .help-frames { --s: .9; width: 234px; height: 99px; }
.help-dialog .help-frames .help-frame:nth-child(2) { left: 117px; }
.help-title { margin: 0 0 10px; font: 600 21px/1.2 var(--h-font); color: var(--h-ink); }
.help-title:focus { outline: none; }
.help-dialog > .help-link { display: block; margin: 0 auto; }
.help-dialog > .help-text { margin-top: 8px; }
.help-legend { list-style: none; margin: 12px 0 0; padding: 0; font: 15px/1.3 var(--h-font); }
.help-legend li { display: flex; align-items: center; gap: 10px; padding: 3px 0; border: 0; }
.help-swatch { flex: none; width: 36px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.help-swatch svg { width: 24px; height: 24px; }
.help-more { display: inline-flex; align-items: center; min-height: 44px; font: 15px/1.2 var(--h-font); color: var(--h-ink); }
.help-dialog .help-ok { display: block; width: 100%; margin-top: 6px; }
.help-how { display: block; margin: 0 auto; min-height: 44px; padding: 0 8px; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.help-rule { margin: 4px 0 0; }
@media (min-width: 900px) { .help-card, .help-strip { left: auto; right: 16px; width: 400px; } .help-card.help-top { right: 60px; } }
@media (prefers-reduced-motion: no-preference) { .help-pulse { animation: help-pulse 1.1s ease-in-out 1; } }
@keyframes help-tick { from, to { opacity: 0; } }
@keyframes help-pulse { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.025); } }
.cd-a { animation: cd-a var(--d) linear var(--loops) both; }
.cd-b { animation: cd-b var(--d) linear var(--loops) both; }
.cd-tap { animation: cd-tap var(--d) linear var(--loops) both; }
@keyframes cd-tap { 0%, 28% { opacity: 0; } 36% { opacity: .4; } 46%, 100% { opacity: 0; } }
@keyframes cd-a { 0%, 46% { opacity: 1; transform: none; } 56%, 100% { opacity: 0; transform: translateX(-90px); } }
@keyframes cd-b { 0%, 46% { opacity: 0; transform: translateX(90px); } 56%, 100% { opacity: 1; transform: none; } }
