/* Birleştir (tahta): merge board with two candy dispensers. */

.tb-wrap {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 10px 10px;
}

/* floating candies behind the board (decor only) */
.tb-decor { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.tb-decor img {
  position: absolute; width: 70px; height: 70px; opacity: .28;
  animation: tb-float 9s ease-in-out infinite;
}
@keyframes tb-float {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-26px) rotate(12deg); }
}

.tb-instr {
  position: relative; z-index: 2; flex: none;
  display: flex; align-items: center; justify-content: center; text-align: center;
  max-width: 100%; padding: 0 6px;
  font-size: clamp(18px, 4.6vw, 22px); font-weight: 900; line-height: 1.1; color: var(--white);
  text-shadow: 0 3px 0 var(--navy), 2px 0 0 var(--navy), -2px 0 0 var(--navy), 0 -2px 0 var(--navy);
  transition: opacity .5s ease, transform .5s ease;
}
.tb-instr.hide { opacity: 0; transform: translateY(-8px) scale(.94); }

/* ---------- board ---------- */
.tb-board {
  position: relative; z-index: 1; flex: none;
  background: var(--white); border: var(--outline); border-radius: var(--r-lg);
  box-shadow: var(--sticker);
  margin-bottom: 6px;
  --cell: 60px;
}
.tb-board.flash { animation: tb-board-flash .5s ease; }
.tb-board.flash.bb-shake { animation: tb-board-flash .5s ease, bb-shake .36s ease; }
@keyframes tb-board-flash {
  0% { background: var(--white); }
  30% { background: #FFF3A8; }
  100% { background: var(--white); }
}
.tb-board.over .tb-inner { animation: tb-over .6s ease both; }
@keyframes tb-over { 40% { transform: scale(.82) rotate(-6deg); } 100% { transform: scale(.92); filter: saturate(.55); } }

.tb-cell {
  position: absolute; left: 0; top: 0;
  border-radius: calc(var(--cell) * .26);
  background: var(--sky-pale);
  border: 2px solid rgba(42, 36, 102, .10);
  transition: background-color .12s ease, transform .12s ease;
}
.tb-cell.alt { background: #E9F8FE; }
.tb-cell.disp { background: transparent; border-color: transparent; }
.tb-cell.ok-move { background: var(--sky-light); transform: scale(1.04); }
.tb-cell.ok-merge { background: var(--yellow); transform: scale(1.08); border-color: var(--navy); }
.tb-cell.no { background: #FFC9C4; }

/* ---------- pieces ---------- */
.tb-piece {
  position: absolute; left: 0; top: 0; z-index: 3;
  width: var(--cell); height: var(--cell);
  will-change: transform; touch-action: none; cursor: grab;
}
.tb-piece.fly { z-index: 30; pointer-events: none; }
.tb-piece.drag { z-index: 40; cursor: grabbing; }
.tb-piece.slide { z-index: 35; pointer-events: none; }
.tb-lift { width: 100%; height: 100%; transition: transform .14s cubic-bezier(.2, 1.6, .4, 1); }
.tb-piece.drag .tb-lift { transform: scale(1.24) rotate(-7deg); }
.tb-inner { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.tb-inner::before { /* soft contact shadow */
  content: ""; position: absolute; left: 20%; right: 20%; bottom: 9%; height: 13%;
  border-radius: 50%; background: rgba(42, 36, 102, .18);
}
.tb-piece.drag .tb-inner::before { transform: translateY(14%) scale(.8); background: rgba(42, 36, 102, .28); }
.tb-inner img {
  position: relative; display: block;
  width: calc(var(--cell) * var(--s, .72)); height: calc(var(--cell) * var(--s, .72));
  pointer-events: none;
}
.tb-badge {
  position: absolute; right: 0; bottom: 0;
  width: max(18px, calc(var(--cell) * .32)); height: max(18px, calc(var(--cell) * .32));
  display: grid; place-items: center;
  background: var(--navy); color: var(--white); border: 2px solid var(--white); border-radius: 50%;
  font-size: max(12px, calc(var(--cell) * .2)); font-weight: 900; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tb-piece[data-top="1"] .tb-badge { background: var(--red); }

/* glow ring for valid merge targets and hint pulses */
.tb-inner::after {
  content: ""; position: absolute; inset: 4%; border-radius: 50%;
  border: 4px solid var(--yellow); opacity: 0; pointer-events: none;
}
.tb-piece.target .tb-inner::after { animation: tb-ring 0.8s ease-in-out infinite; }
.tb-piece.target .tb-inner { animation: tb-breathe .8s ease-in-out infinite; }
@keyframes tb-ring { 0%, 100% { opacity: .95; transform: scale(.92); } 50% { opacity: .5; transform: scale(1.08); } }
@keyframes tb-breathe { 50% { transform: scale(1.08); } }

.tb-inner.hintpulse { animation: tb-hintpulse .7s ease-in-out 3; }
.tb-inner.hintpulse::after { animation: tb-ring .7s ease-in-out 3; }
@keyframes tb-hintpulse { 50% { transform: scale(1.16) rotate(6deg); } }

.tb-inner.pop { animation: tb-pop .42s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes tb-pop {
  0% { transform: scale(.3); }
  55% { transform: scale(1.22, .86); }
  75% { transform: scale(.92, 1.1); }
  100% { transform: scale(1); }
}
.tb-inner.land { animation: tb-land .34s ease both; }
@keyframes tb-land {
  0% { transform: scale(1.18, .8); }
  45% { transform: scale(.92, 1.1); }
  100% { transform: scale(1); }
}
.tb-inner.merge { animation: tb-merge .5s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes tb-merge {
  0% { transform: scale(1.5, .55); }
  30% { transform: scale(.78, 1.32) rotate(-6deg); }
  55% { transform: scale(1.18, .9) rotate(4deg); }
  80% { transform: scale(.96, 1.04); }
  100% { transform: scale(1); }
}
.tb-inner.shake { animation: tb-shake .38s ease; }
@keyframes tb-shake {
  20% { transform: translateX(-12%) rotate(-8deg); } 40% { transform: translateX(10%) rotate(7deg); }
  60% { transform: translateX(-6%) rotate(-4deg); } 80% { transform: translateX(4%); }
}
.tb-inner.jiggle { animation: tb-jiggle .6s ease; }
@keyframes tb-jiggle { 25% { transform: rotate(-10deg) scale(1.05); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-4deg); } }
.tb-inner.vanish { animation: tb-vanish .42s cubic-bezier(.5, -0.4, .8, .6) forwards; }
@keyframes tb-vanish { 0% { transform: scale(1); } 35% { transform: scale(1.45) rotate(15deg); opacity: 1; } 100% { transform: scale(0) rotate(-40deg); opacity: 0; } }
.tb-inner.lucky::after { animation: tb-lucky .5s ease-in-out 3; border-color: var(--white); }
@keyframes tb-lucky { 0%, 100% { opacity: 0; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.18); } }

/* ---------- dispensers ---------- */
.tb-disp {
  position: absolute; left: 0; top: 0; z-index: 4;
  width: var(--cell); height: var(--cell);
  cursor: pointer; touch-action: none;
}
.tb-disp::after { /* "tap me" pulse ring */
  content: ""; position: absolute; inset: 2%; border-radius: 30%;
  border: 4px solid var(--white); opacity: 0; pointer-events: none;
  animation: tb-tapme 1.6s ease-out infinite;
}
.tb-disp.full::after { animation: none; }
@keyframes tb-tapme { 0% { opacity: .95; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.3); } }
.tb-disp-inner {
  position: relative; width: 100%; height: 100%;
  animation: tb-dwobble 2.4s ease-in-out infinite; transform-origin: 50% 90%;
}
.tb-disp.B .tb-disp-inner { animation-delay: -1.2s; }
@keyframes tb-dwobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) scale(1.04); } }
.tb-disp-inner.squirt { animation: tb-squirt .36s ease; }
@keyframes tb-squirt {
  0% { transform: scale(1); }
  30% { transform: scale(1.22, .76); }
  60% { transform: scale(.9, 1.16) translateY(-6%); }
  100% { transform: scale(1); }
}
.tb-disp-inner.nope { animation: tb-shake .4s ease; }
.tb-disp-body {
  position: absolute; left: 8%; right: 8%; bottom: 3%; height: 44%;
  background: var(--red); border: 3px solid var(--navy); border-radius: 22% 22% 26% 26%;
  box-shadow: 0 3px 0 var(--navy);
}
.tb-disp.B .tb-disp-body { background: var(--yellow); }
.tb-disp-body::before { /* chute slot */
  content: ""; position: absolute; left: 32%; right: 32%; bottom: 18%; height: 22%;
  background: var(--navy); border-radius: 6px;
}
.tb-disp-body::after { /* little button */
  content: ""; position: absolute; right: 9%; top: 16%; width: 18%; height: 26%;
  background: var(--white); border: 2px solid var(--navy); border-radius: 50%;
}
.tb-disp-dome {
  position: absolute; left: 13%; right: 13%; top: 2%; height: 62%;
  background: rgba(255, 255, 255, .92); border: 3px solid var(--navy); border-radius: 50% 50% 18% 18%;
  display: grid; place-items: center; overflow: hidden;
}
.tb-disp-dome img { width: 78%; height: 78%; animation: tb-spin 3.2s ease-in-out infinite; }
@keyframes tb-spin { 0%, 100% { transform: rotate(-12deg) translateY(4%); } 50% { transform: rotate(12deg) translateY(-6%); } }
.tb-disp-dome::after { /* glass shine */
  content: ""; position: absolute; left: 16%; top: 12%; width: 22%; height: 30%;
  border-radius: 50%; background: rgba(255, 255, 255, .85); transform: rotate(-25deg);
}

@media (prefers-reduced-motion: reduce) {
  .tb-decor img, .tb-disp-inner, .tb-disp-dome img, .tb-disp::after { animation: none; }
  .tb-inner.pop, .tb-inner.land, .tb-inner.merge, .tb-inner.jiggle { animation-duration: .2s; }
}
