/* Gridnine: original sudoku look in the Chicon palette. Selection, same digits and conflicts never rely on colour alone
   (conflicts get a wavy underline and a corner marker; givens are bold on a tinted tile; selection has an outline). */
:root {
  --gn-tile: #fffdf4; --gn-given: #fff1bf; --gn-peer: #fff0c2; --gn-same: #ffd966; --gn-sel: #ffc933; --gn-line: #e6d3a0; --gn-box: #3b2a4a;
  --gn-user: #19679f; --gn-given-ink: #2b2036; --gn-bad: #b3261e; --gn-bad-bg: #ffd9d2; --gn-note: #6a5d78;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --gn-tile: #251a3d; --gn-given: #392a58; --gn-peer: #30244d; --gn-same: #5a4690; --gn-sel: #7a5fc0; --gn-line: #433563; --gn-box: #cdbfe8;
  --gn-user: #78c4ff; --gn-given-ink: #fff4e0; --gn-bad: #ff9a8a; --gn-bad-bg: #5a2a35; --gn-note: #c5b8dc;
} }
:root[data-theme="dark"] {
  --gn-tile: #251a3d; --gn-given: #392a58; --gn-peer: #30244d; --gn-same: #5a4690; --gn-sel: #7a5fc0; --gn-line: #433563; --gn-box: #cdbfe8;
  --gn-user: #78c4ff; --gn-given-ink: #fff4e0; --gn-bad: #ff9a8a; --gn-bad-bg: #5a2a35; --gn-note: #c5b8dc;
}

.gn-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.gn-stat { display: flex; align-items: baseline; gap: 5px; min-width: 92px; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 4px 10px; font-size: 1.1rem; }
.gn-stat:last-child { justify-content: flex-end; }
.gn-stat small { color: var(--muted); font-size: .75rem; }
.gn-num { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.gn-chico { width: 52px; height: 56px; flex: none; }
.gn-chico .mascot { width: 52px; }
.gn-hint { min-height: 1.4em; margin: 6px 0 2px; text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; }
.gn-how { margin: 8px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }

.gn-board { width: min(calc(100% + 16px), 468px); margin-left: 50%; transform: translateX(-50%); display: grid; grid-template-rows: repeat(9, 1fr);
  border: 3px solid var(--gn-box); border-radius: 8px; overflow: hidden; background: var(--gn-tile); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.gn-row { display: grid; grid-template-columns: repeat(9, 1fr); }
.gn-c { appearance: none; position: relative; aspect-ratio: 1; min-width: 0; padding: 0; margin: 0; border: 0; border-radius: 0; display: grid; place-items: center;
  font: 600 1.45rem/1 var(--font); font-variant-numeric: tabular-nums; color: var(--gn-user); background: var(--gn-tile); cursor: pointer; -webkit-tap-highlight-color: transparent;
  border-right: 1px solid var(--gn-line); border-bottom: 1px solid var(--gn-line); }
.gn-c.rb { border-right: 2px solid var(--gn-box); } .gn-c.bb { border-bottom: 2px solid var(--gn-box); }
.gn-c.last-c { border-right: 0; } .gn-row:last-child .gn-c { border-bottom: 0; }
.gn-c.giv { color: var(--gn-given-ink); font-weight: 800; background: var(--gn-given); }
.gn-c.peer { background: var(--gn-peer); } .gn-c.giv.peer { background: color-mix(in srgb, var(--gn-given) 70%, var(--gn-peer)); }
.gn-c.same { background: var(--gn-same); }
.gn-c.sel { background: var(--gn-sel); box-shadow: inset 0 0 0 3px var(--gn-box); z-index: 1; }
.gn-c:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 2; }
.gn-c.bad { color: var(--gn-bad); background-image: linear-gradient(var(--gn-bad-bg), var(--gn-bad-bg)); text-decoration: underline wavy var(--gn-bad) 2px; text-underline-offset: 5px; }
.gn-c.bad.sel { background-image: none; }
.gn-c.bad::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 11px 11px 0; border-color: transparent var(--gn-bad) transparent transparent; }
.gn-c:disabled { cursor: default; color: inherit; opacity: 1; }
.gn-c.giv:disabled { color: var(--gn-given-ink); }
.gn-notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font: 700 .72rem/1 var(--font); color: var(--gn-note); pointer-events: none; }
.gn-notes i { font-style: normal; display: grid; place-items: center; }

.gn-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.gn-key { appearance: none; position: relative; min-height: 52px; border: 2px solid var(--edge); border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: 0 3px 0 var(--edge);
  font: 800 1.6rem/1 var(--font); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; display: grid; place-items: center; padding: 0; transition: transform .06s; }
.gn-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
.gn-key:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gn-key small { position: absolute; right: 6px; bottom: 3px; font: 700 .65rem/1 var(--font); color: var(--muted); }
.gn-key.done { opacity: .45; }
.gn-key.erase { font-size: 1rem; }
.gn-notesmode .gn-key.dig { border-style: dashed; color: var(--gn-note); }
.gn-tools { display: flex; gap: 8px; margin-top: 10px; justify-content: center; flex-wrap: wrap; }
.gn-tools .btn { min-height: 44px; padding: 8px 14px; font-size: .95rem; box-shadow: 0 3px 0 var(--edge); }
.gn-result { display: block; width: 100%; margin-top: 12px; }
.gn-win { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: no-preference) {
  .gn-board.done { animation: gn-pop .5s 1; }
  @keyframes gn-pop { 40% { transform: translateX(-50%) scale(1.02); } }
}
@media (prefers-reduced-motion: reduce) { .gn-key, .gn-key:active { transition: none; transform: none; } }

.gn-pen { min-height: 1.3em; margin: 0 0 6px; text-align: center; color: var(--gn-bad); font-weight: 800; font-size: .9rem; }
.gn-c.shake { animation: gn-shake .35s 1; }
@media (prefers-reduced-motion: no-preference) { @keyframes gn-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } } }
@media (prefers-reduced-motion: reduce) { .gn-c.shake { animation: none; } }
.gn-c.bad:not(.sel) { font-weight: 800; }
.gn-mode { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.gn-chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-weight: 800; font-size: .95rem; }
.gn-notesmode .gn-chip { background: var(--gn-sel); border-color: var(--gn-box); color: #2b2036; }
.gn-notesbtn { appearance: none; flex: 1; max-width: 190px; min-height: 48px; padding: 6px 12px; border: 2px solid var(--edge); border-radius: 14px; background: var(--card); color: var(--ink);
  box-shadow: 0 3px 0 var(--edge); font: 800 1rem/1.1 var(--font); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.gn-notesbtn[aria-pressed="true"] { background: var(--sun); color: #2b2036; border-color: var(--gold-edge); box-shadow: 0 3px 0 var(--gold-edge); }
.gn-notesbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gn-keys { margin-top: 10px; }
.gn-key { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.gn-notesmode .gn-c.sel { box-shadow: none; outline: 3px dashed var(--gn-box); outline-offset: -3px; }
.gn-break { font-weight: 700; }
