/* Lettertype Fredoka (OFL), op de eigen server: geen verbinding met Google nodig */
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/fredoka-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fredoka-latin-700-normal.woff2) format('woff2'); }
/* Blob Burst - opmaak. Mobiel eerst; iPhone/iPad-veilig (safe areas, geen zoom of scroll). */
:root {
  --bg1: #7c4dff;
  --bg2: #305ceb;
  --bg3: #0e1034;
  --panel: rgba(255, 255, 255, 0.08);
  --gold: #ffcd3c;
  --sub: #b4bdff;
  --font: "Fredoka", ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  --board: min(92vw, 520px);
  --pitch: 40px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg3); color: #fff; font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; touch-action: none; }
button { font-family: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }

/* ---------- Achtergrond ---------- */
#bg {
  position: fixed; inset: -20%;
  background: linear-gradient(135deg, var(--bg1), var(--bg2) 45%, var(--bg3));
  transform: rotate(6deg); /* stilstaand: een eindeloze draai hield de grafische chip continu bezig */
  z-index: 0;
}
body.fever #bg { background: linear-gradient(135deg, #ff6a2a, #b8306b 45%, #1d0b2a); }
#floaters { position: absolute; inset: 0; }
.floater {
  position: absolute; border-radius: 22%; opacity: 0.16;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(110vh) rotate(0deg); }
  to { transform: translateY(-20vh) rotate(360deg); }
}

/* ---------- Layout ---------- */
#app {
  position: fixed; inset: 0; z-index: 1;
  display: grid;
  grid-template-areas: "top" "powers" "board" "tray" "menu" "credit";
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  grid-template-columns: minmax(0, 1fr); /* nooit breder dan het scherm */
  gap: clamp(6px, 1.6vh, 14px);
  padding:
    max(env(safe-area-inset-top), 10px)
    max(env(safe-area-inset-right), 12px)
    max(env(safe-area-inset-bottom), 10px)
    max(env(safe-area-inset-left), 12px);
  max-width: 620px; margin: 0 auto;
}
#top { grid-area: top; }
#powers { grid-area: powers; }
#boardWrap { grid-area: board; }
#tray { grid-area: tray; }
#menu { grid-area: menu; }
#credit { grid-area: credit; margin-top: calc(-1 * clamp(2px, 0.8vh, 8px)); text-align: center; font-size: clamp(11px, 1.3vh, 15px); font-weight: 600; color: rgba(255, 255, 255, 0.55); line-height: 1.2; }
#credit a { color: rgba(255, 255, 255, 0.8); text-decoration: none; }
#credit a:hover, #credit a:focus-visible { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* liggend (iPad liggend, telefoon dwars, desktop) */
@media (min-aspect-ratio: 5/4) {
  #app {
    max-width: none;
    grid-template-areas: "board top" "board powers" "board tray" "board menu" "board credit";
    grid-template-columns: minmax(0, 1fr) minmax(250px, 36%);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    column-gap: clamp(12px, 3vw, 40px);
    max-width: 1400px;
  }
  #tray { align-content: center; }
}

/* ---------- Header ---------- */
#title {
  text-align: center; font-weight: 700; letter-spacing: 0.04em;
  font-size: clamp(20px, 4.2vh, 34px); line-height: 1.1;
  background: linear-gradient(90deg, #ff5c8c, #ffc83c, #3ce6a0, #50aaff, #b46cff, #ff5c8c);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  background-position: 30% 0; /* vaste regenboog: bewegen betekende de titel bij elk beeld opnieuw tekenen */
  filter: drop-shadow(0 2px 0 rgba(20, 10, 50, 0.6));
}
#scoreRow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 2px; }
.stat { display: flex; flex-direction: column; font-weight: 600; font-size: clamp(14px, 2.4vh, 20px); }
.stat.right { align-items: flex-end; }
.statLabel { color: var(--gold); font-size: 0.75em; }
#score {
  font-weight: 700; font-size: clamp(34px, 7vh, 64px); line-height: 1;
  text-shadow: 0 3px 0 rgba(20, 10, 50, 0.5);
  transition: transform 0.12s;
}
#score.pop { transform: scale(1.25); }
#combo { color: var(--gold); font-weight: 700; text-align: right; }
#combo.fever { color: #ff9a3c; animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

