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

body {
  background: #0f0f1a;
  color: #fff;
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Screen management ─────────────────────────────────── */
.screen { display: none; width: 100%; max-width: 480px; padding: 24px; }
.screen.active { display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* ── Title ─────────────────────────────────────────────── */
.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ── Selector groups ───────────────────────────────────── */
.selector-group { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.selector-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888; }
.selector-options { display: flex; gap: 8px; }

.selector-option {
  flex: 1;
  padding: 10px 4px;
  background: #1e1e2e;
  border: 1px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}
.selector-option:hover { border-color: #666; color: #ccc; }
.selector-option.selected {
  background: #4cc9f0;
  border-color: #4cc9f0;
  color: #000;
  font-weight: 600;
}

/* ── Sequence preview ──────────────────────────────────── */
.sequence-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e1e2e;
  padding: 12px;
  border-radius: 8px;
  width: 100%;
}
.preview-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
}
.preview-arrow { color: #555; font-size: 14px; }
.preview-label { color: #666; font-size: 12px; margin-left: 4px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #e63946; color: #fff; }
.btn-secondary {
  background: #1e1e2e;
  color: #eee;
  border: 1px solid #888;
  font-weight: 400;
  font-size: 13px;
  padding: 10px;
}

/* ── Game screen layout ────────────────────────────────── */
#game-screen { gap: 16px; }

/* ── Sequence bar ──────────────────────────────────────── */
.sequence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e1e2e;
  padding: 10px 14px;
  border-radius: 8px;
  width: 100%;
  justify-content: center;
}
.seq-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 1;
  transition: opacity 0.2s, box-shadow 0.2s, transform 0.2s;
}
.seq-swatch.active {
  opacity: 1;
  border: 2px solid #fff;
  box-shadow: 0 0 8px currentColor;
  transform: scale(1.2);
  width: 24px;
  height: 24px;
}
.seq-arrow { color: #ccc; font-size: 10px; }
.seq-label { color: #ddd; font-size: 11px; margin-left: 4px; }

/* ── Grid ──────────────────────────────────────────────── */
.grid-wrapper { width: 100%; display: flex; justify-content: center; }

.maze-grid {
  display: grid;
  gap: 4px;
  /* grid-template-columns set by JS */
}

.cell {
  width: var(--cell-size, 44px);
  height: var(--cell-size, 44px);
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size, 44px) * 0.45);
  font-weight: 400;
  transition: border-color 0.1s, box-shadow 0.1s;
  user-select: none;
  position: relative;
}
.cell:hover { border-color: rgba(255,255,255,0.3); }

.cell.empty {
  background: #1e1e2e;
  border-color: #2a2a3e;
  cursor: default;
}
.cell.empty:hover { border-color: #2a2a3e; }

.cell.current {
  border-color: #fff !important;
  box-shadow: 0 0 10px rgba(255,255,255,0.35);
}

.cell.visited::after {
  content: '●';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size, 44px) * 0.32);
  color: var(--dot-color, white);
}

.cell.end-cell { border-color: #4ade80 !important; }

/* ── Game buttons row ──────────────────────────────────── */
.game-buttons { display: flex; gap: 8px; width: 100%; }
.game-buttons .btn { width: auto; flex: 1; }

/* ── Win overlay ───────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay.active { display: flex; }
.overlay-box {
  background: #1e1e2e;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 36px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.overlay-title { font-size: 32px; font-weight: 700; letter-spacing: 2px; }

.generating-msg {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  color: #888;
  font-size: 18px;
}

/* ── Sequence option list ───────────────────────────────── */
.seq-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.seq-option {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: #1e1e2e;
  border: 1px solid #444;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.seq-option:hover { border-color: #666; }
.seq-option.selected {
  border-color: #fff;
  border-width: 2px;
  padding: 8px 11px; /* compensate for extra border px */
}

.seq-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.seq-dot-arrow { color: #555; font-size: 11px; }
