/* Daily Sudoku r3 — "puzzle editorial + real game UI".
   System fonts only, no external assets. Light / dark tokens; data-theme overrides the device. */

:root {
  --bg: #f7f5ef;
  --surface: #fffdf9;
  --surface-2: #f0ede4;
  --ink: #15211c;
  --ink-2: #4b5852;
  --line: #ddd8cc;
  --line-2: #c3bdae;
  --grid-thick: #22312b;
  --primary: #0e6b58;
  --primary-strong: #0a5546;
  --primary-ink: #ffffff;
  --primary-soft: #dcefe7;
  --sage: #e8eee4;
  --sage-2: #d3ddcf;
  --coral: #b5462f;
  --coral-ink: #ffffff;
  --coral-soft: #fbe4dc;
  --given-bg: #f1eee6;
  --sel: #c4e3d6;
  --peer: #f0f4ec;
  --same: #e2efe8;
  --area: #e6f1eb;
  --target-bg: #c6e7d9;
  --ev: #22312b;
  --focus: #0e6b58;
  --shadow: 0 1px 0 rgba(21, 33, 28, .04), 0 18px 40px -24px rgba(21, 33, 28, .35);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK KR", "Noto Sans CJK JP", "Noto Sans CJK SC", sans-serif;
  --font-display: "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1614; --surface: #161f1c; --surface-2: #1c2723; --ink: #e6ede8; --ink-2: #a8b6ae;
    --line: #2b3733; --line-2: #3d4b45; --grid-thick: #b8c7bf;
    --primary: #5ec9a8; --primary-strong: #8adcc1; --primary-ink: #06201a; --primary-soft: #183b31;
    --sage: #1c2824; --sage-2: #263530; --coral: #f2917b; --coral-ink: #2a0f08; --coral-soft: #3c221b;
    --given-bg: #1d2824; --sel: #285244; --peer: #1a2521; --same: #1f3a31; --area: #1a3129; --target-bg: #2d6a57;
    --ev: #d9e5df; --focus: #8adcc1; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1614; --surface: #161f1c; --surface-2: #1c2723; --ink: #e6ede8; --ink-2: #a8b6ae;
  --line: #2b3733; --line-2: #3d4b45; --grid-thick: #b8c7bf;
  --primary: #5ec9a8; --primary-strong: #8adcc1; --primary-ink: #06201a; --primary-soft: #183b31;
  --sage: #1c2824; --sage-2: #263530; --coral: #f2917b; --coral-ink: #2a0f08; --coral-soft: #3c221b;
  --given-bg: #1d2824; --sel: #285244; --peer: #1a2521; --same: #1f3a31; --area: #1a3129; --target-bg: #2d6a57;
  --ev: #d9e5df; --focus: #8adcc1; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.6;
  overflow-wrap: anywhere; -webkit-font-smoothing: antialiased;
}
:lang(ja) body, body:lang(ja) { font-family: "Hiragino Sans", "Yu Gothic UI", Meiryo, "Noto Sans JP", "Noto Sans CJK JP", var(--font-ui); }
:lang(ko) body, body:lang(ko) { font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", var(--font-ui); word-break: keep-all; }
:lang(zh-Hans) body, body:lang(zh-Hans) { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", var(--font-ui); }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0 0 1em; max-width: 68ch; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 10px 14px; z-index: 20; border-radius: var(--r-sm); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.hdr {
  max-width: 1180px; margin: 0 auto; padding: 8px 16px;
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav tools"; align-items: center; gap: 4px 20px;
}
.brand { grid-area: brand; display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.0625rem; min-height: 44px; }
.brand:hover { color: var(--ink); }
.logo { width: 32px; height: 32px; flex: none; }
.logo-bg { fill: var(--primary-soft); }
.logo-grid { stroke: var(--primary); stroke-width: 1.2; opacity: .45; fill: none; }
.logo-cell { fill: var(--primary); }
.logo-line { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 2.2 1.8; }
.logo-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.4; }
.site-nav { grid-area: nav; display: flex; flex-wrap: wrap; gap: 2px; }
.site-nav a {
  min-height: 44px; min-width: 44px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); text-decoration: none; border-radius: 999px; font-weight: 600; font-size: .9375rem;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--sage); }
