:root {
  --color-bg: #1a1a2e;
  --color-surface: #fff;
  --color-text: #1a1a2e;
  --color-text-light: #6b7280;
  --color-primary: #7c3aed;
  --color-primary-dark: #5b21b6;
  --tile-red: #e21b3c;
  --tile-blue: #1368ce;
  --tile-yellow: #d89e00;
  --tile-green: #26890c;
  --tile-purple: #7b3fe4;
  --tile-teal: #0e9594;
  --tile-orange: #d9640b;
  --radius: 12px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-bg), #16213e);
  color: var(--color-text);
}

.app-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

h1, h2, h3 { margin-top: 0; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover { background: var(--color-primary-dark); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.field input[type="text"],
.field select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  border: 2px solid #d1d5db;
  font-size: 1rem;
}

.toggle-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; }

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-bar-fill { height: 100%; background: var(--color-primary); transition: width 0.2s ease; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
}
.timer.timer-low { color: var(--tile-red); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.tile {
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.tile.selected { outline: 4px solid #fff; outline-offset: -4px; }
.tile-shape { font-size: 1.2rem; }

.tile-color-0 { background: var(--tile-red); }
.tile-color-1 { background: var(--tile-blue); }
.tile-color-2 { background: var(--tile-yellow); }
.tile-color-3 { background: var(--tile-green); }
.tile-color-4 { background: var(--tile-purple); }
.tile-color-5 { background: var(--tile-teal); }
.tile-color-6 { background: var(--tile-orange); }

table.match-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.match-table th, table.match-table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid #e5e7eb; }

.option-pool { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.option-pool span { background: #ede9fe; color: var(--color-primary-dark); padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.9rem; font-weight: 600; }

.review-item { border-bottom: 1px solid #e5e7eb; padding: 1rem 0; }
.review-item.correct { border-left: 4px solid var(--tile-green); padding-left: 0.75rem; }
.review-item.incorrect { border-left: 4px solid var(--tile-red); padding-left: 0.75rem; }

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid #e5e7eb; }
.leaderboard-table tr:first-child td { font-weight: 700; }

.text-muted { color: var(--color-text-light); font-size: 0.9rem; }
.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
