/* =====================================================================
   SUDOKA — стили игры «Нежить»
   Самодостаточный файл: подключается только на странице игры.
   ===================================================================== */

/* ---------- Root ---------- */
.und-root { max-width: 640px; margin-inline: auto; display: flex; flex-direction: column; align-items: center; gap: clamp(.75rem, 2vw, 1rem); }

/* ---------- Head ---------- */
.und-head { text-align: center; width: 100%; }
.und-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.und-head p { color: var(--ink-muted); max-width: 52ch; margin: .35rem auto 0; }

/* ---------- Toolbar: controls + actions in a row ---------- */
.und-toolbar {
  display: flex; flex-wrap: wrap; gap: clamp(.5rem, 2vw, 1rem);
  justify-content: center; align-items: center; width: 100%;
}
.und-controls {
  display: flex; flex-wrap: wrap; gap: .5rem;
  justify-content: center; align-items: center;
}
.und-controls-group {
  display: flex; gap: .25rem; align-items: center;
}
.und-controls-label {
  font-size: .8rem; color: var(--ink-muted); margin-right: .25rem;
}

.und-size,
.und-diff {
  font: inherit; font-size: clamp(.75rem, 2vw, .85rem);
  padding: .35em .85em; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--card);
  color: var(--ink); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.und-size:hover,
.und-diff:hover { background: var(--bg-alt); }
.und-size.active,
.und-diff.active {
  background: var(--terracotta); color: #fff;
  border-color: var(--terracotta);
}

/* ---------- Monster palette ---------- */
.und-palette {
  display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap;
}
.und-monster {
  font: inherit; font-size: clamp(.8rem, 2.5vw, .95rem);
  padding: .45em 1em; border: 2px solid var(--border);
  border-radius: var(--radius); background: var(--card);
  color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: .35em;
  transition: all .15s; user-select: none;
}
.und-monster:hover { border-color: var(--terracotta); background: var(--terracotta-l); }
.und-monster.active {
  border-color: var(--terracotta); background: var(--terracotta);
  color: #fff;
}
.und-monster-icon {
  font-size: 1.2em; line-height: 1;
}
.und-monster-ghost { color: #8B7EC8; }
.und-monster-vampire { color: var(--danger); }
.und-monster-zombie { color: var(--sage-d); }

/* ---------- Board ---------- */
.und-board-wrap {
  position: relative; overflow-x: auto;
  max-width: 100%; -webkit-overflow-scrolling: touch;
}
.und-board {
  display: grid; gap: 1px;
  background: var(--border);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  margin: 0 auto;
}

.und-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); cursor: pointer;
  font-size: clamp(.55rem, 2.5vw, .9rem);
  font-weight: 700;
  transition: background .12s;
  position: relative;
  min-width: clamp(28px, 8vw, 44px);
}
.und-cell:hover { background: var(--bg-alt); }
.und-cell.selected { background: var(--terracotta-l); box-shadow: inset 0 0 0 2px var(--terracotta); }

.und-cell--border {
  background: var(--bg-alt); cursor: pointer;
  color: var(--ink-muted); font-size: clamp(.5rem, 2vw, .75rem);
  font-weight: 600;
}
.und-cell--border:hover { color: var(--terracotta); }
.und-cell--border.und-cell--marked { color: var(--border); }
.und-cell--corner { background: var(--bg); cursor: default; }

.und-cell--mirror {
  cursor: default; background: var(--bg-alt);
}
.und-cell--mirror:hover { background: var(--bg-alt); }
.und-mirror-l,
.und-mirror-r {
  position: absolute; inset: 15%;
  pointer-events: none;
}
.und-mirror-l::after {
  content: ''; position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(to bottom right, transparent 45%, var(--ink) 45%, var(--ink) 55%, transparent 55%);
}
.und-mirror-r::after {
  content: ''; position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(to bottom left, transparent 45%, var(--ink) 45%, var(--ink) 55%, transparent 55%);
}

