#puzzle-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none; /* Hidden by default */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#puzzle-overlay.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

.puzzle-container {
  background: #fff;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  max-width: 95vw;
}

.puzzle-header {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 24px;
    font-weight: 700;
}

#puzzle-message h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 24px;
}

#puzzle-canvas {
  cursor: pointer;
  border: 4px solid #333;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  max-width: 100%;
  height: auto;
}

.puzzle-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.puzzle-controls button {
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: none;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.puzzle-controls .button-1 {
  background: #222;
  color: #fff;
}

.puzzle-controls .button-2 {
  background: #eee;
  color: #222;
}

.puzzle-controls button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.puzzle-controls button:active {
  transform: translateY(-1px);
}

/* Subtler Badge */
.puzzle-hint-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 999;
  animation: puzzle-pulse 3s infinite ease-in-out;
}

/* Pulse animation for the badge */
@keyframes puzzle-pulse {
  0% { transform: scale(1); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
  50% { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
  100% { transform: scale(1); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
}

/* Success Banner */
.puzzle-success-banner {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(46, 204, 113, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

.puzzle-success-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.puzzle-hint-badge:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.15) rotate(15deg);
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

.puzzle-hint-badge::after {
  content: '🧩';
  font-size: 18px;
}

/* Aggressive Hiding for Zero Distraction Mode */
.puzzle-open .search-box, 
.puzzle-open .header-links,
.puzzle-open .top-menu,
.puzzle-open .header-menu,
.puzzle-open .menu-container,
.puzzle-open .menu,
.puzzle-open .header {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ensure the overlay covers everything even more robustly */
.puzzle-open #puzzle-overlay {
    display: flex !important;
    opacity: 1 !important;
    z-index: 2147483647 !important;
}