:root {
  --tile-size: 90px;
  --tile-gap: 12px;
  --board-pad: 12px;
}

* { box-sizing: border-box; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  margin: 0;
}

.app-bg {
  background:
    radial-gradient(ellipse at 12% -8%, rgba(20, 184, 166, 0.22), transparent 55%),
    radial-gradient(ellipse at 92% 110%, rgba(245, 158, 11, 0.18), transparent 55%),
    radial-gradient(ellipse at 50% 40%, rgba(16, 185, 129, 0.08), transparent 65%),
    linear-gradient(180deg, #050e10 0%, #07161b 50%, #040a0e 100%);
}

.glass-panel {
  background: rgba(18, 20, 36, 0.55);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px;
  box-shadow:
    0 20px 60px -20px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.glass-inner {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.glass-btn, .glass-btn-primary {
  padding: 0.55rem 0.95rem;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-family: inherit;
}
.glass-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}
.glass-btn:hover { background: rgba(255, 255, 255, 0.09); }
.glass-btn:active { transform: scale(0.97); }

.glass-btn-primary {
  background: linear-gradient(135deg, #14b8a6 0%, #10b981 50%, #f59e0b 100%);
  color: #06221d;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px -6px rgba(20, 184, 166, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.glass-btn-primary:hover { filter: brightness(1.08); }
.glass-btn-primary:active { transform: scale(0.97); }
.glass-btn-primary:disabled {
  opacity: 0.35;
  filter: grayscale(0.4);
  cursor: not-allowed;
}

/* ============ SCREENS ============ */
.screen { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ LANDING ============ */
.landing-wrap {
  text-align: center;
  animation: landingRise 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes landingRise {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 30px;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 6px 20px -4px rgba(139, 92, 246, 0.6);
}
.brand-logo svg { width: 18px; height: 18px; }
.brand-text { text-align: left; line-height: 1.1; }

.landing-hero { position: relative; }
.landing-title {
  font-size: clamp(3rem, 9vw, 6.5rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin: 0 0 24px;
  color: #f0fdfa;
  text-shadow: 0 4px 40px rgba(20, 184, 166, 0.35);
}
.landing-title-accent {
  background: linear-gradient(135deg, #5eead4 0%, #34d399 35%, #fbbf24 75%, #fb923c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 24px rgba(16, 185, 129, 0.4));
}

.landing-tagline {
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
  color: rgba(203, 213, 225, 0.85);
  max-width: 580px;
  margin: 0 auto 36px;
  line-height: 1.55;
}
.landing-tagline em { color: #99f6e4; font-style: normal; font-weight: 500; }

.landing-figures {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 14px;
  margin: 0 auto 40px;
  max-width: 480px;
  flex-wrap: wrap;
}
.lf-item {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(30,34,55,0.9), rgba(15,17,34,0.85));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7d2fe;
  animation: lfFloat 4s ease-in-out infinite;
}
.lf-item svg { width: 70%; height: 70%; }
.lf-item:nth-child(1) { animation-delay: 0s;   color: #5eead4; }
.lf-item:nth-child(2) { animation-delay: 0.3s; color: #2dd4bf; }
.lf-item:nth-child(3) { animation-delay: 0.6s; color: #34d399; }
.lf-item:nth-child(4) { animation-delay: 0.9s; color: #fbbf24; }
.lf-item:nth-child(5) { animation-delay: 1.2s; color: #fb923c; }
@keyframes lfFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.landing-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 36px;
}
.btn-hero {
  appearance: none;
  border: 0;
  padding: 18px 28px;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  min-width: 220px;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.2s ease;
}
.btn-hero:active { transform: scale(0.98); }
.btn-hero:hover { filter: brightness(1.06); }
.btn-hero-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: white;
}
.btn-hero-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.14);
}
.btn-hero-icon svg { width: 18px; height: 18px; color: white; }
.btn-hero-sub {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-top: 6px;
  padding-left: 46px;
  font-weight: 400;
}
.btn-hero-primary {
  background: linear-gradient(135deg, #14b8a6 0%, #10b981 50%, #f59e0b 100%);
  box-shadow: 0 14px 36px -10px rgba(20, 184, 166, 0.65), inset 0 1px 0 rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.14);
}
.btn-hero-ghost {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.landing-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: rgba(148, 163, 184, 0.85);
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.landing-meta strong { color: #e2e8f0; font-weight: 600; }
.landing-meta .sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(148,163,184,0.4);
}

/* ============ LEVEL SELECT ============ */
.level-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.ls-card {
  background: linear-gradient(145deg, rgba(30,34,55,0.7), rgba(15,17,34,0.5));
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
  padding: 22px 16px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.ls-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), transparent 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ls-card:hover {
  transform: translateY(-3px);
  border-color: rgba(20, 184, 166, 0.5);
  box-shadow: 0 16px 40px -14px rgba(20, 184, 166, 0.5);
}
.ls-card:hover::before { opacity: 1; }
.ls-card::before {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), transparent 55%);
}
.ls-card .ls-num {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #5eead4, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  position: relative;
}
.ls-card .ls-sig {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-top: 8px;
  font-weight: 500;
  position: relative;
}
.ls-card .ls-desc {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 4px;
  position: relative;
}
.ls-card .ls-best {
  margin-top: 8px;
  font-size: 0.68rem;
  color: #fde68a;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
}

.ls-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.ls-badge svg { width: 14px; height: 14px; }
.ls-badge.lock {
  background: rgba(148, 163, 184, 0.12);
  color: rgba(148, 163, 184, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.ls-badge.done {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #052e16;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}
.ls-badge.next-badge {
  width: auto;
  padding: 3px 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #14b8a6, #f59e0b);
  color: #052e1d;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.55);
}

.ls-card.locked {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.4);
}
.ls-card.locked::before { opacity: 0; }
.ls-card.locked .ls-num {
  background: linear-gradient(135deg, #64748b, #475569);
  -webkit-background-clip: text;
  background-clip: text;
}
.ls-card.locked:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow: none;
}

.ls-card.completed {
  border-color: rgba(52, 211, 153, 0.35);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.14), rgba(12, 42, 30, 0.55));
}
.ls-card.completed .ls-num {
  background: linear-gradient(135deg, #86efac, #34d399, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
}

.ls-card.next {
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.28), 0 14px 38px -12px rgba(20, 184, 166, 0.6);
  animation: nextLevelPulse 2.4s ease-in-out infinite;
}
@keyframes nextLevelPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.28), 0 14px 38px -12px rgba(20, 184, 166, 0.5); }
  50%      { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 18px 46px -10px rgba(245, 158, 11, 0.55); }
}

.level-select-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  font-size: 0.85rem;
  color: #cbd5e1;
}
.level-select-footer strong {
  color: #c7d2fe;
  font-weight: 600;
}

/* ============ TUTORIAL ============ */
.tut-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.tut-progress-wrap { flex: 1; }
.tut-progress {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}
.tut-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #14b8a6, #10b981, #fbbf24);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.3, 0.8, 0.4, 1);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.55);
}

.tut-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .tut-grid { grid-template-columns: 1fr auto; align-items: start; }
}

.tut-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #5eead4;
  background: rgba(20, 184, 166, 0.15);
  border: 1px solid rgba(20, 184, 166, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.tut-title {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.tut-text {
  color: rgba(203, 213, 225, 0.85);
  line-height: 1.55;
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.tut-figures-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 10px 0 18px;
}
.tut-fig {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tut-fig .tf-svg {
  width: 48px;
  height: 48px;
  color: #5eead4;
}
.tut-fig .tf-svg svg { width: 100%; height: 100%; }
.tut-fig .tf-name {
  font-size: 0.7rem;
  color: #cbd5e1;
  font-weight: 500;
  line-height: 1.2;
}

.tut-hint {
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.3);
  color: #fde68a;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  margin-bottom: 14px;
  animation: hintPulse 0.4s ease;
}
@keyframes hintPulse {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.tut-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #86efac;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  animation: successPop 0.35s cubic-bezier(0.3, 1.2, 0.4, 1);
}
.tut-success svg { width: 20px; height: 20px; }
@keyframes successPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.tut-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.tut-actions .glass-btn,
.tut-actions .glass-btn-primary {
  flex: 1;
}

/* ============ BOARD ============ */
.brand-logo-sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14b8a6 0%, #10b981 45%, #f59e0b 100%);
  box-shadow: 0 6px 18px -4px rgba(20, 184, 166, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.brand-logo-sm svg { width: 20px; height: 20px; }

.board {
  display: grid;
  grid-template-columns: repeat(4, var(--tile-size));
  grid-template-rows: repeat(4, var(--tile-size));
  gap: var(--tile-gap);
  padding: var(--board-pad);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(20, 184, 166, 0.12), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(245, 158, 11, 0.08), transparent 60%),
    rgba(0, 0, 0, 0.44);
  border-radius: 20px;
  position: relative;
  outline: none;
  touch-action: none;
  box-shadow:
    inset 0 2px 18px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.board-cell {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: 14px;
  padding: calc(var(--tile-size) * 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(145deg, #1e2237 0%, #0f1122 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.14s cubic-bezier(0.25, 0.8, 0.3, 1), box-shadow 0.2s ease;
  will-change: transform;
  overflow: hidden;
}
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 45%);
  pointer-events: none;
}
.tile svg {
  width: 100%;
  height: 100%;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  position: relative;
  z-index: 1;
}

.tile.fig-semicorxera { background: linear-gradient(155deg, #93c5fd 0%, #3b82f6 55%, #1d4ed8 100%); }
.tile.fig-corxera     { background: linear-gradient(155deg, #a5b4fc 0%, #6366f1 55%, #3730a3 100%); }
.tile.fig-corxera_dot { background: linear-gradient(155deg, #c4b5fd 0%, #7c3aed 55%, #5b21b6 100%); }
.tile.fig-negra       { background: linear-gradient(155deg, #d8b4fe 0%, #9333ea 55%, #6b21a8 100%); }
.tile.fig-negra_dot   { background: linear-gradient(155deg, #f0abfc 0%, #c026d3 55%, #86198f 100%); }
.tile.fig-blanca      { background: linear-gradient(155deg, #f9a8d4 0%, #db2777 55%, #9d174d 100%); }
.tile.fig-blanca_dot  { background: linear-gradient(155deg, #fda4af 0%, #e11d48 55%, #9f1239 100%); }
.tile.fig-blanca_ddot { background: linear-gradient(155deg, #fca5a5 0%, #dc2626 55%, #7f1d1d 100%); }

.tile.fig-rodona {
  background: linear-gradient(155deg, #fde68a 0%, #f59e0b 55%, #b45309 100%);
  border-color: rgba(253, 224, 71, 0.55);
  box-shadow:
    0 10px 32px rgba(245, 158, 11, 0.45),
    0 0 0 1px rgba(253, 224, 71, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 4px rgba(120, 53, 15, 0.35);
}
.tile.fig-rodona_dot {
  background: linear-gradient(155deg, #fef08a 0%, #eab308 55%, #854d0e 100%);
  border-color: rgba(253, 224, 71, 0.65);
  box-shadow:
    0 12px 36px rgba(234, 179, 8, 0.6),
    0 0 24px rgba(253, 224, 71, 0.3),
    0 0 0 1px rgba(253, 224, 71, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(113, 63, 18, 0.4);
  animation: rodonaGlow 2.4s ease-in-out infinite;
}

@keyframes rodonaGlow {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.08) saturate(1.1); }
}

.tile.highlight {
  box-shadow:
    0 0 0 3px rgba(250, 204, 21, 0.95),
    0 0 32px rgba(250, 204, 21, 0.55),
    0 8px 22px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: pulse 1.6s ease-in-out infinite;
  z-index: 2;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.85), 0 0 24px rgba(250, 204, 21, 0.4), 0 8px 22px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.2); }
  50%      { box-shadow: 0 0 0 3px rgba(250, 204, 21, 1), 0 0 38px rgba(250, 204, 21, 0.75), 0 8px 22px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.25); }
}

/* ============ SCORE CARDS ============ */
.score-card {
  position: relative;
  background: linear-gradient(145deg, rgba(40, 44, 72, 0.85), rgba(20, 22, 40, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px 16px 10px;
  text-align: center;
  min-width: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.score-card .score-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(148, 163, 184, 0.75);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 4px;
}
.score-card .score-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #f1f5f9;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s ease, color 0.2s ease;
}
.score-card .score-value-sub {
  color: rgba(148, 163, 184, 0.55);
  font-weight: 600;
}
.score-card.best {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.15), rgba(120, 53, 15, 0.15));
  border-color: rgba(251, 191, 36, 0.25);
}
.score-card.best .score-label { color: rgba(253, 224, 71, 0.85); }
.score-card.best .score-value { color: #fde68a; }

.score-card .score-value.score-pop {
  animation: scorePop 0.4s ease;
}
@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); color: #fde047; }
  100% { transform: scale(1); }
}
.score-card .score-delta {
  position: absolute;
  top: -4px;
  right: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde047;
  opacity: 0;
  pointer-events: none;
}
.score-card .score-delta.animate {
  animation: deltaRise 0.9s ease forwards;
}
@keyframes deltaRise {
  0%   { opacity: 0; transform: translateY(4px); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}

/* ============ POWERUP ============ */
.powerup-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  background: linear-gradient(145deg, rgba(40, 44, 72, 0.65), rgba(20, 22, 40, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: all 0.22s ease;
  color: #cbd5e1;
  position: relative;
}
.powerup-btn .powerup-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
  color: rgba(148, 163, 184, 0.85);
  transition: all 0.22s ease;
}
.powerup-btn .powerup-icon svg { width: 22px; height: 22px; }
.powerup-btn .powerup-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.powerup-btn .powerup-name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #e2e8f0;
}
.powerup-btn .eraser-hint {
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.75);
}
.powerup-btn .eraser-cost {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.12);
  color: #fde68a;
  border: 1px solid rgba(250, 204, 21, 0.25);
  white-space: nowrap;
}

.powerup-btn.ready {
  border-color: rgba(250, 204, 21, 0.35);
  background: linear-gradient(145deg, rgba(120, 53, 15, 0.35), rgba(60, 30, 10, 0.3));
  box-shadow: 0 6px 20px rgba(250, 204, 21, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.powerup-btn.ready .powerup-icon {
  color: #fde68a;
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.35);
}
.powerup-btn.ready:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(250, 204, 21, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.powerup-btn.disabled { cursor: not-allowed; opacity: 0.75; }
.powerup-btn.disabled .eraser-cost {
  background: rgba(148, 163, 184, 0.1);
  color: rgba(148, 163, 184, 0.75);
  border-color: rgba(148, 163, 184, 0.18);
}

.powerup-btn.active {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.35), rgba(185, 28, 28, 0.25));
  border-color: rgba(248, 113, 113, 0.6);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.5), 0 8px 24px rgba(239, 68, 68, 0.35);
  animation: eraserPulse 1.4s ease-in-out infinite;
}
.powerup-btn.active .powerup-icon {
  background: rgba(248, 113, 113, 0.25);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}
.powerup-btn.active .eraser-hint { color: #fca5a5; }
.powerup-btn.active .eraser-cost {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}
@keyframes eraserPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.45), 0 8px 24px rgba(239, 68, 68, 0.3); }
  50%      { box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.8), 0 10px 32px rgba(239, 68, 68, 0.55); }
}

.powerup-btn.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* Eraser target tile visuals */
body.eraser-active .board { cursor: crosshair; }
body.eraser-active .tile { cursor: crosshair; }
.tile.eraser-target {
  box-shadow:
    0 0 0 2px rgba(248, 113, 113, 0.5),
    0 8px 22px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.tile.eraser-target:hover {
  box-shadow:
    0 0 0 3px rgba(248, 113, 113, 1),
    0 0 32px rgba(239, 68, 68, 0.6),
    0 8px 22px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translate(var(--tx), var(--ty)) scale(1.03);
}

.tile.erasing { animation: erase 0.42s cubic-bezier(0.4, 0.1, 0.3, 1) forwards; pointer-events: none; }
@keyframes erase {
  0%   { opacity: 1; filter: brightness(1); }
  40%  { opacity: 1; filter: brightness(1.4) saturate(1.3); transform: scale(1.08) translate(var(--tx), var(--ty)); }
  100% { opacity: 0; filter: blur(10px) brightness(2); transform: scale(0.25) translate(var(--tx), var(--ty)); }
}

.tile.spawning { animation: spawn 0.22s cubic-bezier(0.3, 1.2, 0.4, 1) both; }
@keyframes spawn {
  from { transform: scale(0) translate(var(--tx), var(--ty)); opacity: 0; }
  to   { opacity: 1; }
}

.tile.merging { animation: merge 0.28s ease; }
@keyframes merge {
  0%   { filter: brightness(1); }
  35%  { filter: brightness(1.8); transform: scale(1.12) translate(var(--tx), var(--ty)); }
  100% { filter: brightness(1); }
}

.tile.depositing { animation: deposit 0.4s cubic-bezier(0.4, 0.1, 0.3, 1) forwards; pointer-events: none; }
@keyframes deposit {
  from { opacity: 1; filter: brightness(1); }
  to   { opacity: 0; filter: brightness(1.8); transform: scale(0.2) translate(var(--tx), var(--ty)); }
}

/* ============ MEASURES ============ */
.measure-card {
  background: rgba(255, 255, 255, 0.035);
  border-radius: 14px;
  padding: 10px 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  min-height: 104px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}
.measure-card.active {
  border-color: rgba(250, 204, 21, 0.55);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.25), 0 0 22px -4px rgba(250, 204, 21, 0.3);
  background: rgba(250, 204, 21, 0.06);
}
.measure-card.complete {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18) 0%, rgba(16, 185, 129, 0.08) 100%);
  border-color: rgba(52, 211, 153, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.measure-card .mc-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(203, 213, 225, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.measure-card.complete .mc-title { color: rgba(134, 239, 172, 0.8); }
.measure-card.active .mc-title   { color: rgba(253, 224, 71, 0.85); }

.measure-figs {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.measure-figs .plus {
  color: rgba(148, 163, 184, 0.5);
  font-size: 14px;
  line-height: 1;
}

.figure-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.figure-badge svg { width: 100%; height: 100%; color: #e8ecff; }
.figure-badge.deposited {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
}
.figure-badge.deposited svg { color: #86efac; }
.figure-badge.required-next {
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.5);
}
.figure-badge.required-next svg { color: #fde68a; }

#current-target .figure-badge { width: 56px; height: 56px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  :root { --tile-size: 72px; --tile-gap: 10px; --board-pad: 10px; }
  .figure-badge { width: 38px; height: 38px; }
  .measure-card { min-height: 90px; }
  .btn-hero { min-width: 100%; }
  .tut-figures-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 380px) {
  :root { --tile-size: 64px; --tile-gap: 8px; --board-pad: 8px; }
}
