/* Emily's Games launcher — palette and primitives lifted from Game 1 so the
 * launcher and every game feel like the same app.
 */

:root {
  --hk-pink-bg: #ffd1e3;
  --hk-pink-soft: #ffe8f1;
  --hk-pink-hot: #ff6fa5;
  --hk-pink-deep: #cc4d80;
  --hk-purple: #b88cff;
  --hk-purple-deep: #8a5fd9;
  --hk-blue: #8ad7ff;
  --hk-blue-deep: #5fb7e8;
  --hk-red: #ff5b6e;
  --hk-cream: #fff4ee;
  --hk-text: #4a2545;
  --shadow: 0 6px 0 rgba(74, 37, 69, 0.18), 0 12px 24px rgba(74, 37, 69, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Fredoka", "Quicksand", "Comic Sans MS", system-ui, sans-serif;
  color: var(--hk-text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background:
    radial-gradient(circle at 10% 20%, #fff 0 8px, transparent 9px) 0 0/120px 120px,
    radial-gradient(circle at 60% 70%, #fff 0 6px, transparent 7px) 60px 60px/120px 120px,
    linear-gradient(180deg, var(--hk-pink-soft) 0%, var(--hk-pink-bg) 60%, #ffb6cf 100%);
  min-height: 100dvh;
}

/* ----- start overlay (matches Game 1) ----- */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 37, 69, 0.55);
  backdrop-filter: blur(4px);
}
.start-overlay.hidden { display: none; }
.start-card {
  background: var(--hk-cream);
  border: 5px solid var(--hk-text);
  border-radius: 28px;
  padding: 32px 40px;
  text-align: center;
  max-width: 500px;
  box-shadow: var(--shadow);
}
.start-card h1 {
  font-family: "Fredoka", sans-serif;
  font-size: 2.2rem;
  margin: 0 0 12px;
  color: var(--hk-text);
}
.hk-pop { color: var(--hk-pink-hot); }
.start-card p {
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

/* ----- big-btn primitive (matches Game 1) ----- */
.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--hk-cream);
  border: 4px solid var(--hk-text);
  border-radius: 22px;
  padding: 18px 22px;
  min-height: 80px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(74, 37, 69, 0.18), 0 4px 8px rgba(74, 37, 69, 0.18);
}
.big-btn.pink   { background: var(--hk-pink-hot); }
.big-btn.purple { background: var(--hk-purple-deep); }
.big-btn.blue   { background: var(--hk-blue-deep); }

/* ----- launcher layout ----- */
.app {
  padding: 16px clamp(12px, 3vw, 32px) 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.launcher-header {
  text-align: center;
  padding: 12px 0 4px;
}
.launcher-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.4);
}

/* ----- recent row ----- */
.recent-row {
  margin: 16px 0 8px;
  background: rgba(255, 244, 238, 0.7);
  border: 3px solid var(--hk-pink-deep);
  border-radius: 24px;
  padding: 12px 16px 16px;
  box-shadow: var(--shadow);
}
.recent-row h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--hk-pink-deep);
}
.tile-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.tile-row .tile { flex: 0 0 auto; width: 150px; height: 150px; }
.tile-row .tile .tile-emoji { font-size: 4.2rem; }

