:root {
  --bg: #ffe3f0;
  --text: #4a2a3d;
  --text-muted: #9a6f89;
  --card-bg: #ffffff;
  --card-border: rgba(214, 51, 132, 0.12);
  --shadow: 0 10px 30px rgba(214, 51, 132, 0.14);
  --shadow-hover: 0 18px 42px rgba(214, 51, 132, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #221420;
    --text: #ffe3f1;
    --text-muted: #cf9dbb;
    --card-bg: #331e30;
    --card-border: rgba(255, 179, 219, 0.15);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 18px 42px rgba(0, 0, 0, 0.55);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fredoka", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  position: relative;
  touch-action: manipulation;
}

.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
  z-index: 0;
  pointer-events: none;
}

.blob-1 {
  width: 420px;
  height: 420px;
  top: -160px;
  left: -140px;
  background: #ff2f92;
}

.blob-2 {
  width: 380px;
  height: 380px;
  bottom: -140px;
  right: -120px;
  background: #c084fc;
}

.blob-3 {
  width: 320px;
  height: 320px;
  top: 42%;
  left: 58%;
  background: #ffd166;
  opacity: 0.25;
}

.header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 4rem 1.5rem 2.5rem;
  padding-top: calc(4rem + env(safe-area-inset-top));
}

.site-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.site-logo-wrap {
  position: relative;
  flex-shrink: 0;
  border-radius: 22%;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(255, 47, 146, 0.28);
}

/* Tints the logo (a flat-pink PNG) toward the same pink-to-purple gradient
   as the wordmark, so the two read as one lockup instead of two colors. */
.site-logo-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ff2f92, #ff6fb8 45%, #b46bff);
  mix-blend-mode: color;
}

.site-logo {
  display: block;
  width: clamp(1.9rem, 3.8vw, 2.6rem);
  height: clamp(1.9rem, 3.8vw, 2.6rem);
}

.site-title {
  position: relative;
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ff2f92, #ff6fb8 45%, #b46bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Taken out of the flex flow (absolute) so this decorative flourish can't
   throw off the logo+wordmark's centering - .site-title-row's width, and
   so its center, comes only from the logo and the text itself. */
.site-title::after {
  content: "✨";
  position: absolute;
  top: 50%;
  right: -0.1em;
  transform: translate(100%, -60%);
  font-size: 0.5em;
  -webkit-text-fill-color: initial;
  animation: sparkle-bob 2.4s ease-in-out infinite;
}

.site-title::after {
  animation-delay: 1.1s;
}

.site-subtitle {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.grid {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.75rem;
}

.card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-hover);
}

.card-cover {
  position: relative;
  height: 150px;
  overflow: hidden;
  background-color: color-mix(in srgb, var(--accent) 18%, var(--card-bg));
}

.card-icon {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--card-bg);
  padding: 5px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

/* ---- Pretty Bird live preview ---- */

.preview-bird {
  background: linear-gradient(180deg, #bdeeff 0%, #eafcff 55%, #d9f7e3 100%);
}

.bird-pipe-set {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 26px;
  animation: pipe-cross 3.4s linear infinite;
}

.bird-pipe-set:nth-child(2) {
  animation-delay: -1.7s;
}

.bird-pipe {
  position: absolute;
  left: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.bird-pipe img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.bird-pipe-top {
  top: 0;
  height: 45px;
}

/* Real game hangs this cat upside-down, face toward the gap below. */
.bird-pipe-top img {
  transform: scaleY(-1);
}

.bird-pipe-bottom {
  bottom: 0;
  height: 50px;
}

.bird-sprite {
  position: absolute;
  left: 24%;
  top: 45%;
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.18));
  animation: bird-bob 1.2s ease-in-out infinite;
  z-index: 2;
}

@keyframes pipe-cross {
  from {
    transform: translateX(220px);
  }
  to {
    transform: translateX(-40px);
  }
}

@keyframes bird-bob {
  0%,
  100% {
    transform: translateY(-6px) rotate(-8deg);
  }
  50% {
    transform: translateY(16px) rotate(12deg);
  }
}

/* ---- Wordle Land live preview ---- */

.preview-wordle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd6ea, #ffe9f5 60%, #fff);
}

.wordle-row {
  position: relative;
  display: flex;
  gap: 6px;
}

.wordle-tile {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid #f3b8d6;
  border-radius: 6px;
  background: #fff;
  color: #c23b83;
}

.wordle-tile.flip,
.tango-tile.flip {
  animation: tile-flip 0.5s ease forwards;
}

@keyframes tile-flip {
  0% {
    transform: rotateX(0deg);
    background: #fff;
    color: #c23b83;
    border-color: #f3b8d6;
  }
  49% {
    background: #fff;
    color: #c23b83;
    border-color: #f3b8d6;
  }
  50% {
    transform: rotateX(90deg);
  }
  51% {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }
  100% {
    transform: rotateX(0deg);
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }
}

/* ---- Shared tap cursor (the "someone is playing" touch) ---- */

.tap-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

.tap-cursor-bird {
  left: 20%;
  top: 55%;
  font-size: 1.1rem;
  animation: tap-bird 1.2s ease-in-out infinite;
}

@keyframes tap-bird {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.7) translateY(6px);
  }
  45% {
    opacity: 0;
  }
  55% {
    opacity: 1;
    transform: scale(1) translateY(-4px);
  }
  70% {
    opacity: 0;
    transform: scale(0.85) translateY(-10px);
  }
}

