/* ── SUDOKU-SPECIFIC VARIABLES ──────────────────────────────── */
:root {
  --sel-bg:    #c2d9f5;
  --area-bg:   #e8f2fc;
  --same-bg:   #8ab5e5;
  --cell-bd:   #c8d8ea;
  --given-col: #0e1e38;
  --user-col:  #1a55a8;
  --note-col:  #5070a0;
}

[data-theme="dark"] {
  --sel-bg:    #1a3d6a;
  --area-bg:   #162840;
  --same-bg:   #1e4a7a;
  --cell-bd:   #2a4060;
  --given-col: #c8e0f8;
  --user-col:  #7abaf5;
  --note-col:  #6090c8;
}

/* ── HINT AD MODAL ──────────────────────────────────────────── */
#hintModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,15,45,.72);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#hintModal.show { display: flex; }

.hint-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 72px rgba(0,0,40,.32);
  animation: pop .38s cubic-bezier(.34,1.56,.64,1);
  width: 360px;
  max-width: 90vw;
  position: relative;
}

/* only one phase visible at a time — JS toggles these */
#hintPhase1, #hintPhase2, #hintPhase3 { display: none; }
#hintPhase1.active, #hintPhase2.active, #hintPhase3.active { display: block; }

.hint-icon  { font-size: 50px; line-height: 1.15; }
.hint-title { font-size: 1.25em; font-weight: 800; color: var(--primary); margin: 10px 0 6px; }
.hint-sub   { font-size: 14px; color: var(--muted); line-height: 1.55; }

.hint-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}
.hint-btn-primary {
  padding: 11px 24px;
  border: none;
  border-radius: 26px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .16s;
}
.hint-btn-primary:hover { background: var(--primary-dk); transform: translateY(-1px); }
.hint-btn-ghost {
  padding: 9px 24px;
  border: 2px solid var(--btn-border);
  border-radius: 26px;
  background: transparent;
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .16s;
}
.hint-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

#hintPhase2 { position: relative; }
.hint-close-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .14s;
}
.hint-close-btn:hover { border-color: var(--err-color); color: var(--err-color); }

#hintAdSlot { margin: 0 auto; }

.hint-progress-label {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
}
.hint-progress-wrap {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}
.hint-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 1s linear;
}

/* ── GAME CARD CONSTRAINT ───────────────────────────────────── */
.game-card { max-width: 100%; }

/* ── GAME HEADER: TIMER + STATS ─────────────────────────────── */
.timer {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--given-col);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.game-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.mistakes-info { font-size: 13px; color: var(--muted); }
.mistakes-info b { color: var(--err-color); font-weight: 600; }

.best-info { font-size: 13px; color: var(--muted); }
.best-info b { color: var(--primary); font-weight: 600; }

/* ── GAME AREA (grid + side panel side by side) ─────────────── */
.game-area {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ── GRID ───────────────────────────────────────────────────── */
.grid-wrap {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(9, 56px);
  grid-template-rows:    repeat(9, 56px);
  border: 3px solid var(--box-bd);
  border-radius: 4px;
  overflow: hidden;
  transition: filter .25s;
}

.grid-wrap.blurred {
  filter: blur(8px);
  pointer-events: none;
}

.cell {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 400;
  cursor: pointer;
  border-right:  1px solid var(--cell-bd);
  border-bottom: 1px solid var(--cell-bd);
  position: relative;
  transition: background .1s;
  user-select: none;
  background: var(--card-bg);
}

.cell.br { border-right:  2px solid var(--box-bd); }
.cell.bb { border-bottom: 2px solid var(--box-bd); }
.cell.nr { border-right: none; }
.cell.nb { border-bottom: none; }

.cell.is-given { color: var(--given-col); }
.cell.is-user  { color: var(--user-col); }
.cell.is-error { color: var(--err-color) !important; }

/* Highlight layers — order matters: area < same < selected */
.cell.hl-area { background: var(--area-bg); }
.cell.hl-same { background: var(--same-bg); }
.cell.hl-sel  { background: var(--sel-bg) !important; }

/* ── NOTES ──────────────────────────────────────────────────── */
.notes-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows:    repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
}

.note-n {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 400;
  color: var(--note-col);
  line-height: 1;
}

