:root {
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --ink:           #2f3142;
  --muted:         #8a90a6;
  --primary:       #5b6ee1;
  --primary-dark:  #4557c9;
  --primary-soft:  #eef0fd;
  --highlight:     #ffe9a8;

  --tile-bg:       #ffffff;
  --tile-border:   #e2e6f2;

  --correct:       #58b368;
  --present:       #f4b740;
  --absent:        #9aa1b4;

  --danger:        #e5686b;
  --danger-soft:   #fdecec;
  --success-soft:  #e9f7ec;

  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 1.5rem 1.25rem 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.35rem;
}

.app-header {
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-family: "Baloo 2", "Inter", sans-serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 9vw, 2.6rem);
  letter-spacing: 0.03em;
  color: var(--primary-dark);
  position: relative;
  display: inline-block;
}

.app-header h1::after {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 0.08em;
  height: 0.32em;
  background: var(--highlight);
  border-radius: 6px;
  z-index: -1;
  opacity: 0.9;
}

.subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.board {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.6vw, 10px);
  background: var(--surface);
  padding: clamp(12px, 3vw, 18px);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(91, 110, 225, 0.08), 0 1px 2px rgba(47, 49, 66, 0.04);
}

.row {
  display: flex;
  gap: clamp(6px, 1.6vw, 10px);
}

.cell {
  width: clamp(48px, 15vw, 62px);
  height: clamp(48px, 15vw, 62px);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.row.active .cell {
  border-color: #d7ddf5;
}

.cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  caret-color: var(--primary);
  padding: 0;
  font-family: inherit;
}

.cell input:focus {
  outline: none;
}

.cell.focused {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.cell.filled {
  color: var(--ink);
}

.cell.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.cell.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
}

.cell.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
}

.cell.correct span,
.cell.present span,
.cell.absent span {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 700;
  text-transform: uppercase;
}

.hint {
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.1em;
  font-weight: 500;
}

.message {
  text-align: center;
  font-size: 1.02rem;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 14px;
  max-width: 100%;
}

.message.win {
  background: var(--success-soft);
  color: #2f7a3d;
}

.message.lose {
  background: var(--danger-soft);
  color: #b6393c;
}

.message.error {
  background: var(--danger-soft);
  color: #b6393c;
}

.actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 340px;
}

button {
  flex: 1;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 16px rgba(91, 110, 225, 0.28);
  transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  background: var(--primary-dark);
}

button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 3px 8px rgba(91, 110, 225, 0.25);
}

button#restartBtn {
  background: var(--ink);
  box-shadow: 0 6px 16px rgba(47, 49, 66, 0.22);
}

button#restartBtn:hover {
  background: #1f2130;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
  display: inline-block;
}

.swatch.correct { background: var(--correct); }
.swatch.present { background: var(--present); }
.swatch.absent  { background: var(--absent); }

.alphabet {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  max-width: 360px;
  margin-top: 0.1rem;
}

.letter-chip {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 1.5px solid var(--tile-border);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* noch nicht verwendet: weiß */
.letter-chip.unused {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--tile-border);
}

/* kommt nicht vor: dunkel/neutral */
.letter-chip.absent {
  background: var(--absent);
  color: #fff;
  border-color: var(--absent);
}

/* falsche Stelle: gelb */
.letter-chip.present {
  background: var(--present);
  color: #fff;
  border-color: var(--present);
}

/* richtige Stelle: grün */
.letter-chip.correct {
  background: var(--correct);
  color: #fff;
  border-color: var(--correct);
}

@media (max-height: 640px) {
  .app { gap: 0.85rem; padding-top: 1rem; }
  .app-header h1 { font-size: 1.9rem; }
}
