:root {
  --bg: #050910;
  --panel: #131b2d;
  --panel-alt: #18253d;
  --accent: #3f89ff;
  --accent-strong: #f5be0b;
  --text: #eef2ff;
  --muted: #95a5d3;
  --success: #31c48d;
  --danger: #ff5f5f;
  --warning: #ffb020;
  --font: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #0b1224, var(--bg));
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem clamp(1.5rem, 4vw, 4rem);
  background: rgba(12, 18, 34, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.branding h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 0 0 0.25rem;
  letter-spacing: 0.05em;
}

.branding p {
  margin: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.controls label {
  font-weight: 600;
}

.controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem clamp(1.5rem, 4vw, 4rem) 2.5rem;
}

.game-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.game-nav button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.game-nav button:hover,
.game-nav button.active {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(63, 137, 255, 0.28);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.7fr) minmax(0, 1fr);
  gap: 1.75rem;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
  }
}

.game-panel {
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-alt) 100%);
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 560px;
  position: relative;
  overflow: hidden;
}

.game-panel header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.game-panel header p {
  margin: 0;
  color: var(--muted);
}

.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.status-line {
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar section {
  background: rgba(12, 18, 34, 0.75);
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.5rem;
}

.sidebar h3 {
  margin: 0 0 1rem;
}

#score-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#score-list li {
  background: rgba(30, 42, 68, 0.85);
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

#score-list li strong {
  color: var(--accent-strong);
}

.site-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 18, 34, 0.9);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

button.primary {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 0.75rem;
  padding: 0.75rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(63, 137, 255, 0.35);
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.75rem;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: border 0.2s ease;
}

button.ghost:hover {
  border-color: var(--accent);
}

.grid {
  display: grid;
  gap: 0.5rem;
  justify-content: center;
  align-content: center;
  flex: 1;
}

.cell-button {
  background: rgba(30, 42, 68, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 0.66rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.1s ease;
  cursor: pointer;
  user-select: none;
}

.cell-button:active {
  transform: scale(0.95);
}

.cell-button.correct {
  background: rgba(49, 196, 141, 0.9);
}

.cell-button.error {
  background: rgba(255, 95, 95, 0.85);
}

.card-grid {
  display: grid;
  gap: 0.75rem;
  justify-content: center;
  align-content: center;
  flex: 1;
}

.memory-card {
  width: 90px;
  height: 120px;
  perspective: 1000px;
}

.memory-card button {
  width: 100%;
  height: 100%;
  border-radius: 1rem;
  border: none;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 600;
}

.memory-card button .face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  backface-visibility: hidden;
}

.memory-card button .front {
  background: rgba(63, 137, 255, 0.85);
}

.memory-card button .back {
  background: rgba(12, 18, 34, 0.9);
  transform: rotateY(180deg);
}

.memory-card button.revealed {
  transform: rotateY(180deg);
}

.sequence-board {
  display: grid;
  gap: 0.6rem;
  margin: 1rem auto;
  width: min(340px, 100%);
}

.sequence-cell {
  aspect-ratio: 1;
  border-radius: 0.85rem;
  background: rgba(30, 42, 68, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sequence-cell.active {
  background: var(--accent-strong);
  transform: scale(1.05);
}

.number-recall-display {
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  letter-spacing: 0.18em;
  margin-bottom: 1rem;
}

.input-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.input-group input {
  flex: 1;
  background: rgba(12, 18, 34, 0.8);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  width: min(420px, calc(100% - 2rem));
  margin: 1rem auto;
}

.sudoku-cell {
  background: rgba(30, 42, 68, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.sudoku-cell input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  text-align: center;
  font-size: 1.2rem;
  color: var(--accent);
  font-weight: 600;
}

.sudoku-cell.prefilled {
  color: var(--muted);
}

.sudoku-cell:nth-child(3n + 1) {
  border-left-width: 3px;
}

.sudoku-cell:nth-child(-n + 9) {
  border-top-width: 3px;
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom-width: 3px;
}

.sudoku-cell:nth-child(9n) {
  border-right-width: 3px;
}

.sudoku-cell.block-border {
  border-bottom-width: 3px;
}

.reaction-target {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reaction-target button {
  width: clamp(120px, 15vw, 180px);
  height: clamp(120px, 15vw, 180px);
  border-radius: 50%;
  border: none;
  background: rgba(63, 137, 255, 0.85);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.reaction-target button.ready {
  background: var(--accent-strong);
  transform: scale(1.1);
}

.puzzle-grid {
  display: grid;
  gap: 0.4rem;
  margin: 1rem auto;
  width: min(400px, 100%);
}

.puzzle-tile {
  aspect-ratio: 1;
  border-radius: 0.9rem;
  background: rgba(30, 42, 68, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

.puzzle-tile.blank {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  cursor: default;
}

.puzzle-tile:active {
  transform: scale(0.97);
}

.twenty-four-board {
  display: grid;
  gap: 0.75rem;
}

.twenty-four-hand {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(63, 137, 255, 0.2);
  color: var(--accent);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.summary-metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.summary-metrics .metric {
  background: rgba(30, 42, 68, 0.75);
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  min-width: 120px;
}
