/* Gridkoi public site. Brand tokens: brand/README.md. System fonts only (no third-party requests). */
:root {
  --pond: #0E2C36; --kohaku: #EF4B2A; --rice: #F4F6F3; --ogon: #F2B33D; --ink: #10161B;
  --bg: #F4F6F3; --surface: #FFFFFF; --text: #10161B; --muted: #55666B; --line: #D5DEDE; --line-strong: #7E9298;
  --cell: #FFFFFF; --fill: #0E2C36; --x: #8A9BA0; --given: #E7EEEE;
  --hint: rgba(242, 179, 61, .28); --hint-strong: #A36F06; --error: #B3261E; --error-bg: rgba(179, 38, 30, .12);
  --ok: #1D7A57; --disc: #0E2C36; --ring: #EF4B2A; --link: #B8381D;
  --f: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B2229; --surface: #0E2C36; --text: #F4F6F3; --muted: #A9BCBE; --line: #24505C; --line-strong: #6F8D95;
    --cell: #123843; --fill: #F4F6F3; --x: #7E9AA1; --given: #1A4652; --hint: rgba(242, 179, 61, .22); --hint-strong: #F2B33D;
    --error: #FF8A80; --error-bg: rgba(255, 138, 128, .16); --ok: #5FD3A5; --disc: #F4F6F3; --ring: #F26A4B; --link: #FF9A80;
    color-scheme: dark;
  }
  .logo .word { filter: invert(1) hue-rotate(180deg); }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--f); font-size: 16px; line-height: 1.6; }
button { font: inherit; color: inherit; }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--ogon); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 9; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; }
code { background: var(--given); padding: 1px 6px; border-radius: 6px; font-size: .92em; }

/* header + footer */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo img { display: block; }
.top nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.top nav a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 10px; border-radius: 9px; }
.top nav a:hover { background: var(--bg); }
.top nav a.on { background: var(--hint); }
@media (max-width: 520px) { .logo .word { display: none; } .top-in { gap: 8px; } .top nav a { padding: 8px 7px; font-size: 14px; } }
.crumbs { font-size: 13px; color: var(--muted); padding-top: 12px; }
.crumbs a { color: var(--muted); }
main { padding-bottom: 48px; }
.foot { border-top: 1px solid var(--line); background: var(--surface); font-size: 14px; color: var(--muted); }
.foot-in { display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap; padding-top: 18px; padding-bottom: 22px; }
.foot p { margin: 0; max-width: 60ch; }
.foot nav { display: flex; gap: 14px; }
.foot a { color: var(--muted); }

