@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --c1:#FF6B6B; --c2:#FFD93D; --c3:#6BCB77; --c4:#4D96FF;
  --c5:#FF9F45; --c6:#C77DFF; --c7:#00B4D8; --c8:#F72585;
  --bg: #f0e6ff;
  --card-radius: 20px;
  --shadow: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-shapes span {
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
  animation: float 8s ease-in-out infinite;
}
.bg-shapes span:nth-child(1)  { width:120px;height:120px;background:var(--c1);top:5%;left:3%;animation-delay:0s; }
.bg-shapes span:nth-child(2)  { width:80px;height:80px;background:var(--c2);top:15%;right:8%;animation-delay:1s; }
.bg-shapes span:nth-child(3)  { width:160px;height:160px;background:var(--c3);top:50%;left:1%;animation-delay:2s; border-radius:30%; }
.bg-shapes span:nth-child(4)  { width:100px;height:100px;background:var(--c4);bottom:10%;right:5%;animation-delay:3s; }
.bg-shapes span:nth-child(5)  { width:60px;height:60px;background:var(--c5);top:80%;left:20%;animation-delay:0.5s; }
.bg-shapes span:nth-child(6)  { width:90px;height:90px;background:var(--c6);top:30%;right:20%;animation-delay:2.5s; border-radius:20%; }
.bg-shapes span:nth-child(7)  { width:140px;height:140px;background:var(--c7);bottom:5%;left:40%;animation-delay:1.5s; }
.bg-shapes span:nth-child(8)  { width:70px;height:70px;background:var(--c8);top:45%;right:2%;animation-delay:3.5s; }

@keyframes float {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

/* ===== HEADER ===== */
.site-header {
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, #6B48FF 0%, #FF6B6B 50%, #FFD93D 100%);
  padding: 20px 30px 30px;
  text-align: center;
  clip-path: ellipse(100% 85% at 50% 0%);
  padding-bottom: 50px;
}

.site-header h1 {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: white;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.site-header .subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 1.1rem;
  font-weight: 700;
}

.header-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.header-stars span {
  font-size: 1.4rem;
  animation: spin 3s linear infinite;
}
.header-stars span:nth-child(2) { animation-delay: 0.5s; }
.header-stars span:nth-child(3) { animation-delay: 1s; }
@keyframes spin {
  0%,100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(180deg); }
}

/* ===== CONTROLS BAR ===== */
.controls-bar {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: -20px auto 20px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-wrap {
  background: white;
  border-radius: 50px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.search-wrap input {
  border: none;
  outline: none;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
  color: #333;
}
.search-wrap input::placeholder { color: #bbb; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-section {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 4px;
}

.filter-btn {
  background: white;
  border: 3px solid transparent;
  border-radius: 50px;
  padding: 6px 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  color: #555;
}
.filter-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.filter-btn.active {
  background: #6B48FF;
  color: white;
  border-color: #6B48FF;
  transform: translateY(-2px);
}
.filter-btn[data-genre="memory"].active    { background: var(--c1); border-color: var(--c1); }
.filter-btn[data-genre="letters"].active   { background: var(--c4); border-color: var(--c4); }
.filter-btn[data-genre="numbers"].active   { background: var(--c3); border-color: var(--c3); }
.filter-btn[data-genre="board"].active     { background: var(--c2); border-color: var(--c2); color:#333; }
.filter-btn[data-genre="puzzle"].active    { background: var(--c6); border-color: var(--c6); }
.filter-btn[data-genre="active"].active    { background: var(--c8); border-color: var(--c8); }

/* ===== GAME COUNT ===== */
.game-count {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto 15px;
  padding: 0 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #888;
}

/* ===== GAME GRID ===== */
.game-grid {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* ===== GAME CARD ===== */
.game-card {
  background: white;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  position: relative;
}
.game-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
}
.game-card:active { transform: scale(0.97); }

.card-top {
  padding: 30px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 140px;
  position: relative;
}

.card-emoji {
  font-size: 3.5rem;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.15));
  animation: wobble 4s ease-in-out infinite;
}
@keyframes wobble {
  0%,100% { transform: rotate(-3deg) scale(1); }
  50% { transform: rotate(3deg) scale(1.05); }
}
.game-card:hover .card-emoji { animation: none; transform: scale(1.2); }

.card-players {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.3);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
}

