:root {
  --bg: #1e293b;
  --panel: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --correct: #4ade80;
  --wrong: #f87171;
  --key: #334155;
  --key-hover: #475569;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 12px 10px 20px;
}

.game {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ---------- Score bar ---------- */
.score {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 16px;
  width: 100%;
}
.score-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.score-side:last-child { justify-content: flex-end; }
.score-label { color: var(--muted); font-size: 0.85rem; }
.score-num   { font-size: 1.4rem; font-weight: 700; min-width: 1.5ch; text-align: center; }
.score-vs    { color: var(--muted); font-size: 0.8rem; }

.name-btn {
  background: none;
  border: 1px solid var(--key);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 8px;
}
.name-btn:hover { border-color: var(--accent); color: var(--accent); }

.name-input {
  background: var(--key);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 2px 8px;
  width: 100px;
}

.name-list {
  background: var(--panel);
  border: 1px solid var(--key);
  border-radius: 6px;
  list-style: none;
  padding: 4px 0;
  position: absolute;
  z-index: 10;
  min-width: 120px;
}
.name-list li {
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 12px;
}
.name-list li:hover { background: var(--key); }

/* ---------- Level toggle ---------- */
.level-toggle {
  display: flex;
  gap: 6px;
}
.level-btn {
  background: var(--key);
  border: 2px solid transparent;
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 5px 14px;
  text-transform: capitalize;
  transition: border-color 0.15s;
}
.level-btn:hover  { border-color: var(--muted); }
.level-btn.active { border-color: var(--accent); color: var(--accent); }

/* ---------- Stats row ---------- */
.stats {
  color: var(--muted);
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
}
.stats strong { color: var(--text); }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  gap: 2px;
  background: var(--panel);
  border-radius: 6px;
  padding: 4px;
}

/* Invisible but real and reasonably sized so mobile browsers reliably focus
   it (some treat near-zero-size or display:none inputs as unfocusable).
   font-size:16px stops iOS from auto-zooming the page when it gets focus. */
.mobile-input {
  position: absolute;
  width: 40px;
  height: 40px;
  opacity: 0;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 16px;
  pointer-events: none;
}

.cell {
  aspect-ratio: 1;
  width: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  background: var(--key);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cell.blocked {
  background: transparent;
  cursor: default;
}

.cell.selected {
  background: #1d4ed8;
}

.cell.in-word {
  background: #334155;
  outline: 1px solid #475569;
}

.cell.solved {
  background: #166534;
}

.cell .number {
  color: var(--muted);
  font-size: 0.55rem;
  left: 3px;
  position: absolute;
  top: 1px;
}

.cell .letter {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ---------- Clue lists ---------- */
.clue-lists {
  display: flex;
  gap: 16px;
  width: 100%;
}

.clue-col {
  flex: 1;
  min-width: 0;
}

.clue-col h2 {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.clue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
}

.clue-list li {
  background: var(--panel);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 6px 8px;
}
.clue-list li:hover { background: var(--key); }

.clue-list li.solved {
  color: var(--correct);
  text-decoration: line-through;
}

.clue-list li .clue-number {
  color: var(--muted);
  font-weight: 700;
  margin-right: 4px;
}

/* ---------- Result banner ---------- */
.result {
  background: var(--panel);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 20px;
  text-align: center;
  width: 100%;
}
.result.win { color: var(--correct); }

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.action-btn {
  background: var(--key);
  border: none;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 16px;
}
.action-btn:hover { background: var(--key-hover); }

.new-game {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #0f172a;
  cursor: pointer;
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 16px;
}
.new-game:hover  { opacity: 0.9; }
.new-game:active { transform: scale(0.97); }

/* ---------- Home logo ---------- */
.home-btn {
  display: block;
  margin: 1.5rem auto 0;
  max-width: 220px;
}
.home-btn img { display: block; width: 100%; }
.home-btn:hover { opacity: 0.8; }
