/* ----- Reset + base ----- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(ellipse at top, #1e293b 0%, #0f172a 50%, #020617 100%);
  color: #e2e8f0;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }
kbd {
  background: #1e293b; border: 1px solid #334155; border-radius: 4px;
  padding: 2px 6px; font-family: monospace; font-size: 0.9em;
}
/* Kill tap-delay + double-tap-zoom on interactive surfaces and the play area (mobile) */
button, a.share-btn, .ctrl-btn, .pu-btn, .side-btn, .btn, .game-frame, .board {
  touch-action: manipulation;
}

/* ----- Header ----- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right))
           12px calc(20px + env(safe-area-inset-left));
  background: rgba(2,6,23,0.7); backdrop-filter: blur(10px);
  border-bottom: 1px solid #1e293b; position: sticky; top: 0; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  font-size: 28px; background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.site-header nav { display: flex; gap: 18px; font-size: 14px; }

/* ----- Ad slots ----- */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 12px auto; min-height: 90px;
  background: rgba(15,23,42,0.4); border: 1px dashed #334155; border-radius: 8px;
  position: relative; max-width: 970px; width: calc(100% - 24px);
}
.ad-slot .ad-label {
  position: absolute; top: 2px; right: 8px; font-size: 9px; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.ad-top { min-height: 90px; }
.ad-side { min-height: 250px; width: 100%; margin-top: 16px; }
.ad-content { min-height: 250px; margin: 28px auto; }

/* ----- Layout ----- */
.layout {
  display: grid; grid-template-columns: 220px 1fr 220px;
  gap: 20px; padding: 16px; max-width: 1200px; margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 8px; }
  /* Board first so it lands above the fold; stats + action buttons sit below it. */
  .game-area { order: 1; }
  .side-panel.left { order: 2; }
  .side-panel.right { order: 3; }
  /* Stats become a compact horizontal strip instead of a tall 2-col stack.
     Scoped with .layout so it beats the base `.side-panel` rule that follows it. */
  .layout .side-panel { flex-direction: row; flex-wrap: wrap; gap: 8px; justify-content: center; }
  /* Center content vertically so cards stretched to the row's height aren't half-empty. */
  .layout .side-panel .stat-card {
    flex: 1 1 0; min-width: 70px; padding: 8px 6px;
    display: flex; flex-direction: column; justify-content: center;
  }
  .layout .side-panel .stat-label { font-size: 10px; margin-bottom: 2px; }
  /* Shrink + scale the value so big numbers (e.g. 257,268) don't overflow the card. */
  .layout .side-panel .stat-value {
    font-size: clamp(13px, 4.2vw, 20px); line-height: 1.1;
    letter-spacing: -0.3px; font-variant-numeric: tabular-nums;
  }
  .layout .side-panel .side-btn { flex: 1 1 46%; }
  .layout .side-panel .ad-side { flex: 1 1 100%; margin-top: 8px; }
  /* A top leaderboard would shove the game below the fold on a phone — drop it on
     mobile (the side ad now sits below the game + the in-content unit is further down).
     Replace later with a sticky bottom "anchor" ad, the mobile-friendly format. */
  .ad-top { display: none; }
}

/* Very narrow phones: keep the header from overflowing + roomy tap targets */
@media (max-width: 480px) {
  .brand h1 { font-size: 18px; }
  .brand .logo { font-size: 22px; }
  .site-header { padding-left: calc(12px + env(safe-area-inset-left));
                 padding-right: calc(12px + env(safe-area-inset-right)); }
  .site-header nav { gap: 12px; font-size: 13px; }
}

