:root {
  color-scheme: light;
  --ink: #171a1c;
  --muted: #5c6266;
  --wall: #e8e9e6;
  --panel: #d7d9d6;
  --line: #9b9e9d;
  --blue-pencil: #204f93;
  --signal: #b83228;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: #cfd1ce; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(30, 34, 36, .05) 1px, transparent 1px) 0 0 / 84px 100%,
    linear-gradient(var(--wall), #dfe1de);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

.ceiling-light {
  width: min(560px, 68vw);
  height: 15px;
  margin: 0 auto 40px;
  background: #fff;
  box-shadow: 0 0 32px 13px rgba(255, 255, 255, .78);
}

.shell {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 13px;
  border-bottom: 2px solid var(--ink);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.plan-badge {
  padding: 7px 10px;
  color: #e9ebea;
  background: #555b5c;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
}

.facility,
.result-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .2em;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .13em;
}

.room-number {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  font: 700 1.2rem/1 ui-monospace, monospace;
}

.test-console {
  padding: clamp(18px, 4vw, 34px);
  background: var(--panel);
  border: 1px solid #aeb1af;
  box-shadow: 0 18px 45px rgba(34, 38, 39, .16);
}

.status-row {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.status-row p { margin: 0; line-height: 1.65; }
.status-row > p:first-child { font-weight: 600; }
.counter { flex: 0 0 auto; color: var(--muted); font-size: .9rem; }
.counter strong { display: block; color: var(--ink); font: 700 1.15rem/1.4 ui-monospace, monospace; text-align: right; }

.vision-prep {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-left: 5px solid #34393a;
  background: #f4f5f2;
}

.vision-prep strong {
  display: block;
  margin-bottom: 5px;
  font-size: .82rem;
  letter-spacing: .08em;
}

.vision-prep p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.75;
}

.view-selector {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.view-selector legend {
  float: left;
  margin-right: 10px;
  padding: 10px 0;
  color: var(--muted);
  font-size: .88rem;
}

.view-selector label { cursor: pointer; }
.view-selector input { position: absolute; opacity: 0; }
.view-selector span {
  display: block;
  min-width: 74px;
  padding: 9px 15px;
  border: 1px solid #969a99;
  background: #e6e7e4;
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
}
.view-selector input:checked + span { color: white; background: #262a2c; border-color: #262a2c; }
.view-selector input:focus-visible + span { outline: 3px solid #2b69b1; outline-offset: 2px; }
.view-selector:disabled { opacity: .65; }

.premium-coach {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 1px;
  margin: 0 0 18px;
  background: #8f9493;
  border: 1px solid #8f9493;
}

.premium-coach > div,
.sound-switch {
  min-height: 66px;
  padding: 11px 14px;
  background: #eef0ed;
}

.premium-coach > div > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
}

.premium-coach strong {
  font-size: 1rem;
  letter-spacing: .04em;
}

.premium-coach strong b {
  display: inline-block;
  min-width: 2.1em;
  font: 800 1.35rem/1 ui-monospace, monospace;
  text-align: right;
}

.sound-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.sound-switch input { accent-color: #252a2b; }

.explanation-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 11px 14px;
  color: #34393a;
  background: #f7f8f5;
  font-size: .82rem;
  line-height: 1.65;
}

.inspection-unit {
  position: relative;
  min-height: 330px;
  padding: 34px clamp(14px, 4vw, 44px) 20px;
  background: #767b7c;
  border: 5px solid #454a4b;
  box-shadow: inset 0 0 0 2px #9da1a1, 0 5px 0 #303435;
}

.unit-label {
  position: absolute;
  top: 10px;
  left: 14px;
  color: #d8dada;
  font: 700 .67rem/1 ui-monospace, monospace;
  letter-spacing: .11em;
}

.eyepiece {
  display: grid;
  width: min(390px, 92%);
  min-height: 245px;
  margin: 8px auto 0;
  place-items: center;
  background: #303435;
  border: 2px solid #979b9b;
  border-radius: 24px;
  box-shadow: inset 0 0 0 8px #424748, inset 0 0 32px rgba(0,0,0,.72);
}

.view-window {
  position: relative;
  width: min(292px, 78vw);
  height: 110px;
  overflow: hidden;
  background: #e5e6e1;
  border: 8px solid #171a1b;
  border-radius: 9px;
  box-shadow: inset 0 0 28px rgba(26, 30, 31, .24), 0 0 0 2px #111;
}

.window-shade {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,.07) 76%, rgba(0,0,0,.22) 100%);
}

.rod {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 12px;
  height: auto;
  transform: translateX(-50%);
  background: #202223;
  border-radius: 0;
  box-shadow: inset 2px 0 rgba(255,255,255,.12), 1px 0 1px rgba(0,0,0,.2);
}

.rod.left { left: calc(50% - 81px); }
.rod.right { left: calc(50% + 81px); }
.rod.moving { left: 50%; will-change: transform; }

.view-guide {
  margin: 15px 0 0;
  color: white;
  font-size: .92rem;
  text-align: center;
  letter-spacing: .08em;
}

.warning {
  margin: 20px 0 0;
  padding: 15px 17px;
  color: #2a2100;
  background: #e7ca63;
  border-left: 5px solid #675200;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 14px;
  margin-top: 22px;
}

button { font: inherit; }

.start-button,
.response-button,
.retry-button {
  min-height: 64px;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.start-button { color: white; background: #2d3234; }
.response-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: white;
  background: var(--signal);
  box-shadow: inset 0 -5px rgba(0,0,0,.2);
}
.response-button span { font-size: 1.35rem; letter-spacing: .2em; }
.response-button small { font: 700 .7rem/1 ui-monospace, monospace; opacity: .72; }
.response-button:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -2px rgba(0,0,0,.2); }
.response-button:disabled { cursor: not-allowed; filter: grayscale(1); opacity: .35; }
.start-button:focus-visible, .response-button:focus-visible, .retry-button:focus-visible, footer button:focus-visible { outline: 3px solid #2b69b1; outline-offset: 3px; }

.system-message { min-height: 1.5em; margin: 14px 0 0; color: var(--muted); font-size: .9rem; text-align: center; }

.premium-offer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  margin-top: 24px;
  color: white;
  background: #202526;
  border: 1px solid #111516;
  box-shadow: 0 15px 36px rgba(35, 38, 37, .15);
}

.premium-offer__copy { padding: clamp(25px, 5vw, 42px); }
.premium-kicker { margin: 0 0 11px; color: #b9bebe; font-size: .75rem; font-weight: 800; letter-spacing: .2em; }
.premium-offer h2 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.25rem); letter-spacing: .08em; }
.premium-offer__copy > p:last-child { max-width: 580px; margin: 20px 0 0; color: #d3d7d6; font-size: .9rem; line-height: 1.9; }

.premium-price {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 25px;
  background: #15191a;
  border-left: 1px solid #4d5353;
}

.premium-price p { margin: 0; }
.premium-price strong { font: 800 3rem/1 ui-monospace, monospace; }
.premium-price p span { margin-left: 5px; font-size: .78rem; font-weight: 700; }
.premium-price small { margin-top: 8px; color: #abb0af; }
.premium-coming-soon { margin-top: 20px; padding: 13px 12px; color: #d4d8d7; border: 1px solid #626868; font-weight: 800; text-align: center; }

.result-sheet {
  position: relative;
  margin-top: 22px;
  padding: clamp(22px, 4vw, 38px);
  overflow: hidden;
  background: #f4f1e8;
  border: 1px solid #b9b5aa;
  box-shadow: 0 15px 36px rgba(35, 38, 37, .14);
}
.result-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(55, 70, 78, .08) 31px 32px);
}
.paper-mark { position: relative; color: #87847d; font-size: .72rem; letter-spacing: .2em; }
.result-main, .judgement-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.result-main { margin-top: 25px; }
.result-main h2 { margin: 0; font-size: 1.7rem; letter-spacing: .15em; }
.pencil-results { display: flex; gap: clamp(16px, 4vw, 34px); color: var(--blue-pencil); font: italic 700 clamp(1.55rem, 5vw, 2.3rem)/1.2 "Comic Sans MS", "Yu Gothic", cursive; transform: rotate(-1deg); }
.pencil-results span { min-width: 2.8em; padding-bottom: 3px; border-bottom: 2px solid rgba(32,79,147,.5); text-align: center; }
.judgement-row { margin-top: 30px; padding-top: 22px; border-top: 2px solid #aaa69b; }
.judgement-label { display: block; color: var(--muted); font-size: .8rem; }
.judgement-row strong { font-size: 1.75rem; letter-spacing: .15em; }
.judgement-row strong.pass { color: #1d5a3c; }
.judgement-row strong.fail { color: #992e28; }
.retry-button { min-height: 50px; padding: 0 22px; color: white; background: #34393b; }
.disclaimer { position: relative; margin: 22px 0 0; color: #66635c; font-size: .78rem; line-height: 1.7; }

.rules {
  margin-top: 24px;
  padding: clamp(24px, 5vw, 42px);
  background: #eceeeb;
  border: 1px solid #aeb1af;
  border-top: 6px solid var(--ink);
}

.rules-label {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .28em;
}

.rules h2 {
  margin: 0 0 28px;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: .12em;
}

.rules > p:not(.rules-label) {
  max-width: 680px;
  margin: 0 0 12px;
  font-size: 1rem;
  line-height: 1.9;
}

.rules .rules-standard {
  width: fit-content;
  margin-top: 25px;
  padding: 8px 12px;
  color: white;
  background: var(--ink);
  font-weight: 700;
  letter-spacing: .08em;
}

.test-purpose {
  max-width: 740px;
  margin-top: 34px;
  padding: 24px 0 4px;
  border-top: 1px solid #aeb1af;
}

.test-purpose .purpose-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .18em;
}

.test-purpose h3 {
  margin: 0 0 17px;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  line-height: 1.5;
  letter-spacing: .08em;
}

.rules .test-purpose > p:not(.purpose-label) {
  margin: 0 0 12px;
  font-size: .95rem;
  line-height: 1.9;
}

.rules .rules-end {
  margin-top: 28px;
  color: var(--muted);
  font-weight: 700;
}

.why-site {
  margin-top: 24px;
  padding: clamp(26px, 5vw, 48px);
  color: white;
  background: #303536;
  border: 1px solid #222627;
}

.why-site .rules-label { color: #abb0b0; }

.why-site > h2 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(1.65rem, 4.5vw, 2.6rem);
  line-height: 1.35;
  letter-spacing: .09em;
}

.why-lead {
  max-width: 720px;
  margin: 23px 0 0;
  color: #d7dada;
  line-height: 1.9;
}

.why-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 32px;
  border-top: 1px solid #737979;
  border-left: 1px solid #737979;
}

.why-grid article {
  padding: 22px 19px 24px;
  border-right: 1px solid #737979;
  border-bottom: 1px solid #737979;
}

.why-grid span { color: #939999; font: 700 .72rem/1 ui-monospace, monospace; }
.why-grid h3 { margin: 15px 0 12px; font-size: 1rem; letter-spacing: .06em; }
.why-grid p { margin: 0; color: #c8cccc; font-size: .84rem; line-height: 1.8; }
.why-note { margin: 23px 0 0; color: #aeb4b4; font-size: .78rem; line-height: 1.8; }

.scale {
  margin-top: 24px;
  padding: clamp(26px, 5vw, 48px);
  background: #f4f5f2;
  border: 1px solid #aeb1af;
}

.scale h2 {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 4.7rem);
  line-height: 1.05;
  letter-spacing: .04em;
}

.scale-lead {
  max-width: 700px;
  margin: 24px 0 0;
  font-size: 1rem;
  line-height: 1.9;
}

.number-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 34px;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}

.number-card {
  min-width: 0;
  padding: 22px 18px 20px;
  background: #e7e9e5;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.number-card--dark {
  color: white;
  background: var(--ink);
}

.number-card > span,
.number-card > em {
  display: block;
  min-height: 2.8em;
  font-size: .75rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: .06em;
}

.number-card > strong {
  display: block;
  margin-top: 14px;
  font: 800 clamp(1.35rem, 3.2vw, 2rem)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: -.05em;
  white-space: nowrap;
}

.number-card strong small {
  margin-left: 4px;
  font: 700 .7rem/1 "Yu Gothic", sans-serif;
  letter-spacing: 0;
}

.number-card > em {
  min-height: 0;
  margin-top: 9px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
}

.scale-note {
  max-width: 760px;
  margin: 27px 0 0;
  color: #4f5558;
  font-size: .86rem;
  line-height: 1.9;
}

.data-details {
  margin-top: 24px;
  border-top: 1px solid #9da19f;
  border-bottom: 1px solid #9da19f;
}

.data-details summary {
  padding: 16px 2px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .05em;
}

.data-details dl { margin: 0 0 18px; }
.data-details dl div { display: flex; justify-content: space-between; gap: 20px; padding: 8px 2px; border-top: 1px solid #d3d5d1; }
.data-details dt, .data-details dd { margin: 0; font-size: .84rem; }
.data-details dd { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-weight: 700; white-space: nowrap; }
.data-details .data-total { border-top: 2px solid var(--ink); font-weight: 800; }
.data-details > p { margin: 0 0 20px; color: var(--muted); font-size: .78rem; line-height: 1.8; }

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  font-size: .75rem;
  line-height: 1.6;
}

.sources span { color: var(--muted); font-weight: 700; }
.sources a { color: var(--ink); text-underline-offset: 3px; }

footer { width: min(880px, calc(100% - 32px)); margin: 28px auto 50px; color: #5b6061; font-size: .78rem; }
footer p { display: inline; margin: 0 20px 0 0; }
footer button { padding: 4px 0; color: #34393a; background: transparent; border: 0; border-bottom: 1px solid currentColor; cursor: pointer; }
#aboutPanel { max-width: 690px; margin-top: 15px; font-size: .86rem; line-height: 1.8; }
#aboutPanel p { display: block; margin: 0 0 10px; }
#aboutPanel .about-sources { margin-top: 14px; font-size: .78rem; }
#aboutPanel a { color: #34393a; text-underline-offset: 3px; }

@media (max-width: 620px) {
  .ceiling-light { margin-bottom: 25px; }
  .status-row { align-items: flex-start; }
  .status-row > p:first-child { font-size: .92rem; }
  .view-selector { flex-wrap: wrap; }
  .view-selector legend { width: 100%; padding: 0; }
  .view-selector span { min-width: 68px; }
  .header-status { gap: 7px; }
  .plan-badge { padding: 6px 7px; font-size: .62rem; }
  .premium-coach { grid-template-columns: 1fr 1fr; }
  .sound-switch { min-height: 48px; }
  .premium-offer { grid-template-columns: 1fr; }
  .premium-price { border-top: 1px solid #4d5353; border-left: 0; }
  .inspection-unit { min-height: 300px; }
  .eyepiece { min-height: 215px; }
  .view-window { width: min(250px, 76vw); height: 100px; }
  .rod.left { left: calc(50% - 68px); }
  .rod.right { left: calc(50% + 68px); }
  .controls { grid-template-columns: 1fr; }
  .response-button { min-height: 76px; grid-row: 1; }
  .result-main { align-items: flex-start; flex-direction: column; }
  .pencil-results { width: 100%; justify-content: space-between; gap: 8px; }
  .pencil-results span { min-width: 0; flex: 1; }
  .judgement-row { align-items: stretch; flex-direction: column; }
  .why-grid { grid-template-columns: 1fr; }
  .number-board { grid-template-columns: 1fr; }
  .number-card > span { min-height: 0; }
  .number-card > strong { font-size: clamp(1.55rem, 8vw, 2.15rem); }
  footer p { display: block; margin-bottom: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