/* content */
h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin: 18px 0 10px; letter-spacing: -.01em; }
h2 { font-size: 22px; line-height: 1.25; margin: 34px 0 10px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.lead { font-size: 18px; color: var(--muted); max-width: 66ch; margin: 0 0 14px; }
.page-head { padding: 6px 0 4px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--hint-strong); margin: 26px 0 0; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 11px; padding: 11px 18px; font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--line-strong); }
.btn.pri { background: var(--kohaku); border-color: var(--kohaku); color: var(--ink); }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 32px; align-items: center; padding: 10px 0 8px; }
.hero-mark { width: 100%; height: auto; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } .hero-mark { display: none; } }
.today-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.card { display: grid; gap: 4px; padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.card:hover { border-color: var(--line-strong); }
.card .kind { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--hint-strong); }
.card .t { font-size: 19px; font-weight: 700; }
.card .meta { font-size: 14px; color: var(--muted); }
.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.cols3 > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.cols3 p { margin: 0; color: var(--muted); font-size: 15px; }
.defs dl { margin: 0; display: grid; gap: 6px; max-width: 72ch; }
.defs dt { font-weight: 700; margin-top: 8px; }
.defs dd { margin: 0; color: var(--muted); }
.rules { padding-left: 22px; max-width: 72ch; } .rules li { margin: 6px 0; }
.links { padding-left: 20px; } .links li { margin: 4px 0; }
.grades { list-style: none; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.lvl { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--given); }
.lvl.g3 { background: var(--hint); } .lvl.g4, .lvl.g5 { background: var(--error-bg); }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 8px 0; max-width: 72ch; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.archive { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.archive a { display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 600; }
.below { max-width: 72ch; }
details.inline { display: inline; } details.inline summary { display: inline; cursor: pointer; color: var(--link); }

/* game */
.game { margin: 18px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.game-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.game-tabs button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 14px; cursor: pointer; }
.game-tabs button[aria-selected="true"] { background: var(--pond); color: var(--rice); border-color: var(--pond); }
@media (prefers-color-scheme: dark) { .game-tabs button[aria-selected="true"] { background: var(--rice); color: var(--pond); } }
.game-tabs .done::after { content: " ✓"; color: var(--ok); }
.game-tabs .num { min-width: 42px; padding: 8px 10px; }
.game-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .game-body { grid-template-columns: 1fr; } }
.board-wrap { display: grid; place-items: center; min-width: 0; overflow-x: auto; padding: 4px; min-height: 200px; }
.panel { display: grid; gap: 10px; align-content: start; }
.status { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); gap: 8px; }
.status .state { font-weight: 600; text-align: right; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); font-size: 18px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.seg button { border: 0; background: transparent; padding: 9px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.btns button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 2px; cursor: pointer; font-size: 13px; font-weight: 700; }
.btns button:disabled { opacity: .45; cursor: default; }
.hint-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.hint-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint-btn { border: 0; background: var(--ogon); color: var(--ink); font-weight: 800; padding: 10px 18px; border-radius: 10px; cursor: pointer; }
.ladder { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; font-size: 11px; color: var(--muted); }
.ladder li { padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); }
.ladder li.on { background: var(--hint); color: var(--text); border-color: transparent; font-weight: 700; }
.hint-diagram { margin-top: 8px; display: grid; gap: 4px; }
.msg { margin: 0; font-size: 14.5px; min-height: 2.4em; }
.msg.err { color: var(--error); font-weight: 600; }
.msg.ok { color: var(--ok); font-weight: 600; }
.win { background: var(--bg); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.win h2 { margin: 0; font-size: 20px; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); font-size: 16px; display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { padding: 9px 14px; font-size: 14px; }
.replay-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.replay-bar .pos { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.share-text { width: 100%; font: 13px/1.4 ui-monospace, Consolas, monospace; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: none; }

/* board */
.board { --c: 32px; display: inline-grid; user-select: none; -webkit-user-select: none; touch-action: none; font-variant-numeric: tabular-nums; }
.cell { width: var(--c); height: var(--c); border: 0; padding: 0; margin: 0; background: var(--cell); position: relative; cursor: pointer;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; place-items: center; }
.cell:focus-visible { outline: 3px solid var(--ogon); outline-offset: -3px; z-index: 2; }
.cell.l0 { border-left: 2px solid var(--line-strong); } .cell.t0 { border-top: 2px solid var(--line-strong); }
.cell.r5 { border-right: 2px solid var(--line-strong); } .cell.b5 { border-bottom: 2px solid var(--line-strong); }
.cell.f { background: var(--fill); }
.cell.x::before, .cell.x::after { content: ""; position: absolute; width: 46%; height: 2px; background: var(--x); transform: rotate(45deg); }
.cell.x::after { transform: rotate(-45deg); }
.cell.scope { box-shadow: inset 0 0 0 999px var(--hint); }
.cell.f.scope { box-shadow: inset 0 0 0 3px var(--hint-strong); }
.cell.ev { outline: 2px dashed var(--hint-strong); outline-offset: -4px; }
.cell.tg::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: var(--hint-strong); animation: pulse 1.2s ease-in-out infinite; }
.board .cell.wrong { box-shadow: inset 0 0 0 3px var(--error); outline: 2px solid var(--error); outline-offset: -1px; z-index: 1; }
.cell.warn { background-image: repeating-linear-gradient(45deg, var(--error-bg) 0 4px, transparent 4px 8px); }
@keyframes pulse { 50% { transform: scale(1.35); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .cell.tg::after { animation: none; } * { transition: none !important; } }
.clue { display: flex; align-items: flex-end; justify-content: center; gap: 1px; font-size: calc(var(--c) * .42); font-weight: 600; color: var(--text); }
.clue.col { flex-direction: column; padding-bottom: 4px; line-height: 1.15; }
.clue.row { justify-content: flex-end; align-items: center; padding-right: 6px; gap: calc(var(--c) * .26); white-space: nowrap; }
.clue.done { color: var(--muted); opacity: .45; }
.clue.scope { background: var(--hint); border-radius: 6px; }
/* takuzu */
.board.tk .cell { border-radius: 0; }
.tk .cell.given { background: var(--given); cursor: default; }
.tk .sym { width: 58%; height: 58%; border-radius: 50%; display: block; }
.tk .s0 { background: var(--disc); }
.tk .s1 { border: calc(var(--c) * .11) solid var(--ring); }
.tk .count { font-size: 10.5px; color: var(--muted); display: grid; place-items: center; line-height: 1.1; text-align: center; }
.tk .count.bad { color: var(--error); font-weight: 700; }
.solved .cell { cursor: default; }
.solved.ng .cell { border-color: transparent; transition: border-color .6s; }

/* hint diagrams */
.dline { display: grid; grid-template-columns: 74px auto; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.dcells { display: flex; }
.dc { width: 18px; height: 18px; border: 1px solid var(--line); background: var(--cell); margin-right: -1px; position: relative; display: grid; place-items: center; }
.dc.f { background: var(--fill); } .dc.e::after { content: "·"; color: var(--x); }
.dc.hl { box-shadow: inset 0 0 0 2px var(--hint-strong); } .dc.ev { outline: 2px dashed var(--hint-strong); outline-offset: -3px; }
.dc .sym { width: 62%; height: 62%; border-radius: 50%; } .dc .s0 { background: var(--disc); } .dc .s1 { border: 2px solid var(--ring); }
.dline.excl .dcells { opacity: .45; text-decoration: line-through; }
.dnote { font-size: 11.5px; color: var(--muted); }


/* learning pages (Step 4B): diagrams are tables, readable without CSS */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.byline { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.byline a { color: var(--muted); }
.learn section, .learn .page-head { max-width: 76ch; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.tech-list { padding-left: 22px; max-width: 76ch; }
.tech-list h2 { font-size: 19px; margin: 22px 0 4px; }
.tech-list p { margin: 4px 0; }
.dg { margin: 14px 0; overflow-x: auto; position: relative; } /* keeps the visually-hidden labels inside the scroll box */
.dg figcaption { font-size: 13.5px; color: var(--muted); padding-top: 8px; max-width: 64ch; }
.dgrid, .dline { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dgrid td, .dline td { width: 26px; height: 26px; min-width: 26px; padding: 0; text-align: center; vertical-align: middle; border: 1px solid var(--line); background: var(--cell); font-size: 15px; line-height: 1; color: var(--muted); }
.dgrid.w15 td, .dgrid.w14 td, .dgrid.w13 td, .dgrid.w12 td { width: 22px; height: 22px; min-width: 22px; font-size: 13px; }
.dgrid td.f, .dline td.f { background: var(--fill); color: var(--fill); }
.dgrid td.x, .dline td.x { color: var(--x); font-size: 12px; }
.dgrid td.d, .dline td.d { color: var(--disc); font-size: 24px; }
.dgrid td.o, .dline td.o { color: var(--ring); font-size: 22px; font-weight: 700; }
.dgrid td.g { background: var(--given); }
.dgrid td.ln { box-shadow: inset 0 0 0 999px var(--hint); }
.dgrid td.f.ln { box-shadow: inset 0 0 0 3px var(--hint-strong); }
.dgrid td.tg, .dline td.tg { outline: 3px solid var(--hint-strong); outline-offset: -3px; font-weight: 700; }
.dgrid td.tg:not(.d):not(.o):not(.f):not(.x) { color: var(--text); }
.dgrid td.ev, .dline td.ev { outline: 2px dashed var(--kohaku); outline-offset: -4px; }
.dgrid th { font-size: 11.5px; font-weight: 600; color: var(--text); padding: 0 3px; }
.dgrid th.cc { vertical-align: bottom; line-height: 1.15; padding-bottom: 3px; }
.dgrid th.rc { text-align: right; white-space: nowrap; padding-right: 6px; }
.dgrid th.hl { background: var(--hint); }
.dline th { font-size: 12.5px; font-weight: 600; text-align: right; padding-right: 10px; white-space: nowrap; }
.dline th.num { font-size: 11px; color: var(--muted); text-align: center; padding: 0 0 3px; font-weight: 400; }
.dline tr.other td { opacity: .55; }
.example { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 4px 16px 10px; margin: 14px 0; }
.example h3 { margin: 12px 0 2px; }
.example .muted { margin: 0; font-size: 14px; }
.note-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 18px 8px; }
.spoiler > summary { cursor: pointer; font-weight: 700; color: var(--link); margin: 8px 0; }
.hint-box .learn-link { font-size: 13.5px; display: inline-block; margin-top: 6px; }
@media print { .top, .foot, .game { display: none; } }