.hdr-tools { grid-area: tools; display: flex; align-items: center; gap: 6px; }
.lang { position: relative; }
.lang summary {
  list-style: none; cursor: pointer; min-height: 44px; min-width: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font-weight: 600; font-size: .9375rem;
}
.lang summary::-webkit-details-marker { display: none; }
.lang summary:hover { background: var(--surface-2); }
.lang ul { position: absolute; right: 0; z-index: 30; margin: 6px 0 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 11rem; box-shadow: var(--shadow); }
.lang li a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink); }
.lang li a:hover { background: var(--surface-2); }
.lang li a[aria-current="true"] { font-weight: 700; background: var(--sage); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
@media (max-width: 759px) {
  .hdr { grid-template-columns: 1fr auto; grid-template-areas: "brand tools" "nav nav"; padding: 6px 12px 4px; }
  .site-nav { margin: 0 -6px; }
  .site-nav a { padding: 0 12px; font-size: .9063rem; }
}
@media (max-width: 479px) {
  .lang-name { display: none; }
  .lang summary { padding: 0; width: 44px; }
  .brand { font-size: 1rem; gap: 8px; }
}

/* ---------- layout ---------- */
.main { display: block; max-width: 1180px; margin: 0 auto; padding: 28px 16px 64px; }
.main:focus { outline: none; }
.page-title { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.4rem); }
:lang(en) .page-title, :lang(en) .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.012em; }
.lede { font-size: 1.125rem; color: var(--ink-2); max-width: 38em; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.foot { max-width: 1180px; margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-wrap: wrap; gap: 2px 28px; color: var(--ink-2); font-size: .875rem; }
.foot p { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: .9375rem; line-height: 1.2; min-height: 44px; min-width: 44px; padding: 8px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; text-decoration: none;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--primary-ink); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--coral); border-color: var(--coral); color: var(--coral-ink); }
.btn.big { min-height: 52px; padding: 10px 24px; font-size: 1.0625rem; border-radius: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- shared chips / notices ---------- */
.diff { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: .8125rem; font-weight: 700; border: 1.5px solid var(--ink-2); color: var(--ink); background: var(--surface); }
.diff[data-level="medium"] { border-style: dashed; }
.tag { display: inline-flex; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--sage); color: var(--ink); }
.notice { border-radius: var(--r-md); padding: 12px 14px; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); max-width: 640px; }
.notice.bad { border-left-color: var(--coral); background: var(--coral-soft); }
.empty { color: var(--ink-2); border: 1px dashed var(--line-2); border-radius: var(--r-md); padding: 14px 16px; margin: 0; }
progress { appearance: none; -webkit-appearance: none; width: 72px; height: 6px; border: 0; border-radius: 999px; background: var(--sage-2); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--sage-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

/* ---------- mini boards (preview, lessons, diagrams) ---------- */
.mboard { position: relative; width: 100%; aspect-ratio: 1 / 1; container-type: inline-size; border: 2px solid var(--grid-thick); border-radius: 12px; overflow: hidden; background: var(--surface); }
.mboard-lg { box-shadow: var(--shadow); }
.mgrid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); }
.mcell {
  position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; margin: 0; padding: 0;
  border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--primary);
  font: inherit; font-size: 5.6cqi; font-variant-numeric: tabular-nums; line-height: 1;
}
.mcell:nth-child(9n + 3), .mcell:nth-child(9n + 6) { border-right: 2px solid var(--grid-thick); }
.mcell:nth-child(9n) { border-right: 0; }
.mcell:nth-child(n + 19):nth-child(-n + 27), .mcell:nth-child(n + 46):nth-child(-n + 54) { border-bottom: 2px solid var(--grid-thick); }
.mcell:nth-child(n + 73) { border-bottom: 0; }
.mcell.given { background: var(--given-bg); color: var(--ink); font-weight: 700; }
.mcell.entry { color: var(--primary); font-weight: 500; }
.mcell.area { background: var(--area); }
.mcell.target { box-shadow: inset 0 0 0 3px var(--primary); background: var(--target-bg); }
.mcell.solved { color: var(--primary); font-weight: 800; }
.mcell.focus-cell { box-shadow: inset 0 0 0 2px var(--coral); }
.mcell.tried { background: var(--coral-soft); }
.mcell.u-row { background: var(--sage-2); }
.mcell.u-col { background: repeating-linear-gradient(135deg, var(--sage-2) 0 3px, var(--surface) 3px 7px); }
.mcell.u-box { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
button.mcell.choice { cursor: pointer; }
button.mcell.choice:hover:not([disabled]) { background: var(--sel); }
button.mcell.choice:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 0; z-index: 2; }
button.mcell.choice[disabled] { cursor: default; }
.evidence { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ev-line { stroke: var(--ev); stroke-width: 1.8; stroke-dasharray: 5 4; stroke-linecap: round; fill: none; }
.ev-blocker { fill: none; stroke: var(--ev); stroke-width: 2.2; }
.ev-x { stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round; fill: none; }
.ev-line.ev-focus { stroke: var(--coral); stroke-width: 2.6; stroke-dasharray: none; }
.ev-blocker.ev-focus { stroke: var(--coral); stroke-width: 2.8; }
.legend, .unit-key { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8125rem; color: var(--ink-2); }
.legend li, .unit-key li { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 18px; height: 18px; flex: none; border-radius: 4px; display: inline-block; position: relative; }
.sw-target { box-shadow: inset 0 0 0 3px var(--primary); background: var(--target-bg); }
.sw-area { background: var(--area); border: 1px solid var(--line-2); }
.sw-blocker { border: 2.2px solid var(--ev); border-radius: 50%; }
.sw-blocker::after { content: ""; position: absolute; left: 100%; top: 50%; width: 10px; border-top: 2px dashed var(--ev); }
.legend .sw-blocker { margin-right: 10px; }
.sw-x::before, .sw-x::after { content: ""; position: absolute; left: 3px; right: 3px; top: 8px; border-top: 2.2px solid var(--ink-2); transform: rotate(45deg); }
.sw-x::after { transform: rotate(-45deg); }
.sw-row { background: var(--sage-2); border: 1px solid var(--line-2); }
.sw-col { background: repeating-linear-gradient(135deg, var(--sage-2) 0 3px, var(--surface) 3px 7px); border: 1px solid var(--line-2); }
.sw-box { background: var(--primary-soft); border: 1px solid var(--primary); }

/* ---------- home ---------- */
.main-home { padding-top: 12px; }
.hero { display: grid; gap: 28px; padding: 20px 0 36px; align-items: center; }
.display { font-size: clamp(1.9rem, 1.1rem + 3.6vw, 3.25rem); line-height: 1.12; margin-bottom: .4em; max-width: 15em; }
:lang(ja) .display, :lang(ko) .display, :lang(zh-Hans) .display { line-height: 1.25; letter-spacing: -.02em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin: 22px 0 18px; }
.meta-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; color: var(--ink); font-size: .9375rem; }
.meta-list li { display: inline-flex; align-items: center; gap: 8px; }
.meta-list .icon { color: var(--ink-2); width: 18px; height: 18px; }
.hero-board { margin: 0; width: min(100%, 460px); justify-self: center; }
.preview-link { display: block; border-radius: 12px; }
.preview-cap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 10px 2px 0; font-size: .875rem; font-weight: 600; }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 64px; padding: 40px 0 56px; }
  .hero-board { justify-self: end; }
}
@media (max-width: 599px) {
  .hero { padding: 6px 0 28px; gap: 20px; }
  .lede-more { display: none; }
  .lede { font-size: 1.0625rem; margin-bottom: 0; }
  .hero-actions { margin: 16px 0 12px; }
  .hero-actions .btn.big, .hero-actions .btn.quiet { flex: 1 1 100%; }
  .hero-board { width: min(78%, 300px); }
}
.band { padding: 40px 0; border-top: 1px solid var(--line); }
.band-head { margin-bottom: 20px; }
.band-head p { margin-bottom: 0; }
.band-foot { margin: 18px 0 0; }
.band-foot a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; }
.history-grid { display: grid; gap: 28px; }
@media (min-width: 900px) { .history-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 48px; } }
.week { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 12px; min-height: 92px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none;
}
a.day:hover { border-color: var(--primary); color: var(--ink); }
span.day { background: transparent; border-style: dashed; }
.is-today .day { border: 2px solid var(--primary); }
.wd { font-size: .75rem; color: var(--ink-2); font-weight: 600; }
.dn { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.day-mark { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.day-mark .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.day-mark.is-done { background: var(--primary); color: var(--primary-ink); }
.day-mark.is-unreadable { color: var(--coral); }
.day-mark.is-unreadable .icon { width: 22px; height: 22px; stroke-width: 2; }
.ring { width: 26px; height: 26px; }
.ring-bg { fill: none; stroke: var(--line-2); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; }
.dash { width: 12px; border-top: 2px solid var(--line-2); }
.recent { list-style: none; margin: 0; padding: 0; }
.recent a { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 52px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.recent a:hover { background: var(--surface-2); }
.r-date { font-weight: 600; }
.r-detail { margin-left: auto; color: var(--ink-2); font-size: .875rem; font-variant-numeric: tabular-nums; }
.unfinished { margin-top: 22px; }
.flow { list-style: none; counter-reset: f; margin: 0; padding: 0; display: grid; gap: 14px; }
.flow li { counter-increment: f; display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: start; }
.flow li::before {
  content: counter(f); grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums;
}
.flow strong { display: block; }
.flow span { color: var(--ink-2); }
@media (min-width: 900px) { .flow { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; } }

/* ---------- practice / worked example ---------- */
.practice, .example { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 32px; align-items: start; }
.practice { padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.example { padding: 18px; border-radius: var(--r-lg); background: var(--surface-2); margin: 18px 0 8px; }
.practice-board, .example-board { width: min(100%, 340px); }
.practice.compact .practice-board { width: min(100%, 300px); }
@media (min-width: 760px) {
  .practice, .example { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); padding: 24px; }
  .practice.compact { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); }
}
@media (max-width: 759px) { .practice-board, .example-board { justify-self: center; } }
.question { font-weight: 700; font-size: 1.0625rem; }
.board-text { margin-top: 8px; font-size: .875rem; }
.board-text summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 600; }
.board-text summary::before { content: "▸"; margin-right: 8px; font-size: .8em; }
.board-text[open] summary::before { content: "▾"; }
.bt-cell { white-space: nowrap; }
.bt-body { padding: 4px 2px 6px; color: var(--ink); }
.bt-body p { margin: 0 0 6px; }
.bt-body ul { margin: 0 0 8px; padding-left: 1.2em; }
.bt-body li { font-variant-numeric: tabular-nums; }
.reason { font-size: 1.0625rem; }
.choice-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; max-width: 520px; margin: 4px 0 4px; }
.ckey {
  font: inherit; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 48px; min-width: 44px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; position: relative;
}
.ckey:hover:not([disabled]) { background: var(--sel); }
.ckey.is-wrong { background: var(--coral-soft); border-color: var(--coral); text-decoration: line-through; text-decoration-thickness: 2px; }
.ckey.is-correct { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.ckey[disabled]:not(.is-correct) { opacity: .5; cursor: default; }
.feedback:empty { display: none; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); border-left-width: 4px; background: var(--surface); }
.feedback[data-state="correct"] { border-left-color: var(--primary); background: var(--primary-soft); }
.feedback[data-state="wrong"] { border-left-color: var(--coral); background: var(--coral-soft); }
.feedback p { margin: 0; }
.feedback p + p { margin-top: 6px; }
.fb-head { display: flex; align-items: flex-start; gap: 8px; }
.fb-head .icon { margin-top: 3px; }
.lesson-after { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- guide ---------- */
.main-guide { max-width: 980px; }
.guide-lede { margin-bottom: 8px; }
.g-sec { padding: 32px 0; border-top: 1px solid var(--line); }
.g-sec:first-child { border-top: 0; }
.g-cols { display: grid; gap: 20px 40px; align-items: start; }
@media (min-width: 900px) { .g-cols { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); } }
.g-fig { margin: 0; max-width: 300px; }
.g-fig figcaption { margin-top: 8px; font-size: .875rem; color: var(--ink-2); }
.turn { margin: 26px 0 12px; }
.g-end { margin-top: 28px; }