/* ----- Side panels ----- */
.side-panel { display: flex; flex-direction: column; gap: 10px; }
.stat-card {
  background: rgba(30, 41, 59, 0.6); border: 1px solid #1e293b; border-radius: 12px;
  padding: 12px 14px; text-align: center;
}
.stat-label {
  font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px;
  font-weight: 600; margin-bottom: 4px;
}
.stat-value { font-size: 28px; font-weight: 800; color: #f1f5f9; }
.next-tile {
  width: 60px; height: 60px; margin: 6px auto 0;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}
.side-btn {
  background: linear-gradient(135deg, #6366f1, #4f46e5); color: white; border: none;
  padding: 12px 16px; border-radius: 10px; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: transform 0.1s, box-shadow 0.2s;
}
.side-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(99,102,241,0.4); }
.side-btn:active { transform: translateY(0); }

/* ----- Game area ----- */
.game-area { display: flex; flex-direction: column; align-items: center; }
.game-frame {
  position: relative;
  /* Bound by height too so the board + dropper + controls don't overflow in landscape. */
  width: min(95vw, 420px, 72vh);
  background: rgba(2,6,23,0.5);
  border-radius: 16px; padding: 8px 12px 12px;
  border: 2px solid #1e293b;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4);
}

/* The dropper sits ABOVE the board and slides horizontally */
.dropper {
  position: relative; width: 100%;
  display: flex; flex-direction: column; align-items: flex-start;
  transition: transform 0.12s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  margin-bottom: 6px;
}
.dropper-tile {
  width: var(--cell-size, 60px); height: var(--cell-size, 60px);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 22px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.dropper-arrow {
  width: var(--cell-size, 60px); text-align: center;
  color: #f59e0b; font-size: 18px; line-height: 12px;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* Board grid */
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(15,23,42,0.6);
  border-radius: 10px;
  padding: 6px;
  border: 1px solid #1e293b;
}
.cell {
  background: rgba(30,41,59,0.4);
  border-radius: 8px;
}
.tile {
  position: absolute;
  width: calc((100% - 12px - 24px) / 5);
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff;
  font-size: clamp(14px, 4vw, 22px);
  transition: top 0.18s cubic-bezier(0.5, 0, 0.7, 1.4),
              left 0.12s ease-out,
              transform 0.15s ease-out;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  will-change: top, left, transform;
}
.tile.merging { animation: mergePulse 0.3s ease-out; z-index: 5; }
.tile.spawned { animation: spawnPop 0.25s ease-out; }
@keyframes mergePulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); filter: brightness(1.5); }
  100% { transform: scale(1); }
}
@keyframes spawnPop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Merge particles (gold sparks) */
.particle {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%; pointer-events: none; z-index: 8;
  background: radial-gradient(circle, #fff 0%, #fbbf24 55%, #f59e0b 100%);
  animation: particleFly 0.55s ease-out forwards;
}
@keyframes particleFly {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, 0)) scale(0.2); opacity: 0; }
}

/* Screen shake on big merges */
.game-frame.shake { animation: shake 0.25s ease-in-out; }
@keyframes shake {
  0%,100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 3px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-3px, 4px); }
  80% { transform: translate(3px, -3px); }
}

/* Dropper "blocked" bump (full column) */
.dropper-tile.bump { animation: bump 0.22s ease-in-out; }
@keyframes bump {
  0%,100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(-4px, -2px) rotate(-5deg); }
  60% { transform: translate(4px, -1px) rotate(5deg); }
}

/* Landing-shadow ghost (where the current tile will drop) */
.ghost {
  position: absolute; border-radius: 8px; pointer-events: none; z-index: 1;
  border: 2px dashed rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.08);
  transition: left 0.12s ease-out, top 0.12s ease-out;
}
/* Full-column merge target: the drop will combine with the top tile in place */
.ghost.merge {
  border-color: rgba(34, 197, 94, 0.85);
  background: rgba(34, 197, 94, 0.16);
}

