/* Eşini Bul (hafiza) */

.hz-stage { --sh: 5px; --bw: 4px; --cw: 100px; }

/* ---------- HUD ---------- */
.hz-hud {
  position: absolute; left: 12px; right: 12px; top: 4px; height: 48px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none; z-index: 3;
}
.hz-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 14px;
  background: var(--white); border: var(--outline); border-radius: 999px;
  box-shadow: 0 4px 0 var(--navy);
  font-size: 18px; font-weight: 900; color: var(--navy-soft); white-space: nowrap;
}
.hz-chip b { color: var(--navy); font-size: 20px; font-variant-numeric: tabular-nums; }
.hz-chip.bounce { animation: hz-chip-bump .3s ease; }
@keyframes hz-chip-bump { 40% { transform: scale(1.15) rotate(-3deg); } }

.hz-dots { display: flex; gap: 8px; align-items: center; }
.hz-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--sky-pale); border: 3px solid var(--navy);
  transition: transform .3s cubic-bezier(.2, 1.6, .4, 1), background .3s ease;
}
.hz-dot.done { background: var(--yellow); }
.hz-dot.now { background: var(--white); transform: scale(1.35); animation: hz-dot-pulse 1.2s ease-in-out infinite; }
@keyframes hz-dot-pulse { 50% { transform: scale(1.55); } }

.hz-small .hz-hud { height: 34px; justify-content: center; }
.hz-small .hz-chip { display: none; }
.hz-small .hz-dot { width: 22px; height: 22px; }

/* ---------- board ---------- */
.hz-board { position: absolute; z-index: 1; }

.hz-slot {
  position: absolute; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* idle wobble on face-down cards */
.hz-slot.wob:not(.open):not(.matched):not(.deal):not(.out) {
  animation: hz-idle 3.2s ease-in-out infinite;
  animation-delay: var(--wd, 0s);
}
@keyframes hz-idle {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-1.6deg) translateY(-1.5px); }
  75% { transform: rotate(1.6deg) translateY(1px); }
}
.hz-slot.deal {
  animation: hz-deal 560ms cubic-bezier(.2, .9, .3, 1) both;
  animation-delay: var(--dl, 0ms);
}
@keyframes hz-deal {
  0% { transform: translate(var(--dx), var(--dy)) rotate(-28deg) scale(.35); opacity: 0; }
  15% { opacity: 1; }
  62% { transform: translate(0, -8%) rotate(4deg) scale(1.06); }
  80% { transform: translate(0, 0) scale(1.06, .92); }
  92% { transform: scale(.97, 1.04); }
  100% { transform: none; opacity: 1; }
}
.hz-slot.out {
  animation: hz-out 520ms cubic-bezier(.5, -0.3, .8, .6) both;
  animation-delay: var(--ol, 0ms);
}
@keyframes hz-out {
  0% { transform: none; opacity: 1; }
  30% { transform: translateY(6%) scale(1.06, .9); opacity: 1; }
  100% { transform: translateY(-140%) rotate(32deg) scale(.3); opacity: 0; }
}

/* card = perspective holder, carries squash / bounce / shake */
.hz-card {
  position: absolute; inset: 0;
  -webkit-perspective: 900px; perspective: 900px;
  transition: transform .15s ease;
}
@media (hover: hover) {
  .hz-slot:not(.open):not(.matched):hover .hz-card { transform: translateY(-4px) scale(1.03); }
}
.hz-card.lift { animation: hz-lift .43s ease; }
@keyframes hz-lift {
  0% { transform: scale(1); }
  14% { transform: scale(.9, .86); }
  50% { transform: translateY(-7%) scale(1.1); }
  80% { transform: translateY(0) scale(.98, 1.02); }
  100% { transform: scale(1); }
}
.hz-card.bounce { animation: hz-bounce .75s cubic-bezier(.3, .7, .4, 1); }
@keyframes hz-bounce {
  0% { transform: none; }
  15% { transform: translateY(4%) scale(1.12, .84); }
  40% { transform: translateY(-22%) scale(.92, 1.1); }
  62% { transform: translateY(2%) scale(1.1, .9); }
  78% { transform: translateY(-5%) scale(.98, 1.03); }
  100% { transform: none; }
}
.hz-card.nope { animation: hz-nope .5s ease; }
@keyframes hz-nope {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6%) rotate(-5deg); }
  40% { transform: translateX(5%) rotate(4deg); }
  60% { transform: translateX(-3%) rotate(-2deg); }
  80% { transform: translateX(2%) rotate(1deg); }
}
.hz-card.cheer { animation: hz-cheer .6s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes hz-cheer {
  0% { transform: none; }
  35% { transform: translateY(-16%) rotate(-8deg) scale(1.08); }
  70% { transform: translateY(0) rotate(5deg) scale(1.04, .94); }
  100% { transform: none; }
}
.hz-card.nudge { animation: hz-nudge .5s ease; }
@keyframes hz-nudge {
  0%, 100% { transform: none; }
  30% { transform: translateY(-6%) rotate(-3deg); }
  60% { transform: translateY(0) rotate(3deg); }
}

/* inner = the 3D flipper */
.hz-inner {
  position: absolute; inset: 0;
  -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
  -webkit-transition: -webkit-transform .43s cubic-bezier(.35, 1.45, .55, 1);
  transition: transform .43s cubic-bezier(.35, 1.45, .55, 1);
}
.hz-slot.open .hz-inner, .hz-slot.matched .hz-inner {
  -webkit-transform: rotateY(180deg); transform: rotateY(180deg);
}

.hz-face {
  position: absolute; left: 0; right: 0; top: 0; bottom: var(--sh);
  border: var(--bw) solid var(--navy);
  border-radius: calc(var(--cw) * .16);
  box-shadow: 0 var(--sh) 0 var(--navy);
  overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.hz-back { background: var(--sky); -webkit-transform: rotateY(0deg); transform: rotateY(0deg); }
.hz-back-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hz-back-art .hz-sil { transform-origin: 50px 48px; animation: hz-sil 2.6s ease-in-out infinite; animation-delay: var(--wd, 0s); }
@keyframes hz-sil { 50% { transform: translateY(-3px) rotate(-4deg); } }
/* shine sweep across the back */
.hz-back::after {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,.55) 50%, transparent 100%);
  transform: skewX(-18deg) translateX(0);
  animation: hz-shine 4.6s ease-in-out infinite;
  animation-delay: var(--wd, 0s);
  pointer-events: none;
}
/* Safari: animated layers inside a backface-hidden face can bleed through when flipped; pause them while the back is turned away */
.hz-slot.open .hz-back::after, .hz-slot.matched .hz-back::after,
.hz-slot.open .hz-back-art .hz-sil, .hz-slot.matched .hz-back-art .hz-sil { animation: none; }
@keyframes hz-shine {
  0%, 70% { transform: skewX(-18deg) translateX(0); }
  100% { transform: skewX(-18deg) translateX(420%); }
}