.online-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,0.9);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 800;
  color: #6B48FF;
  display: flex;
  align-items: center;
  gap: 3px;
}
.online-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #4BCF7A;
  border-radius: 50%;
  display: inline-block;
}

.card-bottom {
  padding: 15px;
  background: white;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: #2d1b69;
  line-height: 1.2;
}

.card-desc {
  font-size: 0.8rem;
  color: #888;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.tag {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  color: white;
}
.tag-memory  { background: var(--c1); }
.tag-letters { background: var(--c4); }
.tag-numbers { background: var(--c3); }
.tag-board   { background: var(--c2); color: #333; }
.tag-puzzle  { background: var(--c6); }
.tag-active  { background: var(--c8); }

.play-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #6B48FF, #FF6B6B);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  text-align: center;
}
.play-btn:hover { opacity: 0.9; }
.play-btn:active { transform: scale(0.97); }

/* ===== HIDDEN ===== */
.game-card.hidden { display: none; }

/* ===== EMPTY STATE ===== */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.empty-state .emoji { font-size: 4rem; }
.empty-state p { font-size: 1.2rem; font-weight: 700; margin-top: 15px; }

/* ===== CAT MASCOT ===== */
.cat-mascot {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 500;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  filter: drop-shadow(2px 4px 8px rgba(0,0,0,.2));
  animation: catBounce 3s ease-in-out infinite;
}
@keyframes catBounce {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
.cat-mascot:hover { animation: none; transform: scale(1.15); }
.cat-body { font-size: 3.2rem; line-height: 1; }
.cat-bubble {
  background: white;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 800;
  color: #2d1b69;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  max-width: 160px;
  text-align: center;
  margin-bottom: 6px;
  opacity: 0;
  transition: opacity .3s;
  position: relative;
}
.cat-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px; left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: white;
  border-bottom: none;
}
.cat-bubble.visible { opacity: 1; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2d1b69; color: white;
  padding: 12px 24px; border-radius: 50px;
  font-weight: 800; font-size: .95rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  z-index: 9999; white-space: nowrap;
  transition: opacity .5s;
}
.toast-out { opacity: 0; }

