:root {
  --bg-1: #fff7dd;
  --bg-2: #d8f4ff;
  --ink: #123050;
  --ink-soft: #37526f;
  --panel: rgba(255, 255, 255, 0.83);
  --accent-1: #ff8f6b;
  --accent-2: #4ecdc4;
  --accent-3: #6c8cff;
  --line: rgba(18, 48, 80, 0.15);
  --shadow: 0 18px 42px rgba(18, 48, 80, 0.16);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Nunito", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 18% 16%, #fffef7 0%, var(--bg-1) 38%, var(--bg-2) 100%);
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.48;
  pointer-events: none;
  animation: floaty 11s ease-in-out infinite;
}

.shape-a {
  width: 320px;
  height: 320px;
  top: -80px;
  left: -60px;
  background: #ffe37a;
}

.shape-b {
  width: 290px;
  height: 290px;
  right: -95px;
  top: 22%;
  background: #79d8ff;
  animation-delay: 0.8s;
}

.shape-c {
  width: 260px;
  height: 260px;
  left: 46%;
  bottom: -110px;
  background: #ff9eb0;
  animation-delay: 1.6s;
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-12px) scale(1.03);
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 18px 26px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.brand-wrap h1,
.hero h2,
.game-card h3,
#activeGameTitle {
  font-family: "Baloo 2", "Trebuchet MS", sans-serif;
  line-height: 1.02;
  letter-spacing: 0.2px;
}

.brand-kicker {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}

.brand-wrap h1 {
  margin: 2px 0 0;
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
}

.control-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 700;
  font-size: 0.92rem;
}

.picker select {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.pill-btn {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), #72e4d8);
  color: #08303b;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.pill-btn.secondary {
  background: linear-gradient(135deg, #ffd36f, #ffae57);
  color: #563609;
}

.pill-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.pill-btn:active {
  transform: translateY(0);
}

.view {
  margin-top: 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(14px, 3.5vw, 24px);
}

.hero {
  max-width: 780px;
}

.hero h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
}

.hero p {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.7vw, 1.16rem);
}

.game-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.game-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 16px;
  color: #132e48;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  animation: card-enter 600ms ease forwards;
}

.game-card:nth-child(2) {
  animation-delay: 120ms;
}

.game-card:nth-child(3) {
  animation-delay: 220ms;
}

.game-card:nth-child(4) {
  animation-delay: 320ms;
}

.game-card:nth-child(5) {
  animation-delay: 420ms;
}

.game-card:nth-child(6) {
  animation-delay: 520ms;
}

.game-card:nth-child(7) {
  animation-delay: 620ms;
}

@keyframes card-enter {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.9;
}

.snake-card::before {
  background: linear-gradient(150deg, #d6fff2, #b6f0ff 48%, #f8fff7);
}

.obie-card::before {
  background: linear-gradient(150deg, #fff0c8, #ffd2dd 48%, #fff8f4);
}

.space-card::before {
  background: linear-gradient(150deg, #d8dbff, #c6f6ff 50%, #f7f8ff);
}

.tic-card::before {
  background: linear-gradient(150deg, #ffe0f1, #d7ffde 52%, #fff8d7);
}

.pickle-card::before {
  background: linear-gradient(150deg, #f5ffd5, #c6f3ff 52%, #ffe6be);
}

.memory-card::before {
  background: linear-gradient(150deg, #f1e4ff, #d9f6ff 48%, #fff4cf);
}

.math-card::before {
  background: linear-gradient(150deg, #ffecc3, #d8f6ff 48%, #e8e3ff);
}

.card-tag {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  font-weight: 800;
}

.game-card h3 {
  margin: 6px 0 8px;
  font-size: 1.7rem;
}

.game-card p {
  margin: 0;
}

.start-game-btn {
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(130deg, #5e7bff, #3fc6ff);
}

.game-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.game-labels h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.7vw, 2rem);
}

.game-labels p {
  margin: 3px 0 0;
  color: var(--ink-soft);
}

.difficulty-badge {
  justify-self: end;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(145deg, #91a5ff, #7fc4ff);
  color: #fff;
  font-weight: 800;
}

.canvas-wrap {
  margin-top: 14px;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid rgba(18, 48, 80, 0.2);
  background: #0a273f;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
}

.overlay-message {
  position: absolute;
  inset: auto 16px 16px;
  background: rgba(11, 42, 70, 0.82);
  color: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.overlay-message.hidden {
  display: none;
}

.hud-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hud-pill {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  font-weight: 700;
}

.controls-copy {
  margin: 12px 0 8px;
  color: var(--ink-soft);
  font-weight: 700;
}

.touch-controls {
  display: grid;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.dir-middle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dir-btn,
.jump-btn,
.space-btn,
.pickle-btn {
  border: 0;
  border-radius: 14px;
  min-width: 96px;
  min-height: 56px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.dir-btn {
  background: linear-gradient(130deg, #4fb6ff, #5f8dff);
}

.jump-btn {
  width: min(300px, 74vw);
  background: linear-gradient(130deg, #ff8f75, #ff5f8a);
}

.space-controls {
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  width: min(420px, 92vw);
}

.space-btn {
  min-width: 0;
}

.pickle-controls {
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  width: min(420px, 92vw);
}

.pickle-btn {
  min-width: 0;
}

.move-btn {
  background: linear-gradient(130deg, #6f93ff, #5573f0);
}

.shoot-btn {
  background: linear-gradient(130deg, #ffa96d, #ff6f7f);
}

.paddle-btn {
  background: linear-gradient(130deg, #72c374, #5ea95f);
}

.swing-btn {
  background: linear-gradient(130deg, #ff9f67, #ff7c4e);
}

.dir-btn:active,
.jump-btn:active,
.space-btn:active,
.pickle-btn:active {
  transform: scale(0.98);
}

.jump-controls {
  display: flex;
  justify-content: center;
}

.site-foot {
  margin-top: 12px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.93rem;
}

.site-foot a {
  color: #1c77cf;
}

@media (max-width: 820px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .control-wrap {
    justify-content: space-between;
  }

  .game-toolbar {
    grid-template-columns: 1fr;
  }

  .difficulty-badge {
    justify-self: start;
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    max-width: 340px;
    opacity: 0.9;
  }
}

@media (hover: none), (pointer: coarse) {
  .controls-copy {
    font-size: 0.98rem;
  }

  .dir-btn,
  .jump-btn,
  .space-btn,
  .pickle-btn {
    min-height: 60px;
    font-size: 1.02rem;
  }
}