/* ---------- play ---------- */
.main-daily { padding-top: 14px; padding-bottom: 40px; }
.play-title { font-size: 1.125rem; font-weight: 700; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.tag.utc { font-size: .75rem; padding: 1px 8px; }
.play { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .play { grid-template-columns: minmax(0, 560px) minmax(320px, 420px); gap: 36px; justify-content: center; align-items: start; }
  .main-daily .play-title { max-width: 1016px; margin-left: auto; margin-right: auto; }
}
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 10px; font-size: .9375rem; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item .icon { width: 18px; height: 18px; color: var(--ink-2); }
.meta-progress span { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .875rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.small-btn { min-height: 44px; padding: 6px 12px; margin-left: auto; }
.small-btn .ico { display: inline-flex; }
.board-wrap { position: relative; width: 100%; max-width: 560px; }
.board {
  width: 100%; aspect-ratio: 1 / 1; display: grid; grid-template-rows: repeat(9, 1fr);
  border: 2.5px solid var(--grid-thick); border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.board .row { display: grid; grid-template-columns: repeat(9, 1fr); }
.cell {
  position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: clamp(1.15rem, 5.6vw, 1.9rem); cursor: pointer; background: var(--surface); color: var(--primary); font-weight: 500;
}
.cell:nth-child(3n) { border-right: 2px solid var(--grid-thick); }
.cell:nth-child(9) { border-right: 0; }
.row:nth-child(3n) .cell { border-bottom: 2px solid var(--grid-thick); }
.row:nth-child(9) .cell { border-bottom: 0; }
.cell.given { background: var(--given-bg); color: var(--ink); font-weight: 700; }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.sel { background: var(--sel); }
.cell:focus { outline: none; }
.cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }
.cell.bad { color: var(--coral); background: repeating-linear-gradient(135deg, var(--coral-soft) 0 6px, var(--surface) 6px 9px); }
.cell.given.bad { background: repeating-linear-gradient(135deg, var(--coral-soft) 0 6px, var(--given-bg) 6px 9px); }
.cell.bad::after { content: ""; position: absolute; top: 2px; right: 2px; border: 5px solid transparent; border-top-color: var(--coral); border-right-color: var(--coral); }
.cell.h-area { background: var(--area); }
.cell.h-area.sel { background: var(--sel); }
.cell.h-target, .cell.h-target.sel { background: var(--target-bg); box-shadow: inset 0 0 0 3px var(--primary); }
.cell .v { line-height: 1; font-variant-numeric: tabular-nums; }
.notes-grid { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font-size: clamp(.55rem, 1.9vw, .75rem); color: var(--ink-2); line-height: 1; font-weight: 600; }
.notes-grid span { display: flex; align-items: center; justify-content: center; }
.board.notes-on { border-style: dashed; }
.paused-cover { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); border: 2.5px solid var(--grid-thick); border-radius: 12px; text-align: center; padding: 16px; }
.kbhelp { font-size: .8125rem; color: var(--ink-2); margin: 10px 0 0; max-width: 560px; }
@media (pointer: coarse) { .kbhelp { display: none; } }
@media (max-width: 599px) {
  .kbhelp { display: none; }
  .meta-row { gap: 6px 12px; }
  .meta-row .diff { order: 1; }
  .small-btn { order: 3; }
  .meta-progress { order: 4; }
  .timer-wrap { order: 5; margin-left: auto; }
  .main-daily { padding-top: 10px; }
  .play-title { font-size: 1rem; margin-bottom: 4px; }
}
.side, .controls, .dock { display: grid; gap: 10px; min-width: 0; align-content: start; }
.msg { margin: 0; }
.msg:empty { display: none; }
.msg:not(:empty) { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); font-size: .9375rem; }
.msg[data-kind="bad"]:not(:empty) { border-left-color: var(--coral); background: var(--coral-soft); }
.msg[data-kind="ok"]:not(:empty) { border-left-color: var(--primary); background: var(--primary-soft); }
.alert:empty { display: none; }
.alert { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--coral-soft); border: 1px solid var(--coral); font-size: .9375rem; }
.tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tool { min-height: 48px; padding: 6px 8px; font-size: .875rem; gap: 6px; }
.tool .lbl { line-height: 1.15; }
:lang(ja) .tool .lbl { white-space: nowrap; }
@media (max-width: 419px) { .tool { flex-direction: column; gap: 2px; min-height: 52px; padding: 4px; font-size: .8125rem; } }
.tool.toggle[aria-pressed="true"] { background: var(--primary-soft); border: 1.5px dashed var(--primary); }
.hint-btn[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); }
.pad { display: grid; grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 8px; }
.pad button {
  font: inherit; min-height: 52px; min-width: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.pad .pd { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.pad button:hover:not([disabled]) { background: var(--sel); }
.pad button[disabled] { opacity: .45; cursor: not-allowed; }
.pad .erase { color: var(--ink-2); font-size: .75rem; font-weight: 600; flex-direction: column; gap: 2px; }
.pad.notes-on button:not(.erase) { border-style: dashed; border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.pad.notes-on .pd { font-size: 1.05rem; align-self: flex-start; margin-top: 6px; }
.secondary { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.hint-panel { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--r-md); padding: 14px 16px; }
.hint-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hint-head .icon { color: var(--primary); }
.hint-head h2 { font-size: 1.0625rem; margin: 0; }
.step-label { margin-left: auto; color: var(--ink-2); font-size: .8125rem; font-weight: 600; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 10px; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; font-size: .8125rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.steps li::before { content: counter(s) " "; font-weight: 800; }
.steps li[aria-current="step"] { border-color: var(--primary); color: var(--ink); background: var(--primary-soft); font-weight: 700; }
.steps li.done { color: var(--ink); }
.hint-text { margin: 0 0 8px; }
.hint-reason { font-weight: 600; }
.hint-legend .legend { margin: 4px 0 6px; }
.why { margin: 4px 0 10px; }
.why summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 600; font-size: .9375rem; }
.blocked { margin: 4px 0 0; padding-left: 1.2em; color: var(--ink-2); font-size: .875rem; }
.confirm, .corrupt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; }
.corrupt { border-left: 4px solid var(--coral); }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.res-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.res-head h2 { margin: 0; font-size: 1.375rem; }
.res-head h2:focus { outline: none; }
.res-mark { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; }
.res-mark .icon { width: 22px; height: 22px; stroke-width: 2.6; }
.result dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 14px 0 16px; }
.result dt { color: var(--ink-2); }
.result dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.linkrow { margin: 14px 0 0; }
.linkrow label { display: block; font-size: .875rem; color: var(--ink-2); margin-bottom: 4px; }
.linkbox { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); min-height: 44px; }
.next { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 899px) {
  .dock.hinting .pad, .dock.hinting .tools, .dock.hinting .steps { display: none; }
  .hint-panel { padding: 12px 14px; }
}
.hint-actions { margin: 4px 0 6px; }

