*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f14;
  --surface: #17171f;
  --surface2: #1e1e2a;
  --border: #2a2a3a;
  --border-box: #3a3a50;
  --accent: #c8a96e;
  --accent2: #7c9eba;
  --text: #e8e4d9;
  --text-muted: #7a7888;
  --given: #c8a96e;
  --user-color: #7fc8a9;
  --error: #e07070;
  --selected-bg: rgba(200,169,110,0.13);
  --highlight-bg: rgba(200,169,110,0.06);
  --cell-size: 56px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT — jocul centrat, sidebar fix în stânga
═══════════════════════════════════════════════════════════ */

/* Sidebar: fix pe marginea stângă, scroll propriu */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: 500px;
  height: 100vh;
  overflow-y: auto;
  padding: 40px 24px 40px 32px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

/* Jocul: centrat pe toată pagina, ignoră sidebar-ul */
.wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.page-layout {
  display: flex;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */

header { text-align: center; margin-bottom: 28px; }

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  line-height: 1;
}
.logo span {
  color: var(--text-muted);
  font-size: 1rem;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.2em;
  display: block;
  margin-top: 4px;
  font-weight: 300;
}

/* ═══════════════════════════════════════════════════════════
   NIVEL
═══════════════════════════════════════════════════════════ */

.level-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}
.lvl-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.lvl-btn:hover { border-color: var(--accent); color: var(--accent); }
.lvl-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f0f14;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   STATISTICI
═══════════════════════════════════════════════════════════ */

.stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}
.stat-item { text-align: center; }
.stat-val {
  font-family: 'DM Mono', monospace;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 500;
}
.stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}
.mistakes-dots { display: flex; gap: 6px; align-items: center; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-box);
  transition: background 0.2s;
}
.dot.filled { background: var(--error); }

/* ═══════════════════════════════════════════════════════════
   GRILĂ
═══════════════════════════════════════════════════════════ */

.grid-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, var(--cell-size));
  grid-template-rows: repeat(9, var(--cell-size));
  border: 2px solid var(--border-box);
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 1.3rem;
  font-weight: 400;
  cursor: pointer;
  position: relative;
  transition: background 0.12s;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.cell:nth-child(3n) { border-right: 2px solid var(--border-box); }
.cell:nth-child(9n) { border-right: none; }
.cell[data-row="2"], .cell[data-row="5"] { border-bottom: 2px solid var(--border-box); }
.cell[data-row="8"] { border-bottom: none; }

.cell.given { color: var(--given); font-weight: 500; }
.cell.user-cell { color: var(--user-color); }
.cell.error-cell { color: var(--error) !important; }
.cell.selected { background: var(--selected-bg) !important; }
.cell.highlight { background: var(--highlight-bg); }
.cell.same-num { color: var(--accent) !important; }
.cell:hover:not(.given) { background: rgba(255,255,255,0.04); }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%;
  padding: 2px;
}
.note {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem;
  font-family: 'DM Mono', monospace;
  color: var(--text-muted);
  line-height: 1;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   NUMPAD
═══════════════════════════════════════════════════════════ */

.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.num-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  padding: 6px 0;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 400;
}
.num-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(200,169,110,0.08); }
.num-btn.erase { font-size: 0.9rem; letter-spacing: 0.05em; color: var(--text-muted); }
.num-btn.note-active { border-color: var(--accent2); color: var(--accent2); }
.num-btn.disabled-num { opacity: 0.3; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════
   ACȚIUNI
═══════════════════════════════════════════════════════════ */

.actions {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.act-btn {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.act-btn .ico { font-size: 1.1rem; }
.act-btn:hover { border-color: var(--border-box); color: var(--text); }
.act-btn.primary { border-color: var(--accent); color: var(--accent); }
.act-btn.primary:hover { background: rgba(200,169,110,0.1); }

/* ═══════════════════════════════════════════════════════════
   WIN OVERLAY
═══════════════════════════════════════════════════════════ */

.win-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,18,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s;
}
.win-overlay.show { opacity: 1; pointer-events: all; }
.win-card {
  background: var(--surface);
  border: 1px solid var(--border-box);
  border-radius: 4px;
  padding: 40px 48px;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.4s;
}
.win-overlay.show .win-card { transform: translateY(0); }
.win-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 8px;
}
.win-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.win-time { font-family: 'DM Mono', monospace; font-size: 2.5rem; color: var(--text); margin-bottom: 24px; }
.win-btn {
  background: var(--accent);
  color: #0f0f14;
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 32px;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR — instrucțiuni desktop
═══════════════════════════════════════════════════════════ */

.sidebar-inner {
  border-right: 1px solid var(--border);
  padding-right: 20px;
}
.sidebar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin-bottom: 20px;
  letter-spacing: 0.03em;
}
.guide-section { margin-bottom: 18px; }
.guide-heading {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.guide-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.guide-section strong { color: var(--text); }
.guide-item {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.key {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border-box);
  color: var(--text);
  padding: 2px 7px;
  border-radius: 3px;
  margin-bottom: 1px;
  width: fit-content;
}
.badge {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 2px;
  width: fit-content;
}
.badge.easy   { background: rgba(127,200,169,0.15); color: #7fc8a9; border: 1px solid rgba(127,200,169,0.3); }
.badge.medium { background: rgba(200,169,110,0.15); color: var(--accent); border: 1px solid rgba(200,169,110,0.3); }
.badge.hard   { background: rgba(224,112,112,0.15); color: var(--error); border: 1px solid rgba(224,112,112,0.3); }
.sidebar-footer {
  margin-top: 28px;
  font-family: 'Playfair Display', serif;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--border-box);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   INSTRUCȚIUNI MOBILE (sub joc, vizibile doar pe mobil/tabletă)
═══════════════════════════════════════════════════════════ */

.mobile-instructions {
  display: none;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 48px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}
.mobile-instructions .sidebar-title { font-size: 1.3rem; margin-bottom: 24px; }
.mobile-instructions .guide-section p,
.mobile-instructions .guide-item { font-size: 0.92rem; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */

/* Desktop: sidebar vizibilă */
@media (min-width: 1100px) {
  .mobile-instructions { display: none; }
}

/* Tabletă și mobil: sidebar dispare, instrucțiuni apar sub joc */
@media (max-width: 1099px) {
  .sidebar { display: none; }
  .mobile-instructions { display: block; }
  .page-layout {
    flex-direction: column;
    align-items: center;
  }
}

/* Tabletă mică */
@media (max-width: 640px) {
  :root { --cell-size: 42px; }
  .cell { font-size: 1.1rem; }
  .logo { font-size: 2rem; }
  .num-btn { font-size: 1.15rem; padding: 11px 0; }
  .note { font-size: 0.58rem; }
}

/* Mobil */
@media (max-width: 420px) {
  :root { --cell-size: 36px; }
  .cell { font-size: 0.95rem; }
  .logo { font-size: 1.7rem; }
  .num-btn { font-size: 1rem; padding: 10px 0; }
  .note { font-size: 0.5rem; }
  .act-btn { font-size: 0.7rem; }
  .win-card { padding: 32px 24px; }
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════ */

.site-footer {
  text-align: center;
  padding: 16px;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  letter-spacing: 0.04em;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}