/* ---------- Power-ups ---------- */
#powers { display: flex; justify-content: center; gap: 10px; }
.power {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1;
  padding: 6px 14px; border-radius: 999px; font-size: clamp(16px, 2.6vh, 22px); font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s, opacity 0.2s, filter 0.2s;
}
.power:active { transform: scale(0.9); }
.power .ico, .power .cnt { display: inline-flex; align-items: center; justify-content: center; height: 1.2em; line-height: 1; }
.power .ico { font-size: 1.05em; }
.power .cnt { min-width: 0.7em; font-variant-numeric: tabular-nums; }
#pwRotate { background: linear-gradient(#5ae6ff, #1482c8); }
#pwBomb { background: linear-gradient(#ff825a, #c8283c); }
#pwShuffle { background: linear-gradient(#78f08c, #1ea05a); }
#pwUndo { background: linear-gradient(#ffd36a, #e08a1e); }
@media (max-width: 380px) { #powers { gap: 6px; } .power { padding: 6px 10px; gap: 4px; } }
.power.empty { opacity: 0.45; filter: saturate(0.4); }
.power.has { animation: wiggle 2.4s ease-in-out infinite; }
.power.active { animation: shakeit 0.2s linear infinite; box-shadow: 0 0 0 3px #fff, 0 0 24px #ff825a; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-6deg); } 90% { transform: rotate(6deg); } 95% { transform: rotate(-3deg); } }
@keyframes shakeit { 50% { transform: rotate(-8deg) scale(1.06); } }

/* ---------- Bord ---------- */
#boardWrap { display: grid; place-items: center; min-height: 0; position: relative; }
#board {
  position: relative; width: var(--board); height: var(--board);
  padding: calc(2% + 4px); border-radius: 4%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
/* draaiende regenboogrand: een kleurenwiel dat draait (enkel verschuiven, niets opnieuw tekenen) */
#ring { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; z-index: 0; pointer-events: none; }
#ring::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 150%; aspect-ratio: 1;
  translate: -50% -50%; will-change: rotate;
  background: conic-gradient(#ff5c8c, #ffc83c, #3ce6a0, #50aaff, #b46cff, #ff5c8c);
  animation: ringspin 4s linear infinite;
}
#ring::after { content: ''; position: absolute; inset: 4px; border-radius: 3.4%; background: #15163f; }
@keyframes ringspin { to { rotate: 360deg; } }
#cells { z-index: 1; }
body.fever #board { box-shadow: 0 0 30px #ff6a00, 0 0 70px rgba(255, 90, 0, 0.45); }
body.fever #ring::before { background: conic-gradient(#ff3c14, #ffbe28, #ff5a00, #ffd25a, #ff3c14); animation-duration: 1.2s; }
body.fever #ring::after { inset: 6px; background: #1f1230; }
#board.dead #ring::before { animation-play-state: paused; filter: grayscale(0.8); }
#board.shake1 { animation: shake 0.25s; }
#board.shake2 { animation: shake 0.4s; }
#board.shake3 { animation: shakeBig 0.6s; }
#board.punch { animation: punch 0.5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes shake { 20% { translate: -4px 2px; } 40% { translate: 4px -2px; } 60% { translate: -3px -1px; } 80% { translate: 2px 2px; } }
@keyframes shakeBig { 10% { translate: -10px 4px; rotate: -1deg; } 25% { translate: 9px -6px; rotate: 1deg; } 40% { translate: -7px 5px; } 55% { translate: 6px -3px; } 70% { translate: -4px 2px; } 85% { translate: 2px -1px; } }
@keyframes punch { 0% { scale: 1; } 30% { scale: 1.06; } 100% { scale: 1; } }

#cells {
  position: relative; width: 100%; height: 100%;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); gap: 1.2%;
}
.cell { position: relative; border-radius: 20%; background: rgba(255, 255, 255, 0.07); }
.cell.pvline { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6) inset; }