/* ===== USER BAR ===== */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(6px);
  border-radius: 40px;
  padding: 6px 14px 6px 8px;
}
.user-av  { font-size: 1.8rem; line-height: 1; }
.user-name { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: white; }
.switch-btn {
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 40px;
  padding: 6px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.switch-btn:hover { background: rgba(255,255,255,0.4); }

/* ===== FAVOURITE BUTTON ===== */
.fav-btn {
  position: absolute;
  bottom: 8px;
  left: 10px;
  background: rgba(255,255,255,0.3);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;align-items:center;justify-content:center;
  transition: transform 0.2s, background 0.15s;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.fav-btn:hover { transform: scale(1.2); background: rgba(255,255,255,0.5); }
.fav-btn.is-fav { background: rgba(255,255,255,0.6); }

/* ===== SCORE ON CARD ===== */
.card-score {
  font-size: 0.75rem;
  font-weight: 800;
  color: #6B48FF;
  background: #f0ebff;
  border-radius: 8px;
  padding: 3px 8px;
  align-self: flex-start;
}

/* ===== FAVOURITES FILTER ===== */
.filter-btn[data-genre="fav"].active { background: #FF6B6B; border-color: #FF6B6B; }

/* ===== LOCK OVERLAY ===== */
.game-card.locked { cursor: pointer; }
.game-card.locked .card-emoji { filter: grayscale(60%) opacity(.7); }

.lock-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  border-radius: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; pointer-events: none;
}
.lock-icon  { font-size: 2rem; }
.lock-price {
  background: rgba(255,255,255,.9);
  color: #333; font-weight: 900; font-size: .85rem;
  padding: 4px 12px; border-radius: 20px;
}

.unlock-btn {
  display: block; width: 100%; padding: 10px;
  background: linear-gradient(135deg, var(--gc, #6B48FF), #333);
  color: white; border: none; border-radius: 12px;
  font-family: 'Fredoka One', cursive; font-size: .95rem;
  cursor: pointer; transition: opacity .2s;
}
.unlock-btn:hover { opacity: .85; }

/* ===== COIN CHIP ===== */
.coin-chip {
  background: linear-gradient(135deg,#FFD93D,#FF9F45);
  color: #333; font-weight: 900; font-size: .85rem;
  padding: 4px 12px; border-radius: 20px;
  box-shadow: 0 2px 8px rgba(255,183,3,.4);
}

/* ===== REDEEM BUTTON ===== */
.pet-nav-btn {
  background: linear-gradient(135deg, rgba(255,107,107,.7), rgba(255,183,3,.7));
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 40px; padding: 6px 12px;
  font-family: 'Nunito', sans-serif; font-size: .8rem; font-weight: 800;
  color: white; cursor: pointer; transition: opacity .2s;
  white-space: nowrap;
}
.pet-nav-btn:hover { opacity: .85; }

.redeem-btn {
  background: rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 40px; padding: 6px 12px;
  font-family: 'Nunito', sans-serif; font-size: .8rem; font-weight: 800;
  color: white; cursor: pointer; transition: background .2s;
  white-space: nowrap;
}
.redeem-btn:hover { background: rgba(255,255,255,.4); }

.user-actions { display: flex; gap: 6px; align-items: center; }

/* ===== BUY / REDEEM MODAL ===== */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  z-index: 1000; align-items: center; justify-content: center;
  padding: 20px;
}

.buy-modal {
  background: white; border-radius: 28px; padding: 32px 28px;
  max-width: 380px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.buy-modal h2 { font-family: 'Fredoka One', cursive; color: #2d1b69; font-size: 1.5rem; }
.buy-modal p  { color: #888; font-size: .9rem; font-weight: 600; }

.bm-emoji { font-size: 4rem; line-height: 1; }

.bm-price-row {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
}
.bm-price {
  background: linear-gradient(135deg,#FFD93D,#FF9F45);
  color: #333; font-weight: 900; font-size: 1rem;
  padding: 6px 16px; border-radius: 20px;
}
.bm-balance { color: #888; font-weight: 800; font-size: .9rem; align-self: center; }

.bm-btns { display: flex; gap: 10px; width: 100%; }
.bm-buy {
  flex: 1; padding: 14px;
  background: linear-gradient(135deg,#6B48FF,#FF6B6B);
  color: white; border: none; border-radius: 14px;
  font-family: 'Fredoka One', cursive; font-size: 1.1rem;
  cursor: pointer; transition: opacity .2s;
}
.bm-buy:hover { opacity: .9; }
.bm-buy:disabled { cursor: not-allowed; }
.bm-cancel {
  flex: 1; padding: 14px; background: #f0f0f0;
  color: #666; border: none; border-radius: 14px;
  font-family: 'Nunito', sans-serif; font-weight: 800;
  cursor: pointer;
}
.bm-cancel:hover { background: #e8e8e8; }

/* Redeem input */
.redeem-input {
  width: 100%; border: 3px solid #eee; border-radius: 12px;
  padding: 12px 16px; font-family: 'Nunito', sans-serif;
  font-size: 1.2rem; font-weight: 800; color: #333; outline: none;
  text-align: center; letter-spacing: 2px; text-transform: uppercase;
}
.redeem-input:focus { border-color: #6B48FF; }
.redeem-msg { font-weight: 800; font-size: .95rem; min-height: 22px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .site-header { padding-bottom: 40px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-emoji { font-size: 2.5rem; }
  .card-top { min-height: 110px; padding: 20px 15px 15px; }
}