.hz-front {
  background: var(--white);
  display: grid; place-items: center;
  -webkit-transform: rotateY(180deg); transform: rotateY(180deg);
  transition: background .3s ease;
}
.hz-candy {
  width: 84%; height: auto; max-height: 84%; object-fit: contain; display: block;
  pointer-events: none;
}
.hz-slot.matched .hz-front { background: #FFF6B0; }
.hz-slot.matched .hz-candy { animation: hz-float 2.2s ease-in-out infinite; animation-delay: var(--wd, 0s); }
@keyframes hz-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-5%) rotate(3deg) scale(1.04); }
}
/* twinkle on found pairs */
.hz-slot.matched .hz-front::after {
  content: ""; position: absolute; right: 8%; top: 7%;
  width: 22%; height: 22%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l2.6 7.9 7.9 2.6-7.9 2.6L12 22.5l-2.6-7.9L1.5 12l7.9-2.6z' fill='%23FCE600' stroke='%232A2466' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: hz-twinkle 1.6s ease-in-out infinite;
  animation-delay: var(--wd, 0s);
}
@keyframes hz-twinkle {
  0%, 100% { transform: scale(.4) rotate(0deg); opacity: .3; }
  50% { transform: scale(1.1) rotate(45deg); opacity: 1; }
}

/* ---------- tip (7+) ---------- */
.hz-tip {
  position: absolute; left: 50%; top: 50%; z-index: 4;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  background: var(--white); border: var(--outline); border-radius: var(--r-md);
  box-shadow: var(--sticker);
  font-size: 22px; font-weight: 900; color: var(--navy); text-align: center; line-height: 1.15;
  pointer-events: none;
  opacity: 0; transform: translate(-50%, -50%) scale(.6) rotate(-3deg);
  transition: opacity .3s ease, transform .4s cubic-bezier(.2, 1.5, .4, 1);
}
.hz-tip.on { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }

/* ---------- between rounds ---------- */
.hz-banner {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-items: center; padding: 16px;
  background: rgba(42, 36, 102, .35);
  animation: bb-fade .25s ease both;
}
.hz-bcard {
  width: min(100%, 360px);
  background: var(--white); border: var(--outline); border-radius: var(--r-lg);
  box-shadow: 0 8px 0 var(--navy);
  padding: 16px 20px 22px; text-align: center;
  animation: bb-pop .45s cubic-bezier(.2, 1.5, .4, 1) both;
}
.hz-bcard h2 { margin: 2px 0 4px; font-size: clamp(28px, 8vw, 38px); font-weight: 900; line-height: 1.05; }
.hz-bcard p { margin: 0 0 4px; font-size: 20px; font-weight: 800; color: var(--navy-soft); }
.hz-bcandy { width: 96px; height: 96px; display: block; margin: 0 auto; animation: bb-wobble 1.1s ease-in-out infinite; }
.hz-bstars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 2px; }
.hz-bstars svg { width: 52px; height: 52px; animation: bb-star-in .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.hz-bstars svg:nth-child(2) { animation-delay: .15s; }
.hz-bstars svg:nth-child(3) { animation-delay: .3s; }
.hz-next { position: relative; overflow: hidden; margin-top: 14px; min-width: 200px; }
.hz-next svg { width: 26px; height: 26px; }
.hz-next span { position: relative; z-index: 1; }
.hz-next .hz-bar {
  position: absolute; left: 0; bottom: 0; height: 7px; width: 100%;
  background: var(--yellow);
  transform-origin: left center;
  animation: hz-bar var(--auto, 3400ms) linear both;
}
@keyframes hz-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.hz-next { animation: hz-btn-pulse 1s ease-in-out infinite .5s; }
@keyframes hz-btn-pulse { 50% { transform: scale(1.06); } }
.hz-next:active { animation: none; }

/* short screens: tighter banner */
@media (max-height: 680px) {
  .hz-bcandy { width: 72px; height: 72px; }
  .hz-bstars svg { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .hz-slot.wob:not(.open):not(.matched):not(.deal):not(.out),
  .hz-back-art .hz-sil, .hz-back::after, .hz-slot.matched .hz-candy, .hz-dot.now, .hz-next { animation: none; }
  .hz-slot.deal { animation-duration: 260ms; }
  .hz-inner { transition-duration: .3s; }
  .hz-card.bounce, .hz-card.cheer { animation-duration: .4s; }
}
