@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/DMSans.woff2') format('woff2');
}

:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --border: #e5e5e5;
  --text: #1a1a1b;
  --text-secondary: #787c7e;
  --accent: #6aaa64;
  --accent-hover: #5a9a54;
  --correct: #6aaa64;
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-repeat: repeat;
  background-size: auto;
  background-position: top left;
  background-color: var(--bg);
}

.app-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  overflow: hidden;
  min-height: 0;
}

/* ===== SCREENS ===== */
.screen {
  width: min(360px, 100%);
  max-height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  overflow: hidden;
}

.screen.game-screen {
  width: min(600px, 100%);
  max-height: 100%;
}

.screen.is-active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== LOADING SCREEN ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
}

.loading-logo {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: loadingPulse 2s ease-in-out infinite;
}

.loading-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes loadingPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== MAIN MENU ===== */
#mainMenu {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.main-menu-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(106, 170, 100, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(201, 162, 39, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(106, 170, 100, 0.05) 0%, transparent 70%),
    linear-gradient(135deg, #fafbfc 0%, #f0f2f5 50%, #e8ecf0 100%);
  z-index: -1;
}

/* ===== NEW MAIN MENU SCREEN ===== */
.main-menu-screen {
  width: 100% !important;
  max-width: 100% !important;
  height: 100%;
  display: none; /* Hidden by default like other screens */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px !important;
  background: linear-gradient(180deg,
    rgba(147, 112, 219, 0.15) 0%,
    rgba(138, 99, 210, 0.2) 50%,
    rgba(128, 90, 200, 0.25) 100%);
}

.main-menu-screen.is-active {
  display: flex;
}

/* Main Menu Container - Fixed size like game view */
.main-menu-container {
  display: flex;
  flex-direction: column;
  /* Height-based sizing similar to game board */
  height: min(calc(100dvh - 24px), 700px);
  width: auto;
  max-width: 90vw;
  aspect-ratio: 9 / 16;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(248, 245, 255, 0.98) 100%);
  border-radius: 20px;
  box-shadow:
    0 8px 0 rgba(128, 90, 200, 0.2),
    0 12px 40px rgba(128, 90, 200, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
  flex-shrink: 1;
}

/* Main Header */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8f5ff 100%);
  width: 100%;
  border-radius: 20px 20px 0 0;
  box-shadow:
    0 2px 8px rgba(128, 90, 200, 0.1),
    inset 0 -1px 0 rgba(128, 90, 200, 0.1);
}

.main-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.main-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.main-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-coins {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 6px;
  background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
  border-radius: 20px;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.header-coins-icon {
  width: 16px;
  height: 16px;
}

.header-coins-amount {
  font-size: 0.8rem;
  font-weight: 700;
  color: #b8860b;
}

.lang-switcher-compact {
  padding: 5px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border: none;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow:
    0 2px 0 #d0d0d0,
    0 3px 6px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.15s ease;
}

.lang-switcher-compact:hover {
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 #d0d0d0,
    0 4px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.lang-switcher-compact:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 #d0d0d0,
    0 1px 3px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow:
    0 2px 0 #d0d0d0,
    0 3px 6px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.15s ease;
}

.header-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 #d0d0d0,
    0 4px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.header-icon-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 #d0d0d0,
    0 1px 3px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Collection Header */
.collection-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(138, 99, 210, 0.15) 0%, rgba(138, 99, 210, 0.08) 100%);
  border-bottom: 1px solid rgba(138, 99, 210, 0.2);
}

.collection-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#activeCollectionName {
  font-size: 0.85rem;
  font-weight: 700;
  color: #5a3d8a;
  letter-spacing: 0.05em;
}

.collection-progress-text {
  font-size: 0.7rem;
  color: #8a63d2;
  font-weight: 600;
}

/* Level Grid Container */
.level-grid-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
  min-height: 0;
  margin: 0;
  background: linear-gradient(180deg,
    rgba(248, 245, 255, 0.5) 0%,
    rgba(240, 235, 255, 0.6) 100%);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 3px;
  width: 100%;
  max-width: 100%;
  height: 100%;
  aspect-ratio: 1;
}

/* Level Tile */
.level-tile {
  position: relative;
  border-radius: 8px;
  cursor: pointer;
  perspective: 600px;
  transition: transform 0.2s ease;
}

.level-tile:hover {
  transform: scale(1.03);
}

.level-tile:active {
  transform: scale(0.98);
}

.level-tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-tile.is-revealed .level-tile-inner {
  transform: rotateY(180deg);
}

/* Animated flip for newly completed levels */
.level-tile.animate-flip {
  animation: tileFlipPop 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-tile.animate-flip .level-tile-inner {
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tileFlipPop {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.15);
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Card Back (Locked) */
.level-tile-back {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  backface-visibility: hidden;
  background: linear-gradient(145deg, #4a90b8 0%, #2d6a8a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 8px rgba(45, 106, 138, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

/* Ornamental pattern on card back */
.level-tile-back::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 4px,
      rgba(255, 255, 255, 0.03) 4px,
      rgba(255, 255, 255, 0.03) 8px
    );
}

.level-tile-back::after {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
}

/* Lock icon - hidden */
.level-tile-lock {
  display: none;
}

/* Hide lock on revealed tiles */
.level-tile.is-revealed .level-tile-lock {
  display: none;
}

/* Card Front (Revealed - Image Fragment) */
.level-tile-front {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  backface-visibility: hidden;
  transform: rotateY(180deg);
  background-size: 500% 500%;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

/* Subtle shine on revealed tiles */
.level-tile-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.05) 100%
  );
  pointer-events: none;
}

/* Current level indicator */
.level-tile.is-current .level-tile-back {
  background: linear-gradient(145deg, #6aaa64 0%, #4a8a44 100%);
  box-shadow:
    0 2px 12px rgba(106, 170, 100, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: currentLevelPulse 2s ease-in-out infinite;
}

@keyframes currentLevelPulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(106, 170, 100, 0.5); }
  50% { box-shadow: 0 4px 20px rgba(106, 170, 100, 0.7); }
}

.level-tile.is-current .level-tile-lock {
  opacity: 0;
}

.level-tile.is-current .level-tile-back::after {
  content: '';
  display: none;
}

/* Play Button */
.play-button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 16px 12px;
  position: relative;
  z-index: 10;
  background: transparent;
}

