/* Стили игры судоку */
.top-actions { display: flex; gap: 8px; }

.game {
  max-width: 1080px;
  margin: 0 auto;
  padding: 4px 16px 40px;
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  justify-items: center;
}
@media (min-width: 900px) {
  .game {
    grid-template-columns: minmax(0, 560px) 320px;
    justify-content: center;
    align-items: start;
    gap: 32px;
    padding-top: 16px;
  }
}
.board-col, .controls-col { width: 100%; max-width: 560px; }

/* Планшеты и большие экраны: поле растёт по высоте окна, чтобы всё помещалось без прокрутки */
@media (min-width: 600px) and (max-width: 899px) {
  .board-col, .controls-col { max-width: max(560px, min(100%, calc((100dvh - 300px) / 1.25))); }
}
@media (min-width: 900px) {
  .game {
    --side: clamp(300px, 28vw, 400px);
    --board: max(400px, min(calc(100dvh - 150px), calc(100vw - var(--side) - 80px)));
    grid-template-columns: var(--board) var(--side);
    max-width: none;
    padding-bottom: 16px;
  }
  .board-col, .controls-col { max-width: none; }
}

/* ---------- Строка статуса ---------- */
.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 15px;
}
.status-item { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.status-item b { color: var(--text); font-variant-numeric: tabular-nums; }
.level-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 6px 2px;
  font-weight: 700; cursor: pointer;
}
.level-btn svg { width: 16px; height: 16px; color: var(--muted); }
.timer b { min-width: 44px; text-align: right; }
.pause-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: var(--surface-2);
  display: grid; place-items: center; cursor: pointer;
}
.pause-btn svg { width: 14px; height: 14px; }
.pause-btn .i-play { display: none; }
body.paused .pause-btn .i-play { display: block; }
body.paused .pause-btn .i-pause { display: none; }

/* ---------- Поле ---------- */
.board-wrap { position: relative; }
.board {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  box-shadow: var(--shadow);
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 6.4cqi;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: background-color .08s;
}
.cell.c2, .cell.c5 { border-right: 2px solid var(--border-strong); }
.cell.c8 { border-right: 0; }
.cell.r2, .cell.r5 { border-bottom: 2px solid var(--border-strong); }
.cell.r8 { border-bottom: 0; }

.cell.given { color: var(--text); font-weight: 600; }
.cell.peer { background: var(--accent-softer); }
.cell.same { background: var(--same); }
.cell.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.wrong { color: var(--danger); }
.cell.wrong.selected, .cell.wrong.same { background: var(--danger-soft); }
.cell.conflict { background: var(--danger-soft); }
.cell.hinted { color: var(--ok); }
.cell.pop { animation: pop .25s ease-out; }
.cell.flash { animation: flash .6s ease-out; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.notes {
  position: absolute; inset: 6%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: 2.3cqi;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
}
.notes span { display: grid; place-items: center; }
.notes span.hl { color: var(--accent); font-weight: 800; }

body.paused .board .cell { color: transparent !important; }
body.paused .board .notes { visibility: hidden; }
.pause-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 10px;
}
.pause-overlay[hidden] { display: none; }

/* ---------- Инструменты ---------- */
.tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.tool {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px;
  border: 0; background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: 12px;
}
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool svg { width: 26px; height: 26px; }
.tool-flag {
  position: absolute; top: 2px; right: calc(50% - 30px);
  font-style: normal; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.tool[aria-pressed="true"] { color: var(--accent); }
.tool[aria-pressed="true"] .tool-flag { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- Цифры ---------- */
.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}
@media (min-width: 900px) {
  .numpad { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .numpad .num { aspect-ratio: 1.25; font-size: clamp(32px, 3vw, 44px); }
}
.num {
  position: relative;
  aspect-ratio: 0.66;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: clamp(22px, 6.4vw, 30px);
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0;
  transition: transform .06s, background .15s;
}
.num:hover { background: var(--accent-softer); }
.num:active { transform: scale(.95); }
.num.done { opacity: .35; }
.num.hidden { visibility: hidden; }
body.notes-mode .num { color: var(--muted); font-size: clamp(16px, 4.6vw, 22px); }

/* ---------- Кнопки ---------- */
.primary-btn {
  display: inline-flex; justify-content: center; align-items: center;
  height: 46px; padding: 0 22px;
  border-radius: 12px; border: 0;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn.wide { width: 100%; }
.ghost-btn {
  width: 100%; height: 42px; margin-top: 6px;
  border: 0; background: none; color: var(--muted);
  border-radius: 12px; cursor: pointer; font-weight: 500;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.ghost-btn.danger:hover { color: var(--danger); }
.keys-hint { color: var(--muted); font-size: 12px; margin: 14px 2px 0; display: none; }
@media (min-width: 900px) and (hover: hover) { .keys-hint { display: block; } }

/* ---------- Диалоги ---------- */
.dlg {
  width: min(92vw, 380px);
  padding: 22px 20px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.dlg::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.dlg h2 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.dlg .muted { color: var(--muted); text-align: center; margin: 0 0 16px; font-size: 14px; }
.level-list { display: grid; gap: 8px; margin: 14px 0 4px; }
.level-opt {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer; text-align: left;
}
.level-opt:hover { border-color: var(--accent); background: var(--accent-softer); }
.level-opt span { font-size: 13px; color: var(--muted); }
.win-mark {
  width: 56px; height: 56px; margin: 0 auto 10px;
  border-radius: 50%; background: var(--ok); color: #fff;
  display: grid; place-items: center; font-size: 30px; font-weight: 700;
  animation: pop .4s ease-out;
}
.win-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.win-stats div {
  background: var(--surface-2); border-radius: 12px; padding: 10px 6px;
  text-align: center;
}
.win-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.win-stats span { font-size: 12px; color: var(--muted); }

.stats-table { margin: 14px 0 16px; font-size: 14px; }
.stats-table table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table th { color: var(--muted); font-weight: 500; font-size: 12px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 15px;
}
.switch-row:last-of-type { margin-bottom: 16px; }
.switch-row input {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 44px; height: 26px; border-radius: 99px;
  background: var(--border); position: relative; cursor: pointer;
  transition: background .2s;
}
.switch-row input::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(18px); }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .brand-text { display: none; }
  .status { font-size: 14px; }
  .status-label { display: none; }
  .status-item[title="Ошибки"]::before { content: '✕'; color: var(--muted); font-size: 12px; }
}

/* Телефоны: поле крупнее (почти во всю ширину, клетки чуть выше), панель снизу компактнее */
@media (max-width: 899px) {
  .board-wrap { margin: 0 -10px; }
  .board { aspect-ratio: 9 / 10; }
  .tools { gap: 4px; margin-top: -6px; margin-bottom: 8px; }
  .tool { padding: 6px 2px 4px; gap: 2px; font-size: 11px; }
  .tool svg { width: 21px; height: 21px; }
  .tool-flag { top: 0; right: calc(50% - 26px); font-size: 9px; padding: 0 5px; }
  .numpad { gap: 3px; margin: 0 -10px 12px; }
  .num { aspect-ratio: 0.8; font-size: clamp(24px, 7.2vw, 34px); border-radius: 8px; }
  .primary-btn.wide { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .cell.pop, .cell.flash, .win-mark { animation: none; }
}
