/* ═══════════════════════════════════════════════════════════
   BIJULED · rfmss design system
   iPad mini 2012 / iOS 9.3.5 first — ES5, no Grid, no gap
═══════════════════════════════════════════════════════════ */
*, *:before, *:after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #b2c9c3;
  --surface:   #f4efe6;
  --text:      #1a1a1a;
  --muted:     #555;
  --accent:    #d97757;
  --found:     #5a8a6a;
  --border:    rgba(0,0,0,0.08);
  --radius:    12px;
  --cell-size: 60px;
  --cell-gap:  2px;
}

html, body {
  width: 100%;
  min-height: 100%;
  background: #b2c9c3;
  color: #1a1a1a;
  font-family: Georgia, 'Times New Roman', serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ── Screens ────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

/* ── Shared Header Bar ──────────────────────────────────── */
.screen-header-bar {
  background: rgba(244,239,230,0.92);
  padding: 14px 16px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
}
.screen-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a1a;
}
.header-spacer { width: 40px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost, .btn-back {
  font-family: 'Courier New', Courier, monospace;
  cursor: pointer;
  border-radius: 8px;
  -webkit-transition: all 0.15s;
  transition: all 0.15s;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,0.12);
}
.btn-primary {
  background: #d97757;
  color: #fff;
  border-color: #d97757;
  padding: 12px 28px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-height: 48px;
}
.btn-primary:active { background: #c86844; }
.btn-primary.btn-xl { padding: 16px 36px; font-size: 1rem; min-height: 56px; }
.btn-secondary {
  background: #f4efe6;
  color: #1a1a1a;
  padding: 10px 22px;
  font-size: 0.85rem;
  min-height: 44px;
}
.btn-secondary:active { background: rgba(244,239,230,0.7); }
.btn-ghost {
  background: transparent;
  color: #555;
  border-color: rgba(0,0,0,0.15);
  padding: 10px 22px;
  font-size: 0.85rem;
  min-height: 44px;
}
.btn-ghost:active { background: rgba(0,0,0,0.05); }
.btn-back {
  background: #f4efe6;
  border: 1px solid rgba(0,0,0,0.1);
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}
.btn-icon-wrap { margin-right: 8px; }
.btn-icon-wrap svg { display: block; }
.icon-emoji {
  display: block;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.icon-emoji-sm {
  font-size: 18px;
}
.logo-icon-emoji {
  display: inline-block;
  font-size: 72px;
  line-height: 1;
  text-shadow: 0 6px 18px rgba(0,0,0,0.18);
  -webkit-transform: translateY(1px);
  transform: translateY(1px);
}

/* ── MENU SCREEN ────────────────────────────────────────── */
#screen-menu {
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 40px 24px;
}
.menu-content {
  width: 100%;
  max-width: 420px;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
}
.logo-block {
  text-align: center;
  margin-bottom: 48px;
}
.logo-icon { margin-bottom: 16px; }
.logo-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 3rem;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -1px;
  margin-bottom: 6px;
}
.logo-sub {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #555;
}
.menu-buttons {
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
}
.menu-buttons > * + * { margin-top: 12px; }
.menu-buttons .btn-primary,
.menu-buttons .btn-secondary { width: 100%; max-width: 280px; }
.menu-footer {
  margin-top: 40px;
}
.version-tag {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(26,26,26,0.4);
}
.bg-gems-float { 
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.bg-gem-particle {
  position: absolute;
  opacity: 0.15;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-120vh) rotate(360deg); }
}
.menu-bg { display: none; }

