:root {
  color-scheme: dark;
  --bg: #0D0D14;
  --panel: #141421;
  --tile: #191927;
  --tile-strong: #202033;
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #F4F2FF;
  --muted: #A7A3B8;
  --purple: #7C4DFF;
  --purple-dark: #4E2BB7;
  --gold: #F4C95D;
  --danger: #E16A7C;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18px;
}

.topbar,
footer {
  width: min(100%, 520px);
  margin: 0 auto;
}

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

.brand {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.status,
footer {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.export-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.game-surface {
  width: min(100%, 520px);
  margin: 18px auto;
  display: grid;
  align-content: start;
  gap: 22px;
}

.round-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.attempts {
  display: flex;
  gap: 7px;
}

.attempt-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
}

.attempt-dot.used {
  background: var(--danger);
  border-color: var(--danger);
}

.anchor-section h1 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: lowercase;
}

.anchor-grid,
.candidate-grid,
.reveal-grid {
  display: grid;
  gap: 10px;
}

.anchor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.candidate-grid,
.reveal-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.word-tile {
  min-height: 72px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--tile);
  color: var(--text);
  font-size: clamp(1rem, 7vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.anchor-tile {
  min-height: 64px;
  background: var(--panel);
  color: #DCD8FF;
}

.candidate-tile.selected {
  border-color: rgba(124, 77, 255, 0.9);
  background: linear-gradient(180deg, var(--purple), var(--purple-dark));
  box-shadow: 0 0 0 1px rgba(124, 77, 255, 0.25);
}

.word-tile:active {
  transform: scale(0.98);
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  border: 0;
  background: var(--purple);
  color: white;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font-size: 0.74rem;
  font-weight: 600;
}

.reveal-panel {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.reveal-tile {
  background: var(--tile-strong);
}

mark {
  border-radius: 5px;
  background: rgba(244, 201, 93, 0.22);
  color: var(--gold);
  padding: 0 2px;
}

.shake {
  animation: shake 260ms ease;
}

footer {
  text-align: center;
  padding-bottom: 2px;
}

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

@media (min-width: 700px) {
  .app-shell {
    padding: 24px;
  }

  .game-surface {
    gap: 24px;
  }
}