/* ---------- Blokjes ---------- */
.blk {
  position: absolute; inset: 0; border-radius: 20%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 72%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 78%, #000) 100%);
  box-shadow: inset 0 -0.12em 0 color-mix(in srgb, var(--c) 60%, #000), 0 2px 4px rgba(0, 0, 0, 0.25);
  font-size: calc(var(--pitch) * 0.5);
}
.blk::before {
  content: ""; position: absolute; left: 14%; right: 14%; top: 9%; height: 16%;
  border-radius: 99px; background: rgba(255, 255, 255, 0.55);
}
.blk.star::after {
  content: "⭐"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.95em; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}
.cell > .blk { display: none; }
.cell.on > .blk { display: block; }
.cell.ghost > .blk { display: block; opacity: 0.45; }
.cell.pop > .blk { animation: placePop 0.42s ease-out; }
/* neerkomen met wat "squash & stretch" */
@keyframes placePop {
  0% { transform: translateY(-18%) scale(0.55); }
  45% { transform: translateY(4%) scale(1.14, 0.84); }
  70% { transform: translateY(-2%) scale(0.95, 1.06); }
  100% { transform: none; }
}
.cell.junk > .blk { --c: #7a7f96; }

/* ---------- Lade ---------- */
#tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.slot {
  position: relative; aspect-ratio: 1; max-height: 22vh; width: 100%; justify-self: center;
  border-radius: 20%; background: var(--panel); border: 2px solid rgba(255, 255, 255, 0.12);
  touch-action: none; transition: transform 0.2s;
}
@media (min-aspect-ratio: 5/4) { .slot { max-height: 26vh; } }
/* iPad liggend en andere brede schermen met veel hoogte: lade verticaal */
@media (min-aspect-ratio: 5/4) and (max-aspect-ratio: 17/10) and (min-height: 560px) {
  #tray { grid-template-columns: 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); min-height: 0; }
  .slot { height: 100%; width: auto; max-height: none; aspect-ratio: 1; }
}
.slot:hover { transform: scale(1.05); }
.piece { position: absolute; pointer-events: none; }
.slot .piece { left: 50%; top: 50%; translate: -50% -50%; animation: bob 2.4s ease-in-out infinite; }
.slot[data-i="1"] .piece { animation-delay: -0.8s; }
.slot[data-i="2"] .piece { animation-delay: -1.6s; }
.slot .piece.enter { animation: enter 0.35s cubic-bezier(.3, 1.6, .5, 1), bob 2.4s ease-in-out 0.35s infinite; }
@keyframes bob { 50% { transform: translateY(-6%) rotate(2deg); } }
@keyframes enter { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } }
.slot .piece.nofit { opacity: 0.35; filter: grayscale(0.5); }
.piece .blk { position: absolute; }
.rotBadge { position: absolute; top: 4%; right: 6%; font-size: clamp(12px, 2vh, 18px); display: none; }
.slot.canRotate .rotBadge { display: block; animation: pulse 0.8s ease-in-out infinite alternate; }

#ghost { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform; }
#ghost .piece { position: relative; transition: scale 0.15s; filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.35)); }

#bombPreview {
  position: absolute; display: none; z-index: 5; pointer-events: none; border-radius: 10%;
  background: rgba(255, 70, 50, 0.4); border: 3px solid #ffdc78;
  animation: pulse 0.3s ease-in-out infinite alternate;
}

