/* Game Integration Styles 🎮 - CLEAN VERSION */

/* ===== FULLSCREEN GAME BACKGROUND ===== */
.game-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  opacity: 0; /* Start hidden to prevent FOUC */

  /* Tiled grass background - matches actual game texture (grass-middle.png) */
  background-color: #384535; /* Fallback colour */
  background-image: url('/game-assets/grass-tile-bg.png');
  background-repeat: repeat;
  background-size: 32px 32px; /* Game displays at 32x32 (scaled from 16x16) */
  image-rendering: pixelated; /* Crisp pixel art rendering */
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;

  transition: opacity 0.6s ease-in; /* Smooth fade-in when loaded */
}

/* Game loaded state - fade in smoothly */
.game-background.game-loaded {
  opacity: 1;
}

/* Clean canvas styling - no important overrides */
.game-background canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Game disabled state - use visibility instead of display to maintain layout */
.game-background.game-disabled {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Ensure game is visible when not disabled */
.game-background:not(.game-disabled) {
  visibility: visible;
  opacity: 1;
}

/* Game active state (when Konami mode is enabled) */
.game-background.game-active {
  z-index: 1000;
  pointer-events: auto;
}

/* ===== KONAMI GAME MODE ===== */
/* Hide main site content when in game mode */
.site-container {
  opacity: 1;
  transition: opacity 0.75s ease;
}

body.konami-mode .site-container {
  opacity: 0;
  pointer-events: none;
}

body.konami-mode .theme-toggle,
body.konami-mode .accessibility-toggle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.75s ease;
}

/* Show game UI when in Konami mode */
body.konami-mode .game-ui {
  display: block;
}

/* Game UI container (hidden by default) */
.game-ui {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  pointer-events: none;
}

/* Character stats in top-left during game mode */
.game-ui .character-stats {
  position: absolute;
  top: 20px;
  left: 20px;
  background: var(--colour-bg-secondary);
  border: var(--border-main);
  border-radius: 8px;
  padding: var(--spacing-md);
  box-shadow: var(--shadow-main);
  pointer-events: auto;
}

.game-ui .character-portrait {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.game-ui .character-portrait img {
  width: 48px;
  height: 48px;
  border: 1px solid var(--colour-border-light);
  background-color: var(--colour-highlight-bg);
}

.game-ui .character-info {
  color: var(--colour-text-primary);
  font-family: var(--font-family-serif);
}

.game-ui .character-name {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.game-ui .character-level {
  font-size: 0.9rem;
  color: var(--colour-text-secondary);
  margin-bottom: 8px;
}

/* Exit hint */
.game-ui .exit-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 4px;
  font-family: var(--font-family-mono);
  font-size: 0.9rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Hide game on mobile and for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .game-background {
    display: none;
  }
}

@media (max-width: 768px) {
  .game-background {
    display: none;
  }
}

/* ===== KONAMI CODE HINT MESSAGES ===== */
.konami-hint {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.85);
  color: #00ff00;
  padding: 12px 20px;
  border-radius: 8px;
  border: 2px solid #00ff00;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 255, 0, 0.3);
}

.konami-hint.show {
  opacity: 1;
  transform: translateY(0);
}

/* Special styling for success/activation message - full screen flash */
.konami-hint.activation {
  /* Center on screen */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);

  /* Larger and more prominent */
  padding: 32px 48px;
  font-size: 32px;
  border-width: 4px;
  border-radius: 16px;
  text-align: center;
  max-width: 90vw;

  /* Vibrant glow effect */
  background: linear-gradient(135deg, rgba(0, 255, 0, 0.25), rgba(0, 200, 255, 0.25)), rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 40px rgba(0, 255, 0, 0.6),
    0 0 80px rgba(0, 255, 0, 0.4),
    inset 0 0 20px rgba(0, 255, 0, 0.2);
}

.konami-hint.activation.show {
  transform: translate(-50%, -50%) scale(1);
  animation: konamiFlash 3.5s ease-out forwards;
}

