:root {
  color-scheme: dark;
  --bg: #12161d;
  --panel: #1c232d;
  --panel-2: #242d38;
  --text: #f3f6f8;
  --muted: #98a4b3;
  --line: #344151;
  --empty: #181f28;
  --correct: #4fb06d;
  --present: #d7b84f;
  --absent: #596473;
  --accent: #6bb8ff;
  --danger: #ec6f75;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #e9eef5;
  --text: #17202b;
  --muted: #617083;
  --line: #cbd5e1;
  --empty: #f8fafc;
  --correct: #338653;
  --present: #b39224;
  --absent: #8793a3;
  --accent: #1f73c9;
  --danger: #c9434c;
  --shadow: 0 18px 40px rgba(37, 52, 70, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(107, 184, 255, 0.08), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 14px 16px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 14px;
}

.topbar,
.stats-strip,
.message,
.footer-actions {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.icon-button,
.secondary-button,
.key {
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-button {
  flex: 0 0 auto;
  padding: 9px 11px;
  color: var(--accent);
}

.icon-button:hover,
.secondary-button:hover,
.key:hover {
  border-color: var(--accent);
}

.icon-button:active,
.secondary-button:active,
.key:active {
  transform: translateY(1px);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.stats-strip div {
  min-width: 0;
  padding: 10px 6px;
  text-align: center;
  background: var(--panel);
}

.stats-strip strong {
  display: block;
  font-size: 1.1rem;
}

.stats-strip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.game-area {
  display: grid;
  align-content: safe center;
  gap: 14px;
  min-height: 0;
}

.message {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

.message.good {
  color: var(--correct);
}

.message.bad {
  color: var(--danger);
}

.board {
  width: min(100%, 370px);
  aspect-ratio: 5 / 6;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
}

.tile {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--empty);
  color: var(--text);
  font-size: clamp(1.35rem, 7vw, 2.1rem);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  transition: transform 140ms ease, background 180ms ease, border-color 180ms ease;
}

.tile.filled {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  transform: scale(1.02);
}

.tile.correct,
.key.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #ffffff;
}

.tile.present,
.key.present {
  background: var(--present);
  border-color: var(--present);
  color: #141414;
}

.tile.absent,
.key.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #ffffff;
}

.keyboard {
  display: grid;
  gap: 7px;
  touch-action: manipulation;
}

.key-row {
  display: flex;
  justify-content: safe center;
  gap: 6px;
}

.key {
  min-width: 0;
  width: 9.2%;
  height: 48px;
  padding: 0 2px;
  font-weight: 750;
  text-transform: uppercase;
  user-select: none;
}

.key.wide {
  width: 14%;
  font-size: 0.78rem;
}

.footer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.secondary-button {
  min-height: 40px;
  padding: 8px 13px;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.shake {
  animation: shake 220ms ease;
}

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

@media (max-width: 420px) {
  .app-shell {
    padding: 12px 10px;
    gap: 10px;
  }

  .topbar {
    padding: 10px;
  }

  h1 {
    font-size: 1rem;
  }

  .board {
    gap: 6px;
  }

  .key {
    height: 44px;
    border-radius: 6px;
    font-size: 0.86rem;
  }

  .key.wide {
    font-size: 0.7rem;
  }
}