/* ---------- Menu ---------- */
#menu { display: flex; justify-content: center; gap: clamp(6px, 2.4vw, 12px); }
.mbtn {
  /* hoog scherm (app, iPad): niet breder dan 5 knoppen naast elkaar toelaten */
  width: clamp(48px, min(8.5vh, calc((100vw - 24px - 4 * clamp(6px, 2.4vw, 12px)) / 5)), 72px); height: clamp(48px, 7.6vh, 66px); border-radius: 26%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(#966eff, #503cc8);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.mbtn:active { transform: scale(0.88); }
.mbtn.off { opacity: 0.45; filter: grayscale(0.7); }

/* ---------- Popups & effecten ---------- */
#popups { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.popup {
  position: absolute; left: 50%; transform: translate(-50%, -50%);
  font-weight: 700; white-space: nowrap; pointer-events: none;
  text-shadow: 0 3px 0 rgba(20, 10, 50, 0.7), 0 0 18px rgba(0, 0, 0, 0.3);
  animation: popup 1.2s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  25% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
#fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 41; pointer-events: none; background: #fff; opacity: 0; }
#flash.go { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0.75; } 100% { opacity: 0; } }
#bigText {
  position: fixed; left: 50%; top: 42%; z-index: 42; pointer-events: none;
  font-weight: 700; font-size: clamp(44px, 12vw, 120px); white-space: nowrap; opacity: 0;
  background: linear-gradient(90deg, #ff5c8c, #ffc83c, #3ce6a0, #50aaff, #b46cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(20, 10, 50, 0.8)) drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
  transform: translate(-50%, -50%);
}
#bigText.go { animation: bigText 1.5s cubic-bezier(.2, 1.5, .4, 1) forwards; }
@keyframes bigText {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(3) rotate(-10deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(0.9) rotate(3deg); }
  30% { transform: translate(-50%, -50%) scale(1.05) rotate(-2deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
}

/* ---------- Venster ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5, 5, 25, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: max(env(safe-area-inset-top), 16px) 16px max(env(safe-area-inset-bottom), 16px);
  touch-action: pan-y;
}
#modal.hidden { display: none; }
#modalCard {
  width: min(92vw, 440px); max-height: 100%; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 22px; border-radius: 26px; text-align: center;
  background: linear-gradient(#4632aa, #1a1846); border: 3px solid rgba(140, 150, 255, 0.6);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: cardIn 0.35s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes cardIn { from { transform: scale(0.6) translateY(30px); opacity: 0; } }
#modalCard { position: relative; }
.xBtn {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  font-size: 20px; font-weight: 700; line-height: 1; background: rgba(255, 255, 255, 0.14);
}
.xBtn:active { transform: scale(0.9); }
#modalCard h2 { margin: 0 0 6px; padding: 0 36px; font-size: 30px; }
#modalCard .big { font-size: 54px; font-weight: 700; margin: 4px 0; }
#modalCard .sub { color: var(--sub); margin: 4px 0 12px; }
#modalCard .gold { color: var(--gold); }
.btn {
  display: block; width: 100%; margin-top: 10px; padding: 14px; border-radius: 18px;
  font-size: 20px; font-weight: 700;
  background: linear-gradient(#5ee68c, #1fa55a);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}
.btn.alt { background: linear-gradient(#7a6ee0, #4a3cb0); }
.btn.red { background: linear-gradient(#ff7a7a, #d23c4c); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; }
input.name {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.3); color: #fff; font: inherit; font-size: 18px; text-align: center;
  -webkit-user-select: text; user-select: text;
}
.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tab { flex: 1; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); font-weight: 600; }
.tab.on { background: var(--gold); color: #2a1a00; }
.lb { list-style: none; padding: 0; margin: 0; text-align: left; }
.lb li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; padding: 9px 12px; border-radius: 12px; margin-bottom: 5px; background: rgba(0, 0, 0, 0.22); }
.lb li.me { background: rgba(255, 205, 60, 0.25); }
.lb .rk { font-weight: 700; }
.lb .sc { font-weight: 700; color: var(--gold); }
.help { text-align: left; line-height: 1.45; }
.help p { margin: 8px 0; }
.msg { color: #ff9a9a; min-height: 1.2em; margin-top: 8px; }

.mbtn .ico { font-size: clamp(18px, 3vh, 26px); line-height: 1; }
.mbtn .lbl { font-size: clamp(9px, 1.35vh, 12px); font-weight: 600; opacity: 0.9; white-space: nowrap; }
.mbtn.new { background: linear-gradient(#5ee68c, #1fa55a); }

/* Opnieuw spelen op het bord na game over */
#overBar {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
  width: min(80%, 340px); padding: 18px; border-radius: 22px; text-align: center;
  background: rgba(20, 18, 60, 0.88); border: 2px solid rgba(140, 150, 255, 0.6);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); animation: cardIn 0.35s cubic-bezier(.2, 1.5, .4, 1);
}
#overBar.hidden { display: none; }
#overTitle { font-size: clamp(22px, 4vh, 32px); font-weight: 700; margin-bottom: 4px; }
#overBar .btn { box-sizing: border-box; }
#overPlay { animation: softPulse 0.9s ease-in-out infinite alternate; }
@keyframes softPulse { to { transform: scale(1.035); } }

/* wachten op de volgende set van de server */
#tray.waiting { position: relative; }
#tray.waiting::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: bbspin .8s linear infinite;
}
@keyframes bbspin { to { transform: rotate(360deg); } }

/* ---------- Game over: bord kleurt grijs in een golf ---------- */
#board.dead .cell.on > .blk {
  filter: grayscale(1) brightness(0.62);
  transition: filter 0.35s ease calc(var(--i) * 12ms);
}
#board.dying .cell.on > .blk { animation: deadDrop 0.7s cubic-bezier(.3, 1.6, .5, 1) calc(var(--i) * 12ms) both; }
@keyframes deadDrop {
  0% { transform: none; }
  35% { transform: translateY(12%) scale(0.92) rotate(-4deg); }
  70% { transform: translateY(-4%) scale(1.02) rotate(2deg); }
  100% { transform: none; }
}


#overBar .xBtn { top: 8px; right: 8px; width: 34px; height: 34px; font-size: 16px; }
#overTitle { padding: 0 30px; }
#overPtsRow { color: #c9ccff; font-size: clamp(14px, 2.2vh, 17px); margin-bottom: 2px; }
#overPtsRow b { color: #ffd36a; font-size: 1.5em; font-variant-numeric: tabular-nums; }

/* "Nieuw spel" in het menu valt op als het spel voorbij is */
#btnNew.attn { animation: attnPulse 1s ease-in-out infinite; }
@keyframes attnPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(94, 230, 140, 0.7); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(94, 230, 140, 0); }
}

