:root { font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif; color: #17364e; --blue: #2f5fb7; --good: #17835f; --bad: #c2405a; --line: #c3d2e0; }
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(#f2f8ff, #fff 42%); }
.lab { width: min(100%, 720px); margin: auto; padding: 12px max(12px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.eyebrow { margin: 0 0 3px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0 0 6px; font-size: 21px; }
.lead { margin: 0 0 10px; color: #5a6b83; font-size: 13px; line-height: 1.55; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1 1 0; min-height: 44px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #17364e; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.tabs button.active { border-color: var(--blue); color: #fff; background: var(--blue); }

.panel { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.panel label { display: grid; gap: 4px; color: #61728a; font-size: 12px; font-weight: 700; }
.panel output { color: var(--blue); font-size: 15px; font-weight: 800; }
input[type="range"] { width: 100%; min-height: 44px; background: transparent; -webkit-appearance: none; appearance: none; accent-color: var(--blue); touch-action: manipulation; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -11px; border: 3px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 1px 4px #17384b55; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 1px 4px #17384b55; cursor: pointer; }
.question { margin: 0; color: #61728a; font-size: 12px; font-weight: 700; }
.formula { margin: 4px 0 6px; font-size: 26px; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.guide { margin: 0; color: #55657d; font-size: 13px; line-height: 1.6; }

.stage { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.area { display: grid; width: min(100%, 300px); margin: 0 auto; aspect-ratio: 1; gap: 3px; }
.cell { display: grid; place-items: center; border-radius: 6px; font-size: 15px; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cell.sq { background: #cfe0f6; color: #1c4482; }
.cell.side { background: #ddeccf; color: #40631f; }
.cell.corner { background: #fbe3c4; color: #8a5a14; }
.edges { display: flex; justify-content: center; gap: 16px; margin-top: 9px; color: #61728a; font-size: 12px; font-weight: 700; }

.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px; }
.cand { display: grid; gap: 2px; min-height: 58px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #17364e; font: inherit; cursor: pointer; text-align: left; touch-action: manipulation; }
.cand .pair { font-size: 15px; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cand .sums { color: #7a889e; font-size: 11px; }
.cand.correct { border-color: var(--good); background: #e4f6ee; }
.cand.correct .pair { color: #0d5c42; }
.cand.wrong { border-color: var(--bad); background: #fdeef1; }
.cand.wrong .pair { color: #8e2438; }

.result { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.value-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 5px 0; border-bottom: 1px dashed #e2e9f2; }
.value-row:last-of-type { border-bottom: 0; }
.value-row span { min-width: 92px; color: #61728a; font-size: 12px; font-weight: 700; }
.value-row b { font-size: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.value-row b.answer { color: var(--blue); font-size: 21px; }
.note { margin: 8px 0 0; color: #55657d; font-size: 12.5px; line-height: 1.7; }
.note.hint { padding: 8px 10px; border-radius: 9px; background: #fff6e2; color: #7a5a12; }
.warn { margin: 0; color: #8e2438; font-size: 13px; font-weight: 700; line-height: 1.6; }
.actions { margin-top: 10px; }
.actions button { width: 100%; min-height: 44px; border: 0; border-radius: 11px; background: var(--blue); color: #fff; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }

@media (max-width: 420px) {
  h1 { font-size: 19px; }
  .formula { font-size: 22px; }
  .cell { font-size: 13px; }
  .value-row b.answer { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
