:root {
  color-scheme: light;
  --paper: #f7f8f9;
  --white: #fff;
  --ink: #211b1d;
  --muted: #625b5d;
  --line: #ddd8db;
  --red: #b8242b;
  --red-dark: #921920;
  --red-wash: #f9e9e9;
  --green: #244a36;
  --green-wash: #e2eadf;
  --digits: Arial, "Helvetica Neue", system-ui, sans-serif;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--paper); color: var(--ink); }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
h1[tabindex="-1"]:focus { outline: none; }
h1, h2, p { margin: 0; }
.app { width: min(100% - 32px, 544px); margin: auto; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.header { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.brand, .help-button, .text-button { min-height: 44px; border: 0; padding: 0; background: none; font-weight: 800; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 1rem; }
.mark { position: relative; width: 26px; height: 26px; border-radius: 50%; background: var(--red); }
.mark::before { content: ""; position: absolute; inset: 3px; border: 1px solid #f4a3a3; border-radius: 50%; }
.mark::after { content: ""; position: absolute; inset: 37%; border-radius: 50%; background: var(--paper); }
body:has(.home-intro) .brand-name { display: none; }
.help-button, .text-button { color: var(--ink); font-size: .86rem; text-decoration: underline; text-underline-offset: 4px; }
.icon-button { min-width: 44px; min-height: 44px; padding: 0 9px; border: 1px solid var(--line); background: var(--white); font-size: 1.25rem; font-weight: 800; }

.home-intro { padding-top: clamp(20px,6.5vw,36px); text-align: center; }
.home-intro h1 { margin-top: 14px; color: var(--red); font-size: clamp(2.5rem,14vw,5.4rem); font-weight: 950; line-height: 1; letter-spacing: -.09em; }
.title-suffix { margin-inline-start: .1em; font-size: .68em; letter-spacing: -.06em; white-space: nowrap; }
.home-intro p { margin: 12px 0 0; font-size: clamp(.88rem,3.6vw,1.02rem); font-weight: 650; line-height: 1.55; }
.plate-mark { --disc-size: clamp(76px,23vw,108px); position: relative; display: inline-grid; grid-template-rows: 38% 24% 38%; justify-items: center; width: var(--disc-size); aspect-ratio: 1; border: 3px solid var(--red-dark); border-radius: 50%; background: var(--red); color: #fff; }
.plate-mark::before { content: ""; position: absolute; inset: 8%; border: 1px solid #f4a3a3; border-radius: 50%; pointer-events: none; }
.plate-mark::after { content: ""; position: absolute; inset: 42%; border: 1px solid var(--red-dark); border-radius: 50%; background: var(--plate-hole, var(--paper)); pointer-events: none; }
.plate-mark b { grid-row: 1; align-self: end; font: 850 calc(var(--disc-size) * .22)/1 var(--digits); }
.plate-mark small { grid-row: 3; align-self: start; font: 750 calc(var(--disc-size) * .13)/1 var(--digits); }
.home-actions { display: grid; gap: 7px; margin-top: 22px; }
.button { min-height: 49px; padding: 8px 11px; border: 1px solid transparent; border-radius: 8px; font-size: .93rem; font-weight: 850; }
.home-actions .button { min-height: 52px; }
.primary { width: 100%; background: var(--red); color: #fff; }
.primary:not(:disabled):active { background: var(--red-dark); }
.secondary { border-color: var(--line); background: var(--white); }
.secondary:not(:disabled):active { background: var(--red-wash); }
.home-ranking { margin-top: 24px; padding-top: 5px; border-top: 1px solid var(--line); }
.home-ranking-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.home-ranking h2 { font-size: 1.07rem; font-weight: 900; }
.home-ranking p { margin: 0 0 10px; color: var(--muted); font-size: .83rem; line-height: 1.45; }
.home-ranking .button { min-height: 44px; }
.best { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 19px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; font-weight: 750; }
.best strong { color: var(--red); font: 750 1.5rem/1 var(--digits); }
.best small { color: var(--ink); font-size: .86rem; }

.stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 7px 0 8px; padding: 7px 0; }
.stat { min-width: 0; padding: 2px 4px 3px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: .78rem; font-weight: 650; }
.stat b { display: block; margin-top: 3px; font: 750 clamp(1.08rem,4.5vw,1.45rem)/1.22 var(--digits); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { appearance: none; display: block; width: 100%; height: 4px; margin: 0 0 10px; border: 0; background: var(--line); }
.progress::-webkit-progress-bar { background: var(--line); }
.progress::-webkit-progress-value { background: var(--red); }
.progress::-moz-progress-bar { background: var(--red); }
.panel { border: 1px solid var(--line); border-radius: 11px; background: var(--white); padding: 13px; }
body:has(.game-panel) { background: #fffdfa; }
body:has(.game-panel) .app { width: min(100% - 12px, 480px); }
body:has(.game-panel) .header { padding-inline: 8px; }
.game-stats { margin: 3px 0 5px; padding: 5px 0; }
.game-stats .stat span { font-size: .72rem; }
.game-stats .stat b { font-size: clamp(1rem,4vw,1.25rem); }
.game-stats + .progress { height: 3px; margin-bottom: 3px; }
.panel.game-panel { container-type: inline-size; border: 0; padding: 0; background: transparent; }
.weight-stage { position: relative; padding-top: 12px; }
.weight-stage:has(.game-mode) { padding-top: 18px; }
.game-mode { position: absolute; top: 0; right: 8px; color: var(--muted); font-size: .7rem; font-weight: 750; }
.target {
  color: var(--red-dark); font: 800 calc(clamp(3.5rem,18cqi,5.5rem) * var(--target-scale))/1 var(--digits);
  font-variant-numeric: tabular-nums; letter-spacing: -.065em; white-space: nowrap;
}
.target-unit { display: inline-block; position: relative; left: 6px; width: 0; font-size: clamp(.98rem,4.4cqi,1.35rem); letter-spacing: -.01em; }
.bar-stage { position: relative; display: flow-root; }
#barbell { margin: -6px 8px 1px; }
.barbell { display: block; width: 100%; height: auto; max-height: 96px; margin: 0 auto; }
.target-display { display: grid; justify-items: center; align-items: start; min-height: calc(clamp(3.5rem,18cqi,5.5rem) * 1.27); }
.target-reading { position: relative; width: max-content; }
.game-panel[data-answered] .target { opacity: .4; }
.answer-mark {
  position: absolute; top: 51%; left: 50%; translate: -50% -50%;
  display: grid; place-items: center; pointer-events: none;
  color: var(--red-dark); white-space: nowrap;
}
.answer-mark:is([data-outcome="correct"], [data-outcome="wrong"])::before {
  content: ""; box-sizing: border-box; width: clamp(86px,30cqi,120px); aspect-ratio: 1;
  animation: answer-mark-in 150ms ease-out;
}
.answer-mark[data-outcome="correct"]::before { border: clamp(5px,1.5cqi,7px) solid currentColor; border-radius: 50%; }
.answer-mark[data-outcome="wrong"] { color: var(--ink); }
.answer-mark[data-outcome="wrong"]::before {
  width: clamp(50px,18cqi,72px);
  background: linear-gradient(45deg, transparent 45%, currentColor 45% 55%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, currentColor 45% 55%, transparent 55%);
}
.answer-mark:is([data-outcome="correct"], [data-outcome="wrong"]) span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.answer-mark[data-outcome="retry"] {
  background: #fffdfa; padding: 3px 9px; border: 1px solid currentColor; border-radius: 4px;
  font-size: .85rem; font-weight: 850;
}
@keyframes answer-mark-in {
  from { transform: scale(.9); }
  to { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .answer-mark:is([data-outcome="correct"], [data-outcome="wrong"])::before { animation: none; }
}
.bar-control { cursor: pointer; touch-action: manipulation; }
.bar-control:focus-visible { outline: none; }
.bar-control:focus-visible .bar-hit { stroke: var(--red); stroke-width: 2px; }
.bar-control[aria-disabled="true"] { cursor: default; }
.remove-hint { min-height: 23px; text-align: center; visibility: hidden; color: var(--muted); font-size: .72rem; font-weight: 650; }
.remove-hint.visible { visibility: visible; }
.game-panel[data-answered] .remove-hint { visibility: hidden; }
.game-panel[data-answered] :is(.plate, #submit):disabled { opacity: 1; }
.plate-grid { position: relative; display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.plate-grid::after { content: ""; position: absolute; inset: auto 3% 5px; height: 1px; background: var(--line); pointer-events: none; }
.plate { min-height: 80px; min-width: 0; display: grid; justify-items: center; grid-template-rows: 18px 1fr; gap: 2px; border: 0; border-radius: 4px; background: none; padding: 5px 0 6px; }
.plate:focus-visible { outline-offset: -2px; }
.plate:not(:disabled):active .plate-shape { transform: translateY(-3px); }
.plate-weight { font: 800 clamp(.8rem,3.9cqi,.98rem)/1.1 var(--digits); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plate-shape { align-self: end; width: var(--plate-width); height: var(--plate-height); border: 1px solid color-mix(in srgb,var(--plate),#241e24 40%); border-radius: 2px; background: var(--plate); box-shadow: inset -2px 0 0 #211b1d22; }
.game-actions { display: grid; grid-template-columns: minmax(84px,1fr) 2.2fr; gap: 8px; padding: 9px 4px 0; }
.game-actions .button { min-height: 52px; }
.skip { display: block; width: 100%; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: .84rem; text-decoration: underline; text-underline-offset: 3px; }

body:has(.result-card) { background: #fffdfa; }
.result-card { padding: clamp(23px,8vw,43px) 0 23px; text-align: center; }
.result-card h1 { font-size: clamp(1rem,4.6vw,1.35rem); font-weight: 900; letter-spacing: -.045em; }
.result-total { margin: 7px 0 11px; color: var(--red-dark); font: 800 clamp(3.7rem,21vw,7.4rem)/.98 var(--digits); letter-spacing: -.065em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-total span { margin-left: .28em; font: 750 .24em/1 var(--digits); letter-spacing: -.025em; }
.result-metrics { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 16px; font-size: .95rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.result-metrics strong { font: 800 1.44rem/1 var(--digits); }
.result-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.result-actions .primary { grid-column: 1 / -1; }
.result-actions .button { min-height: 51px; }
.share-dialog { background: #fffdfa; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.share-dialog .dialog-top h2 { font-size: 1rem; }
.share-dialog .icon-button { border-radius: 7px; }
.share-formats, .share-actions { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 6px; }
.share-formats .button { min-height: 44px; padding-inline: 4px; font-size: .81rem; }
.share-formats .button[aria-pressed="true"] { background: var(--red-wash); border-color: #d69ba1; color: var(--red-dark); }
#share-artwork { display: grid; justify-items: center; min-height: 160px; margin: 9px 0; }
#share-artwork canvas { display: block; width: min(100%, 380px); height: auto; border-radius: 4px; }
#share-artwork[data-format="story"] canvas { width: min(100%, 245px, 31dvh); }
.share-actions .button { padding-inline: 4px; }
.share-dialog[data-format="x"] #copy-share { grid-column: 1 / -1; min-height: 44px; }
.share-instructions { margin-top: 8px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.share-copy-fallback:not([hidden]) { width: 100%; margin-top: 7px; font: inherit; overflow-wrap: anywhere; }
.share-status { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.share-status:not(:empty) { margin-top: 8px; }

.ranking-entry { display: flex; align-items: center; gap: 7px 12px; flex-wrap: wrap; margin-top: 12px; }
.ranking-entry button { min-height: 44px; padding: 7px; font-size: .84rem; }
.ranking-entry p { color: var(--muted); font-size: .8rem; }
.ranking-entry p:empty { display: none; }
.ranking-intro { color: var(--muted); font-size: .84rem; margin-bottom: 8px; }
.ranking-rows { padding: 0 0 0 26px; max-height: min(55vh,420px); overflow: auto; }
.ranking-rows li { padding: 6px 4px 7px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.ranking-rows strong { float: right; color: var(--red); white-space: nowrap; }
.ranking-rows small { display: block; color: var(--muted); }

dialog { width: min(100% - 32px,465px); background: var(--white); color: var(--ink); border: 1px solid var(--ink); padding: 16px; line-height: 1.65; }
dialog::backdrop { background: #211e1a83; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.rules-dialog { border-radius: 12px; border-color: var(--line); background: #fffdfa; }
.rules-dialog h2 { font-size: 1rem; }
.rules-dialog .icon-button { border-radius: 6px; }
.rules-example {
  margin: 0; padding: 12px 9px 10px; border-block: 1px solid var(--line); text-align: center;
}
.rules-example figcaption { display: flex; justify-content: center; align-items: baseline; gap: 9px; font-size: .83rem; font-weight: 750; }
.rules-example figcaption strong { color: var(--red-dark); font: 850 clamp(2.4rem,12vw,3.5rem)/1 var(--digits); letter-spacing: -.05em; }
.rules-example figcaption small { font-size: .44em; letter-spacing: 0; }
.rules-bar { position: relative; max-width: 250px; height: 53px; margin: 5px auto 1px; }
.rules-bar::before { content: ""; position: absolute; inset: 23px 4% auto; height: 7px; border-radius: 2px; background: #68675f; }
.rules-bar i { position: absolute; top: 5px; left: 29%; height: 43px; width: 10px; border-radius: 2px; background: var(--red); }
.rules-bar i + i { left: auto; right: 29%; }
.rules-equation { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 5px; font-size: .79rem; font-weight: 750; }
.rules-steps { display: grid; gap: 4px; margin: 10px 0 14px; padding: 0; list-style: none; font-size: .83rem; }
.rules-steps strong { display: inline-block; min-width: 3em; color: var(--red-dark); }

@media (max-width: 360px) {
  .app { width: calc(100% - 24px); }
  .panel { padding: 10px; }
  .home-actions .button { padding-inline: 5px; font-size: .86rem; }
}
