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

:root {
  --bg1: #1b1147;
  --bg2: #3a1b6b;
  --ink: #fff;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, var(--bg2), transparent 55%),
              radial-gradient(circle at 85% 80%, #123a6b, transparent 55%),
              linear-gradient(160deg, var(--bg1), #0d0a24 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  overflow-x: hidden;
  position: relative;
}

.glow {
  position: fixed;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: drift 14s ease-in-out infinite alternate;
}
.glow-1 { background: #ff5d73; top: -80px; left: -80px; }
.glow-2 { background: #4dd0ff; bottom: -100px; right: -90px; animation-delay: -7s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

.header, .stage, .board, .controls { position: relative; z-index: 1; width: 100%; max-width: 920px; }

.header { text-align: center; margin-bottom: 18px; }
.header h1 {
  font-size: clamp(28px, 6vw, 46px);
  letter-spacing: 1px;
  text-shadow: 0 4px 24px rgba(255, 255, 255, 0.25);
  animation: pop-in 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.subtitle { opacity: 0.8; margin-top: 8px; font-size: clamp(13px, 2.6vw, 17px); }
@keyframes pop-in { from { transform: scale(0.7); opacity: 0; } }

.stage {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 22px;
  backdrop-filter: blur(8px);
  text-align: center;
}
.message { font-size: clamp(16px, 3.4vw, 22px); font-weight: 700; min-height: 1.4em; }
.message b { color: #ffd23d; }
.message.shake { animation: shake 0.35s; }
@keyframes shake {
  25% { transform: translateX(-6px) rotate(-1deg); }
  75% { transform: translateX(6px) rotate(1deg); }
}

.progress {
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}
.bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #42e6a4, #4dd0ff, #ffd23d);
  transition: width 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.counter { margin-top: 7px; font-size: 14px; opacity: 0.75; font-variant-numeric: tabular-nums; }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  gap: 14px;
  perspective: 1200px;
}

.card {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  aspect-ratio: 3 / 4;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
  animation: deal-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes deal-in { from { transform: translateY(30px) scale(0.7); opacity: 0; } }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.35, 1.4, 0.4, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card:hover:not(.flipped) .card-inner { transform: translateY(-6px) rotateZ(-2deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.face-back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 8px, transparent 8px 16px),
    linear-gradient(150deg, #6a4bff, #2b7bff 60%, #16d1e8);
  border: 3px solid rgba(255, 255, 255, 0.55);
}
.face-back::after {
  content: "?";
  font-size: clamp(38px, 8vw, 58px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.18);
  width: 66%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.face-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--c, #ff8a3d), rgba(0, 0, 0, 0.35) 180%);
  border: 3px solid rgba(255, 255, 255, 0.75);
  padding: 6px;
  text-align: center;
}
.card-emoji {
  font-size: clamp(34px, 7vw, 52px);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}
.card-word {
  font-size: clamp(14px, 3vw, 19px);
  font-weight: 900;
  text-transform: lowercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}
.card-tip {
  font-size: clamp(10px, 2vw, 12px);
  opacity: 0.9;
  line-height: 1.15;
  padding: 0 4px;
}
.card.flipped .card-emoji { animation: bounce 0.7s 0.35s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14px) scale(1.25) rotate(-8deg); }
  65% { transform: translateY(0) scale(0.9); }
}

.controls { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 99px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn:hover { transform: translateY(-3px) scale(1.04); background: rgba(255, 255, 255, 0.2); }
.btn:active { transform: scale(0.96); }
.btn-main { background: linear-gradient(90deg, #ff6fd8, #6a4bff); border-color: transparent; }

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 5, 25, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.3s;
}
.celebrate.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.celebrate-card {
  background: linear-gradient(160deg, #3a1b6b, #123a6b);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  padding: 34px 30px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: pop-in 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.celebrate-emoji { font-size: 64px; animation: bounce 1s infinite; }
.celebrate-card h2 { margin: 10px 0 8px; font-size: 26px; }
.celebrate-card p { opacity: 0.85; margin-bottom: 20px; }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti {
  position: absolute;
  top: -4vh;
  width: 11px;
  height: 16px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

@media (max-width: 480px) {
  .board { grid-template-columns: repeat(2, 1fr); gap: 11px; }
}
