/* Sudoku: game styles. Colors and fonts come from ../shared/eg-theme.css.
   Rule for this game: a square never changes color when you hover over it. Colors change only for selection, matching numbers and hints.
   (On a phone, a hover color can stay stuck after a tap.) So there are no :hover rules anywhere in this file. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.45;
}
[hidden] { display: none !important; }

.noscript { margin: 16px; padding: 16px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; color: #1F3246; }

:focus-visible { outline: 4px solid var(--mid); outline-offset: 2px; }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- extra colors used only by this game ---------- */
:root {
  --cell-bg: #FFFDF6;
  --cell-peer: #F3E7CB;
  --cell-same: #F7C99B;
  --cell-unit: #DCE8F4;
  --line: #B9AB8C;
  --mine: #2A5C93;
  --bad: #A34A0C;
}
:root[data-contrast="high"] {
  --cell-bg: #FFFFFF;
  --cell-peer: #EFEFEF;
  --cell-same: #FFC266;
  --cell-unit: #D3E1F0;
  --line: #000000;
  --mine: #0B3F7A;
  --bad: #8A3800;
}

/* ---------- header and settings ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px 4px;
}
.name-block { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 12px; }
.name { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.kind { margin: 0; white-space: nowrap; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.kind::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--dot); border: 2px solid var(--ink); flex: none; }

.textlink {
  color: var(--ink); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; white-space: nowrap;
}

.settings {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 4px 16px 10px; border-bottom: 2px solid var(--rule);
}
.settings-label { font-size: 18px; margin-right: 2px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px; padding: 8px 16px;
  font: inherit; font-weight: 700; font-size: 20px; line-height: 1.2;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 12px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn.small { min-height: 46px; font-size: 18px; padding: 6px 14px; }
.btn.primary { background: var(--ink); color: var(--card); }
.btn[aria-disabled="true"] { opacity: 0.5; border-style: dashed; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--card); }

/* ---------- layout ---------- */
main { padding: 12px 6px 40px; max-width: 1000px; margin: 0 auto; }
.h2 { margin: 8px 0 4px; font-family: var(--font-head); font-weight: 800; font-size: 28px; line-height: 1.15; }
.h3 { margin: 0 0 8px; font-family: var(--font-head); font-weight: 800; font-size: 24px; line-height: 1.15; }
.panel { background: var(--card); border: 2px solid var(--rule); border-radius: 20px; padding: 4px 18px; margin: 0 0 12px; max-width: 760px; }
.howto { margin: 14px 0; font-size: 20px; }
.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count { margin: 0 0 8px; font-size: 18px; min-height: 26px; }

details.howto-panel { padding: 0 18px; }
details.howto-panel summary {
  min-height: 52px; display: flex; align-items: center; cursor: pointer;
  font-family: var(--font-head); font-weight: 800; font-size: 24px;
}
details.howto-panel[open] summary { border-bottom: 2px solid var(--rule); margin-bottom: 4px; }

.msg {
  margin: 8px 0; padding: 8px 12px;
  font-size: 19px; line-height: 1.35;
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px;
}
.msg:empty { display: none; }

/* ---------- choosing a puzzle ---------- */
.picker { margin: 18px 0 14px; padding: 0 4px; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 520px; }
.levels .btn { min-height: 56px; padding: 8px 4px; }
.nums { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin-top: 8px; }
.nums .btn {
  min-height: 62px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.1;
}
.nums .btn .num { font-size: 22px; }
.nums .btn .state { font-size: 15px; font-weight: 400; min-height: 17px; }
.nums .btn[aria-pressed="true"] .state { font-weight: 700; }

/* ---------- the board ---------- */
.board-wrap {
  background: var(--iconbg); border: 2px solid var(--ink); border-radius: 16px;
  padding: 6px 4px; touch-action: manipulation; width: max-content; margin: 0 auto;
}
/* Double-line outer border, the same as the other flat puzzle boards (see board-border-standard). */
.grid {
  display: grid; grid-template-columns: repeat(9, var(--cs, 40px)); grid-auto-rows: var(--cs, 40px);
  box-sizing: content-box; border: 9px double var(--ink); border-radius: 10px; margin: 0 auto;
  background: var(--cell-bg);
}

