/* ============================================================
   SUDOKU — con sistema temi (theme.css)
   ============================================================ */

.sd-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* ---------- HEADER ---------- */

.sd-header {
  text-align: center;
  margin-bottom: 1.8rem;
  animation: sdFadeDown 0.6s ease-out;
}
@keyframes sdFadeDown {
  from { opacity: 0; transform: translateY(-15px); }
  to { opacity: 1; transform: translateY(0); }
}

.sd-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--game-accent-soft);
  border: 1.5px solid var(--game-accent);
  padding: 0.4rem 1rem;
  border-radius: var(--game-radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--game-accent-dark);
  margin-bottom: 1rem;
  font-family: var(--game-mono);
}

.sd-header h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--game-text);
  line-height: 1.15;
}

.sd-header p {
  font-size: 1rem;
  color: var(--game-text-soft);
  max-width: 500px;
  margin: 0 auto;
}

/* ---------- SETUP ---------- */

.sd-setup {
  background: var(--game-card);
  border: 1.5px solid var(--game-border);
  border-radius: var(--game-radius-lg);
  padding: 2rem;
  max-width: 520px;
  margin: 2rem auto;
  box-shadow: var(--game-shadow-md);
  text-align: center;
}

.sd-setup h2 {
  font-family: var(--game-mono);
  font-size: 1.1rem;
  color: var(--game-text);
  margin-bottom: 1.2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sd-setup-info {
  background: var(--game-bg-soft);
  border: 1.5px solid var(--game-border-soft);
  border-radius: var(--game-radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--game-text-soft);
  text-align: left;
}

.sd-setup-info strong {
  color: var(--game-text);
  font-family: var(--game-mono);
}

/* ---------- BOTTONI ---------- */

.sd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--game-radius);
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.sd-btn-main {
  background: var(--game-accent);
  color: var(--game-text-invert);
  border-color: var(--game-accent);
  padding: 1rem 2rem;
  font-size: 1.05rem;
  width: 100%;
}
.sd-btn-main:hover {
  background: var(--game-accent-dark);
  border-color: var(--game-accent-dark);
}

.sd-btn-ghost {
  background: transparent;
  color: var(--game-text-soft);
  border-color: var(--game-border);
  padding: 0.7rem 1.3rem;
  font-size: 0.9rem;
}
.sd-btn-ghost:hover {
  background: var(--game-bg-soft);
  color: var(--game-text);
  border-color: var(--game-text-soft);
}
.sd-btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- GIOCO ---------- */

.sd-game { animation: sdFadeIn 0.4s ease-out; }
@keyframes sdFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.sd-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sd-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--game-accent-soft);
  border: 1.5px solid var(--game-accent);
  padding: 0.4rem 1rem;
  border-radius: var(--game-radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--game-accent-dark);
  font-family: var(--game-mono);
}

.sd-timer {
  position: relative;
  width: 76px;
  height: 76px;
}
.sd-timer svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}
.sd-timer-bg {
  fill: none;
  stroke: var(--game-border);
  stroke-width: 6;
}
.sd-timer-bar {
  fill: none;
  stroke: var(--game-accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
}
.sd-timer.is-warning .sd-timer-bar { stroke: var(--game-warning); }
.sd-timer.is-danger .sd-timer-bar { stroke: var(--game-error); }
.sd-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--game-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--game-accent-dark);
}
.sd-timer.is-warning .sd-timer-text { color: var(--game-warning); }
.sd-timer.is-danger .sd-timer-text { color: var(--game-error); }

/* ---------- BOARD ---------- */

.sd-board-wrap {
  background: var(--game-card);
  border: 1.5px solid var(--game-border);
  border-radius: var(--game-radius-lg);
  padding: 1.3rem;
  margin-bottom: 1.3rem;
  box-shadow: var(--game-shadow-md);
  display: flex;
  justify-content: center;
}

.sd-board {
  display: grid;
  gap: 0;
  margin: 0 auto;
  --sd-cell-size: 60px;
  background: var(--game-border);
  padding: 3px;
  border-radius: var(--game-radius);
  border: 1.5px solid var(--game-border);
}

/* Celle: bordo uniforme sottile, sfondo chiaro per gli input */
.sd-cell {
  width: var(--sd-cell-size);
  height: var(--sd-cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--game-card);
  border: 1px solid var(--game-border-soft);
  font-family: var(--game-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--game-text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  position: relative;
  box-sizing: border-box;
  margin: 0;
}

.sd-cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-align: center;
  outline: none;
  padding: 0;
  cursor: pointer;
}
.sd-cell input::-webkit-outer-spin-button,
.sd-cell input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.sd-cell input[type=number] { -moz-appearance: textfield; }

/* Celle fisse (numeri dati): sfondo leggermente diverso, testo più marcato */
.sd-cell.fixed {
  background: var(--game-bg-soft);
  color: var(--game-text);
  cursor: default;
}
.sd-cell.fixed input { cursor: default; }

/* Cella selezionata: bordo blu ben visibile + sfondo azzurro soft */
.sd-cell.selected {
  background: var(--game-accent-soft);
  border: 2px solid var(--game-accent);
  box-shadow: 0 0 0 1px var(--game-accent);
  z-index: 3;
}

/* Evidenziazione riga/colonna/box */
.sd-cell.highlight {
  background: var(--game-bg-soft);
}

/* Cella valida (in corso di compilazione corretta) */
.sd-cell.valid {
  background: var(--game-success-soft);
  border-color: var(--game-success);
  color: var(--game-success);
}

/* Cella con errore */
.sd-cell.invalid {
  background: var(--game-error-soft);
  border-color: var(--game-error);
  color: var(--game-error);
}

/* Separatori dei box 3x3 / 2x2: bordo più spesso visibile su chiaro e scuro */
.sd-cell.box-right {
  border-right: 3px solid var(--game-text-soft);
}
.sd-cell.box-bottom {
  border-bottom: 3px solid var(--game-text-soft);
}

/* Input per i simboli (emoji) */
.sd-input-symbol {
  cursor: pointer !important;
  font-size: 1.4rem !important;
}

/* ---------- TASTIERINO ---------- */

.sd-pad {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  padding: 0.9rem;
  margin: 0 auto 1rem;
  max-width: 100%;
  background: var(--game-card);
  border: 1.5px solid var(--game-border);
  border-radius: var(--game-radius);
}

.sd-pad-btn {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--game-bg-soft);
  border: 1.5px solid var(--game-border);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--game-text);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.sd-pad-btn:hover:not(:disabled) {
  background: var(--game-accent-soft);
  border-color: var(--game-accent);
  transform: translateY(-2px);
}
.sd-pad-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sd-pad-clear {
  background: var(--game-error-soft);
  border-color: var(--game-error);
  color: var(--game-error);
  font-size: 1.3rem;
}
.sd-pad-clear:hover:not(:disabled) {
  background: var(--game-error);
  color: var(--game-text-invert);
}

/* ---------- FEEDBACK ---------- */

.sd-feedback {
  border-radius: var(--game-radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
  display: none;
  text-align: center;
  border-left: 4px solid;
}
.sd-feedback.is-visible { display: block; }
.sd-feedback.is-correct {
  background: var(--game-success-soft);
  border-color: var(--game-success);
  color: var(--game-success);
}
.sd-feedback.is-wrong {
  background: var(--game-error-soft);
  border-color: var(--game-error);
  color: var(--game-error);
}
.sd-feedback.is-info {
  background: var(--game-warning-soft);
  border-color: var(--game-warning);
  color: var(--game-warning);
}
.sd-feedback strong {
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--game-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.sd-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.sd-next-wrap { text-align: center; margin-top: 0.5rem; }
.sd-next-wrap.hidden { display: none; }
.sd-btn-next {
  background: var(--game-accent);
  color: var(--game-text-invert);
  border: 1.5px solid var(--game-accent);
  padding: 0.9rem 2rem;
  border-radius: var(--game-radius);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.sd-btn-next:hover { background: var(--game-accent-dark); border-color: var(--game-accent-dark); }

/* ---------- RISULTATO FINALE ---------- */

.sd-final { text-align: center; animation: sdFadeIn 0.5s ease-out; }

.sd-final-score-box {
  background: var(--game-accent-soft);
  border: 2px solid var(--game-accent);
  border-radius: var(--game-radius-lg);
  padding: 2.5rem 1.5rem;
  margin-bottom: 1.5rem;
}

.sd-final-label {
  font-family: var(--game-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--game-accent-dark);
  margin-bottom: 0.5rem;
}

.sd-final-score {
  font-family: var(--game-mono);
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--game-accent-dark);
  margin-bottom: 0.5rem;
}

.sd-final-rating {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--game-text);
  margin-bottom: 0.3rem;
}
.sd-final-sub {
  font-size: 0.85rem;
  color: var(--game-text-soft);
  font-family: var(--game-mono);
}

.sd-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin-bottom: 1.8rem;
}
.sd-stat {
  background: var(--game-card);
  border: 1.5px solid var(--game-border);
  border-radius: var(--game-radius);
  padding: 1rem 0.6rem;
  text-align: center;
}
.sd-stat-value {
  font-family: var(--game-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--game-accent-dark);
  display: block;
  margin-bottom: 0.2rem;
}
.sd-stat-value.is-green { color: var(--game-success); }
.sd-stat-value.is-red { color: var(--game-error); }
.sd-stat-label {
  font-size: 0.7rem;
  color: var(--game-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--game-mono);
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 640px) {
  .sd-wrap { padding: 1rem 0.8rem 3rem; }
  .sd-header h1 { font-size: 1.5rem; }
  .sd-setup { padding: 1.5rem 1.2rem; }
  .sd-board { --sd-cell-size: 40px; }
  .sd-board[style*="repeat(6"] { --sd-cell-size: 42px; }
  .sd-board[style*="repeat(9"] { --sd-cell-size: 30px; }
  .sd-cell { font-size: 1.1rem; }
  .sd-input-symbol { font-size: 1.1rem !important; }
  .sd-timer { width: 64px; height: 64px; }
  .sd-timer-text { font-size: 0.95rem; }
  .sd-stats { grid-template-columns: 1fr 1fr; }
  .sd-stats .sd-stat:last-child { grid-column: 1 / -1; }
  .sd-pad-btn { width: 40px; height: 40px; font-size: 1.3rem; }
}

@media (max-width: 400px) {
  .sd-board { --sd-cell-size: 34px; }
  .sd-board[style*="repeat(6"] { --sd-cell-size: 36px; }
  .sd-board[style*="repeat(9"] { --sd-cell-size: 26px; }
  .sd-cell { font-size: 0.95rem; }
  .sd-input-symbol { font-size: 1rem !important; }
}