/* "+punten" boven een geplaatst blok */
.floatPts {
  position: fixed; z-index: 43; pointer-events: none; font-weight: 700; white-space: nowrap;
  transform: translate(-50%, -50%); text-shadow: 0 2px 0 rgba(20, 10, 50, 0.75);
  animation: floatPts 0.9s cubic-bezier(.2, 1.2, .4, 1) forwards;
}
@keyframes floatPts {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

/* bord gloeit zachtjes mee op de maat van de muziek */

/* 🗑️ weggooien: verschijnt op een blok dat nergens past */
.trashBtn {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); z-index: 3; display: none;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.1;
  font-size: clamp(11px, 1.7vh, 15px); font-weight: 700; color: #fff;
  background: linear-gradient(#ff8a8a, #d23c4c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.3);
}
.slot.canTrash .trashBtn { display: block; animation: trashIn 0.4s cubic-bezier(.3, 1.6, .5, 1); }
.trashBtn:active { transform: translateX(-50%) scale(0.92); }
@keyframes trashIn { from { transform: translateX(-50%) scale(0.3); opacity: 0; } }

/* ---------- Leven in de blokjes ---------- */
.blk { overflow: hidden; }
/* glans die af en toe schuin over alle blokjes loopt (golf over het bord) */
/* de glans zit in een eigen uitgesneden laag: op iPhone (WebKit) lekte hij anders als witte strepen buiten het blokje */
.blk > .shine { position: absolute; inset: 0; pointer-events: none; clip-path: inset(0 round 20%); }
.blk > .shine::before {
  content: ''; position: absolute; inset: -20% auto -20% 0; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-160%) skewX(-18deg);
}
/* de glans loopt enkel af en toe over het bord (app.js zet dan "shining" op body), niet eindeloos */
body.shining .blk > .shine::before { animation: shine 0.9s ease-in-out both; animation-delay: calc(var(--d, 0) * 70ms); }
@keyframes shine {
  from { transform: translateX(-160%) skewX(-18deg); }
  to { transform: translateX(330%) skewX(-18deg); }
}
body.fever .blk > .shine::before { background: linear-gradient(100deg, transparent, rgba(255, 230, 150, 0.75), transparent); }
#board.dead .blk > .shine { display: none; }

/* sterretjes fonkelen */
.blk.star::after { animation: twinkle 1.8s ease-in-out infinite; }
@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.18) rotate(14deg); filter: drop-shadow(0 0 6px rgba(255, 220, 80, 0.9)); }
}

/* lijnen die zo meteen wegspatten: blokjes trillen en lichten op */
.cell.pvline.on > .blk { animation: ready 0.35s ease-in-out infinite alternate; }
@keyframes ready {
  from { transform: scale(1); filter: brightness(1.1); }
  to { transform: scale(1.07); filter: brightness(1.45); }
}

/* golf door de overgebleven blokjes na een wis */
.cell.ripple.on > .blk { animation: ripple 0.55s cubic-bezier(.3, 1.6, .5, 1) var(--rd, 0ms) both; }
@keyframes ripple {
  0% { transform: none; }
  40% { transform: translateY(-14%) scale(1.08); filter: brightness(1.3); }
  100% { transform: none; filter: none; }
}

/* blok aan je vinger: lichtjes wiebelen */
#ghost .blk { animation: jelly 0.5s ease-in-out infinite alternate; }
#ghost .blk:nth-child(even) { animation-delay: -0.25s; }
@keyframes jelly { from { transform: scale(1.04, 0.97); } to { transform: scale(0.97, 1.04); } }

/* fever: blokjes gloeien op de maat */
body.fever .cell.on > .blk { animation: feverGlow 0.9s ease-in-out infinite alternate; animation-delay: calc(var(--d, 0) * 50ms); }
@keyframes feverGlow { from { filter: brightness(1) saturate(1); } to { filter: brightness(1.22) saturate(1.3); } }

/* blok dat nergens past: af en toe een "nee"-schudden */
.slot .piece.nofit { animation: nope 3s ease-in-out infinite; }
@keyframes nope { 0%, 88%, 100% { rotate: 0deg; } 91% { rotate: -6deg; } 94% { rotate: 6deg; } 97% { rotate: -3deg; } }

@media (prefers-reduced-motion: reduce) {
  .blk > .shine::before, .blk.star::after, .cell.pvline.on > .blk, #ghost .blk, body.fever .cell.on > .blk, .slot .piece.nofit { animation: none; }
}
/* volgorde van voorrang: plaatsen/golf/klaar-om-te-wissen gaan boven de fever-gloed */
body .cell.pvline.on > .blk { animation: ready 0.35s ease-in-out infinite alternate; }
body .cell.ripple.on > .blk { animation: ripple 0.55s cubic-bezier(.3, 1.6, .5, 1) var(--rd, 0ms) both; }
body .cell.pop > .blk { animation: placePop 0.42s ease-out; }

