/* Shared base + hub styles. */

:root {
  --bg: #0b1026;
  --bg-2: #141b3d;
  --fg: #ffffff;
  --accent: #ffd600;
  --pink: #ff77c6;
  --cyan: #4fe3ff;
  --wall: #7ec8ff;
  --dot: #ffe082;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* -------- Hub -------- */

.hub {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  text-align: center;
}

.hub__title {
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  margin: 0.5rem 0 0.25rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.hub__subtitle {
  margin: 0 0 2rem;
  opacity: 0.75;
  font-size: 1.05rem;
}

.hub__version {
  margin: 2rem 0 0;
  opacity: 0.35;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  min-height: 1em;
}

.tiles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  background: var(--bg-2);
  border-radius: 1.25rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 1.25rem;
  aspect-ratio: 1 / 1;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.05)
    inset;
  transition: transform 0.08s ease;
}

.tile:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25),
    0 0 0 2px rgba(255, 255, 255, 0.05) inset;
}

.tile__art {
  width: 60%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile__label {
  font-size: 1.1rem;
}

/* Little Pac-Man face made with a single div. */
.pac {
  --size: 100%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 30% 30%, #fff176, var(--accent) 60%);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
.pac::before {
  /* mouth wedge */
  content: "";
  position: absolute;
  top: 50%;
  right: -1px;
  width: 55%;
  height: 55%;
  background: var(--bg-2);
  transform: translateY(-50%);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
}
.pac::after {
  /* eye */
  content: "";
  position: absolute;
  top: 18%;
  left: 48%;
  width: 12%;
  height: 12%;
  background: #111;
  border-radius: 50%;
}

/* Piano Tiles icon — four coloured key bars. */
.tile__art--piano {
  align-items: flex-end;
}

.piano-keys {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  width: 90%;
  height: 90%;
}

.piano-key {
  flex: 1;
  border-radius: 6px 6px 10px 10px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.piano-key:nth-child(1) { height: 75%; }
.piano-key:nth-child(2) { height: 100%; }
.piano-key:nth-child(3) { height: 85%; }
.piano-key:nth-child(4) { height: 60%; }

/* Colouring icon — a rounded palette with coloured dots. */
.tile__art--palette {
  /* Keep the palette centered. */
}

.palette {
  width: 100%;
  height: 100%;
  background: #fff6e0;
  border-radius: 45% 45% 50% 50% / 55% 55% 45% 45%;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3),
    inset 0 0 0 3px #e0c79a;
  position: relative;
}

.palette::after {
  /* Thumb hole. */
  content: "";
  position: absolute;
  right: 10%;
  bottom: 18%;
  width: 20%;
  height: 20%;
  background: var(--bg-2);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #e0c79a;
}

.palette-dot {
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.palette-dot:nth-child(1) { top: 12%;  left: 20%; }
.palette-dot:nth-child(2) { top: 10%;  left: 52%; }
.palette-dot:nth-child(3) { top: 36%;  left: 10%; }
.palette-dot:nth-child(4) { top: 38%;  left: 62%; }
.palette-dot:nth-child(5) { top: 60%;  left: 18%; }
.palette-dot:nth-child(6) { top: 60%;  left: 46%; }

/* Snake tile */
.tile--snake {
  background: linear-gradient(135deg, #0b2b0b 0%, #0b1a0b 100%);
}

.tile__art--snake {
  position: relative;
  width: 60%;
  height: 60%;
}

.snake-icon {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100%;
  height: 100%;
  gap: 3px;
}

.snake-icon__seg {
  background: #4fe340;
  border-radius: 3px;
}

.snake-icon__seg--head {
  background: #8aff80;
}

.snake-icon__food {
  background: #ff4f4f;
  border-radius: 50%;
}

/* School Run icon — a running figure on grass. */
.tile--school-run,
.tile--sr2 {
  background: linear-gradient(180deg, #4fb8ff 62%, #c98d5e 62%);
}

.tile__art--sr2 {
  position: relative;
}

.sr2-star {
  width: 62%;
  aspect-ratio: 1;
  background: #ffd23c;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.sr2-two {
  position: absolute;
  right: 12%;
  bottom: 10%;
  padding: 0 0.3em;
  border-radius: 8px;
  background: #e3342f;
  color: #fff;
  font-weight: 900;
  font-size: 1.5rem;
  transform: rotate(8deg);
}

.tile--platformer {
  background: linear-gradient(180deg, #87CEEB 60%, #5a9e4b 60%);
}

.tile__art--runner {
  position: relative;
}

.runner {
  width: 40%;
  height: 80%;
  position: relative;
}

/* Head */
.runner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36%;
  height: 28%;
  background: #fdd9b5;
  border-radius: 50%;
  box-shadow:
    0 -4px 0 0 #f0c75e,
    -3px -5px 0 0 #f0c75e,
    3px -5px 0 0 #f0c75e;
}

/* Body + legs */
.runner::after {
  content: "";
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 40%;
  background: #2980b9;
  border-radius: 4px;
  box-shadow:
    -6px 28px 0 0 #1a6b5a,
    6px 28px 0 0 #1a6b5a,
    -6px 38px 0 0 #333,
    6px 38px 0 0 #333;
}

/* Security Invaders tile — a pixel-style invader. */
.tile--invaders {
  background: linear-gradient(160deg, #141b3d 0%, #1e0b2e 100%);
}

.tile__art--invaders {
  align-items: center;
  justify-content: center;
}

.invader {
  position: relative;
  width: 80%;
  height: 64%;
  background: #4fe3ff;
  clip-path: polygon(
    22% 0, 78% 0, 78% 15%, 92% 15%, 92% 40%,
    100% 40%, 100% 70%, 78% 70%, 78% 85%, 92% 85%,
    92% 100%, 68% 100%, 68% 85%, 32% 85%, 32% 100%,
    8% 100%, 8% 85%, 22% 85%, 22% 70%, 0 70%,
    0 40%, 8% 40%, 8% 15%, 22% 15%
  );
  filter: drop-shadow(0 0 6px rgba(79, 227, 255, 0.55));
}

.invader__eye {
  position: absolute;
  top: 28%;
  width: 12%;
  height: 16%;
  background: #0b1026;
  border-radius: 2px;
}
.invader__eye--l { left: 28%; }
.invader__eye--r { right: 28%; }

/* -------- Shared win / game-over card (used by every game) -------- */

.pac-win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 38, 0.72);
  backdrop-filter: blur(2px);
  border-radius: 18px;
  padding: 1rem;
  z-index: 5;
}

.pac-win[hidden] {
  display: none;
}

.pac-win__card {
  background: var(--bg-2);
  padding: 1.5rem 1.75rem 1.25rem;
  border-radius: 1.25rem;
  text-align: center;
  max-width: 90vw;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3),
    0 0 0 2px rgba(255, 255, 255, 0.06) inset;
}

.pac-win__title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.pac-win__btn {
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #222;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

.pac-win__btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

/* Jet tile — sky gradient background + CSS fighter-jet silhouette. */
.tile--jet {
  background: linear-gradient(160deg, #7bc0ff 0%, #4fe3ff 55%, #b6deff 100%);
  color: #14213d;
}

.jet-art {
  position: relative;
  width: 80%;
  height: 80%;
}

.jet-art::before {
  /* Fuselage */
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 16%;
  height: 84%;
  background: #eef2f8;
  border-radius: 40% 40% 30% 30% / 30% 30% 20% 20%;
  transform: translateX(-50%);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.15);
}

.jet-art::after {
  /* Wings */
  content: "";
  position: absolute;
  left: 10%;
  top: 55%;
  width: 80%;
  height: 18%;
  background: #eef2f8;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

/* Jingle Climb tile: Christmas tree with baubles and a star. */
.tile--jingle {
  background: linear-gradient(135deg, #12306b 0%, #0a1736 100%);
}

.tile__art--jingle {
  position: relative;
  width: 60%;
  height: 60%;
}

.xmas-tree {
  position: absolute;
  inset: 8% 10% 0;
  background: #1f9a4a;
  clip-path: polygon(50% 0, 72% 32%, 62% 32%, 84% 64%, 72% 64%, 96% 92%, 4% 92%, 28% 64%, 16% 64%, 38% 32%, 28% 32%);
}

.xmas-tree::after {
  content: "";
  position: absolute;
  left: 44%;
  width: 12%;
  top: 92%;
  height: 8%;
  background: #6b3f1d;
}

.xmas-tree__star {
  position: absolute;
  left: 50%;
  top: -14%;
  width: 26%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  background: #ffd34d;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.xmas-tree__bauble {
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
}
