/* Крестики · Задачник — минималистичный тёмный стиль */
:root {
  --bg: #0a0a0b;
  --bg-elev: #131316;
  --border: #22222a;
  --border-strong: #2e2e36;
  --text: #ededf0;
  --text-dim: #8a8a93;
  --text-mute: #5b5b63;
  --accent: #6ee7b7;
  --accent-soft: rgba(110, 231, 183, 0.12);
  --accent-glow: rgba(110, 231, 183, 0.45);
  --danger: #f87171;

  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Instrument Serif', 'Times New Roman', serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 500px;
  background: radial-gradient(closest-side, rgba(110, 231, 183, 0.06), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(20px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 17px;
  color: var(--text-dim);
}

.tiers {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.tier {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.tier:hover { color: var(--text); }
.tier[aria-selected="true"] {
  background: #1c1c22;
  color: var(--accent);
}

.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 64px) clamp(20px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.sub {
  margin: 0 0 32px;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 420px;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin-bottom: 28px;
}
.board {
  display: grid;
  gap: 8px;
  width: 100%;
  aspect-ratio: 1;
}
.board[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.board[data-size="4"] { grid-template-columns: repeat(4, 1fr); gap: 7px; }
.board[data-size="5"] { grid-template-columns: repeat(5, 1fr); gap: 6px; }

.cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  appearance: none;
  padding: 0;
  font: inherit;
  color: inherit;
  outline: none;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 90ms var(--ease);
}
.board[data-size="4"] .cell { border-radius: 12px; }
.board[data-size="5"] .cell { border-radius: 10px; }

.cell:hover:not(:disabled) {
  background: #1a1a20;
  border-color: var(--border-strong);
}
.cell:hover:not(:disabled) .ghost { opacity: 0.18; }
.cell:active:not(:disabled) { transform: scale(0.97); }
.cell:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  z-index: 2;
}
.cell:disabled { cursor: default; }
.cell.is-correct {
  background: linear-gradient(180deg, rgba(110, 231, 183, 0.16), rgba(110, 231, 183, 0.04));
  border-color: rgba(110, 231, 183, 0.55);
  box-shadow: 0 0 24px rgba(110, 231, 183, 0.18);
}
.cell.is-wrong {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.14), rgba(248, 113, 113, 0.03));
  border-color: rgba(248, 113, 113, 0.5);
}
.cell.is-o-winning {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.12), rgba(248, 113, 113, 0.02));
  border-color: rgba(248, 113, 113, 0.4);
}

.mark { width: 58%; height: 58%; display: block; }
.board[data-size="4"] .mark { width: 60%; height: 60%; }
.board[data-size="5"] .mark { width: 62%; height: 62%; }

.mark.x-mark path {
  stroke: var(--text);
  stroke-width: 2.6;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
  animation: drawIn 280ms var(--ease) forwards;
}
.mark.o-mark circle {
  stroke: var(--text-dim);
  stroke-width: 2.6;
  fill: none;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: drawIn 320ms var(--ease) forwards;
}
.board[data-size="4"] .mark.x-mark path,
.board[data-size="5"] .mark.x-mark path,
.board[data-size="4"] .mark.o-mark circle,
.board[data-size="5"] .mark.o-mark circle { stroke-width: 2.2; }

.cell.is-correct .mark.x-mark path { stroke: var(--accent); }
.cell.is-wrong .mark.x-mark path { stroke: var(--danger); }
.cell.is-o-winning .mark.o-mark circle { stroke: var(--danger); }

.ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 140ms var(--ease);
  pointer-events: none;
}
.ghost svg {
  width: 50%;
  height: 50%;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

@keyframes drawIn { to { stroke-dashoffset: 0; } }

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.overlay line {
  stroke-linecap: round;
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  stroke-width: 6;
  fill: none;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.overlay.is-win line {
  stroke: var(--accent);
  animation: drawLine 420ms var(--ease) 120ms forwards;
}
.overlay.is-loss line {
  stroke: var(--danger);
  filter: drop-shadow(0 0 12px rgba(248, 113, 113, 0.5));
  animation: drawLine 420ms var(--ease) 120ms forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 18px;
  min-height: 36px;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.status-win {
  border-color: rgba(110, 231, 183, 0.4);
  background: rgba(110, 231, 183, 0.08);
  color: var(--accent);
}
.status-win .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.18); }
.status-loss {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
}
.status-loss .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18); }

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 90ms var(--ease);
}
.btn:hover { background: #1d1d22; border-color: #34343c; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn-primary {
  background: var(--accent);
  color: #03110a;
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover { background: #82edc4; }

@media (max-width: 520px) {
  .top { padding: 14px 16px; gap: 10px; }
  .brand em { display: none; }
  .stage { padding: 28px 16px 40px; }
  .board { gap: 6px; }
  .board[data-size="4"] { gap: 5px; }
  .board[data-size="5"] { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
