/* ============================================
   GAME PAGES COMMON STYLES
   Hybrid design: Light page with dark game canvas
   ============================================ */

/* ============================================
   OVERRIDE MATZKA.CSS FOR GAME PAGES
   ============================================ */

body {
  background-color: #F9FAFB !important;
  scroll-behavior: smooth;
  overflow-x: hidden;
  padding-top: 50px;
}

main {
  background-color: #F9FAFB !important;
  padding-top: 0;
}

/* ============================================
   FIXED HEADER BAR (50px)
   ============================================ */

.game-header-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
  z-index: 100;
  gap: 1rem;
}

.game-header-title {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}

.game-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.game-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.game-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.game-header-btn:active {
  transform: translateY(0);
}

/* ============================================
   LIGHT HEADER WITH GRADIENT (HIDDEN - REPLACED BY FIXED HEADER)
   ============================================ */

.header-container {
  display: none;
}

.header-container h1 {
  color: white !important;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.header-container .subtitle {
  color: white !important;
  opacity: 0.95;
  font-size: 1rem;
  font-weight: 400;
}

/* Keep logo styling */
.logo-container {
  display: none; /* Hide logo on game pages */
}

/* ============================================
   KEEP GAME CANVAS DARK
   ============================================ */

#game-container {
  background-color: #000 !important;
}

canvas {
  background-color: #000 !important;
}

/* ============================================
   INSTRUCTIONS SECTION - MODAL OVERLAY
   ============================================ */

.instructions-section {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.instructions-section.active {
  display: flex;
}

.instructions-container {
  max-width: 800px;
  width: 100%;
  background-color: white;
  border-radius: 12px;
  padding: 2rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
}

.instructions-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6B7280;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.instructions-close-btn:hover {
  background-color: #F3F4F6;
  color: #111827;
}

/* Instructions toggle is now in header - style as header button */
#toggle-instructions {
  /* Style inherited from .game-header-btn */
}

.toggle-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.toggle-text {
  line-height: 1;
}

.instructions-content {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border-radius: 12px;
  border: 2px solid #1E3A8A;
  color: #111827;
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.instructions-content h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #1E3A8A;
  font-weight: 700;
}

.instruction-block {
  margin-bottom: 1.5rem;
}

.instruction-block:last-child {
  margin-bottom: 0;
}

.instruction-block h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #1E3A8A;
  font-weight: 600;
}

.instruction-block p {
  color: #374151;
  line-height: 1.6;
  margin: 0;
}

.instruction-block ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.instruction-block ul li {
  padding: 0.375rem 0;
  color: #374151;
  position: relative;
  padding-left: 1.5rem;
  line-height: 1.5;
}

.instruction-block ul li:before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #1E3A8A;
  font-weight: bold;
  font-size: 1.2rem;
}

/* ============================================
   IMPROVED BACK BUTTON
   ============================================ */

.back-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: white;
  color: #1E3A8A;
  border: 2px solid #1E3A8A;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
  margin-top: 2rem;
  cursor: pointer;
}

.back-link:hover {
  background-color: #1E3A8A;
  color: white;
  box-shadow: 0 8px 16px rgba(30, 58, 138, 0.2);
  transform: translateY(-2px);
  text-decoration: none;
}

.back-link:active {
  transform: translateY(0);
}

.back-button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: white;
  color: #1E3A8A;
  border: 2px solid #1E3A8A;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.back-button:hover {
  background-color: #1E3A8A;
  color: white;
  box-shadow: 0 8px 16px rgba(30, 58, 138, 0.2);
  transform: translateY(-2px);
  text-decoration: none;
}

.back-button:active {
  transform: translateY(0);
}

/* ============================================
   GAME WRAPPER & SIDEBAR ADJUSTMENTS
   ============================================ */

#game-wrapper {
  background-color: #F9FAFB;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 2rem auto;
  max-width: fit-content;
}

#sidebar {
  background-color: transparent;
}

.stat-box {
  background-color: var(--background-color-card, #1F2937) !important;
  border: 1px solid var(--border-color, #374151) !important;
}

/* ============================================
   GAME OVER OVERLAY
   ============================================ */

#game-over-overlay {
  background-color: rgba(0, 0, 0, 0.9) !important;
}

#game-over-overlay h2 {
  color: #DC2626 !important;
}

.btn {
  background-color: #1E3A8A;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.1s ease;
  font-size: 1rem;
  font-family: inherit;
}

.btn:hover {
  background-color: #1e40af;
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-color, #DC2626) !important;
}

/* ============================================
   GAME TOOL BUTTONS (Sidebar)
   Used across different games (Routing, Firewall, etc.)
   ============================================ */

.tool-btn, .tower-btn {
  background-color: var(--background-color-card, #1F2937) !important;
  border: 1px solid var(--border-color, #374151) !important;
  color: #FFFFFF !important; /* Ensure white text for visibility on dark buttons */
  padding: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
  width: 100%;
  font-family: inherit;
  font-weight: 500;
}

.tool-btn:hover, .tower-btn:hover {
  background-color: rgba(30, 58, 138, 0.2) !important;
  border-color: var(--primary-color, #1E3A8A) !important;
  color: #FFFFFF !important;
}

.tool-btn.active, .tower-btn.active {
  background-color: var(--primary-color, #1E3A8A) !important;
  border-color: var(--primary-color, #1E3A8A) !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 12px rgba(30, 58, 138, 0.3);
}

.tool-icon, .tower-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE GAME PAGE
   ============================================ */

@media (max-width: 768px) {
  body {
    padding-top: 50px;
  }

  .game-header-bar {
    padding: 0 1rem;
    height: 50px;
  }

  .game-header-title {
    font-size: 1rem;
  }

  .game-header-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }

  .instructions-container {
    padding: 1.5rem;
  }

  #game-wrapper {
    flex-direction: column !important;
    align-items: center !important;
  }

  #sidebar {
    display: none;
  }

  .instructions-container {
    padding: 0 1rem;
  }

  .instructions-content {
    padding: 1rem;
  }

  .instructions-content h3 {
    font-size: 1.25rem;
  }

  .instruction-block h4 {
    font-size: 1rem;
  }

  .instruction-block p,
  .instruction-block ul li {
    font-size: 0.95rem;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.instructions-toggle:focus,
.back-link:focus,
.back-button:focus {
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