/* ---------- archive ---------- */
.archive-note { margin-bottom: 14px; }
.alist { list-style: none; margin: 0; padding: 0; max-width: 820px; }
.alist a { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "date status" "diff detail"; align-items: center; gap: 4px 12px; padding: 12px 6px; min-height: 56px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.alist a:hover { background: var(--surface-2); }
.a-date { grid-area: date; font-weight: 600; display: inline-flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.alist .diff { grid-area: diff; justify-self: start; }
.a-detail { grid-area: detail; color: var(--ink-2); font-size: .875rem; font-variant-numeric: tabular-nums; justify-self: end; }
.alist .status { grid-area: status; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .875rem; font-weight: 600; justify-self: end; }
.alist .status .icon { width: 16px; height: 16px; }
.alist .status[data-s="done"] { color: var(--primary); }
.alist .status[data-s="unreadable"] { color: var(--coral); }
@media (min-width: 760px) {
  .alist a { grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr) auto; grid-template-areas: "date diff detail status"; gap: 12px 20px; }
}

/* ---------- root / 404 ---------- */
.main-root { max-width: 760px; }
.root-brand .logo { width: 56px; height: 56px; margin-bottom: 14px; }
.choose { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 479px) { .choose { grid-template-columns: minmax(0, 1fr); } }
.choose a { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; min-height: 72px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); text-decoration: none; color: var(--ink); }
.choose a:hover { border-color: var(--primary); }
.choose .lname { font-size: 1.1875rem; font-weight: 700; }
.choose small { color: var(--ink-2); font-size: .875rem; }
.choose a.suggested { border: 2px solid var(--primary); background: var(--primary-soft); }
.empty-state { max-width: 560px; padding: 24px 0 8px; }
.empty-state .btn-row { margin-top: 22px; }
.empty-state .code { font-size: 4rem; line-height: 1; font-weight: 800; color: var(--line-2); margin: 0 0 8px; font-variant-numeric: tabular-nums; }

/* ---------- settings dialog ---------- */
.sheet { border: 0; padding: 0; width: min(460px, calc(100vw - 32px)); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(8, 16, 13, .5); }
.sheet-body { padding: 18px 20px 20px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.field { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.field legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: .9375rem; }
.opt:has(input:checked) { border: 2px solid var(--primary); background: var(--primary-soft); }
.opt input, .switch input { accent-color: var(--primary); width: 18px; height: 18px; margin: 0; flex: none; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; cursor: pointer; }
.field .small { margin: 0; }
@media (max-width: 599px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .seg { grid-template-columns: 1fr; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .cell, .mcell, .btn, .pad button, .ckey { transition: background-color .12s ease, border-color .12s ease; }
  .evidence > * { animation: ev-in .28s ease-out both; }
  @keyframes ev-in { from { opacity: 0; } to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