/* ── LEVEL SELECT ───────────────────────────────────────── */
#screen-levels { background: #b2c9c3; }
.chapter-scroll {
  -webkit-flex: 1;
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}
.chapter-block { margin-bottom: 24px; }
.chapter-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #555;
  margin-bottom: 10px;
  padding-left: 4px;
}
.levels-row {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin: -5px;
}
.level-tile {
  margin: 5px;
  width: calc(20% - 10px);
  height: 60px;
  min-height: 60px;
  background: #f4efe6;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
  -webkit-transition: all 0.15s;
  transition: all 0.15s;
}
.level-tile:active { -webkit-transform: scale(0.95); transform: scale(0.95); }
.level-tile.locked { opacity: 0.4; pointer-events: none; }
.level-tile.done { background: rgba(90,138,106,0.12); border-color: #5a8a6a; }
.level-tile.current { border-color: #d97757; border-width: 2px; }
.level-num {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
}
.level-stars {
  display: -webkit-flex;
  display: flex;
  color: #d97757;
  margin-top: 2px;
}
.level-stars > * + * { margin-left: 1px; }

/* ── GAME SCREEN ────────────────────────────────────────── */
#screen-game { background: #1a1410; overflow: hidden; }
.game-wrapper {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* HUD */
.game-hud {
  background: rgba(244,239,230,0.92);
  padding: 10px 14px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}
.hud-btn-group {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}
.hud-btn-group > * + * { margin-left: 6px; }
.hud-btn {
  background: #f4efe6;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
}
.hud-stats {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}
.hud-stats > * + * { margin-left: 20px; }
.hud-stat { text-align: center; }
.hud-label {
  display: block;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #444;
}
.hud-value {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.1;
}
.hud-value.gold { color: #d97757; }
.hud-lives {
  display: -webkit-flex;
  display: flex;
}
.hud-lives > * + * { margin-left: 2px; }
.life-heart {
  font-size: 1.5rem;
  color: rgba(26,26,26,0.2);
}
.life-heart.active { color: #d97757; }

/* Objective */
.objective-strip {
  background: rgba(244,239,230,0.7);
  padding: 6px 14px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.objective-strip > * + * { margin-left: 10px; }
.obj-text {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  color: #555;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}
.obj-progress-wrap {
  -webkit-flex: 1;
  flex: 1;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}
.obj-progress-wrap > * + * { margin-left: 8px; }
.obj-progress-bar {
  -webkit-flex: 1;
  flex: 1;
  height: 6px;
  background: rgba(0,0,0,0.1);
  border-radius: 50px;
  overflow: hidden;
}
.obj-progress-fill {
  height: 100%;
  background: #d97757;
  border-radius: 50px;
  -webkit-transition: width 0.4s ease;
  transition: width 0.4s ease;
}
.obj-percent {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  color: #555;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

/* Board */
.board-container {
  -webkit-flex: 1;
  flex: 1;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}
.board-frame {
  position: relative;
  background: #0d0b08;
  border-radius: 12px;
  padding: 6px;
  border: 2px solid rgba(217,119,87,0.25);
  box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.4);
}
.game-board {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  width: calc(8 * var(--cell-size) + 8 * var(--cell-gap));
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#particle-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  border-radius: 12px;
}

/* Cells */
.gem-cell {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: var(--cell-size);
  height: var(--cell-size);
  margin: calc(var(--cell-gap) / 2);
  border-radius: 6px;
  cursor: pointer;
  -webkit-transition: -webkit-transform 0.12s, transform 0.12s;
  transition: transform 0.12s;
  position: relative;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.gem-emoji {
  display: block;
  width: calc(var(--cell-size) - 8px);
  height: calc(var(--cell-size) - 8px);
  object-fit: contain;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-transform: translateY(1px);
  transform: translateY(1px);
}
.gem-type-0 .gem-emoji {
  -webkit-transform: translateY(1px) rotate(0deg);
  transform: translateY(1px) rotate(0deg);
}
.gem-type-1 .gem-emoji {
  -webkit-transform: translateY(1px) rotate(10deg) scale(1.02);
  transform: translateY(1px) rotate(10deg) scale(1.02);
}
.gem-type-2 .gem-emoji {
  -webkit-transform: translateY(1px) rotate(-8deg) scale(1.04);
  transform: translateY(1px) rotate(-8deg) scale(1.04);
}
.gem-type-3 .gem-emoji {
  -webkit-transform: translateY(0px) rotate(4deg) scale(1.01);
  transform: translateY(0px) rotate(4deg) scale(1.01);
}
.gem-type-4 .gem-emoji {
  -webkit-transform: translateY(1px) rotate(-12deg) scale(1.03);
  transform: translateY(1px) rotate(-12deg) scale(1.03);
}
.gem-type-5 .gem-emoji {
  -webkit-transform: translateY(0px) rotate(0deg) scale(1.05);
  transform: translateY(0px) rotate(0deg) scale(1.05);
}
/* ── Gem state animations ───────────────────────────────── */
@-webkit-keyframes gemSelectPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(217,119,87,0.6), 0 0 0 1px rgba(217,119,87,0.4); }
  50%       { box-shadow: 0 0 26px rgba(217,119,87,1.0), 0 0 0 2px rgba(217,119,87,0.8); }
}
@keyframes gemSelectPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(217,119,87,0.6), 0 0 0 1px rgba(217,119,87,0.4); }
  50%       { box-shadow: 0 0 26px rgba(217,119,87,1.0), 0 0 0 2px rgba(217,119,87,0.8); }
}
@-webkit-keyframes gemPop {
  0%   { -webkit-transform: scale(1);   opacity: 1; }
  40%  { -webkit-transform: scale(1.35); opacity: 1; }
  100% { -webkit-transform: scale(0);   opacity: 0; }
}
@keyframes gemPop {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0);    opacity: 0; }
}
@-webkit-keyframes gemShake {
  0%, 100% { -webkit-transform: translateX(0); }
  20%       { -webkit-transform: translateX(-7px); }
  40%       { -webkit-transform: translateX(7px); }
  60%       { -webkit-transform: translateX(-4px); }
  80%       { -webkit-transform: translateX(4px); }
}
@keyframes gemShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
@-webkit-keyframes gemAppear {
  0%   { -webkit-transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { -webkit-transform: scale(1.2) rotate(4deg);  opacity: 1; }
  100% { -webkit-transform: scale(1) rotate(0);       opacity: 1; }
}
@keyframes gemAppear {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0);      opacity: 1; }
}
@-webkit-keyframes scoreFloat {
  0%   { -webkit-transform: translateX(-50%) translateY(0);    opacity: 1; }
  100% { -webkit-transform: translateX(-50%) translateY(-44px); opacity: 0; }
}
@keyframes scoreFloat {
  0%   { transform: translateX(-50%) translateY(0);    opacity: 1; }
  100% { transform: translateX(-50%) translateY(-44px); opacity: 0; }
}

.gem-cell.selected {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
  z-index: 10;
  background: rgba(217,119,87,0.22);
  border-color: #d97757;
  -webkit-animation: gemSelectPulse 0.9s ease-in-out infinite;
  animation: gemSelectPulse 0.9s ease-in-out infinite;
}
.gem-cell.matched .gem-emoji {
  -webkit-animation: gemPop 0.28s cubic-bezier(0.6,0,1,0.6) both;
  animation: gemPop 0.28s cubic-bezier(0.6,0,1,0.6) both;
}
.gem-cell.invalid-swap {
  -webkit-animation: gemShake 0.36s ease both;
  animation: gemShake 0.36s ease both;
}
.gem-cell.hint { border-color: rgba(217,119,87,0.5); }
.gem-cell.blocked { background: rgba(0,0,0,0.4) !important; border-color: transparent; cursor: default; }
.gem-cell.removing {
  -webkit-transform: scale(0);
  transform: scale(0);
  opacity: 0;
}
.gem-cell.falling {
  -webkit-transition: -webkit-transform 0.12s;
  transition: transform 0.12s;
}

/* ── Compliment display ─────────────────────────────────── */
@-webkit-keyframes complimentIn {
  0%   { -webkit-transform: translate(-50%,-50%) scale(0.4); transform: translate(-50%,-50%) scale(0.4); opacity: 0; }
  50%  { -webkit-transform: translate(-50%,-50%) scale(1.08); transform: translate(-50%,-50%) scale(1.08); opacity: 1; }
  100% { -webkit-transform: translate(-50%,-50%) scale(1);    transform: translate(-50%,-50%) scale(1);    opacity: 1; }
}
@keyframes complimentIn {
  0%   { transform: translate(-50%,-50%) scale(0.4); opacity: 0; }
  50%  { transform: translate(-50%,-50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1);    opacity: 1; }
}
@-webkit-keyframes complimentOut {
  0%   { -webkit-transform: translate(-50%,-50%) scale(1);    transform: translate(-50%,-50%) scale(1);    opacity: 1; }
  100% { -webkit-transform: translate(-50%,-50%) scale(1.18); transform: translate(-50%,-50%) scale(1.18); opacity: 0; }
}
@keyframes complimentOut {
  0%   { transform: translate(-50%,-50%) scale(1);    opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.18); opacity: 0; }
}
.compliment-display {
  position: absolute;
  top: 50%; left: 50%;
  -webkit-transform: translate(-50%,-50%) scale(1);
  transform: translate(-50%,-50%) scale(1);
  z-index: 150;
  pointer-events: none;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 18px rgba(0,0,0,0.7), 0 0 40px rgba(217,119,87,0.5);
  opacity: 0;
  letter-spacing: -0.01em;
}
.compliment-display.show {
  -webkit-animation: complimentIn 0.22s cubic-bezier(0.34,1.56,0.64,1) both;
  animation: complimentIn 0.22s cubic-bezier(0.34,1.56,0.64,1) both;
}
.compliment-display.hide {
  -webkit-animation: complimentOut 0.6s ease-out both;
  animation: complimentOut 0.6s ease-out both;
}
.compliment-display.tier-0 { font-size: 2.0rem; color: #f4d6a8; }
.compliment-display.tier-1 { font-size: 2.6rem; color: #f5c26b; }
.compliment-display.tier-2 { font-size: 3.2rem; color: #d97757; }

/* Score popup */
.score-popup {
  position: absolute;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: #f0d870;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  -webkit-animation: scoreFloat 0.95s cubic-bezier(0,0,0.2,1) both;
  animation: scoreFloat 0.95s cubic-bezier(0,0,0.2,1) both;
}

/* Drag ghost */
.gem-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 2000;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: var(--cell-size);
  height: var(--cell-size);
  -webkit-transform: translate(-50%, -50%) scale(1.22);
  transform: translate(-50%, -50%) scale(1.22);
  -webkit-filter: drop-shadow(0 10px 28px rgba(0,0,0,0.8));
  filter: drop-shadow(0 10px 28px rgba(0,0,0,0.8));
  opacity: 0.9;
}
.gem-ghost .gem-emoji {
  width: calc(var(--cell-size) - 4px);
  height: calc(var(--cell-size) - 4px);
}
.gem-cell.dragging {
  opacity: 0.28;
  -webkit-transform: scale(0.82) !important;
  transform: scale(0.82) !important;
  -webkit-transition: -webkit-transform 0.1s, opacity 0.1s !important;
  transition: transform 0.1s, opacity 0.1s !important;
}
.gem-cell.drag-over {
  background: rgba(217,119,87,0.3) !important;
  border-color: rgba(217,119,87,0.75) !important;
  -webkit-transform: scale(1.12) !important;
  transform: scale(1.12) !important;
  box-shadow: 0 0 16px rgba(217,119,87,0.55);
}

/* Gem types — warm rfmss palette */
.gem-0 { background: #d97757; }
.gem-1 { background: #7a9e8e; }
.gem-2 { background: #c4a882; }
.gem-3 { background: #8fa3b8; }
.gem-4 { background: #b89bbf; }
.gem-5 { background: #e8c17a; }
.gem-6 { background: #a8b87a; }

/* ── Fluent emoji special gems ──────────────────────────── */
/* Creature emoji + colored aura ring (--type-color shows
   which gem type it still matches with) */
.gem-special {
  position: relative;
  width: 100%;
  height: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}
.gem-special::before {
  content: '';
  position: absolute;
  inset: 3%;
  border-radius: 50%;
  border: 2px solid var(--type-color);
  box-shadow: 0 0 9px 1px var(--type-color), inset 0 0 7px var(--type-color);
  pointer-events: none;
  -webkit-animation: spAuraPulse 1.4s ease-in-out infinite;
  animation: spAuraPulse 1.4s ease-in-out infinite;
}
.gem-special .gem-emoji {
  width: calc(var(--cell-size) - 14px);
  height: calc(var(--cell-size) - 14px);
}
.gem-sp-rainbow::before {
  border: 2px solid transparent;
  background: conic-gradient(#ff5f5f, #ffb02e, #ffe14d, #63c159, #6d9ee8, #a55fd6, #ff5f5f) border-box;
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  box-shadow: none;
  -webkit-animation: spAuraSpin 2.4s linear infinite;
  animation: spAuraSpin 2.4s linear infinite;
}
.gem-sp-badge {
  position: absolute;
  bottom: -4%;
  right: -6%;
  font-size: calc(var(--cell-size) * 0.32);
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 4px var(--type-color), 0 1px 3px rgba(0,0,0,0.85);
  pointer-events: none;
}
@-webkit-keyframes spAuraPulse {
  0%, 100% { opacity: 0.55; -webkit-transform: scale(1); }
  50%       { opacity: 1;    -webkit-transform: scale(1.05); }
}
@keyframes spAuraPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%       { opacity: 1;    transform: scale(1.05); }
}
@-webkit-keyframes spAuraSpin {
  to { -webkit-transform: rotate(360deg); }
}
@keyframes spAuraSpin {
  to { transform: rotate(360deg); }
}

/* ── Boost Button Animations ────────────────────────────── */
@-webkit-keyframes hammerStrike {
  0%   { -webkit-transform: rotate(-20deg) translateY(0);   transform: rotate(-20deg) translateY(0); }
  40%  { -webkit-transform: rotate(10deg)  translateY(5px); transform: rotate(10deg)  translateY(5px); }
  60%  { -webkit-transform: rotate(-5deg)  translateY(2px); transform: rotate(-5deg)  translateY(2px); }
  100% { -webkit-transform: rotate(0)      translateY(0);   transform: rotate(0)      translateY(0); }
}
@keyframes hammerStrike {
  0%   { transform: rotate(-20deg) translateY(0); }
  40%  { transform: rotate(10deg)  translateY(5px); }
  60%  { transform: rotate(-5deg)  translateY(2px); }
  100% { transform: rotate(0)      translateY(0); }
}
@-webkit-keyframes shuffleSpin {
  0%   { -webkit-transform: rotate(0deg);   transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
@keyframes shuffleSpin {
  0%   { transform: rotate(0deg);   }
  100% { transform: rotate(360deg); }
}
@-webkit-keyframes bombPulse {
  0%,100% { -webkit-transform: scale(1);    transform: scale(1);    opacity: 1; }
  50%      { -webkit-transform: scale(1.18); transform: scale(1.18); opacity: 0.85; }
}
@keyframes bombPulse {
  0%,100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.18); opacity: 0.85; }
}
@-webkit-keyframes impactStarOut {
  0%   { -webkit-transform: scale(0) translate(0,0); transform: scale(0) translate(0,0); opacity: 1; }
  100% { opacity: 0; }
}
@keyframes impactStarOut {
  0%   { transform: scale(0) translate(0,0); opacity: 1; }
  100% { opacity: 0; }
}
@-webkit-keyframes explosionRing {
  0%   { -webkit-transform: scale(0.4); transform: scale(0.4); opacity: 0.9; }
  100% { -webkit-transform: scale(2.4); transform: scale(2.4); opacity: 0; }
}
@keyframes explosionRing {
  0%   { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0; }
}
@-webkit-keyframes boostActivePop {
  0%   { -webkit-transform: scale(1);    transform: scale(1); }
  35%  { -webkit-transform: scale(1.12); transform: scale(1.12); }
  100% { -webkit-transform: scale(1);    transform: scale(1); }
}
@keyframes boostActivePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Boosts */
.boosts-bar {
  background: rgba(30,22,14,0.96);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 10px 14px 12px;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  gap: 10px;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}
.boost-btn {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 10px 14px 8px;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  min-width: 76px;
  -webkit-transition: background 0.18s, border-color 0.18s, -webkit-transform 0.14s;
  transition: background 0.18s, border-color 0.18s, transform 0.14s;
  overflow: visible;
}
.boost-btn:active {
  -webkit-transform: scale(0.93);
  transform: scale(0.93);
}
.boost-btn.active-boost {
  background: rgba(217,119,87,0.18);
  border-color: #d97757;
  -webkit-animation: boostActivePop 0.28s ease both;
  animation: boostActivePop 0.28s ease both;
  -webkit-box-shadow: 0 0 18px rgba(217,119,87,0.35);
  box-shadow: 0 0 18px rgba(217,119,87,0.35);
}
.boost-btn.depleted { opacity: 0.35; pointer-events: none; }

.boost-icon-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-bottom: 4px;
}
.boost-icon {
  color: rgba(244,214,168,0.85);
  -webkit-transition: color 0.18s;
  transition: color 0.18s;
  position: relative;
  z-index: 1;
}
.boost-icon-emoji {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.22));
}
.boost-btn.active-boost .boost-icon { color: #d97757; }

/* Hammer strike animation */
.boost-btn.active-boost .boost-icon-hammer {
  -webkit-animation: hammerStrike 0.35s cubic-bezier(0.36,0.07,0.19,0.97) both;
  animation: hammerStrike 0.35s cubic-bezier(0.36,0.07,0.19,0.97) both;
}
/* Impact stars */
.boost-impact-stars { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.boost-impact-stars .star {
  position: absolute;
  font-size: 10px;
  color: #f5c26b;
  opacity: 0;
}
.boost-impact-stars .star.s1 { top: -6px; left: 2px; }
.boost-impact-stars .star.s2 { top: -2px; right: -4px; }
.boost-impact-stars .star.s3 { bottom: 0; left: -4px; }
.boost-btn.active-boost .star.s1 {
  -webkit-animation: impactStarOut 0.45s 0.1s ease-out both;
  animation: impactStarOut 0.45s 0.1s ease-out both;
  -webkit-transform: translate(-8px, -10px);
  transform: translate(-8px, -10px);
}
.boost-btn.active-boost .star.s2 {
  -webkit-animation: impactStarOut 0.45s 0.15s ease-out both;
  animation: impactStarOut 0.45s 0.15s ease-out both;
  -webkit-transform: translate(10px, -8px);
  transform: translate(10px, -8px);
}
.boost-btn.active-boost .star.s3 {
  -webkit-animation: impactStarOut 0.45s 0.05s ease-out both;
  animation: impactStarOut 0.45s 0.05s ease-out both;
  -webkit-transform: translate(-10px, 6px);
  transform: translate(-10px, 6px);
}

/* Shuffle spin animation */
.boost-btn:active .boost-icon-shuffle,
.boost-shuffle-btn:active .boost-icon-shuffle {
  -webkit-animation: shuffleSpin 0.4s cubic-bezier(0.4,0,0.2,1) both;
  animation: shuffleSpin 0.4s cubic-bezier(0.4,0,0.2,1) both;
}

/* Bomb pulse animation */
.boost-btn.active-boost .boost-icon-bomb {
  -webkit-animation: bombPulse 0.7s ease-in-out infinite;
  animation: bombPulse 0.7s ease-in-out infinite;
}
.boost-explosion-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 28px; height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid rgba(255,80,0,0.7);
  opacity: 0;
  pointer-events: none;
}
.boost-btn.active-boost .boost-explosion-ring {
  -webkit-animation: explosionRing 0.9s ease-out infinite;
  animation: explosionRing 0.9s ease-out infinite;
}

.boost-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(244,214,168,0.75);
}
.boost-hint {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.42rem;
  color: rgba(255,255,255,0.30);
  margin-top: 1px;
  white-space: nowrap;
}
.boost-count {
  position: absolute;
  top: 5px;
  right: 7px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #d97757;
  line-height: 1;
}

/* ── OVERLAYS ───────────────────────────────────────────── */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}
.overlay.hidden { display: none; }
.overlay-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55);
}
.overlay-card {
  position: relative;
  background: #f4efe6;
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  width: 90%;
  max-width: 360px;
  border: 1px solid rgba(0,0,0,0.08);
  -webkit-animation: popIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
  animation: popIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
@-webkit-keyframes popIn {
  from { -webkit-transform: scale(0.7); opacity: 0; }
  to   { -webkit-transform: scale(1);   opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.overlay-icon { margin-bottom: 12px; }
.overlay-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
}
.overlay-sub {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 20px;
}
.overlay-actions {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  margin-top: 20px;
}
.overlay-actions > * + * { margin-top: 10px; }
.overlay-actions .btn-primary,
.overlay-actions .btn-ghost { width: 100%; max-width: 240px; }

/* Stars */
.stars-row {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  margin-bottom: 12px;
}
.stars-row > * + * { margin-left: 8px; }
.star {
  font-size: 2rem;
  color: rgba(26,26,26,0.15);
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
}
.star.earned { color: #d97757; }

/* Score */
.complete-score {
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  padding: 10px 20px;
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  border: 1px solid rgba(0,0,0,0.06);
}
.complete-score-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
}
.complete-score-value {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #d97757;
}

/* Combo Popup */
.combo-popup {
  position: fixed;
  top: 40%;
  left: 50%;
  -webkit-transform: translateX(-50%) scale(0);
  transform: translateX(-50%) scale(0);
  background: #d97757;
  color: #fff;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 50px;
  pointer-events: none;
  z-index: 300;
  -webkit-transition: -webkit-transform 0.2s, transform 0.2s, opacity 0.2s;
  transition: transform 0.2s, opacity 0.2s;
}
.combo-popup.show {
  -webkit-transform: translateX(-50%) scale(1);
  transform: translateX(-50%) scale(1);
}
.combo-popup.hidden { display: none; }

/* ── Responsive ─────────────────────────────────────────── */
/* Large desktop: tela alta o suficiente */
@media screen and (min-width: 601px) and (min-height: 900px) {
  :root { --cell-size: 72px; --cell-gap: 3px; }
}
/* ≤ 600px phones */
@media screen and (max-width: 600px) {
  :root { --cell-size: 50px; --cell-gap: 2px; }
  .board-container { padding: 6px; }
}
/* ≤ 430px small phones */
@media screen and (max-width: 430px) {
  :root { --cell-size: 44px; --cell-gap: 2px; }
  .board-container { padding: 4px; }
}
/* ≤ 360px budget phones */
@media screen and (max-width: 360px) {
  :root { --cell-size: 36px; --cell-gap: 2px; }
  .board-container { padding: 2px; }
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }
