:root {
  --correct:  #10b981;
  --present:  #3b82f6;
  --absent:   #ef4444;
  --selected: #6366f1;

  /* Tile sizing via CSS variables — easy to tweak */
  --tile-font:    1.4em;
  --key-font:     1em;
  --key-padding:  11px 0;
  --h1-size:      1.9em;
  --target-size:  2.2em;
}

/* Slightly larger on roomier screens */
@media (min-width: 400px) {
  :root {
    --tile-font:   1.6em;
    --key-font:    1.1em;
    --key-padding: 13px 0;
    --h1-size:     2.1em;
    --target-size: 2.4em;
  }
}

h1 { margin: 6px 0 2px 0; font-size: var(--h1-size); letter-spacing: 3px; font-weight: 900; }

.tagline {
  font-size: 0.78em;
  color: var(--color-accent-light);
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

#target-box {
  background: linear-gradient(135deg, #1e1b4b, #2e1065);
  border: 2px solid var(--selected);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

#target-num {
  font-size: var(--target-size);
  font-weight: 900;
  color: var(--color-accent-light);
  margin: 2px 0;
  line-height: 1;
}

.target-label {
  font-size: 0.72em;
  color: var(--color-muted);
  font-weight: bold;
  letter-spacing: 1px;
}

/* Grid: 4 rows × 6 digit tiles + sum indicator */
#grid {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.row {
  display: grid;
  grid-template-columns: repeat(6, 1fr) 44px;
  gap: 5px;
  align-items: center;
}

.tile {
  background: var(--color-surface);
  border: 2px solid #334155;
  border-radius: 7px;
  aspect-ratio: 1 / 1;
  font-size: var(--tile-font);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  /* Prevent tiles overflowing on very small screens */
  min-width: 0;
}

.tile.active-slot {
  border-color: var(--selected);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
  transform: scale(1.04);
}

.tile.correct { background: var(--correct); border-color: var(--correct); cursor: default; }
.tile.present { background: var(--present); border-color: var(--present); cursor: default; }
.tile.absent  { background: var(--absent);  border-color: var(--absent);  cursor: default; }

.live-sum-indicator {
  font-size: 0.85em;
  font-weight: bold;
  color: var(--color-muted);
  text-align: center;
  border-left: 2px dashed #334155;
  height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 2px;
}

.live-sum-indicator.match { color: var(--correct); font-size: 1em; }
.live-sum-indicator.fail  { color: #f43f5e; }

#message {
  min-height: 20px;
  margin: 8px 0;
  font-weight: bold;
  color: #f43f5e;
  font-size: 0.9em;
  padding: 0 5px;
}

/* Keyboard: 4 columns for digits 0-9 + backspace, then action row */
#keyboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding-bottom: 8px;
}

.key {
  background: #334155;
  color: white;
  border: 0;
  padding: var(--key-padding);
  font-size: var(--key-font);
  font-weight: bold;
  border-radius: 7px;
  cursor: pointer;
  touch-action: manipulation;
}

.key.wide          { grid-column: span 2; }
.key.action-lock   { background: var(--selected); }
.key.action-valeur { background: #334155; border: 1px solid #475569; color: var(--color-muted); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

.shake { animation: shake 0.3s ease-in-out; }