/* Pure Logic. Paper and ink: cream page, dark green ink (Hitori icon), red accent (Nurikabe Play button). */
:root {
  --paper: #f6f1e5;
  --card: #fffdf7;
  --ink: #1d3327;
  --muted: #5c6b61;
  --line: #ddd5c0;
  --accent: #b8402a;
  --accent-ink: #fff;
  --navy: #1b2d4f;
  --tint: #ece5d1;
  --ok: #2f6b3f;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14201a; --card: #1b2b22; --ink: #ece6d3; --muted: #a2b0a6; --line: #2d4036;
    --accent: #e0674d; --accent-ink: #1a0f0b; --navy: #9db6e6; --tint: #22362b; --ok: #7fc08f;
  }
  .appstore img { filter: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted, small { color: var(--muted); }
.hp { position: absolute; left: -9999px; }

/* Header */
.site-header { background: var(--ink); color: var(--paper); }
.site-header a { color: inherit; text-decoration: none; }
.header-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1.3rem var(--serif); }
.brand-mark { display: grid; grid-template-columns: repeat(3, 10px); gap: 2px; }
.brand-mark i { width: 10px; height: 10px; border-radius: 2px; background: #f6f1e5; opacity: .9; }
.brand-mark i.on { background: var(--accent); }
.main-nav { display: flex; gap: 4px 16px; flex-wrap: wrap; flex: 1; font-size: .95rem; }
.main-nav a { padding: 4px 0; opacity: .88; }
.main-nav a:hover { opacity: 1; text-decoration: underline; }
.site-header .search input[type=search] { padding: 6px 10px; border-radius: 6px; border: 1px solid #ffffff55; background: #ffffff1f; color: #f6f1e5; width: 150px; }
.search input::placeholder { color: #f6f1e5aa; }

/* Layout */
main.wrap { padding-top: 24px; padding-bottom: 48px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.hero { padding: 12px 0 24px; max-width: 760px; }
.hero h1 { font-size: 2.4rem; }
.hero p { font-size: 1.15rem; color: var(--muted); }
.section-title { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 28px 0 16px; }
.list-title { margin-bottom: 0; }

/* Cards */
.card { display: grid; grid-template-columns: 200px 1fr; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 18px; }
.card:not(:has(.card-img)) { grid-template-columns: 1fr; }
.card-img img { width: 100%; height: 100%; max-height: 190px; object-fit: cover; border-radius: 6px; display: block; background: var(--tint); }
.card h2 { font-size: 1.35rem; margin-bottom: .3em; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { color: var(--accent); }
.card p { margin: .3em 0; }
.meta { font-size: .85rem; color: var(--muted); margin: 0 0 .4em; }
.read-more { font-weight: 600; }
@media (max-width: 560px) { .card { grid-template-columns: 1fr; } }
.featured { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.feat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--ink); font: 600 1rem var(--serif); }
.feat img { width: 100%; height: 120px; object-fit: cover; display: block; background: var(--tint); }
.feat span { display: block; padding: 10px 12px; }
.feat:hover { border-color: var(--accent); }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 24px 0; }

/* Post */
.post h1 { font-size: 2.2rem; }
.hero-img { display: block; margin: 8px auto 20px; max-width: 100%; max-height: 360px; object-fit: contain; border-radius: 10px; background: var(--tint); }
.prose { font-size: 1.07rem; }
.prose h2 { margin-top: 1.8em; font-size: 1.5rem; }
.prose h3 { margin-top: 1.4em; }
.prose img, .prose figure svg { max-width: 100%; height: auto; }
.prose figure { margin: 1.4em 0; text-align: center; }
.prose figure.pair { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; align-items: flex-start; }
.prose figure.pair > div { flex: 0 1 260px; }
.prose figcaption { font-size: .88rem; color: var(--muted); margin-top: 6px; }
.prose blockquote { margin: 1.2em 0; padding: .2em 1em; border-left: 4px solid var(--accent); background: var(--tint); border-radius: 0 6px 6px 0; }
.prose table { border-collapse: collapse; margin: 1em 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.prose code { background: var(--tint); padding: 1px 5px; border-radius: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.tags a { background: var(--tint); color: var(--ink); text-decoration: none; padding: 2px 10px; border-radius: 999px; font-size: .85rem; }
.tags a:hover { background: var(--accent); color: var(--accent-ink); }
.prev-next { display: flex; justify-content: space-between; gap: 16px; margin: 32px 0; }
.prev-next a { flex: 1; text-decoration: none; font-family: var(--serif); font-weight: 600; }
.prev-next small { display: block; font-family: var(--sans); font-weight: 400; }
.prev-next .right { text-align: right; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment-body { white-space: pre-wrap; margin: .2em 0; }

/* Promos */
.side-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; }
.side-box h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border: 0; }
.plain small { display: block; }
.sidebar { position: sticky; top: 12px; }
@media (max-width: 860px) { .sidebar { position: static; } }
.appstore { display: inline-block; line-height: 0; }
.promo-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--tint); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; margin: 1.6em 0; font-size: .9rem; }
.promo-inline img { border-radius: 9px; }
.promo-inline div { flex: 1 1 220px; }
.promo-inline strong, .promo-inline span { display: block; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.game-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.game-card .shot { width: 100%; height: 260px; object-fit: cover; object-position: top; display: block; }
.game-card-body { padding: 16px; }
.game-head { display: flex; gap: 12px; align-items: center; }
.game-head img { border-radius: 13px; }
.game-head h2 { margin: 0; }

/* Forms and buttons */
.stack { display: grid; gap: 10px; }
.stack.narrow { max-width: 360px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
textarea { resize: vertical; }
.btn { display: inline-block; padding: 9px 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.1); color: var(--accent-ink); }
.btn.small { padding: 6px 14px; font-size: .85rem; }
.btn.secondary { background: var(--tint); color: var(--ink); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--tint); border: 1px solid var(--line); }
.flash.success { border-color: var(--ok); }
.flash.danger { border-color: var(--accent); }

/* Admin */
.admin-nav { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
button.link.danger { color: #b3261e; }
.pill { background: var(--tint); border-radius: 999px; padding: 1px 9px; font-size: .78rem; }
.pill.warn { background: #f2d9a0; color: #4a3500; }
.post-form label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.post-form label.inline, label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin-right: 14px; }
label.inline input { width: auto; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
.thumb { height: 60px; vertical-align: middle; border-radius: 4px; }
.editor-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.editor-tabs .tab { padding: 5px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; cursor: pointer; font: inherit; }
.editor-tabs .tab.active { background: var(--ink); color: var(--paper); }
.toolbar { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.toolbar button { padding: 4px 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 5px; cursor: pointer; font: .85rem var(--sans); }
#content { font: 15px/1.5 ui-monospace, Menlo, monospace; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 14px 18px; min-height: 300px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--muted); font-size: .85rem; }
.stats b { display: block; font: 700 1.8rem var(--serif); color: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bar { flex: 1; min-width: 4px; background: var(--accent); border-radius: 3px 3px 0 0; position: relative; min-height: 3px; }
.bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--muted); display: none; }
.bar:hover span { display: block; }
.tabs a { margin-right: 14px; }
.tabs a.on { font-weight: 700; color: var(--ink); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--tint); padding: 28px 0 12px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 600px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid ul { list-style: none; padding: 0; margin: 6px 0 0; }
.legal { color: var(--muted); font-size: .8rem; margin-top: 18px; }

/* Live practice boards (static/js/puzzles.js) */
.live-puzzle { max-width: 340px; margin: 1rem 0; }
.lp-board { display: grid; gap: 2px; background: var(--ink); border: 2px solid var(--ink); }
.lp-cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 0; background: var(--card); color: var(--ink);
  font: 600 1.25rem var(--serif); cursor: pointer; position: relative; }
.lp-cell:disabled { opacity: 1; cursor: default; }
.lp-cell[data-m="1"] { background: var(--ink); color: var(--card); }
.lp-hitori .lp-cell[data-m="2"]::after { content: ""; position: absolute; inset: 14%; border: 2px solid var(--accent); border-radius: 50%; }
.lp-nurikabe .lp-cell[data-m="1"], .lp-nurikabe .lp-clue[data-m="1"] { background: var(--ink); }
.lp-nurikabe .lp-clue { background: var(--tint); color: var(--ink); }
.lp-nurikabe .lp-cell[data-m="2"]::after, .lp-norinori .lp-cell[data-m="2"]::after { content: ""; position: absolute; left: 40%; top: 40%; width: 20%; height: 20%; border-radius: 50%; background: var(--accent); }
.lp-norinori .lp-cell[data-tint="0"] { background: #e8d9b8; } .lp-norinori .lp-cell[data-tint="1"] { background: #cfe0d2; }
.lp-norinori .lp-cell[data-tint="2"] { background: #d6dcee; } .lp-norinori .lp-cell[data-tint="3"] { background: #efd0c8; }
.lp-norinori .lp-cell[data-m="1"] { background: var(--accent); }
.lp-norinori .lp-cell { color: var(--ink); }
.lp-norinori .lp-cell { border: 0 solid var(--ink); }
.lp-eT { border-top-width: 3px !important; } .lp-eB { border-bottom-width: 3px !important; }
.lp-eL { border-left-width: 3px !important; } .lp-eR { border-right-width: 3px !important; }
.lp-bar { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.lp-status { font-weight: 600; color: var(--ok); }
.lp-hint { font-size: .9rem; margin: .4rem 0 0; }

/* Top banner: one phone per game, links to /games */

/* Low-key game links, topics page, search page, pager numbers, subtitle */
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font: 400 .72rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: inherit; opacity: .75; }
.side-box .more { font-size: .85rem; }
.side-box.quiet { background: transparent; }
.game-line a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.game-line img { border-radius: 9px; }
.game-line strong, .game-line small { display: block; line-height: 1.3; }
.topic-list { list-style: none; margin: 16px 0; padding: 0; columns: 2 220px; column-gap: 28px; }
.topic-list li { padding: 5px 0; break-inside: avoid; }
.search-page { display: flex; gap: 8px; margin: 12px 0; }
.search-page input[type=search] { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; }
.pager-pages { display: flex; gap: 10px; align-items: center; }
.pager-pages strong { background: var(--ink); color: var(--paper); border-radius: 6px; padding: 0 8px; }
.games-montage { display: block; margin: 0 auto 8px; max-width: 720px; width: 100%; height: auto; }

/* "Help me choose" question tree (static/js/chooser.js) */
.chooser { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin: 1.4em 0; }
.ch-step { margin: 0 0 .2em; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.ch-q, .ch-name { margin: 0 0 .6em; font-size: 1.35rem; }
.ch-answers { display: grid; gap: 10px; }
.ch-answer { text-align: left; border-radius: 10px; padding: 12px 16px; font-size: 1rem; line-height: 1.4; cursor: pointer; border: 1px solid var(--line); }
.ch-answer:hover { border-color: var(--accent); }
.ch-bar { display: flex; gap: 8px; margin-top: 14px; }
.ch-result { border-left: 5px solid var(--accent); padding-left: 14px; }

/* Puzzle of the Week */
.main-nav a.nav-pill { background: var(--accent); color: var(--accent-ink); opacity: 1; border-radius: 999px; padding: 4px 14px; font-weight: 600; }
.main-nav a.nav-pill:hover { filter: brightness(1.1); text-decoration: none; }
.weekly-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; margin: 1.2em 0; }
.weekly-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.weekly-card h2 { margin: 0 0 .1em; font-size: 1.4rem; }
.weekly-card .rules { font-size: .92rem; margin: .4em 0 .6em; }
.weekly-card .live-puzzle { margin: .6rem 0; }
.weekly-links { display: flex; justify-content: space-between; gap: 16px; margin: 24px 0; flex-wrap: wrap; }
.archive-list { list-style: none; margin: 16px 0; padding: 0; }
.archive-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.archive-list small { display: block; }
.week-dates { font: 700 1.3rem var(--serif); color: var(--accent) !important; margin-bottom: .2em; }
