/* =====================================================
   ETHERLEARNING – Sudoku Game Styles
   ===================================================== */

/* ── Game Layout ──────────────────────────────────── */
.game-page { padding: 32px 0 64px; }

.game-layout {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 32px;
  align-items: start;
}

/* Left panel */
.game-panel-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Right panel */
.game-panel-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── SEO Article ───────────────────────────────────── */
.sudoku-seo-article {
  background: var(--paper-warm);
  border-top: 1px solid var(--paper-mid);
  padding: 72px 0 80px;
}

.seo-article-inner {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.85;
}

.seo-article-inner h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 20px;
  line-height: 1.25;
}

.seo-article-inner h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 40px 0 12px;
}

.seo-article-inner h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 24px 0 8px;
}

.seo-article-inner p {
  font-size: 0.97rem;
  margin-bottom: 18px;
  color: var(--ink-soft);
  max-width: none;
}

.seo-article-inner em  { font-style: italic; color: var(--ink); }
.seo-article-inner strong { color: var(--ink); }

.seo-list {
  padding-left: 24px;
  list-style: disc;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seo-list li {
  font-size: 0.97rem;
  color: var(--ink-soft);
}

.seo-list li strong { color: var(--ink); }

/* ── Difficulty Selector ──────────────────────────── */
.difficulty-select {
  background: var(--paper-warm);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.difficulty-select h3 {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.diff-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.diff-btn {
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--paper);
  border: 1.5px solid var(--paper-mid);
  color: var(--ink-soft);
  transition: all var(--transition);
  cursor: pointer;
}

.diff-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.diff-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Timer & Stats ────────────────────────────────── */
.game-stats {
  background: var(--paper-warm);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 0;
}

.stat-box {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-right: 1px solid var(--paper-mid);
}

.stat-box:last-child { border-right: none; }

.stat-box .val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink);
  display: block;
  line-height: 1.1;
}

.stat-box .lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-top: 4px;
}

/* ── Controls Panel — icon bar ────────────────────── */
.controls-panel {
  background: var(--paper-warm);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ctrl-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1.5px solid var(--paper-mid);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.ctrl-btn .icon {
  font-size: 1.35rem;
  line-height: 1;
  display: block;
}

/* Tooltip */
.ctrl-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #111;
  color: #4ade80;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
}

.ctrl-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #111;
}

.ctrl-btn:hover .ctrl-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ctrl-btn:hover {
  background: var(--paper-mid);
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.ctrl-btn.pencil-active {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ── Seed Panel ────────────────────────────────────── */
.seed-panel {
  background: var(--paper-warm);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seed-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 6px;
}

.seed-val-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seed-val {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.seed-copy-btn {
  background: var(--paper);
  border: 1.5px solid var(--paper-mid);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.seed-copy-btn:hover {
  background: var(--paper-mid);
  border-color: var(--accent);
}

.seed-copy-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

.seed-divider {
  height: 1px;
  background: var(--paper-mid);
}

.seed-input-row {
  display: flex;
  gap: 6px;
}

.seed-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--paper);
  border: 1.5px solid var(--paper-mid);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  letter-spacing: 0.03em;
  min-width: 0;
}

.seed-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.seed-input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(209,61,61,0.1);
}

.seed-go-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.seed-go-btn:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.seed-error {
  font-size: 0.75rem;
  color: var(--danger);
  font-weight: 500;
  min-height: 16px;
  display: block;
  margin-top: 2px;
}

/* ── Info Panel ───────────────────────────────────── */
.info-panel {
  background: var(--paper-warm);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.6;
}

.info-panel h3 {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.tip-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--paper-mid);
  font-size: 0.83rem;
}

.tip-row:first-of-type { border-top: none; }
.tip-key {
  background: var(--paper-mid);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Sudoku Board ─────────────────────────────────── */
.sudoku-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 3px solid var(--ink);
  border-radius: 4px;
  overflow: hidden;
  width: min(480px, calc(100vw - 48px));
  height: min(480px, calc(100vw - 48px));
  box-shadow: var(--shadow-lg);
  user-select: none;
  -webkit-user-select: none;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--paper-mid);
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition);
  aspect-ratio: 1;
}

/* 3×3 box borders */
.sudoku-cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 2.5px solid var(--ink-soft);
}
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2.5px solid var(--ink-soft);
}

/* States */
.sudoku-cell:hover:not(.given):not(.selected) {
  background: var(--paper-warm);
}

.sudoku-cell.selected {
  background: var(--accent);
  color: #fff;
}

.sudoku-cell.highlight-row,
.sudoku-cell.highlight-col,
.sudoku-cell.highlight-box {
  background: var(--accent-glow);
}

.sudoku-cell.given {
  color: var(--ink);
  font-weight: 700;
}

.sudoku-cell.user-filled { color: var(--accent); }

.sudoku-cell.error {
  background: rgba(209,61,61,0.1) !important;
  color: var(--danger) !important;
}

.sudoku-cell.hint-flash {
  animation: hintFlash 0.6s ease;
}

@keyframes hintFlash {
  0%  { background: var(--success); color: #fff; }
  100%{ background: var(--paper); color: var(--accent); }
}

/* ── Pencil marks ─────────────────────────────────── */
.pencil-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 1px;
  pointer-events: none;
}

/* All pencil numbers: very faint by default */
.pencil-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: clamp(0.4rem, 1vw, 0.65rem);
  font-weight: 600;
  color: transparent;        /* invisible when not marked */
  transition: color 0.15s, font-size 0.15s;
}

/* Marked (active) numbers stand out clearly */
.pencil-num.active {
  color: var(--accent);
  font-size: clamp(0.45rem, 1.1vw, 0.72rem);
  font-weight: 700;
}

/* On a selected (blue) cell, active marks show white */
.sudoku-cell.selected .pencil-num.active {
  color: rgba(255,255,255,0.95);
}

/* On highlighted cells, marks stay visible but softer */
.sudoku-cell.highlight-row .pencil-num.active,
.sudoku-cell.highlight-col .pencil-num.active,
.sudoku-cell.highlight-box .pencil-num.active {
  color: var(--accent-soft);
}

/* ── Number Input Pad ─────────────────────────────── */
.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  width: min(480px, calc(100vw - 48px));
}

.num-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--paper-warm);
  border: 1.5px solid var(--paper-mid);
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.num-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}

.num-btn.erase {
  font-size: 1rem;
}

/* ── Completion Modal ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,20,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--paper);
  border: 1px solid var(--paper-mid);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-slow);
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon { font-size: 3rem; margin-bottom: 16px; }
.modal-card h2 { margin-bottom: 10px; }
.modal-card p  { margin-bottom: 28px; font-size: 0.95rem; }

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}

.modal-stat .num {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent);
  display: block;
}

.modal-stat .lbl {
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-panel-left,
  .game-panel-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .controls-panel {
    grid-template-columns: repeat(4, 1fr);
  }

  .info-panel { grid-column: span 2; }
}

@media (max-width: 560px) {
  .game-panel-left,
  .game-panel-right {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    grid-template-columns: repeat(4, 1fr);
    grid-column: auto;
  }

  .info-panel { grid-column: auto; }
}