:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f252d;
  --text-dim: #5f6b77;
  --border: #d7dde5;
  --accent: #1a9b5a;
  --empty: #f1f4f8;
  --miss: #8c99a8;
  --present: #d1a037;
  --correct: #3aa76b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 16px;
  -webkit-text-size-adjust: 100%;
}

.app {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 24px rgb(25 35 52 / 8%);
}

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

h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 0.2px;
}

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

.brand-logo {
  display: inline-grid;
  place-items: center;
  height: 28px;
  min-width: 42px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ghost-btn:hover {
  background: #eef2f7;
}

.theme-meta {
  margin-top: 12px;
}

.theme-title {
  font-size: 15px;
  font-weight: 700;
}

.theme-subtitle {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 13px;
}

.status {
  margin: 12px 0 14px;
  min-height: 24px;
  color: var(--text-dim);
  font-size: 14px;
}

.board {
  display: grid;
  gap: 6px;
}

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

.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 24px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--empty);
  transition: transform 120ms ease, background 120ms ease;
}

.cell.filled {
  border-color: #a8b4c2;
}

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

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

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

.keyboard {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.kb-row {
  display: grid;
  gap: 6px;
}

.kb-row:nth-child(1) {
  grid-template-columns: repeat(10, 1fr);
}

.kb-row:nth-child(2) {
  grid-template-columns: repeat(9, 1fr);
}

.kb-row:nth-child(3) {
  grid-template-columns: 1.4fr repeat(7, 1fr) 1.4fr;
}

.key {
  border: 0;
  border-radius: 8px;
  background: #e6ebf2;
  color: #22303c;
  min-height: 42px;
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key.special {
  font-size: 12px;
}

.key.miss {
  background: #9aa6b5;
  color: #fff;
}

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

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

.theme-modal {
  position: fixed;
  inset: 0;
  background: rgb(18 26 34 / 62%);
  display: grid;
  place-items: center;
  padding: 16px;
}

.theme-modal.hidden {
  display: none;
}

.theme-modal-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.theme-modal-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.theme-modal-card p {
  margin: 12px 0 6px;
  color: var(--text-dim);
  font-size: 14px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.theme-btn {
  border: 1px solid #c8d3df;
  background: #f9fbfd;
  color: #22303c;
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}

.theme-btn.daily {
  border-color: #6cc49a;
  background: #ecf8f0;
}

.theme-btn:hover {
  background: #edf3f9;
}

.theme-card {
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 88px auto;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.theme-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgb(25 35 52 / 12%);
}

.theme-image {
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid #dce3ec;
}

.theme-card-body {
  padding: 10px 11px 11px;
  display: grid;
  gap: 4px;
}

.theme-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a2430;
  line-height: 1.2;
}

.theme-card-subtitle {
  font-size: 12px;
  color: #5f6b77;
  line-height: 1.25;
}

@media (max-width: 390px) {
  .app {
    padding: 12px;
  }

  .cell {
    font-size: 20px;
  }

  .theme-grid {
    grid-template-columns: 1fr;
  }
}
