:root {
  --primary: #6366f1; 
  --primary-hover: #4f46e5;
  --secondary: #ec4899; 
  --accent: #14b8a6; 
  --bg-color: #0f172a; 
  --bg-panel: rgba(30, 41, 59, 0.7); 
  --text-main: #f8fafc; 
  --text-muted: #94a3b8; 
  --glass-border: rgba(255, 255, 255, 0.1);
  --success: #22c55e;
  --font-main: 'Inter', sans-serif;
  --font-mono: 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  padding: 2vh 2vw;
}


.background-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: float 10s infinite alternate ease-in-out;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: var(--secondary);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}


.game-container {
  width: 95%;
  max-width: 1200px;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}


.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.level-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.info-panel {
  min-height: 120px;
  border-left: 4px solid var(--accent);
  transition: opacity 0.3s ease;
}

.info-panel.hidden {
  opacity: 0;
  pointer-events: none;
}

.info-panel h3 {
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}


.progress-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  position: relative;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-bar::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--glass-border);
  z-index: 0;
}

.step {
  position: relative;
  z-index: 1;
  background: var(--bg-color);
  border: 2px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.3s ease;
}

.step.active {
  border-color: var(--primary);
  color: var(--text-main);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.step.completed {
  border-color: var(--success);
  color: var(--success);
}


input[type="text"] {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 20px;
}

input[type="text"]:focus {
  border-color: var(--primary);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

button:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}




.app-level {
  text-align: center;
  width: 100%;
}
.protocol-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}
.protocol-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.protocol-btn.selected {
  background: rgba(20, 184, 166, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}


.custom-select {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-main);
  outline: none;
  appearance: none;
  cursor: pointer;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.custom-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.custom-select option {
  background: var(--bg-color);
  color: var(--text-main);
}


.error-banner {
    background: rgba(239, 68, 68, 0.15); 
    border: 1px solid #ef4444;
    color: #fca5a5; 
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    text-align: left;
    line-height: 1.5;
    animation: shake 0.5s ease-in-out;
    
    display: flex;
    align-items: center;
    gap: 15px;
}

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


.segments-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
  width: 100%;
}

.segment {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--glass-border);
  border-radius: 8px;
  padding: 15px;
  min-width: 120px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s;
  position: relative;
  outline: none;
}


:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.segment:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(20, 184, 166, 0.4);
}

.segment .data {
  background: rgba(255,255,255,0.05);
  padding: 4px;
  border-radius: 4px;
  text-align: center;
}

.segment .header-tcp {
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: bold;
}

.segment .header-ip {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: bold;
}


.tcp-level .segment {
  cursor: pointer;
}
.tcp-level .segment:hover {
  border-color: var(--secondary);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.3);
}
.tcp-level .segment.stamped {
  border-style: solid;
  border-color: var(--secondary);
  cursor: default;
}


.ip-level .ip-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  justify-content: center;
  align-items: center;
}
.ip-inputs label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.ip-inputs input {
  width: 100%;
  max-width: 200px;
  margin-bottom: 0;
  padding: 8px;
}


.internet-level {
  width: 100%;
  height: 100%;
  min-height: 450px; 
  position: relative;
}
.router-node {
  position: absolute;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: all 0.2s;
}
.router-node.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.2);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
  color: white;
}


.network-stats {
  position: absolute;
  margin-top: 15px;
  left: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  z-index: 90;  
  backdrop-filter: blur(4px);
}


.graph-edge {
  position: absolute;
  height: 2px;
  background: rgba(255, 255, 255, 0.15);
  transform-origin: 0 50%;
  z-index: 1;
}

.retransmitting-text {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--secondary);
  font-weight: bold;
  animation: pulse 0.8s infinite;
  z-index: 15;
  white-space: nowrap;
}

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

@keyframes pulse-hint {
  0% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.8); }
  70% { box-shadow: 0 0 0 15px rgba(20, 184, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
}

.hint-pulse {
  animation: pulse-hint 1.5s infinite !important;
  border-color: var(--accent) !important;
}


.flying-packet {
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--accent);
  transition: all 1.5s linear;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: bold;
  color: #000;
}


.packet-explosion {
  animation: explode 0.6s ease-out forwards;
  background: rgba(239, 68, 68, 0.9) !important; 
  border: 2px solid #fca5a5 !important;
  color: #fff !important;
  font-size: 1.5rem;
  z-index: 20;
}