.tap-cursor-row {
  top: -22px;
  left: calc(var(--tap-index, 0) * 34px);
  font-size: 1rem;
  opacity: 0.9;
  transition: left 0.2s ease;
  animation: tap-bounce 0.5s ease-in-out infinite;
}

@keyframes tap-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(4px);
  }
}

/* ---- Tango live preview ---- */

.preview-tango {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #efe6ff, #f7f1ff 60%, #fff);
}

.tango-row {
  position: relative;
  display: flex;
  gap: 6px;
}

.tango-tile {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  border: 2px solid #ddc9ff;
  border-radius: 6px;
  background: #fff;
}

/* ---- Queens live preview ---- */

.preview-queens {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffe3ee, #fff7f0 60%, #fff);
}

.queens-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 20px);
  grid-template-rows: repeat(4, 20px);
  gap: 2px;
}

.queens-cell {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.queens-cell .crown {
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.queens-cell.placed .crown {
  opacity: 1;
  transform: scale(1);
}

/* ---- Minesweeper live preview ---- */

.preview-minesweeper {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffe9d6, #fff4ea 60%, #fff);
}

.mine-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 22px);
  grid-template-rows: repeat(5, 22px);
  gap: 2px;
}

.mine-cell {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: linear-gradient(145deg, #ffe0c2, #ffd0a3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  transition: background 0.2s ease;
}

.mine-cell.revealed {
  background: #fff8f0;
}

.mine-cell.n1 { color: #6fa8ff; }
.mine-cell.n2 { color: #4fbf8a; }
.mine-cell.n3 { color: #ff6f8f; }

.mine-cell .mini-paw {
  width: 70%;
  height: 70%;
}

/* ---- Block Blast live preview ---- */

.preview-blockblast {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f9ef, #fff7fb 60%, #fff);
}

.bb-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 20px);
  grid-template-rows: repeat(4, 20px);
  gap: 2px;
}

.bb-cell {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #fff0f6;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.bb-cell.filled {
  background: var(--piece-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.bb-cell.clearing {
  animation: bb-clear 0.26s ease forwards;
}

@keyframes bb-clear {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* ---- Solitaire live preview ---- */

.preview-solitaire {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e3fff0, #f2fff8 60%, #fff);
}

.solitaire-row {
  position: relative;
  display: flex;
  gap: 8px;
}

.solitaire-slot {
  position: relative;
  width: 30px;
  height: 42px;
  border-radius: 5px;
  border: 1.5px dashed #bcead4;
}

.solitaire-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #fffdfb;
  border: 1px solid #e6d9cf;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.14);
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1.15;
}

.solitaire-card-moving {
  z-index: 2;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.solitaire-card-red {
  color: #e91e8c;
}

.solitaire-card-black {
  color: #4a1942;
}

.tap-cursor-solitaire {
  top: -18px;
  left: 0;
  font-size: 1rem;
  opacity: 0;
  transition: transform 0.5s ease, opacity 0.3s ease;
}

@keyframes sparkle-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-4px) rotate(12deg);
  }
}

.card-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.card-title {
  margin: 0 0 0.15rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.card-tagline {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
}

.card-description {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #ff8fc7));
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  transition: transform 0.2s ease;
}

.card:hover .play-btn {
  transform: translateX(3px);
}

.card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  padding: 2.5rem 1.5rem;
  border: 2px dashed var(--card-border);
  background: transparent;
  box-shadow: none;
}

.placeholder-icon {
  font-size: 2rem;
}

.placeholder-text {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1rem 1.5rem 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer p {
  margin: 0.3rem 0;
}

.footer .credit {
  font-weight: 600;
  font-size: 0.85rem;
  color: #ff5eae;
}

/* ---- Profile badge + switcher ---- */

.profile-badge {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  right: calc(1rem + env(safe-area-inset-right));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem 0.4rem 0.6rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.profile-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(74, 25, 66, 0.4);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.profile-modal.hidden {
  display: none;
}

.profile-modal-content {
  position: relative;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.75rem;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--card-border);
}

.profile-modal-content h2 {
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
  font-weight: 600;
  color: #b3106b;
}

.profile-modal-sub {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
}

.profile-row {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.profile-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: #fff7fb;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.profile-select span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-select:hover {
  background: #ffe9f3;
}

.profile-select.active {
  background: linear-gradient(135deg, #e91e8c, #ff6fb0);
  color: #fff;
  border-color: transparent;
}

.profile-delete {
  flex-shrink: 0;
  width: 40px;
  border: 1px solid rgba(214, 51, 132, 0.25);
  border-radius: 12px;
  background: #fff0f5;
  color: #d6336c;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.profile-delete:hover {
  background: #ffd7e6;
  transform: scale(1.05);
}

.profile-delete:active {
  transform: scale(0.94);
}

.profile-manage-btn {
  display: block;
  margin: 0 0 0.9rem;
  background: none;
  border: none;
  color: #d6336c;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}

.profile-form {
  display: flex;
  gap: 0.5rem;
}

.profile-form input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  font-family: inherit;
  font-size: 0.9rem;
  color: #1a1a1a;
  background: #fff;
}

.profile-form input:focus {
  outline: 2px solid #ff8fc7;
  outline-offset: 1px;
}

.profile-add-btn {
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: #e91e8c;
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.profile-guest-btn {
  display: block;
  margin: 0.9rem auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}

@media (max-width: 600px) {
  .profile-badge {
    top: calc(0.6rem + env(safe-area-inset-top));
    right: calc(0.6rem + env(safe-area-inset-right));
    padding: 0.35rem 0.7rem 0.35rem 0.5rem;
    font-size: 0.75rem;
  }
}