.play-button-main {
  padding: 18px 64px;
  background: linear-gradient(180deg, #7dbd76 0%, #6aaa64 50%, #5a9a54 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow:
    0 8px 0 #3d7a3a,
    0 10px 20px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
  position: relative;
}

.play-button-main:hover {
  transform: translateY(-3px);
  box-shadow:
    0 11px 0 #3d7a3a,
    0 15px 25px rgba(0, 0, 0, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

.play-button-main:active {
  transform: translateY(5px);
  box-shadow:
    0 3px 0 #3d7a3a,
    0 4px 10px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

/* No Ads Button */
.vip-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  position: absolute;
  right: 16px;
}

.vip-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.vip-button:hover .vip-icon {
  transform: scale(1.1);
}

.vip-button:active {
  transform: scale(0.95);
}

/* Bottom Navigation */
.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 12px 14px;
  background: linear-gradient(180deg, #f8f5ff 0%, #efe8ff 100%);
  gap: 6px;
  width: 100%;
  border-radius: 0 0 20px 20px;
  box-shadow:
    inset 0 1px 0 rgba(128, 90, 200, 0.1);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.nav-item:hover .nav-icon {
  transform: scale(1.1);
}

.nav-item:hover .nav-label {
  color: #8a63d2;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-icon {
  font-size: 1.3rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.nav-icon-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.nav-item:hover .nav-icon-img {
  transform: scale(1.1);
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.nav-item-primary {
  background: linear-gradient(135deg, #6aaa64 0%, #5a9a54 100%);
  padding: 8px 20px;
  box-shadow: 0 2px 10px rgba(106, 170, 100, 0.4);
}

.nav-item-primary .nav-icon {
  filter: grayscale(1) brightness(10);
}

.nav-item-primary .nav-label {
  color: white;
}

.nav-item-primary:hover {
  background: linear-gradient(135deg, #5a9a54 0%, #4a8a44 100%);
  box-shadow: 0 4px 15px rgba(106, 170, 100, 0.5);
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ff6b6b;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item-primary .nav-badge {
  background: white;
  color: #6aaa64;
}

.nav-quest-badge {
  position: absolute;
  top: 0;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: linear-gradient(180deg, #ff6b6b 0%, #ee5a5a 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(238, 90, 90, 0.5);
  animation: questBadgePulse 2s ease-in-out infinite;
}

.nav-quest-badge.is-visible {
  display: flex;
}

@keyframes questBadgePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Main Menu Responsive */
@media (max-width: 360px) {
  .main-header {
    padding: 8px 12px;
  }

  .main-logo {
    width: 28px;
    height: 28px;
  }

  .main-title {
    font-size: 0.95rem;
  }

  .level-grid {
    gap: 2px;
  }

  .level-tile {
    border-radius: 6px;
  }

  .play-button-main {
    padding: 14px 48px;
    font-size: 1.1rem;
  }

  .nav-icon-img {
    width: 32px;
    height: 32px;
  }

  .nav-item {
    padding: 6px 10px;
  }

  .nav-icon {
    font-size: 1.1rem;
  }

  .nav-label {
    font-size: 0.6rem;
  }
}

@media (max-height: 600px) {
  .level-grid {
    gap: 2px;
  }

  .main-header {
    padding: 6px 12px;
  }

  .level-grid-container {
    padding: 8px;
  }

  .play-button-container {
    padding: 4px 12px;
  }

  .play-button-main {
    padding: 10px 32px;
    font-size: 0.95rem;
  }

  .vip-button,
  .vip-icon {
    width: 44px;
    height: 44px;
  }

  .main-nav {
    padding: 6px 8px 8px;
  }

  .nav-item {
    padding: 6px 8px;
  }

  .nav-icon-img {
    width: 28px;
    height: 28px;
  }

  .nav-icon {
    font-size: 1.1rem;
  }

  .nav-label {
    font-size: 0.55rem;
  }
}

/* Short screens (under 500px height) - scale down UI elements */
@media (max-height: 500px) {
  .main-menu-container {
    height: calc(100dvh - 16px);
  }

  .main-header {
    padding: 6px 10px;
  }

  .main-logo {
    width: 28px;
    height: 28px;
  }

  .main-title {
    font-size: 0.9rem;
  }

  .level-grid-container {
    padding: 4px;
  }

  .play-button-container {
    padding: 2px 8px 4px;
  }

  .play-button-main {
    padding: 8px 24px;
    font-size: 0.8rem;
  }

  .vip-button,
  .vip-icon {
    width: 36px;
    height: 36px;
  }

  .main-nav {
    padding: 4px 6px 6px;
  }

  .nav-icon-img {
    width: 24px;
    height: 24px;
  }

  .nav-label {
    font-size: 0.5rem;
  }
}

/* Very short screens (under 400px height) */
@media (max-height: 400px) {
  .main-menu-container {
    height: calc(100dvh - 12px);
  }

  .main-header {
    padding: 4px 8px;
  }

  .main-logo {
    width: 24px;
    height: 24px;
  }

  .main-title {
    font-size: 0.8rem;
  }

  .header-coins-icon {
    width: 14px;
    height: 14px;
  }

  .header-coins-amount {
    font-size: 0.7rem;
  }

  .lang-switcher-compact,
  .header-icon-btn {
    padding: 4px 6px;
    font-size: 0.65rem;
  }

  .level-grid-container {
    padding: 2px;
  }

  .play-button-container {
    padding: 2px 6px 3px;
  }

  .play-button-main {
    padding: 6px 20px;
    font-size: 0.7rem;
  }

  .vip-button,
  .vip-icon {
    width: 28px;
    height: 28px;
  }

  .main-nav {
    padding: 3px 4px 4px;
  }

  .nav-icon-img {
    width: 20px;
    height: 20px;
  }

  .nav-label {
    font-size: 0.45rem;
  }
}

.menu-card {
  width: 100%;
  padding: 24px 20px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  max-width: 400px;
}

.menu-card.main-menu-card {
  padding: 24px 20px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.04);
  max-width: 380px;
  max-height: calc(100dvh - 40px);
  margin: 0 auto;
  overflow-y: auto;
  position: relative;
}

/* Language Switcher */
.lang-switcher {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  text-transform: uppercase;
}

.lang-switcher:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.lang-switcher:active {
  transform: scale(0.95);
}

.menu-logo-img {
  width: 70px;
  height: 70px;
  margin: 0 auto 12px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  display: block;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.menu-copy {
  margin: 0 0 16px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-size: 0.85rem;
}

.menu-actions {
  display: grid;
  gap: 10px;
  width: 100%;
}

/* ===== BUTTONS ===== */
button {
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: linear-gradient(180deg, #7dbd76 0%, #6aaa64 50%, #5a9a54 100%);
  color: white;
  box-shadow:
    0 4px 0 #3d7a3a,
    0 5px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.primary:hover {
  background: linear-gradient(180deg, #8dcd86 0%, #7aba74 50%, #6aaa64 100%);
  box-shadow:
    0 5px 0 #3d7a3a,
    0 7px 14px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.primary:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #3d7a3a,
    0 2px 4px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.secondary:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ghost {
  background: transparent;
  color: var(--text-secondary);
}

.ghost:hover {
  color: var(--text);
}

/* Daily Puzzle Button */
.daily-button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.daily-button:hover {
  background: #efefef;
}

.daily-icon {
  font-size: 18px;
}

.daily-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.daily-text strong {
  font-size: 0.85rem;
}

.daily-text small {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.daily-button.is-completed {
  opacity: 0.6;
}

.daily-button.is-completed .daily-text small {
  color: var(--accent);
}

/* Level Button */
.level-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.level-button-text {
  font-weight: 600;
}

.level-badge {
  background: rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.back-button {
  position: fixed;
  top: 12px;
  left: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 16px;
  font-size: 0.9rem;
  z-index: 101;
}

.back-button:hover {
  color: var(--text);
  background: #efefef;
}

/* ===== FORM CONTROLS ===== */
.control {
  text-align: left;
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

input[type="file"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input[type="file"]:focus,
select:focus {
  outline: none;
  border-color: var(--text);
}

select {
  cursor: pointer;
}

/* ===== GAME SCREEN ===== */
.game-screen {
  gap: 8px;
  position: relative;
  justify-content: center;
}

.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.game-header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.game-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}

.game-stat .stat-label {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: lowercase;
}

.game-coins {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px 4px 6px;
}

.game-coins-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.game-coins-amount {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text);
}

.game-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 0;
  box-shadow:
    0 2px 0 #d0d0d0,
    0 3px 6px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e8e8e8 100%);
  transform: translateY(-1px);
  box-shadow:
    0 4px 0 #d0d0d0,
    0 5px 10px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.icon-button:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #d0d0d0,
    0 2px 4px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.game-back-btn {
  font-size: 1rem;
}

/* ===== GAME BOARD ===== */
.board-shell {
  position: relative;
  /* Height-based sizing: derive width from height via aspect-ratio */
  /* Images are 512x768 = 2:3 ratio */
  height: min(calc(100dvh - 70px), 780px);
  width: auto;
  max-width: 90vw;
  aspect-ratio: 2 / 3;
  background: #c9a227;
  border-radius: var(--radius-lg);
  border: 3px solid #a68419;
  overflow: hidden;
  --board-padding: 10px;
  flex-shrink: 1;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.board {
  position: absolute;
  inset: var(--board-padding);
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 4), 1fr);
  grid-template-rows: repeat(var(--grid-size, 4), 1fr);
  gap: 0;
  /* Performance: contain layout changes to board */
  contain: layout style;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.group-outline {
  position: absolute;
  border: 2px solid var(--text);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 3;
}

.group-outline.is-visible {
  opacity: 1;
}

.ghost-container {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 4), 1fr);
  grid-template-rows: repeat(var(--grid-size, 4), 1fr);
  gap: 0;
  pointer-events: none;
  z-index: 1;
}

.ghost-preview {
  border-radius: 8px;
  background-repeat: no-repeat;
  opacity: 0.35;
  border: 2px dashed var(--text-secondary);
  box-sizing: border-box;
}

/* ===== WIN OVERLAY ===== */
.win-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.win-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
  animation: winFlash 0.6s ease-out;
}

@keyframes winFlash {
  0% { background: rgba(255, 215, 0, 0.4); }
  100% { background: transparent; }
}

.win-top {
  width: 100%;
  padding: 16px 16px 20px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 70%, transparent 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transform: translateY(-10px);
  opacity: 0;
  transition: all 0.3s ease 0.1s;
}

.win-overlay.is-visible .win-top {
  transform: translateY(0);
  opacity: 1;
}

.win-label {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 25%, #FF6B4A 50%, #FFD700 75%, #FFA500 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.02em;
  text-shadow: none;
  filter: drop-shadow(0 2px 4px rgba(255, 165, 0, 0.3));
  animation: winLabelShine 2s ease-in-out infinite, winLabelBounce 0.6s ease-out;
}

@keyframes winLabelShine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes winLabelBounce {
  0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(3deg); }
  70% { transform: scale(0.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.win-bottom {
  width: 100%;
  padding: 20px 16px 16px;
  background: linear-gradient(0deg, var(--bg) 0%, var(--bg) 70%, transparent 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.3s ease 0.15s;
}

.win-overlay.is-visible .win-bottom {
  transform: translateY(0);
  opacity: 1;
}

/* Fun NEXT Button */
.win-next-btn {
  width: 100%;
  padding: 16px 32px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #7dbd76 0%, #6aaa64 50%, #5a9a54 100%);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 6px 0 #3d7a3a,
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transform-origin: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.win-overlay.is-visible .win-next-btn {
  animation: nextButtonEntrance 0.5s ease-out 0.2s both;
}

@keyframes nextButtonEntrance {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes nextButtonPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 6px 0 #3d7a3a,
      0 8px 20px rgba(0, 0, 0, 0.3),
      0 0 0 0 rgba(106, 170, 100, 0.4),
      inset 0 2px 0 rgba(255, 255, 255, 0.3);
  }
  50% {
    transform: scale(1.03);
    box-shadow:
      0 6px 0 #3d7a3a,
      0 8px 20px rgba(0, 0, 0, 0.3),
      0 0 0 12px rgba(106, 170, 100, 0),
      inset 0 2px 0 rgba(255, 255, 255, 0.3);
  }
}

.win-next-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -100%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transform: skewX(-20deg);
  animation: nextButtonShine 2s ease-in-out infinite;
}

@keyframes nextButtonShine {
  0%, 100% { left: -100%; }
  50%, 60% { left: 150%; }
}

.win-next-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow:
    0 8px 0 #3d7a3a,
    0 12px 30px rgba(0, 0, 0, 0.35),
    0 0 20px rgba(106, 170, 100, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.win-next-btn:active {
  transform: scale(0.98) translateY(4px);
  box-shadow:
    0 2px 0 #3d7a3a,
    0 4px 10px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

/* Sparkle decoration around NEXT button */
.win-next-btn::after {
  content: '✨';
  position: absolute;
  font-size: 1.2rem;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  animation: sparkleRotate 1s ease-in-out infinite;
}

@keyframes sparkleRotate {
  0%, 100% { transform: translateY(-50%) scale(1) rotate(0deg); }
  50% { transform: translateY(-50%) scale(1.3) rotate(15deg); }
}

.win-home-btn {
  width: 100%;
  padding: 10px 24px;
  font-size: 0.85rem;
  background: rgba(128, 90, 200, 0.1);
  color: #805ac8;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.win-home-btn:hover {
  background: rgba(128, 90, 200, 0.2);
  color: #6a4aa8;
  transform: scale(1.02);
}

/* ===== GAME FOOTER (Hidden - consolidated into header) ===== */
.game-footer {
  display: none;
}

.game-meta {
  display: none;
}

/* Compact hint button */
.hint-button-compact {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  background: linear-gradient(180deg, #b044c4 0%, #9C27B0 50%, #7B1FA2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    0 3px 0 #5c1478,
    0 4px 8px rgba(156, 39, 176, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.hint-button-compact:hover {
  transform: translateY(-1px);
  box-shadow:
    0 5px 0 #5c1478,
    0 7px 14px rgba(156, 39, 176, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hint-button-compact:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #5c1478,
    0 2px 4px rgba(156, 39, 176, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.hint-button-compact .hint-icon {
  font-size: 0.9rem;
}

.hint-button-compact .hint-video-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: none;
}

.hint-count-compact {
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

.hint-button-compact.is-empty {
  background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
  box-shadow: 0 2px 8px rgba(255, 87, 34, 0.35);
}

.hint-button-compact.is-empty .hint-icon {
  display: none;
}

.hint-button-compact.is-empty .hint-video-icon {
  display: inline-block;
}

.hint-button-compact.is-empty .hint-count-compact {
  display: none;
}

.status {
  display: none; /* Hide status text for compact layout */
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 16px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ===== PUZZLE PIECES ===== */
.piece {
  --drag-x: 0px;
  --drag-y: 0px;
  --drag-scale: 1;
  --border-size: 2px;
  --radius: 8px;
  --border-color: rgba(255, 255, 255, 0.9);
  /* Border visibility flags */
  --bt: var(--border-size);  /* top */
  --br: var(--border-size);  /* right */
  --bb: var(--border-size);  /* bottom */
  --bl: var(--border-size);  /* left */
  /* Radius flags */
  --rtl: var(--radius);  /* top-left */
  --rtr: var(--radius);  /* top-right */
  --rbr: var(--radius);  /* bottom-right */
  --rbl: var(--radius);  /* bottom-left */

  position: relative;
  border-radius: var(--rtl) var(--rtr) var(--rbr) var(--rbl);
  background-repeat: no-repeat;
  cursor: grab;
  animation: pieceReveal 0.2s ease both;
  transform: translate(var(--drag-x), var(--drag-y)) scale(var(--drag-scale));
  touch-action: none;
  transition: transform 0.25s ease, border-radius 0.15s ease;
  overflow: hidden;

  /* Performance optimizations */
  will-change: transform;
  contain: layout style paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Visual border overlay - creates gaps between pieces */
.piece::before {
  content: "";
  position: absolute;
  inset: 0;
  border-style: solid;
  border-color: var(--border-color);
  border-width: var(--bt) var(--br) var(--bb) var(--bl);
  border-radius: var(--rtl) var(--rtr) var(--rbr) var(--rbl);
  pointer-events: none;
  z-index: 1;
}

.piece.dragging {
  opacity: 0.95;
  cursor: grabbing;
  pointer-events: none;
  --drag-scale: 1.05;
  z-index: 100;
  transition: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  /* Enhanced GPU acceleration for smooth dragging */
  will-change: transform, opacity;
  transform: translate3d(var(--drag-x), var(--drag-y), 0) scale(var(--drag-scale));
}

.piece.no-transition {
  transition: none;
}

/* Connected pieces - hide border and straighten corners on connected sides */
.piece.join-right {
  --br: 0px;
  --rtr: 0px;
  --rbr: 0px;
}

.piece.join-left {
  --bl: 0px;
  --rtl: 0px;
  --rbl: 0px;
}

.piece.join-top {
  --bt: 0px;
  --rtl: 0px;
  --rtr: 0px;
}

.piece.join-bottom {
  --bb: 0px;
  --rbl: 0px;
  --rbr: 0px;
}

/* Solved state - all corners become straight with animation */
.board.is-solved .piece {
  --rtl: 0px !important;
  --rtr: 0px !important;
  --rbr: 0px !important;
  --rbl: 0px !important;
  --bt: 0px !important;
  --br: 0px !important;
  --bb: 0px !important;
  --bl: 0px !important;
  animation: solvedPulse 0.8s ease-out forwards;
}

/* Shine overlay effect on pieces when solved */
.board.is-solved .piece::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.5) 50%,
    rgba(255, 255, 255, 0) 60%,
    transparent 80%
  );
  transform: translateX(-150%);
  animation: shineEffect 1.2s ease-out 0.3s forwards;
  pointer-events: none;
}

@keyframes shineEffect {
  0% {
    transform: translateX(-150%);
  }
  100% {
    transform: translateX(150%);
  }
}

/* Board shell glow effect when solved */
.board-shell:has(.board.is-solved) {
  animation: boardGlow 1.5s ease-out forwards;
}

@keyframes boardGlow {
  0% {
    box-shadow:
      0 4px 15px rgba(0, 0, 0, 0.2),
      0 0 0 rgba(255, 215, 0, 0);
  }
  30% {
    box-shadow:
      0 4px 15px rgba(0, 0, 0, 0.2),
      0 0 40px rgba(255, 215, 0, 0.6),
      0 0 80px rgba(255, 215, 0, 0.3),
      inset 0 0 30px rgba(255, 255, 255, 0.1);
  }
  100% {
    box-shadow:
      0 4px 15px rgba(0, 0, 0, 0.2),
      0 0 20px rgba(255, 215, 0, 0.3),
      0 0 40px rgba(255, 215, 0, 0.15);
  }
}

@keyframes solvedPulse {
  0% {
    transform: translate(var(--drag-x), var(--drag-y)) scale(1);
    filter: brightness(1) saturate(1);
  }
  20% {
    transform: translate(var(--drag-x), var(--drag-y)) scale(1.03);
    filter: brightness(1.2) saturate(1.1);
  }
  40% {
    transform: translate(var(--drag-x), var(--drag-y)) scale(0.98);
    filter: brightness(1.1) saturate(1.05);
  }
  60% {
    transform: translate(var(--drag-x), var(--drag-y)) scale(1.01);
    filter: brightness(1.05) saturate(1);
  }
  100% {
    transform: translate(var(--drag-x), var(--drag-y)) scale(1);
    filter: brightness(1) saturate(1);
  }
}

/* Stagger the animation for each piece */
.board.is-solved .piece:nth-child(1) { animation-delay: 0ms; }
.board.is-solved .piece:nth-child(2) { animation-delay: 25ms; }
.board.is-solved .piece:nth-child(3) { animation-delay: 50ms; }
.board.is-solved .piece:nth-child(4) { animation-delay: 75ms; }
.board.is-solved .piece:nth-child(5) { animation-delay: 100ms; }
.board.is-solved .piece:nth-child(6) { animation-delay: 125ms; }
.board.is-solved .piece:nth-child(7) { animation-delay: 150ms; }
.board.is-solved .piece:nth-child(8) { animation-delay: 175ms; }
.board.is-solved .piece:nth-child(9) { animation-delay: 200ms; }
.board.is-solved .piece:nth-child(n+10) { animation-delay: 225ms; }

/* Stagger shine effect per piece row for wave effect */
.board.is-solved .piece:nth-child(1)::after,
.board.is-solved .piece:nth-child(2)::after,
.board.is-solved .piece:nth-child(3)::after,
.board.is-solved .piece:nth-child(4)::after { animation-delay: 0.3s; }
.board.is-solved .piece:nth-child(5)::after,
.board.is-solved .piece:nth-child(6)::after,
.board.is-solved .piece:nth-child(7)::after,
.board.is-solved .piece:nth-child(8)::after { animation-delay: 0.35s; }
.board.is-solved .piece:nth-child(9)::after,
.board.is-solved .piece:nth-child(10)::after,
.board.is-solved .piece:nth-child(11)::after,
.board.is-solved .piece:nth-child(12)::after { animation-delay: 0.4s; }
.board.is-solved .piece:nth-child(n+13)::after { animation-delay: 0.45s; }

@keyframes pieceReveal {
  from {
    opacity: 0;
    transform: translate(var(--drag-x), var(--drag-y)) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(var(--drag-x), var(--drag-y)) scale(1);
  }
}

/* Shuffle animation */
.piece.revealed {
  animation: none;
}

.board.is-animating .piece {
  animation: none !important;
}

.board.is-animating.is-gathering .piece {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  transform:
    translate(
      calc(var(--gather-x, 0) * 1px),
      calc(var(--gather-y, 0) * 1px)
    )
    scale(0.5)
    rotate(calc(var(--mix-rotate, 0) * 1deg));
  opacity: 0.85;
}

.board.is-animating.is-swirling .piece {
  transition: transform 0.3s ease-in-out;
  transform:
    translate(
      calc(var(--gather-x, 0) * 1px),
      calc(var(--gather-y, 0) * 1px)
    )
    scale(0.5)
    rotate(calc(var(--swirl-rotate, 0) * 1deg));
  opacity: 0.85;
}

.board.is-animating.is-scattering .piece {
  transition: transform 0.5s cubic-bezier(0.2, 1.1, 0.4, 1), opacity 0.4s ease;
  transition-delay: calc(var(--scatter-delay, 0) * 1ms);
  transform: translate(0px, 0px) scale(1) rotate(0deg);
  opacity: 1;
}

/* ===== LOADING TILES ===== */
.loading-piece {
  background: linear-gradient(
    110deg,
    var(--surface) 0%,
    var(--surface) 40%,
    var(--border) 50%,
    var(--surface) 60%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite, loadingPop 0.3s ease-out backwards;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes loadingPop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== CONFETTI ===== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
  contain: strict;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.confetti.is-active {
  animation: confettiFall var(--fall-duration, 3s) ease-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(var(--rotation, 720deg)) scale(0.5);
  }
}

.confetti-square {
  border-radius: 2px;
}

.confetti-circle {
  border-radius: 50%;
}

.confetti-triangle {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid currentColor;
  background: none !important;
}

/* Star confetti */
.confetti-star {
  background: none !important;
  width: 0;
  height: 0;
  border: none;
  font-size: 14px;
  line-height: 1;
}

.confetti-star::before {
  content: '⭐';
}

/* Ribbon confetti - longer pieces */
.confetti-ribbon {
  width: 4px;
  height: 16px;
  border-radius: 2px;
}

/* ===== CELEBRATION STARS ===== */
.celebration-star {
  position: fixed;
  pointer-events: none;
  z-index: 201;
  font-size: 24px;
  opacity: 0;
  animation: starBurst 1s ease-out forwards;
}

@keyframes starBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: translate(var(--tx), var(--ty)) scale(1.2) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--tx) * 1.5), calc(var(--ty) * 1.5)) scale(0.5) rotate(360deg);
  }
}

/* ===== SPARKLE EFFECTS ===== */
.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 202;
  width: 8px;
  height: 8px;
  background: radial-gradient(circle, #FFD700 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  animation: sparkleFloat 1.5s ease-out forwards;
}

@keyframes sparkleFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-20px) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0);
  }
}

/* ===== FIREWORK BURST ===== */
.firework {
  position: fixed;
  pointer-events: none;
  z-index: 203;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
  animation: fireworkBurst 0.8s ease-out forwards;
}

@keyframes fireworkBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--fx), var(--fy)) scale(0.3);
  }
}

/* ===== COIN RAIN ===== */
.coin-rain {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  font-size: 20px;
  opacity: 0;
  animation: coinFall var(--coin-duration, 2s) ease-in forwards;
}

@keyframes coinFall {
  0% {
    opacity: 1;
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* ===== SCREEN CELEBRATION PULSE ===== */
.screen-celebrate {
  animation: screenPulse 0.3s ease-out;
}

@keyframes screenPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

/* ===== GALLERY ===== */
.gallery-screen {
  width: min(500px, 100%);
  max-height: 100%;
}

.gallery-container {
  width: 100%;
  padding: 20px;
  max-height: 100%;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  max-width: 500px;
}

.gallery-container h2 {
  text-align: center;
  margin-bottom: 8px;
}

.gallery-container .menu-copy {
  text-align: center;
  margin-bottom: 24px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.gallery-item {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  font-size: 0.7rem;
  text-align: center;
}

.gallery-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 0.9rem;
}

.gallery-grid:not(:empty) + .gallery-empty {
  display: none;
}

/* Gallery Modal for full view */
.gallery-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.gallery-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.gallery-modal img {
  max-width: 90%;
  max-height: 80%;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.gallery-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Gallery modal navigation */
.gallery-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-modal-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.gallery-modal-prev {
  left: 20px;
}

.gallery-modal-next {
  right: 20px;
}

.gallery-modal-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
}

/* Gallery item delete button */
.gallery-item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  padding: 0;
  line-height: 1;
}

.gallery-item:hover .gallery-item-delete {
  opacity: 1;
}

.gallery-item-delete:hover {
  background: rgba(220, 50, 50, 0.8);
}

/* ===== COLLECTIONS SCREEN ===== */
.collections-screen {
  width: min(360px, 100%);
  height: min(calc(100dvh - 24px), 700px);
  max-width: 90vw;
}

.collections-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  overflow: hidden;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.collections-header {
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  border-radius: 20px 20px 0 0;
}

.collections-header .back-button {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.collections-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #333;
  text-align: center;
}

.collections-tip {
  margin: 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  color: #2e7d32;
  font-size: 0.85rem;
  text-align: center;
  border-bottom: 1px solid rgba(46, 125, 50, 0.15);
}

.collections-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

/* Collection Card - 2 column optimized */
.collection-card {
  background: white;
  border-radius: 16px;
  overflow: visible;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  border: 2px solid transparent;
  position: relative;
}

.collection-card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 18px;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: -1;
}

.collection-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.collection-card:active {
  transform: scale(0.98);
}

/* Different colors for each collection */
.collection-card[data-collection="classic"] {
  border-color: rgba(106, 170, 100, 0.3);
}
.collection-card[data-collection="classic"]::before {
  background: linear-gradient(135deg, rgba(106, 170, 100, 0.2) 0%, rgba(74, 138, 68, 0.1) 100%);
}
.collection-card[data-collection="classic"]:hover {
  border-color: rgba(106, 170, 100, 0.6);
}
.collection-card[data-collection="classic"]:hover::before {
  opacity: 1;
}

.collection-card[data-collection="classic2"] {
  border-color: rgba(255, 152, 0, 0.3);
}
.collection-card[data-collection="classic2"]::before {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.2) 0%, rgba(245, 124, 0, 0.1) 100%);
}
.collection-card[data-collection="classic2"]:hover {
  border-color: rgba(255, 152, 0, 0.6);
}
.collection-card[data-collection="classic2"]:hover::before {
  opacity: 1;
}

.collection-card-artwork {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  flex-shrink: 0;
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
}

.collection-card-artwork img,
.collection-artwork-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.collection-card:hover .collection-artwork-img,
.collection-card:hover .collection-card-artwork img {
  transform: scale(1.05);
}

.collection-card-locked .collection-artwork-img,
.collection-card.is-locked .collection-card-artwork img {
  filter: blur(4px) brightness(0.7);
}

.collection-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
}

.lock-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.lock-icon-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.collection-card-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.collection-card-owned-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Gallery preview in card */
.collection-gallery-preview {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  gap: 3px;
  align-items: center;
}

.gallery-preview-thumb {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  border: 1.5px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.gallery-preview-more {
  background: rgba(0, 0, 0, 0.65);
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.6rem;
  font-weight: 600;
}

/* Card info section */
.collection-card-info {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.collection-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.collection-card-icon {
  font-size: 1rem;
}

.collection-card-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.collection-card-count {
  margin: 0;
  font-size: 0.7rem;
  color: #888;
}

.collection-card-status {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.collection-card-status.status-free {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  color: #2e7d32;
}

.collection-card-status.status-free::before {
  content: '✓ ';
}

.collection-card-status.status-locked {
  background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
  color: #c62828;
}

.collection-card-status.status-locked::before {
  content: '🔒 ';
  font-size: 0.5rem;
}

.collection-card-status.status-unlocked {
  background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
  color: #1565c0;
  animation: unlocked-pulse 2s ease-in-out infinite;
}

.collection-card-status.status-unlocked::before {
  content: '✨ ';
}

.collection-card-status.status-owned {
  background: linear-gradient(135deg, #ffe082 0%, #ffd54f 100%);
  color: #e65100;
}

.collection-card-status.status-owned::before {
  content: '⭐ ';
}

@keyframes unlocked-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Progress bar */
.collection-progress-bar {
  height: 4px;
  background: #e8e8e8;
  border-radius: 2px;
  overflow: hidden;
}

.collection-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6aaa64 0%, #4a8a44 100%);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.collection-progress-text-small {
  font-size: 0.65rem;
  color: #999;
  text-align: center;
}

/* Card buttons */
.collection-card-buttons {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.collection-btn-play,
.collection-btn-own,
.collection-btn-ad {
  flex: 1;
  padding: 6px 6px;
  border: none;
  border-radius: 16px;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.15s ease;
  min-height: 28px;
  max-height: 28px;
}

.collection-btn-play {
  background: linear-gradient(180deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  box-shadow: 0 2px 0 #3a6a34;
  font-size: 0.7rem;
}

.collection-btn-play:hover {
  background: linear-gradient(180deg, #7bbb75 0%, #5a9a54 100%);
  transform: scale(1.02);
}

.collection-btn-play:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 1px 0 #3a6a34;
}

/* Active collection indicator */
.collection-card.is-active {
  border: 3px solid #6aaa64;
  box-shadow: 0 0 20px rgba(106, 170, 100, 0.4), 0 4px 16px rgba(0, 0, 0, 0.15);
}

.collection-card.is-active::after {
  content: '✓ Now Playing';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(106, 170, 100, 0.4);
  z-index: 10;
}

.collection-btn-own {
  background: linear-gradient(180deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  box-shadow: 0 2px 0 #e69500;
}

.collection-btn-own:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #e69500;
}

.collection-btn-ad {
  background: linear-gradient(180deg, #ff7043 0%, #e64a19 100%);
  color: white;
  box-shadow: 0 2px 0 #bf360c;
}

.collection-btn-ad:hover {
  background: linear-gradient(180deg, #ff8a65 0%, #ff5722 100%);
}

.collection-btn-ad:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #bf360c;
}

.card-ad-badge {
  background: rgba(255, 255, 255, 0.35);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.55rem;
  font-weight: 700;
  margin-left: 2px;
  animation: badge-glow 1.5s ease-in-out infinite;
}

/* Video ad icon in buttons */
.btn-ad-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.collection-btn-ad .btn-ad-icon {
  width: 14px;
  height: 14px;
  margin-right: 2px;
}

.preview-btn-ad .btn-ad-icon,
.locked-btn-primary .btn-ad-icon {
  width: 20px;
  height: 20px;
}

@keyframes badge-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Free badge for Classic */
.collection-card-free-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ===== COLLECTION PREVIEW SCREEN ===== */
.collection-preview-screen {
  width: min(400px, 100%);
  height: min(calc(100dvh - 24px), 700px);
  max-width: 95vw;
}

.preview-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #f8f5ff 100%);
  overflow: hidden;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  position: relative;
}

.preview-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.preview-close-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

/* Preview Gallery - Stacked Cards Design */
.preview-gallery {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 200px;
  background: linear-gradient(180deg, rgba(138, 99, 210, 0.08) 0%, rgba(138, 99, 210, 0.02) 100%);
}

.preview-card-stack {
  position: relative;
  width: 180px;
  height: 180px;
  perspective: 1000px;
}

.preview-card {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, filter 0.3s ease;
}

.preview-card-back {
  transform: translateX(-30px) translateY(-10px) rotate(-12deg) scale(0.85);
  filter: blur(4px) brightness(0.7);
  z-index: 1;
}

.preview-card-mid {
  transform: translateX(30px) translateY(-5px) rotate(8deg) scale(0.9);
  filter: blur(2px) brightness(0.85);
  z-index: 2;
}

.preview-card-front {
  transform: translateY(0) rotate(0deg) scale(1);
  filter: brightness(1);
  z-index: 3;
  border: 3px solid white;
}

.preview-card-stack:hover .preview-card-back {
  transform: translateX(-40px) translateY(-15px) rotate(-15deg) scale(0.85);
}

.preview-card-stack:hover .preview-card-mid {
  transform: translateX(40px) translateY(-10px) rotate(12deg) scale(0.9);
}

.preview-card-stack:hover .preview-card-front {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* Preview Info Section */
.preview-info-section {
  text-align: center;
  padding: 16px 20px;
  background: white;
}

.preview-title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #333;
}

.preview-description {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #666;
  font-weight: 500;
}

.preview-unlock-hint {
  margin: 8px 0;
  font-size: 0.85rem;
  color: #666;
  font-weight: 500;
  line-height: 1.4;
}

.preview-ad-badge {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(135deg, #8a63d2 0%, #6a43b2 100%);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 20px;
}

/* Legacy classes kept for compatibility */
.preview-puzzle-img {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-puzzle-img.blurred {
  filter: blur(2px) brightness(0.95);
}

.preview-puzzle-item {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 2px solid white;
}

.preview-puzzle-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(4px) brightness(0.9);
}

.preview-puzzle-item::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.preview-info {
  text-align: center;
  background: white;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.preview-description {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: #333;
  font-weight: 700;
}

.preview-benefits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-benefits li {
  color: #555;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.preview-benefits li::before {
  content: '✓';
  color: #6aaa64;
  font-weight: bold;
  font-size: 1rem;
}

.preview-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding: 16px;
  background: white;
  border-radius: 16px 16px 20px 20px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
}

.preview-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.preview-btn-play {
  background: linear-gradient(180deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  box-shadow: 0 3px 0 #3a6a34, 0 4px 12px rgba(106, 170, 100, 0.3);
}

.preview-btn-play:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a6a34;
}

.preview-btn-ad {
  background: linear-gradient(180deg, #8a63d2 0%, #6a43b2 100%);
  color: white;
  box-shadow: 0 3px 0 #4a2382, 0 4px 12px rgba(138, 99, 210, 0.3);
}

.preview-btn-ad:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #4a2382;
}

.preview-btn-own {
  background: linear-gradient(180deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  box-shadow: 0 3px 0 #e69500, 0 4px 12px rgba(255, 179, 0, 0.3);
}

.preview-btn-own:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #e69500;
}

.ad-progress-badge {
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ===== COLLECTIONS RESPONSIVE ===== */

/* Mobile-first base styles - Collections */
@media (max-width: 480px) {
  .collections-screen,
  .collection-preview-screen {
    width: 100%;
    max-width: 100%;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .collections-container,
  .preview-container {
    border-radius: 16px;
  }

  .collections-header,
  .preview-header {
    padding: 12px 14px;
    border-radius: 16px 16px 0 0;
  }

  .collections-header h2,
  .preview-header h2 {
    font-size: 1rem;
  }

  .collections-header .back-button,
  .preview-header .back-button,
  .preview-header #previewBackBtn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .collections-grid {
    padding: 10px;
    gap: 8px;
  }

  .collection-card {
    border-radius: 12px;
  }

  .collection-card-artwork {
    border-radius: 10px 10px 0 0;
  }

  .collection-card-info {
    padding: 8px 10px 10px;
    gap: 4px;
  }

  .collection-card-icon {
    font-size: 0.85rem;
  }

  .collection-card-name {
    font-size: 0.8rem;
  }

  .collection-card-count {
    font-size: 0.6rem;
  }

  .collection-card-status {
    font-size: 0.55rem;
    padding: 2px 5px;
  }

  .collection-progress-bar {
    height: 3px;
  }

  .collection-progress-text-small {
    font-size: 0.55rem;
  }

  .collection-card-buttons {
    gap: 4px;
    margin-top: 3px;
  }

  .collection-btn-play,
  .collection-btn-own,
  .collection-btn-ad {
    padding: 5px 4px;
    font-size: 0.6rem;
    border-radius: 12px;
    min-height: 24px;
    max-height: 24px;
    gap: 2px;
  }

  .card-ad-badge {
    font-size: 0.5rem;
    padding: 1px 4px;
  }

  .lock-icon {
    font-size: 1.4rem;
  }

  .lock-icon-img {
    width: 36px;
    height: 36px;
  }

  /* Preview screen mobile - stacked cards */
  .preview-gallery {
    padding: 16px;
    min-height: 180px;
  }

  .preview-card-stack {
    width: 150px;
    height: 150px;
  }

  .preview-card-front {
    border-width: 2px;
  }

  .preview-info-section {
    padding: 12px 16px;
  }

  .preview-title {
    font-size: 1.3rem;
  }

  .preview-description {
    font-size: 0.9rem;
  }

  .preview-ad-badge {
    font-size: 0.75rem;
    padding: 3px 10px;
  }

  .preview-content {
    padding: 12px;
    gap: 12px;
  }

  .preview-puzzle-img,
  .preview-puzzle-item {
    width: 48px;
    height: 48px;
  }

  .preview-info {
    padding: 12px;
    border-radius: 12px;
  }

  .preview-description {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  .preview-benefits li {
    font-size: 0.8rem;
  }

  .preview-buttons {
    padding: 12px;
    gap: 6px;
    border-radius: 12px 12px 16px 16px;
  }

  .preview-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-radius: 20px;
  }

  .ad-progress-badge {
    font-size: 0.7rem;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  .collections-screen,
  .collection-preview-screen {
    height: calc(100dvh - 12px);
  }

  .collections-grid {
    padding: 8px;
    gap: 6px;
  }

  .collection-card-info {
    padding: 6px 8px 8px;
  }

  .collection-card-name {
    font-size: 0.75rem;
  }

  .collection-btn-play,
  .collection-btn-own,
  .collection-btn-ad {
    font-size: 0.55rem;
    min-height: 22px;
    max-height: 22px;
  }

  .preview-puzzle-img,
  .preview-puzzle-item {
    width: 40px;
    height: 40px;
  }

  .preview-btn {
    padding: 9px 12px;
    font-size: 0.8rem;
  }
}

/* Tablets and larger - Collections */
@media (min-width: 768px) {
  .collections-screen,
  .collection-preview-screen {
    width: min(400px, 90vw);
    height: min(calc(100dvh - 40px), 750px);
  }

  .collections-header,
  .preview-header {
    padding: 16px 20px;
  }

  .collections-header h2,
  .preview-header h2 {
    font-size: 1.25rem;
  }

  .collections-grid {
    padding: 16px;
    gap: 12px;
  }

  .collection-card-info {
    padding: 12px 14px 14px;
  }

  .collection-card-name {
    font-size: 1rem;
  }

  .collection-btn-play,
  .collection-btn-own,
  .collection-btn-ad {
    padding: 8px 8px;
    font-size: 0.75rem;
    min-height: 32px;
    max-height: 32px;
  }

  .preview-content {
    padding: 20px;
    gap: 20px;
  }

  .preview-puzzle-img,
  .preview-puzzle-item {
    width: 64px;
    height: 64px;
  }

  .preview-btn {
    padding: 14px 20px;
    font-size: 1rem;
  }
}

/* Locked Level Popup - Responsive */
@media (max-width: 480px) {
  .locked-popup-content {
    padding: 24px 20px;
    width: min(300px, 90vw);
    border-radius: 20px;
  }

  .locked-popup-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
  }

  .locked-popup-subtitle {
    font-size: 0.9rem;
  }

  .locked-collection-name {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }

  .locked-ad-progress {
    font-size: 0.8rem;
    padding: 6px 12px;
    margin-bottom: 16px;
  }

  .locked-popup-buttons {
    gap: 10px;
  }

  .locked-btn-primary,
  .locked-btn-secondary,
  .locked-btn-cancel {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

@media (max-width: 360px) {
  .locked-popup-content {
    padding: 20px 16px;
    width: min(280px, 92vw);
  }

  .locked-popup-icon {
    font-size: 2.4rem;
  }

  .locked-collection-name {
    font-size: 1.1rem;
  }

  .locked-btn-primary,
  .locked-btn-secondary,
  .locked-btn-cancel {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}

/* Collection Unlocked Popup - Responsive */
@media (max-width: 480px) {
  .collection-unlocked-content {
    padding: 24px 20px;
    width: min(300px, 90vw);
    border-radius: 20px;
  }

  .unlock-icon {
    font-size: 3rem;
    margin-bottom: 12px;
  }

  .unlock-title {
    font-size: 1.2rem;
  }

  .unlocked-collection-name {
    font-size: 1.3rem;
  }

  .unlock-buttons {
    gap: 10px;
  }

  .unlock-btn-primary,
  .unlock-btn-secondary {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

@media (max-width: 360px) {
  .collection-unlocked-content {
    padding: 20px 16px;
    width: min(280px, 92vw);
  }

  .unlock-icon {
    font-size: 2.5rem;
  }

  .unlock-title {
    font-size: 1.1rem;
  }

  .unlocked-collection-name {
    font-size: 1.2rem;
  }

  .unlock-btn-primary,
  .unlock-btn-secondary {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .collections-screen,
  .collection-preview-screen {
    height: calc(100dvh - 10px);
  }

  .collections-grid {
    padding: 8px;
  }

  .collection-card-artwork {
    aspect-ratio: 4 / 3;
  }

  .preview-content {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px;
    gap: 10px;
  }

  .preview-artwork {
    flex: 1;
    min-width: 150px;
  }

  .preview-info {
    flex: 1;
    min-width: 150px;
  }

  /* Stacked cards landscape layout */
  .preview-gallery {
    flex: 0 0 auto;
    padding: 10px;
    min-height: 120px;
  }

  .preview-card-stack {
    width: 100px;
    height: 100px;
  }

  .preview-card-back {
    transform: translateX(-20px) translateY(-6px) rotate(-10deg) scale(0.85);
  }

  .preview-card-mid {
    transform: translateX(20px) translateY(-3px) rotate(6deg) scale(0.9);
  }

  .preview-card-front {
    border-width: 2px;
  }

  .preview-info-section {
    padding: 8px 12px;
  }

  .preview-title {
    font-size: 1.1rem;
    margin-bottom: 2px;
  }

  .preview-description {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  .preview-ad-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .preview-buttons {
    flex-direction: row;
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
  }

  .preview-btn {
    flex: 1;
    min-width: 100px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .locked-popup-content,
  .collection-unlocked-content {
    padding: 16px 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .locked-popup-icon,
  .unlock-icon {
    font-size: 2rem;
    margin-bottom: 8px;
  }

  .locked-popup-buttons,
  .unlock-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .locked-btn-primary,
  .locked-btn-secondary,
  .locked-btn-cancel,
  .unlock-btn-primary,
  .unlock-btn-secondary {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    font-size: 0.8rem;
  }
}

/* ===== RESPONSIVE ===== */

/* Large screens - center and constrain width */
@media (min-width: 768px) {
  .app-content {
    padding: 10px 40px;
  }

  .menu-card.main-menu-card {
    max-width: 400px;
    padding: 28px 28px 32px;
  }

  .menu-logo-img {
    width: 90px;
    height: 90px;
    margin-bottom: 16px;
    border-radius: 20px;
  }

  h1 {
    font-size: 1.75rem;
  }

  .menu-copy {
    font-size: 0.9rem;
    margin-bottom: 20px;
  }

  .menu-actions {
    gap: 10px;
  }

  button {
    padding: 14px 24px;
  }

  .daily-button {
    padding: 12px 16px;
  }
}

/* Small screens */
@media (max-width: 400px) {
  .app-content {
    padding: 8px 12px;
  }

  .menu-card {
    padding: 20px 16px;
  }

  .menu-card.main-menu-card {
    padding: 20px 16px 24px;
    border-radius: 20px;
  }

  .menu-logo-img {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    border-radius: 14px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .menu-copy {
    font-size: 0.8rem;
    margin-bottom: 14px;
  }

  button {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .daily-button {
    padding: 8px 12px;
  }

  .daily-icon {
    font-size: 16px;
  }

  .daily-text strong {
    font-size: 0.8rem;
  }

  .daily-text small {
    font-size: 0.65rem;
  }

  .menu-actions {
    gap: 8px;
  }
}

/* Very small screens */
@media (max-width: 320px) {
  .app-content {
    padding: 6px 10px;
  }

  .menu-card.main-menu-card {
    padding: 16px 14px 20px;
  }

  .menu-logo-img {
    width: 50px;
    height: 50px;
  }

  h1 {
    font-size: 1.2rem;
  }
}

/* ===== GAME SCREEN RESPONSIVE ===== */

/* Tablets - height-based sizing */
@media (min-width: 768px) {
  .board-shell {
    height: min(calc(100dvh - 80px), 750px);
    width: auto;
    max-width: 90vw;
    --board-padding: 12px;
  }

  .game-header {
    max-width: 520px;
    margin: 0 auto;
  }
}

/* Large screens - height-based sizing */
@media (min-width: 1024px) {
  .board-shell {
    height: min(calc(100dvh - 80px), 780px);
    width: auto;
    max-width: 90vw;
    --board-padding: 14px;
  }

  .game-header {
    max-width: 520px;
  }
}

/* Mobile portrait - height-based sizing */
@media (max-width: 480px) {
  .game-screen {
    gap: 6px;
  }

  .board-shell {
    height: min(calc(100dvh - 60px), 650px);
    width: auto;
    max-width: 92vw;
    --board-padding: 8px;
  }

  .game-header {
    padding: 5px 8px;
  }

  .game-stat {
    font-size: 0.8rem;
  }

  .game-stat .stat-label {
    font-size: 0.65rem;
  }

  .hint-button-compact {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .hint-count-compact {
    padding: 1px 5px;
    font-size: 0.6rem;
  }
}

/* Very small mobile screens - height-based sizing */
@media (max-width: 360px) {
  .board-shell {
    height: min(calc(100dvh - 55px), 600px);
    width: auto;
    max-width: 94vw;
    --board-padding: 6px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .game-stat {
    font-size: 0.75rem;
  }

  .game-stat .stat-label {
    font-size: 0.6rem;
  }

  .game-header-center {
    gap: 6px;
  }

  .game-coins {
    padding: 2px 6px 2px 4px;
  }

  .game-coins-icon {
    width: 12px;
    height: 12px;
  }

  .game-coins-amount {
    font-size: 0.7rem;
  }

  .game-header-actions {
    gap: 3px;
  }

  .hint-button-compact {
    padding: 3px 6px;
    font-size: 0.65rem;
  }
}

/* Handle very short screens (landscape mobile) - height-based sizing */
@media (max-height: 500px) {
  .app-content {
    padding: 4px 10px;
  }

  .board-shell {
    /* Height-based: maximize height, derive width from aspect-ratio */
    height: calc(100dvh - 50px);
    width: auto;
    max-width: 90vw;
    aspect-ratio: 2 / 3;
  }

  .game-screen {
    gap: 3px;
  }

  .game-header {
    padding: 4px 8px;
  }

  .game-stat {
    font-size: 0.75rem;
  }

  .game-stat .stat-label {
    font-size: 0.6rem;
  }

  .hint-button-compact {
    padding: 3px 6px;
    font-size: 0.65rem;
  }

  .hint-button-compact .hint-icon {
    font-size: 0.75rem;
  }

  .hint-count-compact {
    padding: 1px 4px;
    font-size: 0.55rem;
  }

  .menu-card.main-menu-card {
    padding: 12px 16px;
  }

  .menu-logo-img {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
  }

  h1 {
    font-size: 1.1rem;
    margin-bottom: 4px;
  }

  .menu-copy {
    font-size: 0.75rem;
    margin-bottom: 10px;
  }

  button {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .menu-actions {
    gap: 6px;
  }

  .game-header {
    max-width: 480px;
  }

  /* Compact collection header for landscape */
  .collection-header {
    padding: 4px 8px;
  }

  .collection-title {
    flex-direction: row;
    gap: 8px;
  }

  #activeCollectionName {
    font-size: 0.7rem;
  }

  .collection-progress-text {
    font-size: 0.6rem;
  }

  .level-grid-container {
    padding: 6px;
  }

  .level-grid {
    gap: 4px;
  }

  .level-tile {
    border-radius: 4px;
  }

  .play-button-container {
    padding: 6px 12px;
  }

  .play-button-main {
    padding: 8px 32px;
    font-size: 0.9rem;
  }

  .main-nav {
    padding: 4px 8px;
    gap: 4px;
  }

  .nav-item {
    padding: 4px 6px;
  }

  .nav-icon-img {
    width: 20px;
    height: 20px;
  }

  .nav-label {
    font-size: 0.55rem;
  }
}

/* Explicit landscape orientation - height-based sizing */
@media (orientation: landscape) and (max-height: 600px) {
  .board-shell {
    /* Height-based: maximize height, derive width from aspect-ratio */
    height: calc(100dvh - 60px);
    width: auto;
    max-width: 90vw;
    aspect-ratio: 2 / 3;
  }

  .game-header {
    max-width: 480px;
  }

  .game-footer {
    max-width: 480px;
  }
}

/* ===== MOBILE LANDSCAPE - SIDE BARS LAYOUT ===== */
/* Only applies to touch devices in landscape with short height */
@media (orientation: landscape) and (max-height: 450px) and (hover: none) and (pointer: coarse) {
  .app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .app-content {
    padding: 0 8px;
  }

  .screen.game-screen {
    width: 100%;
    max-width: 100%;
  }

  .game-screen {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
  }

  /* Header becomes left sidebar */
  .game-header {
    flex-direction: column;
    width: 52px;
    height: calc(100dvh - 16px);
    padding: 10px 6px;
    gap: 8px;
    border-radius: var(--radius-lg);
    align-items: center;
    justify-content: space-between;
  }

  .game-header-center {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }

  .game-stat {
    flex-direction: column;
    gap: 1px;
    text-align: center;
    font-size: 0.7rem;
  }

  .game-stat .stat-label {
    font-size: 0.5rem;
  }

  .game-coins {
    flex-direction: column;
    padding: 4px;
    gap: 2px;
  }

  .game-coins-icon {
    width: 14px;
    height: 14px;
  }

  .game-coins-amount {
    font-size: 0.7rem;
  }

  .game-header-actions {
    flex-direction: column;
    gap: 4px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .hint-button-compact {
    flex-direction: column;
    padding: 5px 4px;
    gap: 2px;
  }

  .hint-button-compact .hint-icon {
    font-size: 0.8rem;
  }

  .hint-count-compact {
    font-size: 0.55rem;
    min-width: 14px;
    height: 14px;
  }

  /* Board in center - maximize height */
  .board-shell {
    height: calc(100dvh - 16px);
    width: auto;
    aspect-ratio: 2 / 3;
    --board-padding: 5px;
  }

  /* Hide status text in landscape */
  .status {
    display: none;
  }
}

/* ===== WELCOME MESSAGE ===== */
.welcome-message {
  color: #6aaa64;
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  display: none;
}

/* ===== LEADERBOARD BUTTON ===== */
.leaderboard-btn {
  background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
  color: #1a1a1b;
  border: none;
  font-weight: 600;
}

.leaderboard-btn:hover {
  background: linear-gradient(135deg, #ffb300 0%, #ff9800 100%);
  transform: translateY(-2px);
}

/* ===== LEADERBOARD MODAL ===== */
.leaderboard-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.leaderboard-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.leaderboard-content {
  background: #1a1a1b;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
}

.leaderboard-content h2 {
  color: #fff;
  margin: 0 0 16px 0;
  text-align: center;
  font-size: 1.5rem;
}

.leaderboard-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #787c7e;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.leaderboard-close:hover {
  color: #fff;
}

/* Leaderboard Tabs */
.leaderboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: #2a2a2b;
  border-radius: 8px;
  padding: 4px;
}

.leaderboard-tab {
  flex: 1;
  background: none;
  border: none;
  color: #787c7e;
  padding: 8px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.leaderboard-tab:hover {
  color: #fff;
}

.leaderboard-tab.is-active {
  background: #6aaa64;
  color: #fff;
}

/* User Rank Info */
.leaderboard-user-rank {
  margin-bottom: 12px;
}

.user-rank-info {
  background: linear-gradient(135deg, #2a2a2b 0%, #333 100%);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid #444;
}

.user-rank-info span {
  color: #b3b3b3;
  font-size: 0.8rem;
}

.user-rank-info strong {
  color: #6aaa64;
}

/* Leaderboard List */
.leaderboard-list {
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  max-height: 400px;
}

.leaderboard-loading,
.leaderboard-empty,
.leaderboard-error {
  text-align: center;
  color: #787c7e;
  padding: 32px 16px;
}

.leaderboard-error {
  color: #e74c3c;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #2a2a2b;
  border-radius: 8px;
  margin-bottom: 6px;
  gap: 12px;
}

.leaderboard-item.is-current-user {
  background: linear-gradient(135deg, #1a3a1a 0%, #2a4a2a 100%);
  border: 1px solid #6aaa64;
}

.leaderboard-item.rank-1 {
  background: linear-gradient(135deg, #3a3a1a 0%, #4a4a2a 100%);
  border: 1px solid #ffd700;
}

.leaderboard-item.rank-2 {
  background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%);
  border: 1px solid #c0c0c0;
}

.leaderboard-item.rank-3 {
  background: linear-gradient(135deg, #2a2015 0%, #3a3025 100%);
  border: 1px solid #cd7f32;
}

.leaderboard-rank {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3b;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.rank-1 .leaderboard-rank {
  background: linear-gradient(135deg, #ffd700, #ffb300);
  color: #1a1a1b;
}

.rank-2 .leaderboard-rank {
  background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
  color: #1a1a1b;
}

.rank-3 .leaderboard-rank {
  background: linear-gradient(135deg, #cd7f32, #a0642a);
  color: #1a1a1b;
}

.leaderboard-name {
  flex: 1;
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-details {
  display: flex;
  gap: 8px;
  color: #787c7e;
  font-size: 0.75rem;
}

.lb-level {
  background: #3a3a3b;
  padding: 2px 6px;
  border-radius: 4px;
}

.lb-time {
  color: #b3b3b3;
}

.leaderboard-score {
  font-weight: 700;
  color: #6aaa64;
  font-size: 0.9rem;
  min-width: 50px;
  text-align: right;
}

.leaderboard-refresh {
  width: 100%;
  margin-top: 16px;
  padding: 12px 20px;
  background: #2a2a2b;
  border: 1px solid #444;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.leaderboard-refresh:hover:not(:disabled) {
  background: #3a3a3b;
  border-color: #6aaa64;
}

.leaderboard-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== WIN OVERLAY UPDATES ===== */
.win-stats {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 0;
  text-align: center;
}

.share-btn {
  width: 100%;
  background: linear-gradient(135deg, #1da1f2 0%, #0d8ecf 100%);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.share-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #0d8ecf 0%, #0a7ab8 100%);
  transform: translateY(-2px);
}

.share-btn:disabled {
  background: #3a3a3b;
  color: #787c7e;
  cursor: not-allowed;
}

/* Share Level as Post button */
.share-level-btn {
  width: 100%;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.share-level-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #f7931e 0%, #e8850a 100%);
  transform: translateY(-2px);
}

.share-level-btn:disabled {
  background: #3a3a3b;
  color: #787c7e;
  cursor: not-allowed;
}

/* Share Game button (in gameplay) */
.share-game-btn {
  margin-top: 12px;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.share-game-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #f7931e 0%, #e8850a 100%);
  transform: translateY(-2px);
}

.share-game-btn:disabled {
  background: #3a3a3b;
  color: #787c7e;
  cursor: not-allowed;
}

/* Share button in create menu */
.share-create-btn {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.share-create-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #f7931e 0%, #e8850a 100%);
  transform: translateY(-2px);
}

.share-create-btn:disabled {
  background: #3a3a3b;
  color: #787c7e;
  cursor: not-allowed;
}

/* ===== POSTING OVERLAY ===== */
.posting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.posting-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
}

.posting-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.posting-text {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
}

.posting-link {
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: none;
}

.posting-link.is-visible {
  display: inline-block;
}

.posting-link:hover {
  background: var(--accent-hover);
}

/* ===== SHARE MODAL ===== */
.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.share-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.share-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.share-modal-content h2 {
  margin: 0 0 12px 0;
  text-align: center;
  font-size: 1.3rem;
  color: var(--text);
}

.share-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #787c7e;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.share-modal-close:hover {
  color: var(--text);
}

.share-stats-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 0 16px 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text);
}

.share-comment-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 80px;
  max-height: 150px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease;
}

.share-comment-input:focus {
  outline: none;
  border-color: var(--accent);
}

.share-comment-input::placeholder {
  color: var(--text-secondary);
}

.share-modal-actions {
  display: flex;
  gap: 12px;
}

.share-modal-actions button {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.9rem;
}

.share-modal-actions .primary {
  background: linear-gradient(135deg, #1da1f2 0%, #0d8ecf 100%);
}

.share-modal-actions .primary:hover {
  background: linear-gradient(135deg, #0d8ecf 0%, #0a7ab8 100%);
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 480px) {
  .leaderboard-content {
    padding: 16px;
    max-height: 85vh;
  }

  .leaderboard-tab {
    font-size: 0.7rem;
    padding: 6px 2px;
  }

  .user-rank-info {
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .leaderboard-item {
    padding: 8px 10px;
    gap: 8px;
  }

  .leaderboard-details {
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
  }

  .share-modal-content {
    padding: 20px;
  }

  .share-modal-actions {
    flex-direction: column;
  }
}

/* ===== POPUP ANIMATIONS ===== */

@keyframes popupFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popupSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes popupScaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popupBounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Base popup styles */
.popup-animated {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.popup-animated.is-active,
.popup-animated.is-visible {
  opacity: 1;
  visibility: visible;
}

.popup-animated.is-active > *:first-child,
.popup-animated.is-visible > *:first-child {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ===== SETTINGS ===== */

.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 16px;
}

.settings-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.settings-modal.is-active .settings-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.settings-content {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px;
  width: min(320px, 100%);
  position: relative;
  border: 1px solid var(--border);
}

.settings-content h2 {
  margin: 0 0 20px 0;
  font-size: 1.3rem;
  color: var(--text);
}

.settings-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease, color 0.2s ease;
}

.settings-close:hover {
  background: var(--surface);
  color: var(--text);
}

.settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-option:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 1rem;
  color: var(--text);
}

/* Toggle Button */
.toggle-button {
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: var(--border);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.3s ease;
  padding: 0;
}

.toggle-button.is-on {
  background: var(--accent);
}

.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-button.is-on .toggle-slider {
  transform: translateX(24px);
}

/* ===== VIP MODAL ===== */
.vip-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.vip-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.vip-content {
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  position: relative;
  text-align: center;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: vipModalEntrance 0.4s ease-out;
}

.vip-modal.is-active .vip-content {
  animation: vipModalEntrance 0.4s ease-out;
}

@keyframes vipModalEntrance {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.vip-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: linear-gradient(180deg, #ff6b6b 0%, #ee5a5a 100%);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow:
    0 3px 0 #c0392b,
    0 4px 12px rgba(238, 90, 90, 0.4);
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
  aspect-ratio: 1;
}

.vip-close:hover {
  transform: scale(1.1);
  box-shadow:
    0 4px 0 #c0392b,
    0 6px 16px rgba(238, 90, 90, 0.5);
}

.vip-close:active {
  transform: scale(0.95) translateY(2px);
  box-shadow:
    0 1px 0 #c0392b,
    0 2px 6px rgba(238, 90, 90, 0.3);
}

.vip-icon-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vip-modal-icon {
  width: 100px;
  height: 100px;
  object-fit: contain;
  position: relative;
  z-index: 2;
  animation: vipIconFloat 3s ease-in-out infinite;
}

@keyframes vipIconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.vip-icon-glow {
  position: absolute;
  inset: 10px;
  background: radial-gradient(circle, rgba(106, 170, 100, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: vipGlowPulse 2s ease-in-out infinite;
  z-index: 1;
}

@keyframes vipGlowPulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.vip-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.vip-description {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.vip-benefit {
  margin: 0 0 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.vip-buy-btn {
  width: 100%;
  padding: 16px 32px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #ffd54f 0%, #ffca28 50%, #ffb300 100%);
  color: #5d4037;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 6px 0 #e69500,
    0 8px 20px rgba(255, 179, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
}

.vip-buy-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -100%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  transform: skewX(-20deg);
  animation: buyButtonShine 2.5s ease-in-out infinite;
}

@keyframes buyButtonShine {
  0%, 100% { left: -100%; }
  50%, 70% { left: 150%; }
}

.vip-buy-btn:hover {
  transform: translateY(-3px);
  box-shadow:
    0 9px 0 #e69500,
    0 12px 30px rgba(255, 179, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.vip-buy-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #e69500,
    0 4px 10px rgba(255, 179, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.vip-buy-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* VIP Success Popup */
.vip-success-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.vip-success-popup.is-active {
  opacity: 1;
  visibility: visible;
}

.vip-success-content {
  background: linear-gradient(145deg, #ffffff 0%, #f0fff0 100%);
  border-radius: 24px;
  padding: 40px 32px;
  width: min(340px, 100%);
  text-align: center;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 0 3px rgba(106, 170, 100, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: vipSuccessEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes vipSuccessEntrance {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(40px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.vip-success-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: vipSuccessBounce 0.6s ease-out 0.2s both;
}

@keyframes vipSuccessBounce {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-20deg);
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.vip-success-title {
  margin: 0 0 12px;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.vip-success-message {
  margin: 0 0 28px;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.vip-success-btn {
  padding: 14px 48px;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow:
    0 5px 0 var(--accent-dark),
    0 6px 16px rgba(106, 170, 100, 0.4);
  transition: all 0.15s ease;
}

.vip-success-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 7px 0 var(--accent-dark),
    0 10px 24px rgba(106, 170, 100, 0.5);
}

.vip-success-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 var(--accent-dark),
    0 3px 8px rgba(106, 170, 100, 0.3);
}

.vip-buy-btn:disabled::before {
  animation: none;
}

/* ===== SHARE PUZZLE MODAL ===== */
.share-puzzle-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.share-puzzle-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.share-puzzle-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.share-puzzle-content h2 {
  margin: 0 0 8px 0;
  text-align: center;
  font-size: 1.3rem;
  color: var(--text);
}

.share-puzzle-hint {
  text-align: center;
  color: #787c7e;
  font-size: 0.9rem;
  margin: 0 0 16px 0;
}

.share-puzzle-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #787c7e;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.share-puzzle-close:hover {
  color: var(--text);
}

.puzzle-title-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.puzzle-title-input:focus {
  outline: none;
  border-color: var(--accent);
}

.share-puzzle-actions {
  display: flex;
  gap: 12px;
}

.share-puzzle-actions button {
  flex: 1;
}

/* ===== CONTENT GUIDELINES ===== */
.content-guidelines-btn {
  background: none;
  border: none;
  color: #787c7e;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px;
  text-decoration: underline;
}

.content-guidelines-btn:hover {
  color: var(--text);
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.75rem;
  font-weight: bold;
  font-style: italic;
}

.guidelines-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.guidelines-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.guidelines-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.guidelines-content h2 {
  margin: 0 0 16px 0;
  text-align: center;
  font-size: 1.3rem;
  color: var(--text);
}

.guidelines-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #787c7e;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.guidelines-close:hover {
  color: var(--text);
}

.guidelines-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.guidelines-text p {
  margin: 0 0 12px 0;
}

.guidelines-text ul {
  margin: 0 0 16px 0;
  padding-left: 20px;
}

.guidelines-text li {
  margin-bottom: 10px;
}

.guidelines-text li strong {
  color: var(--text);
}

.guidelines-warning {
  background: rgba(255, 100, 100, 0.1);
  border-left: 3px solid #e74c3c;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #c0392b;
  border-radius: 0 8px 8px 0;
}

.guidelines-content .primary {
  width: 100%;
  margin-top: 16px;
}

/* ===== DEBUG CONSOLE ===== */
.debug-console {
  display: none;
  position: fixed;
  bottom: 50px;
  left: 0;
  right: 0;
  height: 40%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  overflow: hidden;
  border-top: 2px solid #0f0;
  font-family: monospace;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: #111;
  border-bottom: 1px solid #333;
}

.debug-title {
  color: #0f0;
  font-weight: bold;
}

.debug-clear-btn {
  background: #333;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.debug-log {
  height: calc(100% - 40px);
  overflow-y: auto;
  padding: 8px;
  font-size: 12px;
  color: #0f0;
}

.debug-toggle-btn {
  position: fixed;
  bottom: 10px;
  left: 10px;
  z-index: 10000;
  background: #111;
  color: #0f0;
  border: 2px solid #0f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

/* ===== QUESTS SYSTEM ===== */
.quests-btn {
  position: relative;
}

.quests-btn.has-rewards {
  animation: quest-pulse 2s ease-in-out infinite;
}

@keyframes quest-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(106, 170, 100, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(106, 170, 100, 0); }
}

.quest-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(135deg, #ff6b4a 0%, #ff4a6b 100%);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Quests Modal */
.quests-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.quests-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.quests-modal.is-visible .quests-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.quests-content {
  background: linear-gradient(145deg, #ffffff 0%, #f8f5ff 100%);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(138, 99, 210, 0.2);
}

.quests-content h2 {
  color: #5a3d8a;
  margin: 0 0 4px 0;
  text-align: center;
  font-size: 1.6rem;
  position: relative;
}

.quests-content h2::before {
  content: '🏆';
  margin-right: 8px;
}

.quests-subtitle {
  color: #666;
  text-align: center;
  margin: 0 0 16px 0;
  font-size: 0.9rem;
}

.quests-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: linear-gradient(180deg, #ff6b6b 0%, #ee5a5a 100%);
  border: none;
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #c0392b;
  z-index: 10;
}

.quests-close:hover {
  transform: scale(1.1);
}

.quests-close:active {
  transform: scale(0.95);
  box-shadow: 0 1px 0 #c0392b;
}

.quests-list {
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  max-height: 400px;
  padding-right: 4px;
}

.quests-list::-webkit-scrollbar {
  width: 6px;
}

.quests-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.quests-list::-webkit-scrollbar-thumb {
  background: rgba(138, 99, 210, 0.4);
  border-radius: 3px;
}

.quests-loading {
  text-align: center;
  color: #666;
  padding: 32px 16px;
}

/* Quest Item */
.quest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 14px;
  margin-bottom: 10px;
  transition: all 0.25s ease;
  border: 1px solid rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.quest-item:hover {
  background: linear-gradient(145deg, #ffffff 0%, #f1f3f5 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quest-item.is-completed {
  background: linear-gradient(145deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 1px solid rgba(106, 170, 100, 0.4);
}

.quest-item.is-completed::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: #6aaa64;
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.quest-item.is-claimed {
  opacity: 0.5;
  background: #f5f5f5;
  border-color: transparent;
}

.quest-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f0e6ff 0%, #e0d0ff 100%);
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(138, 99, 210, 0.2);
  border: 1px solid rgba(138, 99, 210, 0.15);
}

.quest-info {
  flex: 1;
  min-width: 0;
}

.quest-name {
  color: #333;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 3px;
}

.quest-desc {
  color: #666;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.quest-progress-bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8a63d2 0%, #a78bfa 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.quest-item.is-completed .quest-progress-fill {
  background: linear-gradient(90deg, #6aaa64 0%, #81c784 100%);
}

.quest-progress-text {
  color: #666;
  font-size: 0.7rem;
}

.quest-reward {
  text-align: center;
  flex-shrink: 0;
}

.quest-reward-amount {
  display: block;
  color: #d4a017;
  font-weight: 700;
  font-size: 0.9rem;
}

.quest-reward-amount::before {
  content: '🪙 ';
}

.quest-claim-btn {
  background: linear-gradient(135deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
  box-shadow: 0 4px 0 #3a6a34, 0 6px 20px rgba(106, 170, 100, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quest-claim-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #3a6a34, 0 8px 25px rgba(106, 170, 100, 0.4);
}

.quest-claim-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #3a6a34, 0 4px 15px rgba(106, 170, 100, 0.3);
}

.quest-claimed-badge {
  color: #6aaa64;
  font-size: 0.8rem;
  font-weight: 600;
}

.quest-claimed-badge::before {
  content: '✓ ';
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: linear-gradient(135deg, #333 0%, #1a1a1b 100%);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 90vw;
}

.toast-notification.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Quest Notification */
.quest-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, #1a1a1b 0%, #2a2a2b 100%);
  border: 1px solid #6aaa64;
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2000;
  opacity: 0;
  transition: all 0.4s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.quest-notification.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.quest-notif-icon {
  font-size: 2rem;
}

.quest-notif-text {
  display: flex;
  flex-direction: column;
}

.quest-notif-title {
  color: #6aaa64;
  font-weight: 700;
  font-size: 0.85rem;
}

.quest-notif-name {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.quest-notif-reward {
  color: #c9b458;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 480px) {
  .quests-content {
    padding: 16px;
    max-height: 85vh;
  }

  .quest-item {
    padding: 10px;
    gap: 10px;
  }

  .quest-icon {
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
  }

  .quest-name {
    font-size: 0.9rem;
  }

  .quest-desc {
    font-size: 0.75rem;
  }

  .quest-notification {
    width: calc(100% - 32px);
    max-width: 320px;
  }
}

/* ===== QUEST CELEBRATION ANIMATIONS ===== */

/* Flying Coins */
.flying-coin {
  position: fixed;
  font-size: 1.5rem;
  z-index: 3000;
  pointer-events: none;
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.flying-coin.is-flying {
  animation: flyToCoin 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes flyToCoin {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.3) rotate(180deg) translateX(calc(var(--end-x) * 0.3)) translateY(calc(var(--end-y) * 0.3 - 30px));
    opacity: 1;
  }
  100% {
    transform: scale(0.5) rotate(360deg) translateX(var(--end-x)) translateY(var(--end-y));
    opacity: 0;
  }
}

/* Star Burst */
.star-burst-container {
  position: fixed;
  z-index: 3000;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.star-particle {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
}

.star-particle.is-bursting {
  animation: starBurst 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes starBurst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2) rotate(180deg)
      translateX(calc(cos(var(--angle)) * var(--distance) * 0.5))
      translateY(calc(sin(var(--angle)) * var(--distance) * 0.5));
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(360deg)
      translateX(calc(cos(var(--angle)) * var(--distance)))
      translateY(calc(sin(var(--angle)) * var(--distance)));
  }
}

/* Fallback for browsers without trigonometric functions */
@supports not (transform: translateX(calc(cos(45deg) * 10px))) {
  .star-particle.is-bursting {
    animation: starBurstFallback 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }

  @keyframes starBurstFallback {
    0% {
      opacity: 1;
      transform: translate(-50%, -50%) scale(0);
    }
    50% {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1.5);
    }
    100% {
      opacity: 0;
      transform: translate(-50%, -50%) scale(0) translateY(-50px);
    }
  }
}

/* Reward Popup */
.reward-popup {
  position: fixed;
  z-index: 3000;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #1a1a1b;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.reward-popup.is-visible {
  animation: rewardPopIn 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) forwards;
}

.reward-popup.is-fading {
  animation: rewardPopOut 0.5s ease-out forwards;
}

@keyframes rewardPopIn {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -80%) scale(1.2) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -100%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes rewardPopOut {
  0% {
    transform: translate(-50%, -100%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -150%) scale(0.5);
    opacity: 0;
  }
}

.reward-popup-icon {
  font-size: 1.3rem;
}

.reward-popup-text {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Mini Confetti */
.mini-confetti-container {
  position: fixed;
  z-index: 2999;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.mini-confetti {
  position: absolute;
  opacity: 0;
}

.mini-confetti.is-exploding {
  animation: confettiExplode 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes confettiExplode {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform:
      translate(
        calc(cos(var(--angle)) * var(--velocity)),
        calc(sin(var(--angle)) * var(--velocity) + 50px)
      )
      rotate(var(--rotation))
      scale(0.3);
  }
}

/* Fallback for mini confetti */
@supports not (transform: translateX(calc(cos(45deg) * 10px))) {
  .mini-confetti.is-exploding {
    animation: confettiExplodeFallback 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }

  @keyframes confettiExplodeFallback {
    0% {
      opacity: 1;
      transform: translate(0, 0) scale(1);
    }
    50% {
      opacity: 1;
    }
    100% {
      opacity: 0;
      transform: translate(
        calc((var(--velocity) * 0.7) * (1 - 2 * (var(--angle) / 360))),
        calc(var(--velocity) + 30px)
      ) rotate(var(--rotation)) scale(0);
    }
  }
}

/* Quest Claim Overlay */
.quest-claim-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: pointer;
}

.quest-claim-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.quest-claim-overlay.is-closing {
  opacity: 0;
}

.quest-claim-content {
  text-align: center;
  transform: scale(0.5) translateY(50px);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.2, 1.2, 0.3, 1);
}

.quest-claim-overlay.is-visible .quest-claim-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.quest-claim-overlay.is-closing .quest-claim-content {
  transform: scale(1.2) translateY(-30px);
  opacity: 0;
}

.quest-claim-icon {
  font-size: 5rem;
  margin-bottom: 16px;
  animation: iconBounce 0.6s cubic-bezier(0.2, 1.5, 0.4, 1) 0.2s both;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

@keyframes iconBounce {
  0% {
    transform: scale(0) rotate(-20deg);
  }
  50% {
    transform: scale(1.3) rotate(10deg);
  }
  75% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.quest-claim-title {
  color: #6aaa64;
  font-size: 1.2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
  animation: slideUp 0.4s ease-out 0.3s both;
}

.quest-claim-name {
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  animation: slideUp 0.4s ease-out 0.4s both;
}

.quest-claim-reward {
  color: #FFD700;
  font-size: 2rem;
  font-weight: 700;
  animation: rewardPulse 0.6s ease-out 0.5s both;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rewardPulse {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Quest Notification Celebration */
.quest-notification.is-celebrating {
  animation: notifCelebrate 0.6s ease-out;
}

@keyframes notifCelebrate {
  0%, 100% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
  15% {
    transform: translateX(-50%) translateY(0) rotate(-3deg) scale(1.05);
  }
  30% {
    transform: translateX(-50%) translateY(0) rotate(3deg) scale(1.05);
  }
  45% {
    transform: translateX(-50%) translateY(0) rotate(-2deg);
  }
  60% {
    transform: translateX(-50%) translateY(0) rotate(2deg);
  }
  75% {
    transform: translateX(-50%) translateY(0) rotate(-1deg);
  }
}

/* Enhanced Quest Claim Button */
.quest-claim-btn {
  position: relative;
  overflow: hidden;
}

.quest-claim-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.quest-claim-btn:active::before {
  width: 200px;
  height: 200px;
}

/* Glowing effect for claimable quests */
.quest-item.is-completed:not(.is-claimed) {
  animation: questGlow 2s ease-in-out infinite;
}

@keyframes questGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(106, 170, 100, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(106, 170, 100, 0.6), 0 0 30px rgba(106, 170, 100, 0.3);
  }
}

/* ===== STATISTICS MODAL (Moderators Only) ===== */

.statistics-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.statistics-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.statistics-modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 16px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  animation: statsSlideIn 0.3s ease forwards;
}

@keyframes statsSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.statistics-modal-content h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  color: #fff;
  text-align: center;
}

.statistics-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.statistics-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.statistics-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Statistics Tabs */
.statistics-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.statistics-tab {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.statistics-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.statistics-tab.is-active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Statistics Content */
.statistics-content {
  min-height: 200px;
}

.stats-loading {
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  padding: 40px;
  font-size: 0.9rem;
}

.stats-error {
  text-align: center;
  color: #ff6b6b;
  padding: 40px;
  background: rgba(255, 107, 107, 0.1);
  border-radius: 12px;
}

/* Statistics Sections */
.stats-section {
  margin-bottom: 24px;
}

.stats-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-section-icon {
  font-size: 1.1rem;
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: all 0.2s ease;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-value.highlight {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Level Retention */
.retention-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.retention-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.retention-level {
  font-weight: 600;
  color: #fff;
  min-width: 70px;
}

.retention-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.retention-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.retention-percent {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  min-width: 45px;
  text-align: right;
}

/* Top Players */
.top-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.top-player-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.top-player:nth-child(1) .top-player-rank {
  background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
  color: #1a1a2e;
}

.top-player:nth-child(2) .top-player-rank {
  background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 100%);
  color: #1a1a2e;
}

.top-player:nth-child(3) .top-player-rank {
  background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
  color: #1a1a2e;
}

.top-player-name {
  flex: 1;
  color: #fff;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-player-score {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

/* Difficulty Distribution */
.difficulty-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.difficulty-label {
  min-width: 80px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
}

.difficulty-bar-container {
  flex: 1;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.difficulty-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}

.difficulty-bar.easy { background: #4ade80; }
.difficulty-bar.medium { background: #fbbf24; }
.difficulty-bar.hard { background: #f97316; }
.difficulty-bar.expert { background: #ef4444; }
.difficulty-bar.master { background: #a855f7; }
.difficulty-bar.insane { background: #ec4899; }
.difficulty-bar.legendary { background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); }

.difficulty-count {
  min-width: 50px;
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

/* Statistics Button */
.statistics-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
}

.statistics-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 480px) {
  .statistics-modal-content {
    padding: 16px;
    max-height: 90vh;
  }

  .statistics-tabs {
    gap: 6px;
  }

  .statistics-tab {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .retention-item,
  .top-player {
    padding: 8px 10px;
  }
}

/* ===== LEADERBOARD MODAL ===== */
.leaderboard-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
}

.leaderboard-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.leaderboard-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(400px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.leaderboard-content h2 {
  margin: 0 0 20px 0;
  font-size: 1.4rem;
  text-align: center;
  color: var(--text);
}

.leaderboard-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease, color 0.2s ease;
}

.leaderboard-close:hover {
  background: var(--surface);
  color: var(--text);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-list p {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.leaderboard-item:nth-child(1) {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
  border-color: #e6c200;
}

.leaderboard-item:nth-child(2) {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
  border-color: #a8a8a8;
}

.leaderboard-item:nth-child(3) {
  background: linear-gradient(135deg, #cd7f32 0%, #e8a860 100%);
  border-color: #b5722d;
}

.leaderboard-rank {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 40px;
  color: var(--text);
}

.leaderboard-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg);
}

.leaderboard-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}

/* ===== TUTORIAL OVERLAY ===== */
.tutorial-overlay {
  --hand-start-x: 0px;
  --hand-start-y: 0px;
  --hand-end-x: 100px;
  --hand-end-y: 0px;
  position: absolute;
  inset: 0;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.tutorial-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.tutorial-hand {
  position: absolute;
  width: 48px;
  height: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M13 1.5c-1.1 0-2 .9-2 2v8.5c0 .3-.2.5-.5.5s-.5-.2-.5-.5V6.5c0-1.1-.9-2-2-2s-2 .9-2 2v8c0 .3-.2.5-.5.5s-.5-.2-.5-.5v-4c0-1.1-.9-2-2-2s-2 .9-2 2v6c0 5.5 4.5 10 10 10 5.5 0 10-4.5 10-10v-6c0-1.1-.9-2-2-2s-2 .9-2 2v4c0 .3-.2.5-.5.5s-.5-.2-.5-.5v-8.5c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%);
  left: var(--hand-start-x);
  top: var(--hand-start-y);
  animation: tutorialDragHand 2s ease-in-out infinite;
}

@keyframes tutorialDragHand {
  0%, 10% {
    left: var(--hand-start-x);
    top: var(--hand-start-y);
    transform: translate(-50%, -50%) scale(1);
  }
  20% {
    left: var(--hand-start-x);
    top: var(--hand-start-y);
    transform: translate(-50%, -40%) scale(0.9);
  }
  70% {
    left: var(--hand-end-x);
    top: var(--hand-end-y);
    transform: translate(-50%, -40%) scale(0.9);
  }
  80%, 100% {
    left: var(--hand-end-x);
    top: var(--hand-end-y);
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Tutorial source tile (drag from here) */
.piece.tutorial-source {
  box-shadow: 0 0 0 4px #4CAF50, 0 0 30px rgba(76, 175, 80, 0.7);
  animation: tutorialSourcePulse 1.2s ease-in-out infinite;
  z-index: 50;
}

.piece.tutorial-source.dragging {
  z-index: 100;
}

@keyframes tutorialSourcePulse {
  0%, 100% {
    box-shadow: 0 0 0 4px #4CAF50, 0 0 30px rgba(76, 175, 80, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px #4CAF50, 0 0 40px rgba(76, 175, 80, 0.9);
  }
}

/* Tutorial target tile (drop here) */
.piece.tutorial-target {
  position: relative;
  box-shadow: 0 0 0 4px #FF9800, 0 0 30px rgba(255, 152, 0, 0.7);
  animation: tutorialTargetPulse 1.2s ease-in-out infinite;
  z-index: 5;
}

.piece.tutorial-target::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 3px dashed #FF9800;
  border-radius: 8px;
  animation: tutorialTargetDash 0.5s linear infinite;
  pointer-events: none;
}

@keyframes tutorialTargetPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px #FF9800, 0 0 30px rgba(255, 152, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px #FF9800, 0 0 45px rgba(255, 152, 0, 0.9);
  }
}

@keyframes tutorialTargetDash {
  0% {
    border-color: #FF9800;
  }
  50% {
    border-color: #FFC107;
  }
  100% {
    border-color: #FF9800;
  }
}

/* ===== HINT SYSTEM ===== */
.game-bottom-actions {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.hint-button-large {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(156, 39, 176, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hint-button-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(156, 39, 176, 0.5);
}

.hint-button-large:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(156, 39, 176, 0.4);
}

.hint-icon {
  font-size: 1rem;
}

.hint-video-icon {
  font-size: 1rem;
  display: none;
}

.hint-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.hint-count-large {
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

/* When hints are empty, show video icon and change style */
.hint-button-large.is-empty {
  background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
  box-shadow: 0 4px 15px rgba(255, 87, 34, 0.4);
}

.hint-button-large.is-empty:hover {
  box-shadow: 0 6px 20px rgba(255, 87, 34, 0.5);
}

.hint-button-large.is-empty .hint-icon {
  display: none;
}

.hint-button-large.is-empty .hint-video-icon {
  display: inline;
}

.hint-button-large.is-empty .hint-count-large {
  display: none;
}

/* Hint highlighted tiles */
.piece.hint-source {
  box-shadow: 0 0 0 4px #9C27B0, 0 0 30px rgba(156, 39, 176, 0.7);
  animation: hintSourcePulse 0.8s ease-in-out infinite;
  z-index: 50;
}

.piece.hint-source.dragging {
  z-index: 100;
}

@keyframes hintSourcePulse {
  0%, 100% {
    box-shadow: 0 0 0 4px #9C27B0, 0 0 30px rgba(156, 39, 176, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px #9C27B0, 0 0 40px rgba(156, 39, 176, 0.9);
  }
}

.piece.hint-target {
  position: relative;
  box-shadow: 0 0 0 4px #E91E63, 0 0 30px rgba(233, 30, 99, 0.7);
  animation: hintTargetPulse 0.8s ease-in-out infinite;
  z-index: 5;
}

.piece.hint-target::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 3px dashed #E91E63;
  border-radius: 8px;
  animation: hintTargetDash 0.4s linear infinite;
  pointer-events: none;
}

@keyframes hintTargetPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px #E91E63, 0 0 30px rgba(233, 30, 99, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px #E91E63, 0 0 45px rgba(233, 30, 99, 0.9);
  }
}

@keyframes hintTargetDash {
  0% {
    border-color: #E91E63;
  }
  50% {
    border-color: #FF4081;
  }
  100% {
    border-color: #E91E63;
  }
}

/* Hint Arrow */
.hint-arrow {
  position: absolute;
  height: 4px;
  display: flex;
  align-items: center;
  transform-origin: left center;
  pointer-events: none;
  z-index: 200;
  animation: hintArrowPulse 1s ease-in-out infinite;
}

.hint-arrow-line {
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, #9C27B0, #E91E63);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(156, 39, 176, 0.8);
}

.hint-arrow-head {
  font-size: 24px;
  color: #E91E63;
  text-shadow: 0 0 10px rgba(233, 30, 99, 0.8);
  margin-left: -5px;
  animation: hintArrowHeadBounce 0.5s ease-in-out infinite;
}

@keyframes hintArrowPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes hintArrowHeadBounce {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(5px);
  }
}

/* ===== SOCIAL PANEL MODAL ===== */
.social-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.social-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.social-modal.is-active .social-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.social-content {
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 24px;
  padding: 28px 24px;
  width: min(360px, 100%);
  position: relative;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: socialModalEntrance 0.4s ease-out;
}

@keyframes socialModalEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.social-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: linear-gradient(180deg, #ff6b6b 0%, #ee5a5a 100%);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 3px 0 #c0392b;
  transition: all 0.15s ease;
  padding: 0;
  aspect-ratio: 1;
}

.social-close:hover {
  transform: scale(1.1);
}

.social-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}

.social-subtitle {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.social-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.social-action-btn:hover {
  background: linear-gradient(145deg, #ffffff 0%, #f1f3f5 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.social-action-btn:active {
  transform: translateY(0);
}

.social-action-icon {
  font-size: 1.5rem;
}

.social-action-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.social-no-features {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 20px;
}

/* ===== POST-LEVEL SHARE POPUP ===== */
.share-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.share-popup.is-active {
  opacity: 1;
  visibility: visible;
}

.share-popup.is-active .share-popup-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.share-popup-content {
  background: linear-gradient(145deg, #ffffff 0%, #f0f8ff 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: sharePopupEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sharePopupEntrance {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(40px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.share-popup-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: shareIconBounce 0.6s ease-out 0.2s both;
}

@keyframes shareIconBounce {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-20deg);
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.share-popup-title {
  margin: 0 0 20px;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.share-popup-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
}

.share-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.share-stat-icon {
  font-size: 1.5rem;
}

.share-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.share-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.share-new-record {
  background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.share-popup-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  width: 100%;
}

.share-popup-btn {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.share-btn-primary {
  background: linear-gradient(180deg, #4267B2 0%, #365899 100%);
  color: white;
  box-shadow: 0 4px 0 #2d4373, 0 6px 16px rgba(66, 103, 178, 0.4);
}

.share-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #2d4373, 0 10px 24px rgba(66, 103, 178, 0.5);
}

.share-btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2d4373;
}

.share-btn-secondary {
  background: linear-gradient(180deg, #6aaa64 0%, #538d4e 100%);
  color: white;
  box-shadow: 0 4px 0 #3a5a34, 0 6px 16px rgba(106, 170, 100, 0.4);
}

.share-btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #3a5a34, 0 10px 24px rgba(106, 170, 100, 0.5);
}

.share-btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #3a5a34;
}

/* Share bonus badge */
.share-bonus-badge {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #5d4037;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: bonusPulse 1.5s ease-in-out infinite;
}

@keyframes bonusPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ===== RETENTION PROMPT ===== */
.retention-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 450;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.retention-prompt.is-active {
  opacity: 1;
  visibility: visible;
}

.retention-prompt.is-active .retention-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.retention-content {
  background: linear-gradient(145deg, #ffffff 0%, #fff5f5 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  position: relative;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: retentionEntrance 0.4s ease-out;
}

@keyframes retentionEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.retention-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
  padding: 0;
}

.retention-close:hover {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}

.retention-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.retention-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}

.retention-message {
  margin: 0 0 20px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.retention-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.retention-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, #ff6b8a 0%, #ee5a79 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #c74b68, 0 6px 16px rgba(238, 90, 121, 0.4);
  transition: all 0.2s ease;
}

.retention-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #c74b68, 0 10px 24px rgba(238, 90, 121, 0.5);
}

.retention-action-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c74b68;
}

.retention-later-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s ease;
}

.retention-later-btn:hover {
  color: var(--text);
}

/* ===== RATE PROMPT ===== */
.rate-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 450;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.rate-prompt.is-active {
  opacity: 1;
  visibility: visible;
}

.rate-prompt.is-active .rate-content {
  animation: popupSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.rate-content {
  background: linear-gradient(145deg, #ffffff 0%, #fffbeb 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  position: relative;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: rateEntrance 0.4s ease-out;
}

@keyframes rateEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.rate-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
  padding: 0;
}

.rate-close:hover {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}

.rate-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: starSpin 0.6s ease-out;
}

@keyframes starSpin {
  0% {
    transform: scale(0) rotate(-180deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.rate-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}

.rate-message {
  margin: 0 0 24px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.rate-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rate-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #e69500, 0 6px 16px rgba(255, 179, 0, 0.4);
  transition: all 0.2s ease;
}

.rate-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #e69500, 0 10px 24px rgba(255, 179, 0, 0.5);
}

.rate-action-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #e69500;
}

.rate-later-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s ease;
}

.rate-later-btn:hover {
  color: var(--text);
}

/* ===== LOCKED LEVEL POPUP ===== */
.locked-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.locked-popup.is-active {
  opacity: 1;
  visibility: visible;
}

.locked-popup-content {
  background: linear-gradient(145deg, #ffffff 0%, #f0f0ff 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: lockedPopupEntrance 0.4s ease-out;
}

@keyframes lockedPopupEntrance {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.locked-popup-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: lockShake 0.5s ease-out;
}

@keyframes lockShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
}

.locked-popup-subtitle {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 500;
  color: #666;
}

.locked-collection-name {
  margin: 0 0 16px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #5a3d8a;
}

.locked-ad-progress {
  background: rgba(138, 99, 210, 0.1);
  color: #8a63d2;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: inline-block;
}

.locked-popup-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.locked-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, #8a63d2 0%, #6a43b2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #4a2382, 0 6px 16px rgba(138, 99, 210, 0.4);
  transition: all 0.2s ease;
}

.locked-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #4a2382, 0 10px 24px rgba(138, 99, 210, 0.5);
}

.locked-btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #4a2382;
}

.ad-count-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.locked-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, #ffd54f 0%, #ffb300 100%);
  color: #5d4037;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #e69500, 0 6px 16px rgba(255, 179, 0, 0.4);
  transition: all 0.2s ease;
}

.locked-btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #e69500, 0 10px 24px rgba(255, 179, 0, 0.5);
}

.locked-btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #e69500;
}

.locked-btn-cancel {
  background: none;
  border: none;
  color: #888;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 10px;
  transition: color 0.2s ease;
}

.locked-btn-cancel:hover {
  color: #333;
}

/* ===== COLLECTION UNLOCKED POPUP ===== */
.collection-unlocked-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.collection-unlocked-popup.is-active {
  opacity: 1;
  visibility: visible;
}

.collection-unlocked-content {
  background: linear-gradient(145deg, #ffffff 0%, #f5fff5 100%);
  border-radius: 24px;
  padding: 32px 28px;
  width: min(340px, 100%);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: unlockPopupEntrance 0.5s ease-out;
}

@keyframes unlockPopupEntrance {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  50% {
    transform: scale(1.05) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.unlock-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: celebrationBounce 1s ease-out infinite;
}

@keyframes celebrationBounce {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.1) translateY(-10px); }
}

.unlock-title {
  margin: 0 0 12px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
}

.unlocked-collection-name {
  margin: 0 0 24px;
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6aaa64 0%, #4a8a44 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.unlock-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unlock-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, #6aaa64 0%, #4a8a44 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #3a6a34, 0 6px 16px rgba(106, 170, 100, 0.4);
  transition: all 0.2s ease;
}

.unlock-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #3a6a34, 0 10px 24px rgba(106, 170, 100, 0.5);
}

.unlock-btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #3a6a34;
}

.unlock-btn-secondary {
  background: none;
  border: 2px solid rgba(106, 170, 100, 0.3);
  color: #4a8a44;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 20px;
  border-radius: 50px;
  transition: all 0.2s ease;
}

.unlock-btn-secondary:hover {
  background: rgba(106, 170, 100, 0.1);
  border-color: rgba(106, 170, 100, 0.5);
}

/* ===== DEBUG MENU ===== */
.debug-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 30, 40, 0.98);
  border: 2px solid #444;
  border-radius: 12px;
  z-index: 99999;
  min-width: 280px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.debug-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #333;
  border-bottom: 1px solid #444;
  border-radius: 10px 10px 0 0;
  color: #ff6b6b;
  font-weight: 700;
  font-size: 0.9rem;
}

.debug-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.debug-close:hover {
  color: #fff;
}

.debug-menu-content {
  padding: 12px;
}

.debug-section {
  margin-bottom: 16px;
}

.debug-section:last-child {
  margin-bottom: 0;
}

.debug-section-title {
  color: #888;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-left: 4px;
}

.debug-btn {
  display: inline-block;
  padding: 8px 12px;
  margin: 3px;
  background: #444;
  color: #fff;
  border: 1px solid #555;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.debug-btn:hover {
  background: #555;
  border-color: #666;
}

.debug-btn:active {
  background: #666;
  transform: scale(0.98);
}

.debug-btn-wide {
  display: block;
  width: 100%;
  margin: 3px 0;
}

/* ===== RESPONSIVE MODALS - MOBILE & LANDSCAPE ===== */

/* Small screens (width-based) */
@media (max-width: 400px) {
  .social-content,
  .share-popup-content,
  .locked-popup-content,
  .collection-unlocked-content,
  .vip-content,
  .settings-content,
  .quests-content {
    padding: 20px 16px;
    border-radius: 16px;
  }

  .social-title,
  .share-popup-title {
    font-size: 1.3rem;
  }

  .social-subtitle {
    font-size: 0.8rem;
    margin-bottom: 14px;
  }

  .social-action-btn {
    padding: 12px 14px;
    gap: 10px;
  }

  .social-action-icon {
    font-size: 1.3rem;
  }

  .social-action-text {
    font-size: 0.9rem;
  }

  .share-popup-icon,
  .unlock-icon {
    font-size: 3rem;
    margin-bottom: 8px;
  }

  .locked-popup-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
  }

  .share-popup-stats {
    gap: 20px;
  }

  .share-stat-icon {
    font-size: 1.2rem;
  }

  .share-stat-value {
    font-size: 1.1rem;
  }

  .share-popup-btn,
  .locked-btn-primary,
  .locked-btn-secondary,
  .unlock-btn-primary,
  .unlock-btn-secondary {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .quests-content h2 {
    font-size: 1.3rem;
  }

  .quests-subtitle {
    font-size: 0.8rem;
  }

  .quest-item {
    padding: 12px;
  }

  .vip-modal-icon {
    width: 50px;
    height: 50px;
  }

  .vip-content h2 {
    font-size: 1.4rem;
  }

  .vip-content p {
    font-size: 0.85rem;
  }
}

/* Landscape mode - short height */
@media (max-height: 500px) {
  .social-modal,
  .share-popup,
  .locked-popup,
  .collection-unlocked-popup,
  .vip-modal,
  .settings-modal,
  .quests-modal,
  .vip-success-popup {
    padding: 8px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .social-content,
  .share-popup-content,
  .locked-popup-content,
  .collection-unlocked-content,
  .vip-content,
  .settings-content,
  .quests-content,
  .vip-success-content {
    padding: 16px 14px;
    border-radius: 14px;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    margin: auto;
  }

  .social-title,
  .share-popup-title,
  .unlock-title {
    font-size: 1.1rem;
    margin-bottom: 6px;
  }

  .social-subtitle,
  .quests-subtitle {
    font-size: 0.75rem;
    margin-bottom: 10px;
  }

  .social-close,
  .quests-close,
  .settings-close {
    width: 28px;
    height: 28px;
    font-size: 1rem;
    top: 8px;
    right: 8px;
  }

  .social-buttons {
    gap: 6px;
  }

  .social-action-btn {
    padding: 10px 12px;
    gap: 8px;
    border-radius: 10px;
  }

  .social-action-icon {
    font-size: 1.2rem;
  }

  .social-action-text {
    font-size: 0.85rem;
  }

  .share-popup-icon,
  .unlock-icon {
    font-size: 2.5rem;
    margin-bottom: 6px;
  }

  .locked-popup-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
  }

  .share-popup-stats {
    gap: 16px;
    margin-bottom: 10px;
  }

  .share-stat-icon {
    font-size: 1rem;
  }

  .share-stat-label {
    font-size: 0.65rem;
  }

  .share-stat-value {
    font-size: 1rem;
  }

  .share-new-record {
    padding: 6px 14px;
    font-size: 0.8rem;
    margin-bottom: 12px;
  }

  .share-popup-buttons,
  .locked-popup-buttons,
  .unlock-buttons {
    gap: 8px;
    margin-top: 12px;
  }

  .share-popup-btn,
  .locked-btn-primary,
  .locked-btn-secondary,
  .unlock-btn-primary,
  .unlock-btn-secondary {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-radius: 25px;
  }

  .locked-popup-subtitle {
    font-size: 0.85rem;
    margin-bottom: 4px;
  }

  .locked-collection-name,
  .unlocked-collection-name {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .locked-ad-progress {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
  }

  .quests-content {
    max-height: calc(100dvh - 16px);
    padding: 14px 12px;
  }

  .quests-content h2 {
    font-size: 1.2rem;
    margin-bottom: 2px;
  }

  .quests-list {
    max-height: calc(100dvh - 120px);
  }

  .quest-item {
    padding: 10px;
    gap: 10px;
  }

  .quest-icon {
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
  }

  .quest-name {
    font-size: 0.85rem;
  }

  .quest-desc {
    font-size: 0.7rem;
  }

  .quest-reward {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .vip-content {
    padding: 16px;
  }

  .vip-modal-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
  }

  .vip-content h2 {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  .vip-content .vip-subtitle {
    font-size: 0.8rem;
    margin-bottom: 10px;
  }

  .vip-content p {
    font-size: 0.8rem;
    margin-bottom: 14px;
  }

  .vip-buy-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .settings-content {
    padding: 16px;
  }

  .settings-content h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .settings-option {
    padding: 8px 0;
  }

  .settings-label {
    font-size: 0.9rem;
  }

  .toggle-button {
    width: 44px;
    height: 24px;
  }

  .toggle-slider {
    width: 18px;
    height: 18px;
  }

  .toggle-button.is-on .toggle-slider {
    transform: translateX(20px);
  }
}

/* Very short landscape (e.g., iPhone SE landscape) */
@media (max-height: 400px) {
  .social-content,
  .share-popup-content,
  .locked-popup-content,
  .collection-unlocked-content,
  .vip-content,
  .settings-content,
  .quests-content {
    padding: 12px 10px;
  }

  .social-title,
  .share-popup-title,
  .unlock-title {
    font-size: 1rem;
  }

  .share-popup-icon,
  .unlock-icon {
    font-size: 2rem;
    margin-bottom: 4px;
  }

  .locked-popup-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
  }

  .share-popup-stats {
    gap: 12px;
    margin-bottom: 8px;
  }

  .share-popup-buttons,
  .locked-popup-buttons,
  .unlock-buttons,
  .social-buttons {
    gap: 6px;
  }

  .share-popup-btn,
  .locked-btn-primary,
  .locked-btn-secondary,
  .unlock-btn-primary,
  .unlock-btn-secondary,
  .social-action-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .quests-content h2 {
    font-size: 1rem;
  }

  .quests-list {
    max-height: calc(100dvh - 100px);
  }

  .quest-item {
    padding: 8px;
  }

  .quest-icon {
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
  }
}

/* ===== LOW-END DEVICE OPTIMIZATIONS ===== */
/* Applied via JS: document.documentElement.classList.add('low-end-device') */

/* Disable expensive shine animations */
.low-end-device .board.is-solved .piece::after {
  animation: none !important;
  background: none !important;
}

/* Reduce animation durations */
.low-end-device .piece {
  animation-duration: 0.15s !important;
  transition-duration: 0.15s !important;
}

/* Disable complex glow effects */
.low-end-device .board-shell:has(.board.is-solved) {
  animation: none !important;
}

/* Simplify confetti animations */
.low-end-device .confetti {
  animation-duration: 2s !important;
}

/* Disable celebration bounces */
.low-end-device .unlock-icon,
.low-end-device .celebration-star {
  animation: none !important;
}

/* Reduce firework complexity */
.low-end-device .firework,
.low-end-device .sparkle {
  animation-duration: 0.6s !important;
}

/* Disable backdrop blur (expensive on mobile) */
.low-end-device .social-modal,
.low-end-device .share-popup,
.low-end-device .retention-prompt,
.low-end-device .rate-prompt,
.low-end-device .vip-modal,
.low-end-device .settings-modal,
.low-end-device .quests-modal {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Simplify box shadows */
.low-end-device .piece.dragging {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
}

/* Disable tutorial pulse animations */
.low-end-device .piece.tutorial-source,
.low-end-device .piece.tutorial-target,
.low-end-device .piece.hint-source,
.low-end-device .piece.hint-target {
  animation: none !important;
}

/* Use simpler transforms */
.low-end-device .level-tile-inner {
  transition-duration: 0.3s !important;
}

/* Reduce modal animation complexity */
.low-end-device .social-content,
.low-end-device .share-popup-content,
.low-end-device .locked-popup-content,
.low-end-device .collection-unlocked-content {
  animation-duration: 0.2s !important;
}