.cell {
  position: relative; width: var(--cs, 40px); height: var(--cs, 40px); margin: 0; padding: 0;
  font: inherit; color: var(--ink); background: var(--cell-bg);
  border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.br { border-right: 3px solid var(--ink); }
.cell.bb { border-bottom: 3px solid var(--ink); }
.cell.peer { background: var(--cell-peer); }
.cell.hu { background: var(--cell-unit); }
.cell.same { background: var(--cell-same); }

.v { font-family: var(--font-head); font-weight: 800; font-size: calc(var(--cs, 40px) * 0.62); line-height: 1; }
.cell.given .v { color: var(--ink); }
.cell.mine .v { color: var(--mine); font-weight: 700; }

/* A number that repeats in its row, column or box: dashed outline inside the square, plus a message. Never color alone. */
.cell.bad { outline: 3px dashed var(--bad); outline-offset: -5px; }
.cell.bad .v { color: var(--bad); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* The chosen square: a solid orange frame. */
.cell.sel { outline: 4px solid var(--dot); outline-offset: -4px; z-index: 2; }
.cell.sel.bad { outline: 4px solid var(--dot); box-shadow: inset 0 0 0 7px var(--cell-bg); }
:root[data-contrast="high"] .cell.sel { outline-color: #000; outline-width: 5px; }
/* The square a hint talks about: a blue frame. */
.cell.hint { box-shadow: inset 0 0 0 4px var(--mid); z-index: 1; }
.cell.hint.sel { box-shadow: inset 0 0 0 9px var(--mid); }

/* Small pencil numbers */
.nt { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 2px; }
.nt i {
  font-style: normal; font-weight: 700; color: var(--mine); text-align: center;
  font-size: calc(var(--cs, 40px) * 0.27); line-height: 1; display: flex; align-items: center; justify-content: center;
}

/* ---------- the number pad and buttons ---------- */
.dock { margin-top: 10px; padding: 0; }
.pad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; }
.padbtn { min-height: 56px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.padbtn .pd { font-family: var(--font-head); font-weight: 800; font-size: 28px; }
.padbtn .pl { font-size: 14px; font-weight: 400; }
.padbtn.erase { font-size: 20px; }
.pad.notes-on .padbtn[data-d] .pd { font-size: 22px; }
.pad.notes-on .padbtn[data-d] { border-style: dotted; }
.controls { display: grid; gap: 8px; }
.controls.four-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.controls.two-up { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.controls .btn { min-height: 56px; font-size: 19px; padding: 6px 4px; }
.confirm-text { margin: 0 0 8px; font-size: 19px; }

/* Wide screens: board on the left, numbers and buttons on the right. */
#screen-play.wide { display: grid; grid-template-columns: max-content minmax(300px, 1fr); column-gap: 24px; align-items: start; }
#screen-play.wide .titlerow, #screen-play.wide .count { grid-column: 1 / -1; }
#screen-play.wide .board-wrap { grid-column: 1; grid-row: 3 / span 2; margin: 0; }
#screen-play.wide .dock { grid-column: 2; grid-row: 3; margin-top: 0; }
#screen-play.wide .clear { grid-column: 2; grid-row: 4; margin-top: 0; }
#screen-play.wide .msg { margin-top: 0; }

/* ---------- finished ---------- */
.clear { margin-top: 16px; padding: 18px; }
.clear-title { margin: 0 0 6px; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.clear p { margin: 0 0 14px; }
.clear-buttons { display: grid; gap: 8px; }
.clear-buttons .btn { min-height: 56px; }

@media (min-width: 440px) {
  .controls.four-up { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #screen-play.wide .controls.four-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
