/* ==========================================================================
   SENTINELLEFT - Cyber-Radar Minimum Dominating Set Defense Design System
   Copyright (C) 2026 Left Gaming / Douglas Knoll
   SPDX-License-Identifier: GPL-3.0-or-later
   Released under the GNU General Public License v3.0 or later.
   ========================================================================== */

:root {
  --bg-main: #050713;
  --bg-gradient: radial-gradient(circle at 50% 35%, #0e162f 0%, #050713 75%, #020308 100%);
  --surface-glass: rgba(12, 18, 36, 0.78);
  --surface-glass-hover: rgba(22, 32, 60, 0.88);
  --surface-card: rgba(16, 24, 46, 0.94);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-glow: rgba(0, 240, 255, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.5);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.55);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.5);
  --accent-crimson: #f43f5e;
  --accent-crimson-glow: rgba(244, 63, 94, 0.65);

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 12px 40px -4px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

/* Header & HUD */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 10;
  gap: 16px;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 1.15rem;
  background: linear-gradient(135deg, #10b981 0%, #00f0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 26px;
  height: 26px;
  color: var(--accent-emerald);
  filter: drop-shadow(0 0 8px var(--accent-emerald-glow));
}

.mission-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mission-badge:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-glass-glow);
}

.mission-badge .label {
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.mission-badge .val {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.mission-badge .chevron-icon {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.mission-badge:hover .chevron-icon {
  color: var(--text-primary);
  transform: translateY(1px);
}

/* Header Stats */
.header-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  min-width: 84px;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.coverage-stat {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.coverage-stat .stat-value {
  color: var(--accent-emerald);
  text-shadow: 0 0 10px var(--accent-emerald-glow);
}

.coverage-stat.full-coverage {
  border-color: rgba(0, 240, 255, 0.5);
  background: rgba(0, 240, 255, 0.15);
}

.coverage-stat.full-coverage .stat-value {
  color: #fff;
  text-shadow: 0 0 14px var(--accent-cyan-glow);
}

.sentinel-stat {
  border-color: rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
  transition: all 0.25s ease;
}

.sentinel-stat .stat-value {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
}

.sentinel-stat.at-limit {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.14);
}

.sentinel-stat.at-limit .stat-value {
  color: var(--accent-amber);
  text-shadow: 0 0 10px var(--accent-amber-glow);
}

@keyframes limitShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.sentinel-limit-shake {
  animation: limitShake 0.3s ease;
  border-color: var(--accent-crimson) !important;
}

.conflict-stat {
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.12);
  transition: all 0.3s ease;
}

.conflict-stat .stat-value {
  color: var(--accent-crimson);
  text-shadow: 0 0 12px var(--accent-crimson-glow);
}

.conflict-stat.zero-conflict {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.conflict-stat.zero-conflict .stat-value {
  color: var(--text-secondary);
  text-shadow: none;
}

/* Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.icon-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Playfield */
.game-board {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

/* Canvas Instructions Footer */
.canvas-footer-tip {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 28, 0.75);
  backdrop-filter: blur(10px);
  padding: 8px 20px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  font-size: 0.85rem;
  color: var(--text-secondary);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

.canvas-footer-tip strong {
  color: var(--text-primary);
}

/* Hint Toast */
.hint-toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #d1fae5;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
}

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

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 10, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: var(--surface-card);
  border: 1px solid var(--border-glass-glow);
  box-shadow: var(--shadow-elevated), 0 0 50px rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px;
  position: relative;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-large {
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes modalScaleUp {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s ease;
}

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

/* Mission Grid */
.mission-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.mission-btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.mission-btn:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--accent-emerald);
  transform: translateY(-2px);
}

.mission-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(0, 240, 255, 0.3));
  border-color: var(--accent-emerald);
  box-shadow: 0 0 16px var(--accent-emerald-glow);
}

.mission-btn .star-indicator {
  font-size: 0.62rem;
  letter-spacing: -1px;
  margin-top: 2px;
  color: var(--accent-amber);
}

/* Sandbox Form */
.sandbox-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.slider-val {
  color: var(--accent-emerald);
  font-weight: 700;
  font-family: var(--font-mono);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Primary / Secondary Buttons */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, #10b981 0%, #00f0ff 100%);
  color: #040612;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.4);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.55);
}

.btn-secondary {
  width: 100%;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Help Content */
.help-content {
  color: var(--text-secondary);
  line-height: 1.65;
  font-size: 0.92rem;
}

.help-content h3 {
  color: var(--text-primary);
  font-size: 1.05rem;
  margin-top: 18px;
  margin-bottom: 6px;
}

.help-content h3:first-of-type {
  margin-top: 0;
}

.math {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-weight: 600;
}

.math-equation {
  margin: 12px 0;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.4);
  border-left: 3px solid var(--accent-emerald);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: #38bdf8;
  font-weight: 700;
  text-align: center;
}

.keyboard-shortcuts {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-glass);
}

.keyboard-shortcuts h4 {
  color: var(--text-primary);
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.keyboard-shortcuts ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-shortcuts kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* Victory Overlay */
.victory-card {
  text-align: center;
  max-width: 420px;
}

.victory-trophy {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trophy-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-emerald-glow) 0%, transparent 70%);
  animation: pulseGlow 2s infinite ease-in-out;
}

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

.trophy-emoji {
  font-size: 2.5rem;
  z-index: 1;
}

.star-rating {
  font-size: 1.6rem;
  letter-spacing: 4px;
  margin-bottom: 12px;
  color: var(--accent-amber);
}

.victory-title {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #10b981 0%, #00f0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.victory-subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.v-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

.v-stat-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.v-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.victory-buttons {
  display: flex;
  gap: 12px;
}

/* Utilities */
.hidden {
  display: none !important;
}

.font-mono {
  font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 680px) {
  .game-header {
    padding: 10px 14px;
  }
  .logo-text {
    display: none;
  }
  .stat-card {
    min-width: 62px;
    padding: 4px 8px;
  }
  .stat-label {
    font-size: 0.58rem;
  }
  .stat-value {
    font-size: 0.92rem;
  }
  .header-actions {
    gap: 4px;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  .canvas-footer-tip {
    font-size: 0.75rem;
    padding: 6px 14px;
    bottom: 12px;
    width: 90%;
    white-space: normal;
  }
}


/* --- Left Gaming Cross-Navigation Bar --- */
.lg-crossnav {
  width: 100%;
  background: rgba(6, 8, 14, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  position: relative;
  z-index: 9999;
  box-sizing: border-box;
}
.is-in-iframe .lg-crossnav {
  display: none !important;
}
.lg-crossnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lg-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #00f0ff;
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.lg-back-link:hover {
  background: rgba(0, 240, 255, 0.12);
}
.lg-game-dropdown {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lg-hub-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.1em;
}
.lg-nav-select {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}
.lg-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lg-fullscreen-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #94a3b8;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.lg-fullscreen-btn:hover {
  color: #fff;
  border-color: #00f0ff;
  background: rgba(0, 240, 255, 0.08);
}
@media (max-width: 600px) {
  .lg-back-text {
    display: none;
  }
}