@keyframes explode {
  0% { transform: scale(1); }
  25% { transform: scale(3) rotate(-15deg); }
  50% { transform: scale(4) rotate(15deg); background: rgba(239, 68, 68, 0.5) !important; opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}


.typewriter-cursor {
  animation: blink 0.8s step-end infinite;
  font-weight: bolder;
  color: var(--accent);
}

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


.dest-level {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.assembly-area {
  display: flex;
  gap: 10px;
  min-height: 100px;
  border: 2px dashed var(--glass-border);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}
.final-message-box {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--success);
  padding: 20px;
  border-radius: 8px;
  font-size: 1.5rem;
  color: var(--success);
  margin-top: 20px;
  text-align: center;
  font-weight: bold;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s;
  
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.final-message-box.visible {
  opacity: 1;
  transform: translateY(0);
}

.action-btn {
  margin-top: 20px;
}


.cyber-bubble {
    position: absolute;
    background: rgba(0, 0, 0, 0.9); 
    border: 1px solid var(--accent);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    
    
    z-index: 100; 
    
    backdrop-filter: blur(4px);
    animation: popIn 0.3s ease-out forwards;
    pointer-events: none;
    
    
    max-width: 250px; 
    white-space: normal; 
    line-height: 1.4;
    
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.3);
}

.cyber-bubble.dest {
    border-color: var(--secondary);
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}


.cyber-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: var(--accent) transparent transparent transparent;
}

.cyber-bubble.dest::after {
    border-color: var(--secondary) transparent transparent transparent;
    left: auto;
    right: 20px; 
}


.handshake-status {
  position: absolute;
  bottom: 20px; 
  right: 20px;
  color: #ffaa00;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: bold;
  z-index: 85;
  text-align: right;
  text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

@keyframes popIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.hacker-report {
  margin-top: 40px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--accent);
  border-left: 5px solid var(--accent);
  padding: 20px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 0 15px rgba(20, 184, 166, 0.2);
  animation: popIn 0.5s ease-out forwards;
}

.site-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 50px;
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 100%;
    z-index: 10;
    position: relative;
}

.site-footer a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.site-footer a:hover {
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

@media (max-width: 1024px) {
  h1 { font-size: 2rem; margin-top: 5px; }
  .step { font-size: 0.8rem; padding: 6px 12px; }
}

@media (max-width: 768px) {
  h1 { font-size: 1.6rem; }
  .subtitle { font-size: 0.95rem; }
  .progress-bar::before { display: none; }
  .progress-bar { justify-content: center; }
  
  .glass-panel { padding: 15px; }
  
  .ip-inputs { flex-direction: column; gap: 15px; }
  .ip-inputs > div { width: 100%; display: flex; flex-direction: column; align-items: center; }
  
  .segment { min-width: 100%; }

  .network-stats {
      width: calc(100% - 20px);
      text-align: center;
      left: 10px;
      top: 10px;
      font-size: 0.8rem;
      padding: 6px 10px;
  }


  .handshake-status {
      bottom: 10px; 
      top: auto;    
      left: 20px;
      right: 20px;
      text-align: center;
  }

  .cyber-bubble {
      font-size: 0.8rem;
      padding: 8px 12px;
      left: 50% !important; 
      transform: translateX(-50%) !important;
      top: 110px !important; 
      width: max-content;
      max-width: 90vw;
  }
  
  .cyber-bubble::after {
      display: none;
  }

  .final-message-box {
      font-size: 1.1rem; 
      padding: 15px; 
  }

  .final-message-box span {
      display: block; 
      line-height: 1.4;
      margin-top: 10px;
  }

  /* Inverte a ordem: A Explicação sobe para baixo do título no Mobile! */
  .game-container {
      display: flex;
      flex-direction: column;
  }
  header { order: 1; margin-bottom: 10px; }
  .info-panel { order: 2; margin-bottom: 15px; } /* Painel de texto agora vem antes */
  .level-area { order: 3; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .game-container { gap: 10px; }
  
  button { width: 100%; font-size: 0.95rem; padding: 10px 15px; }
  input[type="text"] { font-size: 0.95rem; }
  
  .protocol-selector { flex-direction: column; width: 100%; }
  .protocol-btn { width: 100%; }
  
  .step { width: 100%; text-align: center; }
}