:root {
  --sky1: #8fdcff;
  --sky2: #eef8ff;
  --panel: rgba(255, 255, 255, 0.86);
  --blue-card: #5b7cff;
  --blue-card-dark: #415ee2;
  --yellow: #ffd84f;
  --pink: #ff8ccf;
  --pink-soft: #ffd8f0;
  --purple: #8368ff;
  --text: #24324d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Trebuchet MS', 'Comic Sans MS', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.95) 0 70px, transparent 71px),
    radial-gradient(circle at 76% 16%, rgba(255, 255, 255, 0.95) 0 62px, transparent 63px),
    linear-gradient(to bottom, rgba(255,255,255,0) 66%, rgba(112, 201, 102, 0.45) 66%),
    linear-gradient(var(--sky1), var(--sky2));
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255,255,255,0.8) 0 1.5px, transparent 2px);
  background-size: 160px 160px, 220px 220px;
  background-position: 20px 30px, 110px 80px;
  opacity: 0.55;
}
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
}
.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,244,251,0.95));
  border-radius: 24px;
  padding: 18px 22px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  border: 3px solid rgba(255, 255, 255, 0.6);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-badge {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5b7cff, #7c4cff);
  box-shadow: 0 8px 20px rgba(92, 95, 255, 0.28);
  overflow: hidden;
}
.brand-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-badge {
  text-decoration: none;
}
.brand-name {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5f46d8;
  margin-bottom: 6px;
  text-decoration: none;
}
.brand-name:hover {
  text-decoration: underline;
}
.title-bar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  color: #24324d;
}
.title-bar p { margin: 6px 0 0; font-size: 1.05rem; color: #3c4b6a; }
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
button, .home-btn {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), #ffb3df);
  color: white;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 0 6px 0 #e06aac;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:active, .home-btn:active { transform: translateY(2px); box-shadow: 0 4px 0 #e06aac; }
.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}
.board-wrap, .matched-column {
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(250,244,255,0.92));
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.1);
  border: 3px solid rgba(255,255,255,0.5);
}
.stats-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 1rem;
}
.stats-bar span {
  background: rgba(255,255,255,0.96);
  padding: 10px 14px;
  border-radius: 999px;
  color: #24324d;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 14px;
}
.card {
  background: transparent;
  border: none;
  padding: 0;
  perspective: 1000px;
  min-height: 150px;
}
.card-inner {
  position: relative;
  min-height: 150px;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s ease, translate 0.18s ease;
}
.card:hover .card-inner { translate: 0 -4px; }
.card.flipped .card-inner,
.card.matched .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}
.card-front {
  background: linear-gradient(145deg, var(--blue-card), var(--blue-card-dark));
  box-shadow: inset 0 0 0 5px rgba(255,255,255,0.16), 0 10px 18px rgba(88, 102, 224, 0.25);
}
.card-front::before {
  content: '';
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  box-shadow:
    -34px 0 0 -10px rgba(255,255,255,0.16),
    34px 0 0 -10px rgba(255,255,255,0.16),
    0 -34px 0 -10px rgba(255,255,255,0.16),
    0 34px 0 -10px rgba(255,255,255,0.16);
}
.card-back {
  transform: rotateY(180deg);
  background: white;
  border: 4px solid #ffd86d;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 20px rgba(255, 180, 80, 0.18);
}
.card-back img {
  max-width: 100%;
  max-height: 78px;
  object-fit: contain;
}
.word-card {
  font-size: 1.55rem;
  font-weight: 800;
  text-transform: capitalize;
  color: #24324d;
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
.card.matched .card-inner {
  animation: pop 0.55s ease;
}
.card.matched-slot {
  visibility: hidden;
  pointer-events: none;
}
@keyframes pop {
  0% { transform: rotateY(180deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}
.matched-column h2 {
  margin: 0 0 14px;
  text-align: center;
  color: #5f46d8;
  text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}
.matched-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.match-chip {
  background: rgba(255,255,255,0.98);
  border-radius: 18px;
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  color: #24324d;
  box-shadow: inset 0 0 0 2px #ffdf8f;
}
.match-chip img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
@media (max-width: 980px) {
  .play-area { grid-template-columns: 1fr; }
  .matched-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}
.victory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 50, 77, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
}
.victory-overlay.hidden {
  display: none;
}
.victory-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,244,251,0.98));
  border-radius: 28px;
  padding: 28px;
  width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  border: 3px solid rgba(255,255,255,0.6);
}
.victory-card h2 {
  margin: 0 0 10px;
  color: #5f46d8;
}
.victory-card p {
  margin: 0 0 18px;
  color: #41516f;
}
.victory-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .title-bar { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .game-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}