/* ---------- Modus ---------- */
#modeChip {
  display: block; margin: 2px auto 0; padding: 3px 12px; border-radius: 999px; line-height: 1.2;
  font-size: clamp(12px, 1.8vh, 15px); font-weight: 700; color: #fff; white-space: nowrap;
  background: rgba(255, 255, 255, 0.14); border: 1.5px solid rgba(255, 255, 255, 0.25);
  font-variant-numeric: tabular-nums;
}
#modeChip:active { transform: scale(0.95); }
#modeChip[data-gm="daily"] { background: linear-gradient(#5aa8ff, #2f6fd6); }
#modeChip[data-gm="blitz"] { background: linear-gradient(#ffb347, #e8642c); min-width: 5.2em; }
#modeChip.hurry { animation: hurry 0.5s ease-in-out infinite alternate; background: linear-gradient(#ff6b6b, #c8283c); }
@keyframes hurry { to { transform: scale(1.12); box-shadow: 0 0 18px rgba(255, 80, 80, 0.8); } }
.modes { display: grid; gap: 10px; margin-top: 10px; }
.modeCard {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; text-align: left; color: #fff;
  background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.15);
}
.modeCard.cur { border-color: #ffd36a; background: rgba(255, 211, 106, 0.14); }
.modeCard:active { transform: scale(0.97); }
.modeCard .mIco { font-size: 34px; line-height: 1; }
.modeCard .mTxt { display: grid; gap: 2px; }
.modeCard b { font-size: 19px; }
.modeCard .mTxt span { font-size: 14px; color: var(--sub); line-height: 1.3; }
.modeTabs { margin-bottom: 0; }
.modeTabs .tab { font-size: 13px; padding: 7px 4px; }
.linkBtn { margin-top: 8px; padding: 6px 10px; font-size: 15px; font-weight: 600; color: #c9ccff; background: none; text-decoration: underline; text-underline-offset: 3px; }

/* app: aankoop en privacylink in de uitleg */
#appExtras { display: grid; gap: 4px; justify-items: center; margin: 6px 0 4px; }
#appExtras .btn { width: 100%; }
#appExtras .btn[disabled] { opacity: 0.5; }
.privacyLink { display: inline-block; font-size: 13px; }

/* ---------- Zuinig: wie even niets doet, krijgt een stilstaand scherm (de telefoon koelt af) ---------- */
body.calm .floater, body.calm #ring::before, body.calm .slot .piece, body.calm .power.has,
body.calm .blk.star::after, body.calm .slot.canRotate .rotBadge, body.calm .slot .piece.nofit,
body.calm #overPlay, body.calm #btnNew.attn { animation-play-state: paused; }

/* Blitz: grote startknop op het bord */
#startBar { position: absolute; inset: 0; z-index: 8; display: grid; place-content: center; justify-items: center; gap: 14px; border-radius: inherit; background: rgba(12, 10, 44, 0.55); }
#startBar.hidden { display: none; }
#startBtn {
  font: inherit; font-weight: 700; font-size: clamp(34px, 11vw, 60px); letter-spacing: 1px; color: #fff; padding: 0.35em 0.9em; border-radius: 0.5em;
  background: linear-gradient(180deg, #ffd24a, #ff8a1f); border: 3px solid #fff3; box-shadow: 0 8px 0 #b3560a, 0 18px 40px rgba(0, 0, 0, 0.5);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); animation: startPulse 1.1s ease-in-out infinite alternate; touch-action: manipulation;
}
#startBtn:active { transform: translateY(6px) scale(0.98); box-shadow: 0 2px 0 #b3560a; animation: none; }
#startSub { font-size: clamp(16px, 4.6vw, 22px); font-weight: 600; color: #ffe9a8; text-align: center; padding: 0 12px; }
@keyframes startPulse { to { transform: scale(1.06); } }
body.prestart #tray, body.prestart #powers { opacity: 0; pointer-events: none; }
body.calm #startBtn { animation-play-state: paused; }
.modeCard.done { opacity: 0.55; }

/* Brede schermen: ranglijst aller tijden links naast het bord */
#hall { display: none; }
@media (min-aspect-ratio: 5/4) and (min-width: 1100px) {
  #app {
    grid-template-areas: "hall board top" "hall board powers" "hall board tray" "hall board menu" "hall board credit";
    grid-template-columns: clamp(200px, 15vw, 400px) minmax(0, 1fr) minmax(250px, 32%);
    max-width: 1700px;
  }
  #hall {
    grid-area: hall; display: block; align-self: center; visibility: hidden; padding: 14px; border-radius: 22px;
    background: rgba(20, 18, 60, 0.45); border: 2px solid rgba(140, 150, 255, 0.35); max-height: 86vh; overflow: hidden;
  }
  #hall.ready { visibility: visible; }
  #hallTitle { font: inherit; font-weight: 700; font-size: clamp(17px, 2.1vh, 30px); color: #ffe08a; background: none; border: 0; padding: 2px 4px 12px; width: 100%; text-align: center; cursor: pointer; }
  #hall .lb li { grid-template-columns: 2.3em minmax(0, 1fr) auto; padding: 0.55em 0.7em; margin-bottom: 0.35em; font-size: clamp(14px, 1.65vh, 24px); }
  #hall .lb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Grote schermen (4K, grote monitor): alles naast het bord groeit mee */
@media (min-aspect-ratio: 5/4) and (min-width: 1100px) and (min-height: 900px) {
  /* bord tot 80% van de hoogte, alles samen gecentreerd */
  #app { grid-template-columns: clamp(200px, 15vw, 400px) minmax(0, 80vh) minmax(250px, 46vh); justify-content: center; max-width: none; }
  #title { font-size: clamp(34px, 4vh, 68px); }
  #modeChip { font-size: clamp(15px, 1.7vh, 26px); padding: 0.25em 0.9em; }
  .stat { font-size: clamp(20px, 2.2vh, 34px); }
  #score { font-size: clamp(64px, 6.2vh, 110px); }
  .power { font-size: clamp(22px, 2.3vh, 38px); padding: 0.3em 0.7em; }
  .mbtn { width: clamp(72px, 6.8vh, 116px); height: clamp(66px, 6.3vh, 106px); }
  .mbtn .ico { font-size: clamp(26px, 2.6vh, 44px); }
  .mbtn .lbl { font-size: clamp(12px, 1.2vh, 19px); }
  #menu { gap: clamp(12px, 1.4vh, 24px); }
}

/* ================= Blobjes-uiterlijk (proef: ?skin=blob) ================= */
.blk > .jel { display: none; }
body.skin-blob .blk[data-c="1"] { --spr: url(skins/blob/1.webp); --f0: #f38fa8; --f1: #d41f2c; --f2: #d21b28; }
body.skin-blob .blk[data-c="2"] { --spr: url(skins/blob/2.webp); --f0: #f9d196; --f1: #f06f12; --f2: #ea5b0c; }
body.skin-blob .blk[data-c="3"] { --spr: url(skins/blob/3.webp); --f0: #f9efa1; --f1: #edc11d; --f2: #e4b91a; }
body.skin-blob .blk[data-c="4"] { --spr: url(skins/blob/4.webp); --f0: #c5f7a7; --f1: #53c029; --f2: #3db921; }
body.skin-blob .blk[data-c="5"] { --spr: url(skins/blob/5.webp); --f0: #73cbf9; --f1: #0177ed; --f2: #0066e9; }
body.skin-blob .blk[data-c="6"] { --spr: url(skins/blob/6.webp); --f0: #cc91f4; --f1: #9240f0; --f2: #822eef; }
body.skin-blob .blk[data-c="7"] { --spr: url(skins/blob/7.webp); --f0: #92f9ef; --f1: #00bdb2; --f2: #00beb0; }
body.skin-blob .blk { background: none; box-shadow: none; border-radius: 0; overflow: visible; }
body.skin-blob .blk > .jel { display: block; position: absolute; inset: -3.75%; background: var(--spr) center / 100% 100% no-repeat; transform-origin: 50% 56%; }
body.skin-blob .blk::before { display: none; content: ''; position: absolute; inset: 0; height: auto; border-radius: 0;
  background: linear-gradient(var(--f0), var(--f1) 55%, var(--f2)); box-shadow: var(--seam, none); }
body.skin-blob .blk > .shine { display: none; }
body.skin-blob .blk.star::after {
  content: ''; inset: auto; right: -7%; top: -11%; width: 52%; height: 52%; display: block; z-index: 2;
  background: url(skins/blob/star.webp) center / contain no-repeat; transform: rotate(14deg); animation: none; filter: none;
}
/* blok in de lade en aan je vinger: blobjes platgedrukt tot één strak blok */
body.skin-blob .piece .blk { clip-path: inset(0 round var(--r, 30%)); }
body.skin-blob .piece .blk::before { display: block; }
body.skin-blob .piece .blk > .jel { transform: scale(1.34, 1.4); }
body.skin-blob .piece .blk.star::after { right: 6%; top: 4%; width: 40%; height: 40%; }
body.skin-blob #ghost .blk { animation: none; }
/* neergezet: het blok veert open en elk blobje krijgt zijn ronde vorm terug */
body.skin-blob .cell.pop > .blk { animation: blobOpen 0.56s linear both; }
body.skin-blob .cell.pop > .blk::before { display: block; animation: blobFill 0.56s linear both; }
body.skin-blob .cell.pop > .blk > .jel { animation: blobWobble 0.56s ease-out both; }
@keyframes blobOpen {
  0%, 12% { clip-path: inset(0% round 22% 22% 22% 22%); transform: scale(1.106); }
  42%, 100% { clip-path: inset(-40% round 0% 0% 0% 0%); transform: none; }
}
@keyframes blobFill { 0%, 12% { opacity: 1; } 32%, 100% { opacity: 0; } }
@keyframes blobWobble {
  0% { transform: scale(1.34, 1.4); }
  12% { transform: scale(1.3, 1.34); }
  38% { transform: scale(0.86, 1.14); }
  58% { transform: scale(1.1, 0.9); }
  78% { transform: scale(0.96, 1.05); }
  100% { transform: none; }
}
body.skin-blob #title img { height: 0.98em; width: 0.98em; vertical-align: -0.16em; margin: 0 0.015em; }
body.skin-blob .floater { border-radius: 47% 53% 44% 56% / 58% 50% 50% 42%; }
@media (prefers-reduced-motion: reduce) {
  body.skin-blob .cell.pop > .blk, body.skin-blob .cell.pop > .blk::before, body.skin-blob .cell.pop > .blk > .jel { animation: none; }
}

/* ================= Kerst-blobjes (proef: ?skin=xmas) ================= */
body.skin-xmas .blk[data-c="1"] { --spr: url(skins/xmas/1.webp); }
body.skin-xmas .blk[data-c="2"] { --spr: url(skins/xmas/2.webp); }
body.skin-xmas .blk[data-c="3"] { --spr: url(skins/xmas/3.webp); }
body.skin-xmas .blk[data-c="4"] { --spr: url(skins/xmas/4.webp); }
body.skin-xmas .blk[data-c="5"] { --spr: url(skins/xmas/5.webp); }
body.skin-xmas .blk[data-c="6"] { --spr: url(skins/xmas/6.webp); }
body.skin-xmas .blk[data-c="7"] { --spr: url(skins/xmas/7.webp); }
/* de afbeelding is breder en hoger: mutsen en oorwarmers steken buiten het vakje uit */
body.skin-xmas .blk > .jel { inset: -46.75% -19.875% -3.75%; transform-origin: 50% 65.6%; }
body.skin-xmas .cell.on > .blk { z-index: 1; }
body.skin-xmas #title img { width: 1.27em; height: 1.37em; vertical-align: -0.2em; margin: -0.39em -0.12em 0; }
body.skin-xmas .blk.star::after { right: -10%; top: -2%; }
#snow { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#snow > i { position: absolute; top: -40px; background: url(skins/xmas/snow.webp) center / contain no-repeat; animation: snowFall linear infinite; will-change: transform; }
@keyframes snowFall { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(var(--sway, 0px), 110vh) rotate(240deg); } }
body.calm #snow > i { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { #snow { display: none; } }

/* blok vastgenomen: de blobjes trekken een ander gezichtje */
body.skin-blob #ghost .blk[data-c="1"] > .jel { background-image: url(skins/blob/1-held.webp); }
body.skin-blob #ghost .blk[data-c="2"] > .jel { background-image: url(skins/blob/2-held.webp); }
body.skin-blob #ghost .blk[data-c="3"] > .jel { background-image: url(skins/blob/3-held.webp); }
body.skin-blob #ghost .blk[data-c="4"] > .jel { background-image: url(skins/blob/4-held.webp); }
body.skin-blob #ghost .blk[data-c="5"] > .jel { background-image: url(skins/blob/5-held.webp); }
body.skin-blob #ghost .blk[data-c="6"] > .jel { background-image: url(skins/blob/6-held.webp); }
body.skin-blob #ghost .blk[data-c="7"] > .jel { background-image: url(skins/blob/7-held.webp); }
body.skin-xmas #ghost .blk[data-c="1"] > .jel { background-image: url(skins/xmas/1-held.webp); }
body.skin-xmas #ghost .blk[data-c="2"] > .jel { background-image: url(skins/xmas/2-held.webp); }
body.skin-xmas #ghost .blk[data-c="3"] > .jel { background-image: url(skins/xmas/3-held.webp); }
body.skin-xmas #ghost .blk[data-c="4"] > .jel { background-image: url(skins/xmas/4-held.webp); }
body.skin-xmas #ghost .blk[data-c="5"] > .jel { background-image: url(skins/xmas/5-held.webp); }
body.skin-xmas #ghost .blk[data-c="6"] > .jel { background-image: url(skins/xmas/6-held.webp); }
body.skin-xmas #ghost .blk[data-c="7"] > .jel { background-image: url(skins/xmas/7-held.webp); }

/* terugnemen heb je wel, maar kan nu niet (laatste blok van een set, na een power-up) */
.power.wait { opacity: 0.55; animation: none; }
.btn.gold { background: linear-gradient(#ffd75e, #f29a1f); color: #4a2a00 !important; text-shadow: none !important; -webkit-text-stroke: 0 !important; }

/* knop Stoppen: enkel zichtbaar tijdens een spel met punten; dan passen er 6 knoppen naast elkaar */
.mbtn.quit { background: linear-gradient(#ffd75e, #f29a1f); }
.mbtn.quit .lbl { color: #4a2a00; text-shadow: none; }
.mbtn.hidden { display: none; }
@media (max-aspect-ratio: 5/4) {
  #menu:has(#btnQuit:not(.hidden)) .mbtn { width: clamp(46px, min(8.5vh, calc((100vw - 24px - 5 * clamp(5px, 2vw, 12px)) / 6)), 72px); }
  #menu:has(#btnQuit:not(.hidden)) { gap: clamp(5px, 2vw, 12px); }
}