/* ── SIDE PANEL ─────────────────────────────────────────────── */
.side-panel {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.actions { display: flex; flex-direction: column; gap: 6px; }

/* ── NUMPAD ─────────────────────────────────────────────────── */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.n-btn {
  aspect-ratio: 1;
  border: 2px solid var(--btn-border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 20px;
  font-weight: 400;
  color: var(--given-col);
  cursor: pointer;
  position: relative;
  transition: .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.n-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.n-btn.done  { opacity: .22; pointer-events: none; }

.n-rem {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 9px;
  color: var(--label-col);
  font-weight: 400;
}

/* ── SIDE PANEL INLINE AD (hidden by default) ────────────────── */
.side-panel-ad     { display: none; }
.side-panel-mid-ad { display: none; }

/* ── BANNER MIJLOC JOC (hidden by default) ───────────────────── */
.game-mid-ad { display: none; margin: 0 auto 14px; }

@media (max-width: 775px) {
  .hdr-nav .ad-leaderboard { display: none; }
  .game-mid-ad { display: flex; }
}

/* game-col pe toată lățimea când sidebar-ul e ascuns (≤1100px) */
@media (max-width: 1100px) {
  .content-row { grid-template-columns: 1fr; }
}

/* ── 775–1100 px: banner 300×250 în side panel, celule nemodificate ── */
@media (min-width: 775px) and (max-width: 1100px) {
  .right-sidebar { display: none; }
  .side-panel { width: 300px; }
  .side-panel-ad { display: flex; }
  /* side panel se duce sub grilă dacă nu mai încape (ex. <884px) */
  .game-area { flex-wrap: wrap; }

  /* Butoane acțiune pe 2 coloane */
  .actions { flex-direction: row; flex-wrap: wrap; gap: 5px; }
  .act-btn  { flex: 1 1 calc(50% - 3px); font-size: 12px; padding: 6px 8px; }

  /* Numpad pe 5 coloane, butoane mai mici */
  .numpad { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .n-btn  { height: 36px; aspect-ratio: unset; font-size: 15px; }
  .n-rem  { display: none; }
}

/* ── 775–910 px: celule 42px, butoane doar iconiță pe o linie ── */
@media (min-width: 775px) and (max-width: 910px) {
  .grid-wrap {
    grid-template-columns: repeat(9, 42px);
    grid-template-rows:    repeat(9, 42px);
  }
  .cell { width: 42px; height: 42px; font-size: 18px; }
  .note-n { font-size: 8px; }

  .actions { flex-wrap: nowrap; }
  .act-btn  { flex: 1; font-size: 0; padding: 8px 4px; justify-content: center; }
  .act-icon { font-size: 15px; }
}

/* ── 650–770 px: numpad mai mic ──────────────────────────────── */
@media (min-width: 650px) and (max-width: 775px) {
  .numpad { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .n-btn  { height: 36px; aspect-ratio: unset; font-size: 15px; }
  .n-rem  { display: none; }
}

/* ── RESPONSIVE — SUDOKU SPECIFIC ───────────────────────────── */
@media (max-width: 775px) {
  .grid-wrap {
    grid-template-columns: repeat(9, 42px);
    grid-template-rows:    repeat(9, 42px);
  }
  .cell { width: 42px; height: 42px; font-size: 19px; }
  .note-n { font-size: 9px; }
}

@media (max-width: 650px) {
  .game-area { flex-direction: column; align-items: stretch; }

  .grid-wrap {
    grid-template-columns: repeat(9, 38px);
    grid-template-rows:    repeat(9, 38px);
    align-self: center;
  }
  .cell { width: 38px; height: 38px; font-size: 15px; }
  .note-n { font-size: 8px; }

  .side-panel { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; }

  .actions { order:3; flex: 0 0 200px; flex-direction: row; flex-wrap: wrap; }
  .act-btn  { flex: 1 1 calc(50% - 4px); }

  .numpad { order:1; flex: 1 1 100%; grid-template-columns: repeat(5, 1fr); align-content: start; }
  .n-btn  { aspect-ratio: unset; height: 38px; font-size: 17px; }
  .n-rem  { display: none; }

  .side-panel-mid-ad { display: flex; order: 2; flex: 1 1 100%; margin: 0 auto; }

  .best-box { order:4; flex: 1 1 120px; }

  .game-header .diff-group { order: 1; width: 100%; justify-content: center; }
  .timer-wrap { order: 2; width: 100%; justify-content: center; }
  .game-stats { order: 3; align-items: center; flex-direction: row; gap: 12px; }
}

@media (max-width: 380px) {
  .grid-wrap {
    grid-template-columns: repeat(9, 34px);
    grid-template-rows:    repeat(9, 34px);
  }
  .cell { width: 34px; height: 34px; font-size: 14px; }
}