@keyframes konamiFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  15% {
    transform: translate(-50%, -50%) scale(1);
  }
  85% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
}

/* ===== LOAD TIMING OVERLAY (DEBUG - DEV ONLY) ===== */
#load-timing-overlay {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.9);
  color: #00ff00;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 12px;
  border-radius: 4px;
  border: 1px solid #00ff00;
  z-index: 9999;
  max-width: 450px;
  pointer-events: auto;
  line-height: 1.6;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

#load-timing-overlay .timing-header {
  font-weight: bold;
  color: #ffff00;
  margin-bottom: 8px;
  border-bottom: 1px solid #00ff00;
  padding-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#load-timing-overlay .timing-header-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

#load-timing-overlay .copy-button {
  background: #00ff00;
  color: #000;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  transition: background 0.2s;
  margin: 2px;
}

#load-timing-overlay .copy-button:hover {
  background: #00ffff;
}

#load-timing-overlay .copy-button:active {
  background: #ffff00;
}

#load-timing-overlay .copy-button.copied {
  background: #ffff00;
  color: #000;
}

#load-timing-overlay .timing-entry {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

#load-timing-overlay .timing-label {
  color: #00ffff;
}

#load-timing-overlay .timing-value {
  color: #00ff00;
  font-weight: bold;
  margin-left: 12px;
}

#load-timing-overlay .timing-phase {
  color: #ff00ff;
  font-style: italic;
  margin-top: 4px;
}

#load-timing-overlay.hidden {
  display: none;
}

/* ===== FEATURE FLAGS SECTION (DEBUG - DEV ONLY) ===== */
#feature-flags-section {
  border-bottom: 1px solid #00ff00;
  margin-bottom: 12px;
  padding-bottom: 8px;
}

.feature-flags-header {
  font-weight: bold;
  color: #ffff00;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.feature-flags-header:hover {
  color: #ffff77;
}

.collapse-toggle {
  background: transparent;
  border: 1px solid #00ff00;
  color: #00ff00;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
  line-height: 1;
  min-width: 24px;
  margin: 0 0 0 5px;
}

.collapse-toggle:hover {
  background: #00ff00;
  color: #000;
}

.feature-flags-content {
  margin-top: 8px;
}

.feature-flag-empty {
  color: #999;
  font-size: 11px;
  font-style: italic;
  padding: 4px 0;
}

.feature-flag-select-wrapper {
  margin: 8px 0;
}

.feature-flag-select-label {
  display: block;
  color: #00ffff;
  font-size: 11px;
  margin-bottom: 4px;
}

.feature-flag-select {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #00ff00;
  color: #00ff00;
  padding: 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
}

.feature-flag-select:hover {
  border-color: #00ffff;
}

.feature-flag-select:focus {
  outline: none;
  border-color: #ffff00;
}

.feature-flag-select optgroup {
  color: #ff00ff;
  font-weight: bold;
}

.feature-flag-select option {
  color: #00ff00;
  background: #1a1a1a;
  padding: 4px;
}

.feature-flag-checkbox-area {
  margin-top: 12px;
  padding: 8px;
  background: rgba(0, 255, 0, 0.05);
  border: 1px solid #00ff00;
  border-radius: 3px;
}

.feature-flag-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 6px;
}

.feature-flag-checkbox {
  cursor: pointer;
  margin-right: 8px;
  accent-color: #00ff00;
  width: 18px;
  height: 18px;
}

.feature-flag-checkbox-text {
  color: #00ffff;
  font-size: 13px;
  font-weight: bold;
  user-select: none;
}

.feature-flag-description {
  color: #999;
  font-size: 10px;
  line-height: 1.4;
  margin-top: 4px;
}

.reset-flags-button {
  background: #333;
  border: 1px solid #ff00ff;
  color: #ff00ff;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
  margin-top: 8px;
  width: 100%;
}

.reset-flags-button:hover {
  background: #ff00ff;
  color: #000;
}

.reset-flags-button:active {
  transform: scale(0.98);
}