/* Tile color palette - extend to 2048+ */
.t-2     { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); color: #334155; }
.t-4     { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #78350f; }
.t-8     { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.t-16    { background: linear-gradient(135deg, #fb923c, #ea580c); }
.t-32    { background: linear-gradient(135deg, #f87171, #dc2626); }
.t-64    { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.t-128   { background: linear-gradient(135deg, #ec4899, #be185d); font-size: clamp(12px, 3.5vw, 18px); }
.t-256   { background: linear-gradient(135deg, #d946ef, #a21caf); font-size: clamp(12px, 3.5vw, 18px); }
.t-512   { background: linear-gradient(135deg, #a855f7, #7e22ce); font-size: clamp(12px, 3.5vw, 18px); }
.t-1024  { background: linear-gradient(135deg, #6366f1, #4338ca); font-size: clamp(11px, 3vw, 16px); }
.t-2048  { background: linear-gradient(135deg, #fbbf24, #f59e0b, #ef4444); font-size: clamp(11px, 3vw, 16px);
           box-shadow: 0 0 24px rgba(251,191,36,0.7), 0 4px 8px rgba(0,0,0,0.3); animation: glow 1.5s ease-in-out infinite alternate; }
.t-4096  { background: linear-gradient(135deg, #10b981, #047857); font-size: clamp(10px, 2.8vw, 14px);
           box-shadow: 0 0 24px rgba(16,185,129,0.75), 0 4px 8px rgba(0,0,0,0.3); animation: glow4096 1.5s ease-in-out infinite alternate; }
.t-8192  { background: linear-gradient(115deg, #06b6d4, #3b82f6, #8b5cf6, #06b6d4); background-size: 300% 300%;
           font-size: clamp(10px, 2.8vw, 14px);
           box-shadow: 0 0 24px rgba(6,182,212,0.75), 0 4px 8px rgba(0,0,0,0.3);
           animation: glow8192 1.5s ease-in-out infinite alternate, shimmer8192 3.2s linear infinite; }
@keyframes glow {
  from { box-shadow: 0 0 24px rgba(251,191,36,0.7), 0 4px 8px rgba(0,0,0,0.3); }
  to   { box-shadow: 0 0 36px rgba(251,191,36,1), 0 4px 8px rgba(0,0,0,0.3); }
}
@keyframes glow4096 {
  from { box-shadow: 0 0 24px rgba(16,185,129,0.75), 0 4px 8px rgba(0,0,0,0.3); }
  to   { box-shadow: 0 0 40px rgba(16,185,129,1), 0 4px 8px rgba(0,0,0,0.3); }
}
@keyframes glow8192 {
  from { box-shadow: 0 0 24px rgba(6,182,212,0.75), 0 4px 8px rgba(0,0,0,0.3); }
  to   { box-shadow: 0 0 44px rgba(139,92,246,1), 0 4px 8px rgba(0,0,0,0.3); }
}
@keyframes shimmer8192 {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* Combo popup */
.combo-popup {
  position: absolute; pointer-events: none; z-index: 10;
  font-weight: 900; font-size: 28px; color: #fbbf24;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* Controls */
.controls {
  display: flex; gap: 10px; margin-top: 8px; width: 100%;
  max-width: 420px; justify-content: center;
}
.ctrl-btn {
  flex: 1; padding: 16px; border-radius: 12px; border: none;
  background: rgba(30,41,59,0.8); color: white; font-size: 20px; font-weight: 800;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  border: 1px solid #334155;
}
.ctrl-btn:active { transform: scale(0.96); background: rgba(51,65,85,0.8); }
.ctrl-btn.drop {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white; font-size: 16px; flex: 2; letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(239,68,68,0.4);
}

/* ----- Power-ups (Bomb + Swap-board) ----- */
.powerups {
  display: flex; gap: 10px; margin-top: 10px; width: 100%; max-width: 420px; justify-content: center;
}
.powerups[hidden] { display: none !important; }
.pu-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 10px; border-radius: 12px; border: 1px solid #334155;
  background: rgba(30,41,59,0.8); color: #e2e8f0; font-weight: 800; font-size: 14px;
  cursor: pointer; transition: transform 0.1s, background 0.15s, box-shadow 0.2s;
}
.pu-btn:hover { background: rgba(51,65,85,0.85); }
.pu-btn:active { transform: scale(0.96); }
.pu-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.pu-btn .pu-ic { font-size: 18px; }
.pu-btn .pu-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 900;
  background: #38bdf8; color: #06283d;
}
.pu-btn .pu-count.ad { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.pu-btn.active {
  border-color: #f59e0b; background: rgba(245,158,11,0.18); color: #fff;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.55), 0 6px 14px rgba(245,158,11,0.28);
}
/* Locked until the board reaches the unlock tile */
.pu-btn.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.6); }
.pu-btn.locked .pu-count { background: #475569; color: #cbd5e1; letter-spacing: 0.2px; }
/* One-shot pulse the moment a power-up unlocks mid-game */
.pu-btn.just-unlocked { animation: puUnlock 0.6s ease-out 2; }
@keyframes puUnlock {
  0%   { box-shadow: 0 0 0 0 rgba(56,189,248,0.0); }
  35%  { box-shadow: 0 0 0 3px rgba(56,189,248,0.7), 0 6px 16px rgba(56,189,248,0.45); transform: translateY(-2px); }
  100% { box-shadow: 0 0 0 0 rgba(56,189,248,0.0); transform: translateY(0); }
}

/* Targeting mode (a power-up is armed) */
.board.targeting { cursor: crosshair; }
.board.targeting .tile { cursor: pointer; }
.board.targeting .tile:hover { transform: scale(1.06); filter: brightness(1.15); z-index: 6; }
.tile.selected {
  outline: 3px solid #fbbf24; outline-offset: -2px;
  box-shadow: 0 0 18px rgba(251,191,36,0.9); z-index: 7;
}
.tile.bombed { animation: tileBomb 0.32s ease-out forwards; z-index: 8; }
@keyframes tileBomb {
  0%   { transform: scale(1);   filter: brightness(1); }
  40%  { transform: scale(1.3); filter: brightness(2) saturate(2); }
  100% { transform: scale(0);   opacity: 0; filter: brightness(3); }
}

/* Hint bar shown while targeting */
.power-hint {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  z-index: 45; pointer-events: none; white-space: nowrap; max-width: 94%;
  background: rgba(2,6,23,0.9); border: 1px solid #f59e0b; border-radius: 999px;
  padding: 6px 14px; font-size: 12px; font-weight: 700; color: #fde68a;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.power-hint[hidden] { display: none !important; }

/* Goal indicator — what you're climbing toward (top of the frame, in normal flow) */
.goal-bar {
  margin: 0 auto 8px; width: fit-content; max-width: 100%;
  text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
  color: #fcd34d; background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.3); border-radius: 999px; padding: 4px 14px;
}

/* Top row of the frame: goal indicator + upcoming-tile preview side by side, so
   "Next" is always visible with the board (above the fold) — no scrolling on phones. */
.frame-top {
  display: flex; align-items: stretch; justify-content: center;
  flex-wrap: wrap; gap: 8px 10px; margin-bottom: 8px;
}
/* Stretch the goal pill to the Next chip's height and centre its text, so the
   two pills read as a matched pair. */
.frame-top .goal-bar { margin: 0; display: flex; align-items: center; justify-content: center; gap: 5px; line-height: 1; }
.goal-ic { font-size: 15px; line-height: 1; }
.next-mini {
  display: flex; align-items: center; gap: 7px;
  background: rgba(30,41,59,0.6); border: 1px solid #1e293b;
  border-radius: 999px; padding: 4px 14px;
}
.next-mini-label {
  font-size: 12px; letter-spacing: 0.3px; line-height: 1;
  color: #e2e8f0; font-weight: 700;
}
.next-mini .next-tile {
  width: 30px; height: 30px; margin: 0; border-radius: 7px;
  font-size: 17px; line-height: 1; box-shadow: none;
}

/* Overlay (game over) */
.overlay {
  position: absolute; inset: 0; background: rgba(2,6,23,0.85);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
  border-radius: 14px; z-index: 50;
  animation: fadeIn 0.3s ease;
}
.overlay[hidden] { display: none !important; }
.share-row[hidden] { display: none !important; }
.cookie-banner[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  background: linear-gradient(135deg, rgba(30,41,59,0.95), rgba(15,23,42,0.95));
  border: 1px solid #334155; border-radius: 16px; padding: 28px;
  text-align: center; max-width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.overlay-card h2 { font-size: 28px; margin-bottom: 6px; color: #f1f5f9; }
.overlay-card p { color: #94a3b8; font-size: 13px; margin-bottom: 4px; }
.big-score {
  font-size: 56px; font-weight: 900; margin: 8px 0;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #ef4444);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.best-line { color: #cbd5e1; margin-bottom: 18px; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn {
  padding: 12px 24px; border-radius: 10px; border: 1px solid #334155;
  background: rgba(30,41,59,0.8); color: white; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover { background: rgba(51,65,85,0.8); }
.btn.primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5); border-color: transparent;
}
.btn.primary:hover { box-shadow: 0 6px 14px rgba(99,102,241,0.4); }
.share-row {
  display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap;
}
.share-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid #334155;
  background: #1e293b; color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
}
.share-btn:hover { background: #334155; }

/* Content sections (SEO) */
.content-section {
  max-width: 760px; margin: 32px auto; padding: 24px;
  background: rgba(15,23,42,0.5); border-radius: 12px;
  border: 1px solid #1e293b;
}
.content-section h2 {
  font-size: 22px; margin-bottom: 14px; color: #f1f5f9;
}
.content-section h3 { font-size: 17px; margin: 16px 0 8px; color: #cbd5e1; }
.content-section p, .content-section li { line-height: 1.6; color: #cbd5e1; font-size: 14px; }
.content-section ol, .content-section ul { padding-left: 20px; margin: 10px 0; }
.content-section li { margin-bottom: 6px; }

/* Cookie banner */
.cookie-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(2,6,23,0.95); backdrop-filter: blur(10px);
  padding: 14px calc(20px + env(safe-area-inset-right))
           calc(14px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  border-top: 1px solid #1e293b;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  z-index: 200; flex-wrap: wrap; font-size: 13px;
}
.cookie-banner button {
  padding: 8px 18px; border-radius: 6px; border: none;
  background: linear-gradient(135deg, #6366f1, #4f46e5); color: white;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn.cookie-ghost { background: transparent; border: 1px solid #334155; color: #cbd5e1; }
.cookie-btn.cookie-ghost:hover { background: rgba(51,65,85,0.5); }

/* Footer */
.site-footer {
  text-align: center; padding: 24px; color: #64748b; font-size: 12px;
  border-top: 1px solid #1e293b; margin-top: 32px;
}
.site-footer nav { margin-top: 6px; }

/* Reward (rewarded-ad) buttons */
.side-btn.reward, .btn.reward {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: transparent; color: #fff;
}
.side-btn.reward:hover, .btn.reward:hover { box-shadow: 0 6px 14px rgba(16,185,129,0.45); }
.side-btn[hidden], .btn[hidden] { display: none !important; }
.side-btn:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Simulated rewarded-ad modal (fallback shown until AdSense H5 Games Ads is live) */
.ad-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(2,6,23,0.92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.ad-modal[hidden] { display: none !important; }
.ad-modal-card {
  width: min(92vw, 360px); text-align: center; padding: 28px 24px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.ad-modal-card .ad-tag {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #64748b;
}
.ad-modal-card .ad-visual {
  margin: 14px auto; width: 84px; height: 84px; border-radius: 18px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.ad-modal-card h3 { font-size: 18px; color: #f1f5f9; margin-bottom: 6px; }
.ad-modal-card p { color: #94a3b8; font-size: 13px; margin-bottom: 4px; }
.ad-modal-card .ad-count { font-weight: 800; color: #fbbf24; }
.ad-skip {
  margin-top: 14px; background: none; border: none; color: #64748b;
  font-size: 12px; cursor: pointer; text-decoration: underline;
}
.ad-skip:hover { color: #94a3b8; }

/* Simulated full-screen interstitial (between games) */
.interstitial {
  position: fixed; inset: 0; z-index: 320;
  background: rgba(2,6,23,0.96); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; animation: fadeIn 0.2s ease;
}
.interstitial[hidden] { display: none !important; }
.interstitial .ad-tag {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #64748b;
}
.interstitial .ad-creative {
  width: min(86vw, 320px); aspect-ratio: 4 / 3; border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.interstitial .ad-creative .big { font-size: 30px; font-weight: 900; margin-bottom: 6px; }
.interstitial .ad-creative .small { font-size: 13px; opacity: 0.9; }
.interstitial .inter-action {
  min-width: 180px; padding: 12px 24px; border-radius: 10px; border: none;
  font-weight: 800; font-size: 15px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #10b981, #059669);
}
.interstitial .inter-action:disabled { opacity: 0.5; cursor: default; background: #334155; }

/* Achievement unlock toasts */
.achv-toasts {
  position: fixed; top: 12px; left: 0; right: 0; z-index: 340;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.achv-toast {
  display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 360px); padding: 12px 16px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #f59e0b; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(245,158,11,0.3);
  transform: translateY(-120%); opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2,0.9,0.3,1.2), opacity 0.35s;
}
.achv-toast.show { transform: translateY(0); opacity: 1; }
.achv-toast .achv-ic { font-size: 28px; }
.achv-toast .achv-txt { font-size: 13px; color: #e2e8f0; line-height: 1.35; }
.achv-toast .achv-txt b { color: #fbbf24; }

/* Achievements modal list (reuses .ad-modal backdrop) */
.achv-card { width: min(94vw, 420px); }
.achv-card h3 { font-size: 20px; color: #f1f5f9; margin-bottom: 14px; }
.achv-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; margin-bottom: 16px; }
.achv-row {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(15,23,42,0.6); border: 1px solid #1e293b; opacity: 0.55;
}
.achv-row.got { opacity: 1; border-color: #f59e0b; background: rgba(245,158,11,0.08); }
.achv-row .achv-ic { font-size: 26px; width: 32px; text-align: center; }
.achv-row .achv-txt { flex: 1; font-size: 13px; color: #cbd5e1; line-height: 1.3; }
.achv-row .achv-txt b { color: #f1f5f9; }
.achv-row .achv-check { color: #10b981; font-weight: 900; font-size: 18px; }

/* ----- Milestone celebration (2048 / 4096 / 8192) ----- */
.confetti-layer {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  z-index: 40; border-radius: 16px;
}
.confetti {
  position: absolute; top: -6%; width: 9px; height: 14px; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { top: -6%;  transform: translateX(0) rotate(0); opacity: 1; }
  100% { top: 106%; transform: translateX(var(--dx, 0)) rotate(var(--rot, 360deg)); opacity: 0.85; }
}
.milestone-banner {
  position: absolute; inset: 0; z-index: 60; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; opacity: 0; transform: scale(0.6);
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2,0.9,0.3,1.4);
}
.milestone-banner.show { opacity: 1; transform: scale(1); }
.milestone-title {
  font-size: clamp(40px, 14vw, 72px); font-weight: 900; line-height: 1;
  color: var(--mile-color, #fbbf24);
  text-shadow: 0 0 28px var(--mile-color, #fbbf24), 0 4px 14px rgba(0,0,0,0.7);
  animation: milestonePop 0.6s ease-out;
}
.milestone-sub {
  margin-top: 12px; font-size: clamp(16px, 5vw, 26px); font-weight: 800;
  letter-spacing: 3px; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.85);
}
@keyframes milestonePop {
  0%   { transform: scale(0.4) rotate(-6deg); }
  60%  { transform: scale(1.15) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}
/* Gold-rain star pieces (deluxe 4096/8192 confetti) */
.confetti.star {
  width: 15px; height: 15px; border-radius: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  box-shadow: 0 0 8px rgba(251,191,36,0.95);
}
/* Radial shockwave bursting from a deluxe milestone tile */
.shockwave {
  position: absolute; width: 48px; height: 48px; border-radius: 50%;
  pointer-events: none; z-index: 9; border: 5px solid #fff;
  transform: translate(-50%, -50%) scale(0.2);
  animation: shockwaveExpand 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes shockwaveExpand {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0.85; border-width: 6px; }
  100% { transform: translate(-50%, -50%) scale(9);   opacity: 0;    border-width: 1px; }
}
/* Sustained pulsing glow of the whole frame during a deluxe celebration */
.game-frame.celebrating { animation: framePulse 1.5s ease-in-out; }
@keyframes framePulse {
  0%, 100% { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4); }
  25%      { box-shadow: 0 0 90px var(--cele-color, #fbbf24), 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 50px var(--cele-color, #fbbf24), 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4); }
  75%      { box-shadow: 0 0 90px var(--cele-color, #fbbf24), 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* --- Ad slots: hidden until AdSense approval ------------------------------
   The loader in index.html is commented out, but .ad-slot still paints a
   dashed 90px box labelled "Advertisement". On a live domain that reads as a
   broken page to a visitor and as placeholder ad inventory to an AdSense
   reviewer, which is a known rejection reason. !important is deliberate: this
   is a temporary switch that must beat every rule above it, including the
   responsive overrides. Delete this block when the real publisher id goes in. */
.ad-slot { display: none !important; }
