:root {
  --bg: #0d0f14;
  --card: #171a22;
  --tile: #1e232e;
  --line: #2a303d;
  --text: #f2f4f8;
  --muted: #8b93a7;
  --accent: #c9b6ff;
  --danger: #ff5c5c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, #1c2230 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

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

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand span {
  color: var(--accent);
}

.stats {
  display: flex;
  gap: 8px;
}

.stat {
  min-width: 64px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 10px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.stat small {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 16px 0;
}

.answer {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 0.15s, color 0.15s;
}

.answer .hint {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.answer.good {
  border-color: var(--accent);
  color: var(--accent);
}

.answer.bad {
  border-color: var(--danger);
  color: var(--danger);
  animation: shake 0.3s;
}

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

.letters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tile {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.12s, background 0.12s;
}

.tile:active {
  transform: scale(0.94);
}

.tile.used {
  opacity: 0.25;
  pointer-events: none;
}

.controls {
  display: flex;
  gap: 8px;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

.ghost {
  flex: 1;
  height: 52px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
}

.primary {
  flex: 2;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: #1a1226;
  font-size: 16px;
  font-weight: 700;
}

.primary:active {
  transform: scale(0.98);
}

.words {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
}

.words li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 13px;
  text-transform: uppercase;
  animation: pop 0.18s;
}

.words li b {
  color: var(--accent);
  margin-left: 5px;
  font-size: 11px;
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

.card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card.win {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(201, 182, 255, 0.25), 0 24px 70px rgba(169, 140, 224, 0.2);
  animation: win-pop 0.35s ease;
}

.card.win .card-label {
  color: var(--accent);
  font-weight: 600;
}

@keyframes win-pop {
  from {
    transform: scale(0.94);
    opacity: 0.6;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.card-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-score {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.card-sub {
  color: var(--muted);
  margin-top: -6px;
}

.card-seed {
  font-size: 14px;
  color: var(--muted);
  margin: 8px 0 14px;
}

.card-seed b {
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wide {
  flex: none;
  width: 100%;
}

.goal {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
}

.goal-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #151922;
  border: 1px solid var(--line);
  overflow: hidden;
}

.goal-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #a98ce0, var(--accent));
  transition: width 0.25s ease;
}

.goal-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.stars {
  font-size: 30px;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 2px 0 6px;
}

.record {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.record.new {
  color: var(--accent);
  font-weight: 600;
}

.card-missed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.missed {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-height: 120px;
  overflow-y: auto;
}

.missed span {
  background: #10131a;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 7px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}