/* ----- chip strip ----- */
.chip-strip {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 12px 4px;
  margin: 8px 0 16px;
  overflow-x: auto;
  background: rgba(255, 232, 241, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 22px;
  border: 3px solid var(--hk-pink-deep);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.4rem;
  background: var(--hk-cream);
  color: var(--hk-text);
  border: 3px solid var(--hk-text);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 56px;
  min-height: 56px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  opacity: 0.7;
}
.chip .chip-label {
  font-size: 0.85rem;
  font-weight: 600;
}
.chip:hover { transform: translateY(-2px); opacity: 1; }
.chip.active {
  transform: scale(1.12);
  opacity: 1;
  border-color: var(--hk-pink-deep);
  background: #fff;
  box-shadow: 0 4px 0 rgba(74, 37, 69, 0.25), 0 8px 16px rgba(74, 37, 69, 0.18);
}
.chip[data-color="pink"].active   { background: var(--hk-pink-soft); }
.chip[data-color="purple"].active { background: #ece1ff; }
.chip[data-color="blue"].active   { background: #d6f0ff; }

/* ----- tile area ----- */
.tile-area { transition: opacity 0.18s ease; }
.tile-area.is-changing { opacity: 0; }

.cat-block {
  margin-bottom: 24px;
  content-visibility: auto;
  contain-intrinsic-size: 1px 400px;
}
.cat-heading {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 12px 4px 10px;
  color: var(--hk-text);
}

/* When a single category is selected, hide other blocks AND headings. */
.tile-area:not([data-filter="all"]) .cat-heading { display: none; }
.tile-area[data-filter="cooking"]   .cat-block:not([data-category="cooking"])   { display: none; }
.tile-area[data-filter="music"]     .cat-block:not([data-category="music"])     { display: none; }
.tile-area[data-filter="art"]       .cat-block:not([data-category="art"])       { display: none; }
.tile-area[data-filter="puzzles"]   .cat-block:not([data-category="puzzles"])   { display: none; }
.tile-area[data-filter="animals"]   .cat-block:not([data-category="animals"])   { display: none; }
.tile-area[data-filter="adventure"] .cat-block:not([data-category="adventure"]) { display: none; }
.tile-area[data-filter="dressup"]   .cat-block:not([data-category="dressup"])   { display: none; }
.tile-area[data-filter="math"]      .cat-block:not([data-category="math"])      { display: none; }
.tile-area[data-filter="letters"]   .cat-block:not([data-category="letters"])   { display: none; }
.tile-area[data-filter="vehicles"]  .cat-block:not([data-category="vehicles"])  { display: none; }
.tile-area[data-filter="magic"]     .cat-block:not([data-category="magic"])     { display: none; }
.tile-area[data-filter="sports"]    .cat-block:not([data-category="sports"])    { display: none; }
.tile-area[data-filter="special"]   .cat-block:not([data-category="special"])   { display: none; }

/* "Built" filter: keep all category blocks, but hide stub tiles inside them. */
.tile-area[data-filter="built"] .tile.is-stub { display: none; }
/* And hide an entire category block if it has zero built tiles. */
.tile-area[data-filter="built"] .cat-block[data-built-count="0"] { display: none; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ----- tile ----- */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 1;
  background: var(--hk-cream);
  border: 4px solid var(--hk-text);
  border-radius: 18px;
  text-decoration: none;
  color: var(--hk-text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  contain: layout paint;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 6px;
  text-align: center;
}
.tile:hover { transform: translateY(-3px) scale(1.02); }
.tile:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 2px 0 rgba(74, 37, 69, 0.18), 0 4px 8px rgba(74, 37, 69, 0.18);
}
.tile.speaking { animation: tile-pulse 0.6s ease-in-out; }
@keyframes tile-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.tile[data-color="pink"]   { background: var(--hk-pink-soft); }
.tile[data-color="purple"] { background: #ece1ff; }
.tile[data-color="blue"]   { background: #d6f0ff; }

.tile-emoji {
  font-size: clamp(3rem, 8vw, 4rem);
  line-height: 1;
  pointer-events: none;
}
.tile-name {
  font-size: 0.78rem;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.tile-num {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.7rem;
  color: var(--hk-pink-deep);
  opacity: 0.6;
}
.tile.is-stub {
  filter: grayscale(0.7);
  opacity: 0.55;
  background: #efe6e6;
  cursor: default;
  border-style: dashed;
}
.tile.is-stub:hover { transform: none; }
.tile.is-stub .lock-overlay {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 1.2rem;
  opacity: 0.85;
}

.coming-soon-bubble {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 3px solid var(--hk-text);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--hk-pink-deep);
  box-shadow: var(--shadow);
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
  animation: pop-bubble 1.5s ease forwards;
}

@keyframes pop-bubble {
  0%   { transform: translateX(-50%) scale(0); opacity: 0; }
  20%  { transform: translateX(-50%) scale(1.2); opacity: 1; }
  40%  { transform: translateX(-50%) scale(1); }
  90%  { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.8); opacity: 0; }
}

/* ----- particles ----- */
#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}
.particle {
  position: absolute;
  pointer-events: none;
  font-size: 1.8rem;
  animation: float-up 1.2s ease-out forwards;
}
.particle.heart { color: var(--hk-pink-hot); }
.particle.sparkle { color: #ffd54f; }
@keyframes float-up {
  0%   { transform: translate(0, 0) scale(0.6); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--dx, 0), -120px) scale(1.2); opacity: 0; }
}

/* ----- responsive ----- */
@media (max-width: 720px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .tile-emoji { font-size: 3rem; }
  .start-card h1 { font-size: 1.7rem; }
  .launcher-header h1 { font-size: 1.6rem; }
  .chip { font-size: 1.2rem; min-width: 50px; min-height: 50px; padding: 6px 10px; }
}
@media (max-width: 480px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .tile-row .tile { width: 120px; height: 120px; }
  .tile-row .tile .tile-emoji { font-size: 3.4rem; }
}
