:root {
  color-scheme: dark;
  --bg: #04060b;
  --panel: #0b1120;
  --panel-2: #101a31;
  --border: #1d3767;
  --border-soft: #173059;
  --text: #edf5ff;
  --muted: #89a3d4;
  --bright: #5eb6ff;
  --bright-2: #2e75ff;
  --snake: #3c8cff;
  --snake-head: #89d0ff;
  --food: #ff7a3d;
  --cell: #111a2e;
  --pellet: #ffe680;
  --ghost: #2f56c8;
  --ghost-2: #ff4d8d;
  --ghost-3: #ffab3d;
  --bird: #ffd86b;
  --pipe: #22b573;
  --ttt-x: #6cd7ff;
  --ttt-o: #ff7aa8;
  --cell-size: min(7vw, 24px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(46, 117, 255, 0.14), transparent 32%),
    linear-gradient(180deg, #050812 0%, #04060b 100%);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(100%, 1100px);
  background: linear-gradient(180deg, rgba(16, 26, 49, 0.96), rgba(11, 17, 32, 0.98));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

.header,
.status-bar,
.status-actions,
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.scoreboard,
.best-score,
.leaderboard-group,
.game-tab,
button {
  border: 1px solid var(--border);
}

.scoreboard,
.best-score {
  min-width: 92px;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: center;
  background: rgba(11, 20, 38, 0.82);
}

.scoreboard span,
.best-score span,
.help,
#status,
.leaderboard-header p,
.leaderboard-entry span {
  color: var(--muted);
}

.scoreboard strong,
.best-score strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.game-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}

.help {
  margin: 0 0 16px;
  line-height: 1.5;
}

button,
.game-tab {
  font: inherit;
  color: inherit;
  background: #12203b;
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

button:hover,
.game-tab:hover {
  background: #183055;
}

.game-tab.is-active {
  background: linear-gradient(180deg, #21488f, #16356b);
  border-color: #3f7eff;
}

.status-bar {
  margin-bottom: 16px;
}

.status-actions {
  justify-content: flex-end;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
}

.game-shell,
.leaderboard {
  min-width: 0;
}

.leaderboard {
  padding: 16px;
  background: rgba(10, 17, 32, 0.9);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}

.leaderboard-header {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.leaderboard-header p {
  margin: 0;
  font-size: 0.95rem;
}

.leaderboard-groups {
  display: grid;
  gap: 12px;
}

.leaderboard-group {
  background: rgba(16, 26, 49, 0.9);
  border-radius: 12px;
  padding: 12px;
}

.leaderboard-group h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
}

.leaderboard-entry strong {
  color: var(--bright);
}

.leaderboard-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.board-wrap {
  overflow-x: auto;
}

.board-host {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(7, 12, 24, 0.88);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(94, 182, 255, 0.05);
}

.board {
  display: grid;
  gap: 3px;
  width: fit-content;
  padding: 12px;
  background: #091222;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.board-snake {
  grid-template-columns: repeat(16, var(--cell-size));
  grid-template-rows: repeat(16, var(--cell-size));
}

.board-pacman {
  grid-template-columns: repeat(14, var(--cell-size));
  grid-template-rows: repeat(14, var(--cell-size));
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--cell);
  border-radius: 6px;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.cell-snake {
  background: var(--snake);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.cell-head {
  background: var(--snake-head);
  transform: scale(1.06);
  box-shadow: 0 0 12px rgba(137, 208, 255, 0.4);
}

.cell-food {
  background: radial-gradient(circle at 40% 35%, #ffe2bf, var(--food));
  box-shadow: 0 0 14px rgba(255, 122, 61, 0.35);
}

.cell-wall {
  background: #16305c;
}

.cell-pellet {
  position: relative;
}

.cell-pellet::after {
  content: "";
  position: absolute;
  inset: 34%;
  border-radius: 999px;
  background: var(--pellet);
}

.cell-player {
  background: radial-gradient(circle at 35% 35%, #fff2b8, #ffd048);
  box-shadow: 0 0 12px rgba(255, 214, 97, 0.34);
}

.cell-ghost {
  background: var(--ghost);
  box-shadow: 0 0 10px rgba(47, 86, 200, 0.3);
}

.cell-ghost-1 {
  background: var(--ghost);
}

.cell-ghost-2 {
  background: var(--ghost-2);
  box-shadow: 0 0 10px rgba(255, 77, 141, 0.3);
}

.cell-ghost-3 {
  background: var(--ghost-3);
  box-shadow: 0 0 10px rgba(255, 171, 61, 0.3);
}

.flappy-scene {
  position: relative;
  width: min(100%, 420px);
  height: 420px;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(46, 117, 255, 0.18), transparent 60%),
    linear-gradient(180deg, #091224 0%, #08101e 100%);
  border: 1px solid var(--border);
}

.flappy-cloud {
  position: absolute;
  width: 74px;
  height: 24px;
  border-radius: 999px;
  background: rgba(210, 233, 255, 0.16);
  filter: blur(0.5px);
}

.flappy-bird {
  position: absolute;
  left: 72px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d7f5ff, var(--bird));
  box-shadow: 0 0 18px rgba(94, 182, 255, 0.28);
}

.flappy-pipe {
  position: absolute;
  width: 52px;
  background: linear-gradient(180deg, #52e29c, var(--pipe));
  border: 1px solid #89ffbe;
  border-radius: 12px;
}

.tictactoe-wrap {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
}

.tictactoe-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ttt-chip {
  padding: 12px;
  border-radius: 12px;
  background: rgba(13, 22, 41, 0.9);
  border: 1px solid var(--border-soft);
  text-align: center;
}

.ttt-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ttt-cell {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #142444, #0c1830);
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 700;
  display: grid;
  place-items: center;
}

.ttt-cell:hover {
  background: linear-gradient(180deg, #1d3563, #122448);
}

.ttt-cell-x {
  color: var(--ttt-x);
  text-shadow: 0 0 18px rgba(108, 215, 255, 0.28);
}

.ttt-cell-o {
  color: var(--ttt-o);
  text-shadow: 0 0 18px rgba(255, 122, 168, 0.24);
}

.ttt-cell-win {
  border-color: #ffd86b;
  box-shadow: 0 0 22px rgba(255, 216, 107, 0.22);
}

.ttt-summary {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(11, 20, 38, 0.82);
  color: var(--muted);
}

.controls {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.control-primary {
  min-width: 112px;
}

@media (max-width: 920px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 16px;
  }

  .panel {
    padding: 18px;
  }

  .header,
  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-actions {
    width: 100%;
    justify-content: space-between;
  }

  .board-host {
    min-height: 360px;
  }

  .tictactoe-meta {
    grid-template-columns: 1fr;
  }
}
