:root {
  color-scheme: dark;
  --ink: #f4f1e6;
  --muted: #bac8c6;
  --page: #121b1e;
  --panel: #1d292d;
  --line: #46595c;
  --tape: #ffca79;
  --green: #a9e3bd;
  --red: #ffb8a5;
  font-family: Inter, "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; color: var(--ink); background: radial-gradient(ellipse at 50% 0%, #25383b, var(--page) 56%); }
button, input { font: inherit; }
button, summary { cursor: pointer; touch-action: manipulation; }
button { min-height: 44px; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
section[tabindex]:focus { outline: none; }
h1, h2, p, figure { margin: 0; }
.app {
  max-width: 1040px;
  margin: auto;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.cover {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "copy art";
  align-items: center;
  gap: 28px;
  margin-top: clamp(12px, 9vh, 106px);
  padding: clamp(18px, 4.5vw, 46px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 24px 80px #08111460;
}
.cover-image { grid-area: art; }
.cover-copy { grid-area: copy; }
.cover-art { display: block; width: 100%; height: auto; }
.cover h1 { font-size: clamp(40px, 7vw, 78px); line-height: 1.13; letter-spacing: -.065em; }
.cover-copy > p { margin: 16px 0 22px; color: var(--muted); line-height: 1.7; }
.primary {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--tape);
  color: #211709;
  font-weight: 800;
  text-align: left;
}
.primary span { font-size: 1.25em; line-height: 1; }
.primary:disabled { border-color: var(--line); background: #27373a; color: var(--muted); cursor: default; }
.primary:not(:disabled):active { transform: translateY(1px); }
.guide { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.guide > summary { padding: 11px 3px; min-height: 44px; color: var(--ink); font-weight: 650; }
.guide > ol { padding-left: 1.35em; margin: 5px 0 8px; }
.guide > p { padding-bottom: 5px; }
.game-header, .brand, .progress { display: flex; align-items: center; }
.game-header { justify-content: space-between; gap: 10px; min-height: 46px; margin-bottom: 18px; }
.brand { gap: 7px; font-weight: 800; white-space: nowrap; }
.brand svg, .size svg { width: 22px; height: 22px; color: var(--tape); }
.progress { gap: 9px; white-space: nowrap; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.progress-bars { display: flex; gap: 3px; }
.progress-bars i { display: block; width: 13px; height: 4px; border-radius: 4px; background: var(--line); }
.progress-bars .current { background: var(--tape); }
.progress-bars .ok { background: var(--green); }
.progress-bars .miss { background: var(--red); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.observation { min-width: 0; }
.observation h2 { margin: 0 0 9px 3px; font-size: clamp(19px, 4vw, 27px); line-height: 1.35; }
.stage {
  overflow: hidden;
  border: 1px solid #82938b;
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 10%, #f7f1e2, #e9dfc8 86%);
  color: #37494b;
}
.stage svg { display: block; width: 100%; height: auto; }
.stage figcaption {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 12px 8px;
  font-size: 12px;
  font-weight: 750;
}
.views { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 8px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.views button { min-width: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 750; }
.views button[aria-pressed="true"] { background: #40585a; color: #fffaf0; }
.controls { margin-top: 38px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); min-width: 0; }
.controls h2 { margin-bottom: 10px; font-size: 18px; }
.sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
.size {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #27363a;
  color: var(--ink);
  font-size: clamp(18px, 4.9vw, 25px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.size svg { width: 17px; height: 17px; }
.size[aria-pressed="true"] { background: var(--tape); border-color: var(--tape); color: #211709; }
.size[aria-pressed="true"] svg { color: #5d3915; }
.catalog { margin-top: 5px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; text-align: center; }
table caption { color: var(--muted); text-align: left; padding-bottom: 5px; }
th, td { padding: 7px 3px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th:first-child { width: 49px; }
th { color: var(--ink); }
td { font-variant-numeric: tabular-nums; }
.verdict { display: flex; align-items: center; min-height: 43px; gap: 9px; font-size: 23px; font-weight: 850; }
.verdict b { display: grid; place-items: center; width: 36px; height: 36px; border: 2px solid currentColor; border-radius: 50%; font-size: 20px; }
.verdict.ok { color: var(--green); }
.verdict.miss { color: var(--red); }
.comparison { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; margin: 11px 0 7px; }
.comparison > span { text-align: center; color: var(--muted); }
.comparison div { padding: 7px 9px; background: #28383c; border-radius: 10px; font-size: 12px; color: var(--muted); }
.comparison strong { display: block; font-size: 27px; color: var(--ink); line-height: 1.25; font-variant-numeric: tabular-nums; }
.measurement { color: var(--muted); font-size: 13px; line-height: 1.55; margin-bottom: 10px; }
#why p { padding: 4px 0; border-bottom: 1px solid var(--line); }
#why h3 { font-size: 14px; color: var(--ink); margin: 9px 0 2px; }
#next { margin-top: 12px; }
.finish { max-width: 600px; margin: auto; }
.finish-header { border: 1px solid var(--line); border-radius: 20px; padding: 20px; background: var(--panel); text-align: center; }
.finish-header h2 { font-size: 20px; }
.score { font-size: 26px; color: var(--muted); font-variant-numeric: tabular-nums; }
.score strong { font-size: clamp(49px, 13vw, 86px); line-height: 1.1; color: var(--tape); }
.marks { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.marks b, .results b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #293a3d; }
.mark-ok { color: var(--green); }
.mark-miss { color: var(--red); }
.results { margin: 12px 0; padding: 0; list-style: none; }
.results li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.results small { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.replay-parcel { animation: pack .68s cubic-bezier(.19,.72,.31,1) both; }
@keyframes pack { from { transform: translateY(var(--start)); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .replay-parcel { animation: none; } }
@media (hover: hover) {
  .size[aria-pressed="false"]:hover, .views button:hover { border-color: var(--muted); background: #35484b; }
  .primary:not(:disabled):hover { background: #ffda9d; }
}
@media (max-width: 660px) {
  .app { padding-top: max(13px, env(safe-area-inset-top)); }
  .cover { grid-template-columns: 1fr; grid-template-areas: "art" "copy"; margin-top: 3px; gap: 13px; }
  .cover-art { max-height: 246px; }
  .cover h1 { font-size: clamp(34px, 10vw, 58px); }
  .cover-copy > p { margin: 9px 0 13px; }
  .game-header { margin-bottom: 8px; }
  .workspace { grid-template-columns: 1fr; gap: 10px; }
  .controls { margin-top: 0; padding: 11px; }
  .controls h2 { margin-bottom: 7px; }
  .size { min-height: 51px; }
}
@media (max-width: 365px) {
  .app { padding-right: max(11px, env(safe-area-inset-right)); padding-left: max(11px, env(safe-area-inset-left)); }
  .progress-bars i { width: 8px; }
  .results li { gap: 6px; }
}

/* --- v2 additions --- */
.best { margin-top: 12px; color: var(--tape); font-size: 14px; font-weight: 700; }
.size { position: relative; }
.size kbd { display: none; position: absolute; top: 4px; right: 6px; font-family: inherit; font-size: 10px; font-weight: 600; line-height: 1; color: var(--muted); opacity: .8; }
@media (hover: hover) and (pointer: fine) { .size kbd { display: block; } }
.size[aria-pressed="true"] kbd { color: #5d3915; }
.verdict span { flex: 1; min-width: 0; }
.verdict em { font-style: normal; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.verdict.near { color: var(--tape); }
.progress-bars .near { background: var(--tape); opacity: .75; }
.mark-near { color: var(--tape); }
.rank { margin-top: 4px; font-size: 20px; font-weight: 800; }
.record { min-height: 1.4em; margin-top: 4px; color: var(--tape); font-size: 14px; font-weight: 700; }
.results li > span small { display: block; color: var(--muted); font-size: 12px; text-align: left; }
.share { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.secondary {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 11px; background: #27363a; color: var(--ink);
  font-weight: 750; text-decoration: none;
}
@media (hover: hover) { .secondary:hover { background: #35484b; border-color: var(--muted); } }
.share-status { min-height: 1.4em; margin-bottom: 8px; color: var(--green); font-size: 13px; text-align: center; }
.noscript { padding: 24px; text-align: center; }