/* Pencil marks */
.und-pencils {
  position: absolute; inset: 2px; display: grid;
  grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  pointer-events: none; font-size: clamp(.3rem, 1.5vw, .5rem);
  line-height: 1; font-weight: 400;
}
.und-pencil-G { color: #8B7EC8; display: flex; align-items: flex-start; justify-content: flex-start; padding: 1px; }
.und-pencil-V { color: var(--danger); display: flex; align-items: flex-start; justify-content: flex-end; padding: 1px; }
.und-pencil-Z { color: var(--sage-d); display: flex; align-items: flex-end; justify-content: center; padding: 1px; }

/* ---------- Actions ---------- */
.und-actions {
  display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap;
}
.und-btn {
  font: inherit; font-size: clamp(.75rem, 2vw, .85rem);
  padding: .45em 1.2em; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card);
  color: var(--ink); cursor: pointer;
  transition: all .15s;
}
.und-btn:hover { background: var(--bg-alt); border-color: var(--terracotta); }
.und-btn--primary {
  background: var(--terracotta); color: #fff;
  border-color: var(--terracotta);
}
.und-btn--primary:hover { background: var(--terracotta-d); }
.und-btn--active {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
}
.und-btn--active:hover { opacity: .85; background: var(--ink); }

/* ---------- Status ---------- */
.und-status {
  font-size: clamp(.75rem, 2vw, .85rem);
  color: var(--ink-muted); text-align: center;
  min-height: 1.2em; width: 100%;
}

/* ---------- Help (short numbered steps) ---------- */
.und-help {
  text-align: center; color: var(--ink-muted);
  font-size: clamp(.65rem, 1.8vw, .75rem);
  max-width: 54ch; line-height: 1.5;
}
.und-help strong { color: var(--ink); }
.und-help kbd {
  font: inherit; background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px; padding: 0 .3em;
}

/* ---------- Rules ---------- */
.und-rules {
  width: 100%; color: var(--ink-muted);
  font-size: clamp(.75rem, 1.9vw, .85rem);
  line-height: 1.6;
}
.und-rules h2 { font-size: 1.2rem; margin-bottom: .75rem; color: var(--ink); }
.und-rules h3 { font-size: 1rem; margin: 1rem 0 .5rem; color: var(--ink); }
.und-rules p { margin: .5em 0; }
.und-rules ul { padding-left: 1.25rem; margin-bottom: .75rem; }
.und-rules li { margin-bottom: .35rem; }
.und-rules li strong { color: var(--ink); }
.und-rules code {
  font: inherit; background: var(--bg-alt);
  padding: 0 .25em; border-radius: 2px;
}
.und-rules em { color: var(--ink); }

/* ---------- Legend (like gss-legend) ---------- */
.und-legend {
  margin: .75rem 0 .75rem 1.25rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.und-legend-item {
  display: flex; align-items: center; gap: .55rem;
  color: var(--ink-muted);
}
.und-legend-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.und-legend-item strong { color: var(--ink); }

/* ---------- Modal ---------- */
.und-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(58,46,42,0.35);
  visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .25s, visibility .25s;
}
.und-modal.show { visibility: visible; opacity: 1; pointer-events: auto; }
.und-modal-inner {
  background: var(--card); border-radius: var(--radius-lg);
  padding: clamp(1.2rem, 4vw, 2rem); text-align: center;
  box-shadow: var(--shadow-lg); max-width: 340px; width: 90%;
}
.und-modal-inner h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); margin: 0 0 .5rem; }
.und-modal-inner p { color: var(--ink-muted); margin: 0 0 1rem; }
.und-modal-inner .und-btn { margin: .25rem; }

/* ---------- Animations ---------- */
@keyframes und-wrong {
  0%, 100% { color: var(--danger); }
  50% { color: var(--danger-l); }
}
.und-wrong { animation: und-wrong .4s ease 2; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .und-toolbar { flex-direction: column; }
  .und-controls { flex-direction: column; align-items: center; }
  .und-palette { gap: .35rem; }
  .und-monster { padding: .35em .7em; }
  .und-legend { margin-left: 0; }
}
