:root {
  --bg-light: #ffffff;
  --text-light: #000000;
  --bg-dark: #1a1a1a;
  --text-dark: #f0f0f0;
  --accent: #555;
  --brand-green: #00aa44;
}

* {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  box-sizing: border-box;
  scroll-behavior: smooth; 
  -webkit-tap-highlight-color: transparent; /* Removes the blue flash when tapping on mobile */
}

body {
  margin: 0;
  background: #050505; 
  display: flex;
  flex-direction: column; 
  align-items: center; 
  overflow-x: hidden; 
  overflow-y: auto; 
  min-height: 100vh;
  touch-action: manipulation; 
  
  /* Disables accidental text highlighting across the entire app */
  -webkit-user-select: none; 
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none; 
}

/* Crucial override: Allows users to still select and edit text inside the Custom IP input */
input, textarea {
  -webkit-user-select: auto;
  -moz-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1; /* Keeps it behind the main UI frame */
  pointer-events: none; /* Allows clicks to pass through to the app */
}

#frameWrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-shrink: 0;
}

.phoneFrame {
  background: var(--bg-light);
  width: 420px;
  max-width: 100%;
  min-height: 100vh; 
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: background 0.3s, color 0.3s;
  color: var(--text-light);
  padding-bottom: 10px;
  flex-shrink: 0; 
}

.phoneFrame.dark {
  background: var(--bg-dark);
  color: var(--text-dark);
  --accent: #888;
}

.headerBar {
  width: 100%;
  background: black;
  color: white;
  padding: 15px 15px 10px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.headerTopRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.logoText {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
  transition: transform 0.2s ease;
}

.logoText a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
  display: inline-block;
}

.logoText:hover { transform: scale(1.05); }
.logoText:hover a { color: var(--brand-green); }

.headerControls {
  display: flex;
  gap: 8px;
}

.iconBtn {
  background: #333;
  border: 1px solid #444;
  color: white;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s, transform 0.1s, filter 0.2s;
}

.iconBtn:hover { 
  background: #444; 
  filter: brightness(1.15);
}

.iconBtn:active {
  transform: scale(0.97);
}

/* LOCKED BUTTON GEOMETRY */
#themeToggle { width: 54px; text-align: center; white-space: nowrap; flex-shrink: 1; }
#audioToggle { width: 86px; text-align: center; white-space: nowrap; flex-shrink: 1; }
#modeToggle { width: 118px; text-align: center; white-space: nowrap; flex-shrink: 1; }
#routerToggleBtn { width: 118px; text-align: center; white-space: nowrap; flex-shrink: 1; }

.serverRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.navLinks {
  display: flex;
  gap: 6px;
}

.targetGroup {
  display: flex;
  align-items: center;
  gap: 5px;
}

select {
  background: #222;
  color: white;
  border: 1px solid #444;
  padding: 4px;
  border-radius: 4px;
  font-size: 11px;
}

.custom-ip-input {
  display: none;
  background: #222;
  border: 1px solid #444;
  color: white;
  padding: 4px;
  border-radius: 4px;
  font-size: 11px;
  width: 100px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.custom-ip-input:focus {
  border-color: var(--brand-green);
}

#blockWarning {
  display: none;
  width: 90%;
  background: #ff3333;
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 6px;
  text-align: center;
  border-radius: 6px;
  margin-top: 10px;
  text-transform: uppercase;
  box-shadow: 0 2px 10px rgba(255,51,51,0.2);
}

.pingWrapper {
  margin: 10px 0 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  position: relative;
  height: 70px;
  flex-shrink: 0;
}

#pingValueContainer {
  position: relative;
  display: inline-block;
  font-size: 72px;
  font-weight: 300;
  line-height: 1;
}

.unit-main {
  position: absolute;
  left: 100%; 
  bottom: 10px;
  margin-left: 8px; 
  font-size: 20px;
  opacity: 0.5;
  text-transform: lowercase;
  font-weight: 400;
  white-space: nowrap;
}

.unit-small {
  font-size: 11px;
  opacity: 0.6;
  text-transform: lowercase;
  margin-left: 1px;
  font-weight: normal;
}

.statusWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px; 
  margin-bottom: 15px;
  width: 100%;
  flex-shrink: 0;
}

#statusCircle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: lightgray;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: 900;
  color: black;
  text-transform: uppercase;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  letter-spacing: 1px;
}

/* --- Pulse Animations --- */
@keyframes pulseIdle {
  0% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 0 rgba(0, 170, 68, 0.4); }
  70% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 15px rgba(0, 170, 68, 0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 0 rgba(0, 170, 68, 0); }
}

.pulse-idle { animation: pulseIdle 2s infinite cubic-bezier(0.66, 0, 0, 1) !important; }

.dark .pulse-idle { animation: pulseIdleDark 2s infinite cubic-bezier(0.66, 0, 0, 1) !important; }
@keyframes pulseIdleDark {
  0% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(0, 170, 68, 0.4); }
  70% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 15px rgba(0, 170, 68, 0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(0, 170, 68, 0); }
}

@keyframes pulseRunning {
  0% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 0 rgba(255, 51, 51, 0.4); }
  70% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 15px rgba(255, 51, 51, 0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.2), 0 0 0 0 rgba(255, 51, 51, 0); }
}

.pulse-running { animation: pulseRunning 1.5s infinite cubic-bezier(0.66, 0, 0, 1) !important; }

.dark .pulse-running { animation: pulseRunningDark 1.5s infinite cubic-bezier(0.66, 0, 0, 1) !important; }
@keyframes pulseRunningDark {
  0% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(255, 51, 51, 0.4); }
  70% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 15px rgba(255, 51, 51, 0); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 0 0 rgba(255, 51, 51, 0); }
}
/* ------------------------ */

.microBadge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 75px;
  height: 75px;
  border-radius: 50%;
  background: #222;
  color: #aaa;
  border: 2px solid #333;
  transition: all 0.3s;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.microBadge .icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 4px;
}

.microBadge .lbl {
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.statsGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 90%;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 12px;
  flex-shrink: 0;
}

.statBox { text-align: center; }
.statLabel { font-size: 10px; opacity: 0.6; display: block; margin-bottom: 2px; text-transform: uppercase; }
.statValue { font-size: 15px; font-weight: bold; }
.lossDetail { font-size: 10px; display: block; margin-top: 4px; opacity: 0.7; text-transform: uppercase; }

.bottomStatsRow {
  display: flex;
  width: 90%;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.lossBox {
  flex: 1;
  text-align: center;
}

.advanced-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 140px; 
  flex-shrink: 0; 
  background: rgba(128, 128, 128, 0.05);
  border-radius: 8px;
  padding: 8px 8px; 
  gap: 5px;
  border: 1px solid rgba(128, 128, 128, 0.15);
  transition: opacity 0.3s;
}

.advanced-control select {
  width: 100%;
  font-size: 9px;
  padding: 2px;
  background: #eee;
  color: #000;
  border: 1px solid #ccc;
}
.dark .advanced-control select {
  background: #333;
  color: #fff;
  border: 1px solid #555;
}

.switch-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 9px;
  font-weight: bold;
  color: var(--accent);
  gap: 4px;
}

.dark .switch-wrapper {
  color: var(--text-dark);
}

.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 16px;
}

.switch input { 
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .2s;
  border-radius: 16px;
}
.dark .slider { background-color: #444; }

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--brand-green);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

.timers {
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  background: rgba(128,128,128,0.1);
  padding: 6px 20px;
  border-radius: 20px;
  margin-bottom: 15px;
  flex-shrink: 0;
}

.lowS {
  text-transform: lowercase !important;
  display: inline-block;
}

.mainActions {
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.btn {
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.1s, filter 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.15); }

#toggleBtn { background: var(--brand-green); color: white; font-size: 16px; }
#resetBtn { background: #333; color: white; font-size: 13px; }

/* The Landscape Docking Station is hidden in Portrait mode */
#landscapeToggleWrapper {
  display: none;
}

.graphContainer {
  position: relative;
  width: 90%;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 0; 
  flex-grow: 1; 
  min-height: 100px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  touch-action: pan-y; 
}
.dark .graphContainer { background: #222; border-color: #444; }

.zoomControls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}

.zoomBtn {
  background: rgba(0, 0, 0, 0.4);
  color: white;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  backdrop-filter: blur(2px);
}

.zoomBtn:hover { background: rgba(0, 170, 68, 0.8); }
.zoomBtn:active { transform: scale(0.9); }

.dark .zoomBtn { background: rgba(255, 255, 255, 0.15); color: #f0f0f0; }
.dark .zoomBtn:hover { background: rgba(0, 170, 68, 0.8); }

canvas { 
  width: 100%; 
  height: 100%; 
  display: block; 
  border-radius: 12px;
  cursor: grab;
}
canvas:active { cursor: grabbing; }

/* --- Graph Footer & Legends --- */
.graphFooter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 90%;
  margin-top: auto; 
  margin-bottom: 15px;
}

.legendItem {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: bold;
  color: var(--accent);
  opacity: 0.8;
  transition: opacity 0.3s;
}

.legendLine {
  width: 35px;
  height: 4px;
  border-radius: 2px;
}

.pingLine {
  background: linear-gradient(to right, #32cd32 0%, #32cd32 50%, #ffd700 50%, #ffa500 75%, #ffa500 100%);
}

.wifiLine {
  background: #00aaff;
}

.scrollArrow {
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--brand-green);
  margin-top: 0; 
  margin-bottom: 0;
  animation: bounce 2s infinite;
  text-decoration: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 170, 68, 0.08); 
  border: 1px solid rgba(0, 170, 68, 0.3); 
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.scrollArrow:hover {
  background: rgba(0, 170, 68, 0.15);
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  60% { transform: translateY(-4px); }
}

.info-section {
  width: 100%;
  max-width: 860px;
  padding: 20px 20px 60px;
  color: #e0e0e0;
  line-height: 1.6;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
  .card-wide { grid-column: span 2; }
}

.info-card {
  background: rgba(17, 17, 17, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.info-card h2 {
  margin-top: 0;
  color: #fff;
  font-size: 18px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
  margin-bottom: 15px;
  text-align: center;
}

.info-card h3 {
  color: var(--brand-green);
  font-size: 15px;
  margin-top: 0;
  margin-bottom: 5px;
  text-transform: uppercase;
  text-align: center;
}

.info-card p {
  font-size: 14px;
  margin-bottom: 15px;
  color: #bbb;
}

.info-card p:last-child { margin-bottom: 0; }

.support-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
  width: 100%;
}

.support-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  text-decoration: none;
  padding: 12px 8px;
  border-radius: 8px;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 11px;
  transition: transform 0.1s, filter 0.2s;
  height: 100%;
}

.support-btn:active { transform: scale(0.97); }
.support-btn:hover { filter: brightness(1.15); }

.btn-paypal { background: #0070ba; }
.btn-patreon { background: #ff424d; }
.btn-bmac { background: #ffdd00; color: #000000; }
.btn-contact { background: #444444; color: #ffffff; border: 1px solid #555; }

@media (max-width: 380px) {
  .advanced-control { width: calc(33.3% - 4px); padding: 4px 2px; }
  .advanced-control select { font-size: 8px; }
  .statusWrapper { gap: 10px; }
  #statusCircle { width: 95px; height: 95px; font-size: 20px; }
  .microBadge { width: 65px; height: 65px; }
  #pingValueContainer { font-size: 60px; }
  .unit-main { font-size: 16px; margin-left: 4px; }
}

@media (max-width: 950px) and (max-height: 600px) and (orientation: landscape) {
  .phoneFrame {
    width: 100%;
    max-width: none;
    display: grid;
    align-content: start;
    grid-template-columns: minmax(200px, 35%) 1fr;
    grid-template-rows: auto auto auto auto auto auto auto auto 1fr;
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
    padding-top: 0px; 
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    gap: 2px 12px;
    align-items: center;
  }

  .headerBar {
    grid-column: 1 / 3;
    margin-left: calc(-1 * max(15px, env(safe-area-inset-left)));
    margin-right: calc(-1 * max(15px, env(safe-area-inset-right)));
    margin-top: 0px; 
    width: auto;
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
    padding-top: 6px; 
    padding-bottom: 8px; 
  }

  .headerControls { display: none; }

  #blockWarning { grid-column: 1 / 3; }
  
  .pingWrapper { display: contents; }
  
  #pingValueContainer {
    grid-column: 1 / 2;
    grid-row: 3;
    justify-self: center;
    align-self: center;
    padding-top: 0;
    font-size: 50px; 
  }
  .unit-main { font-size: 16px; bottom: 5px; }

  #landscapeToggleWrapper {
    display: flex;
    grid-column: 2 / 3;
    grid-row: 3;
    width: 100%;
    justify-content: space-between; 
    align-items: flex-start;
    margin-top: 4px;
    z-index: 10;
    position: relative;
    top: -15px; 
  }

  #modeToggle, #routerToggleBtn, #audioToggle, #themeToggle {
    position: static !important;
    margin: 0 !important;
    z-index: 10;
  }

  .statusWrapper { grid-column: 1 / 2; grid-row: 4; margin-bottom: 0px; margin-top: 0px; gap: 15px; }
  #statusCircle { width: 70px; height: 70px; font-size: 16px; } 
  .microBadge { width: 58px; height: 58px; border-width: 2px; } 
  .microBadge .icon { font-size: 20px; margin-bottom: 2px; }
  .microBadge .lbl { font-size: 10px; }
  
  .statsGrid { grid-column: 1 / 2; grid-row: 5; width: 100%; margin-bottom: 0px; margin-top: 0px; font-size: 9px;}
  
  .bottomStatsRow { 
    grid-column: 1 / 2; 
    grid-row: 6; 
    width: 100%; 
    margin-bottom: 0px; 
    margin-top: 0px;
    display: grid;
    grid-template-columns: 1fr 1fr; 
    grid-template-rows: auto auto;
    gap: 4px 8px; 
  }
  
  .lossBox {
    grid-column: 1 / 3; 
    grid-row: 1;
    flex: unset;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 4px;
  }

  #bbContainer { grid-column: 1 / 2; grid-row: 2; }
  #wifiContainer { grid-column: 2 / 3; grid-row: 2; }
  
  .advanced-control { width: 100%; padding: 4px; margin: 0; }
  .advanced-control select { font-size: 8px; }
  .switch { width: 22px; height: 12px; }
  .slider:before { height: 8px; width: 8px; left: 2px; bottom: 2px; }
  input:checked + .slider:before { transform: translateX(10px); }

  #wifiContainer > div:nth-child(1) { font-size: 9px !important; }
  #wifiStatusText { width: 30px !important; }
  #wifiContainer > div:nth-child(2) { font-size: 13px !important; }
  #wifiContainer > div:nth-child(2) span { font-size: 9px !important; }
  #wifiContainer > div:nth-child(3) { font-size: 8px !important; margin-top: 1px !important; }

  .timers { 
      grid-column: 1 / 2; 
      grid-row: 7; 
      margin-top: 10px; 
      margin-bottom: 2px; 
      font-size: 9px; 
      padding: 2px 8px; 
      align-self: start; 
  }
  
  .mainActions { 
      grid-column: 1 / 2; 
      grid-row: 8; 
      width: 100%; 
      flex-direction: row; 
      flex-wrap: wrap; 
      justify-content: space-between; 
      gap: 2px;
      align-self: start;
  }
  .mainActions .btn { flex: 1; margin: 0; padding: 6px; font-size: 10px;}
  .mainActions .iconBtn { width: 100%; margin: 0; padding: 6px;}

  .graphContainer {
    grid-column: 2 / 3;
    grid-row: 3 / 8;
    width: 100%;
    height: auto;
    min-height: 120px;
    margin-top: 34px; 
    margin-bottom: 4px; 
  }

  .graphFooter { 
    grid-column: 2 / 3; 
    grid-row: 8; 
    width: 100%; 
    margin-top: 0px; 
    margin-bottom: 0px; 
    padding: 0 10px; 
    justify-content: space-between; 
    align-self: start; 
  }

  .scrollArrow { 
      margin: 0; 
      width: 24px; 
      height: 24px; 
      position: relative;
      top: 10px; 
  }
  
  .phoneFrame > p { 
      grid-column: 2 / 3; 
      grid-row: 8; 
      margin-top: 0; 
      margin-bottom: 0px; 
      font-size: 8px; 
      text-align: center; 
      position: relative; 
      top: -25px; 
      align-self: end; 
  }
  
  .statValue { font-size: 10px; }
  .statLabel { font-size: 7px; }

  /* Landscape Tutorial Box Overrides */
  #tutorialBox.pos-landscape-right {
      left: auto !important;
      right: 15px !important;
      transform: none !important;
      bottom: 15px !important;
      top: auto !important;
      width: 300px !important;
      max-width: 50vw !important;
  }
  
  #tutorialBox.pos-landscape-left {
      left: 15px !important;
      right: auto !important;
      transform: none !important;
      bottom: 15px !important;
      top: auto !important;
      width: 300px !important;
      max-width: 45vw !important;
  }

  #tutorialBox.pos-landscape-top-left {
      left: 15px !important;
      right: auto !important;
      transform: none !important;
      top: 15px !important;
      bottom: auto !important;
      width: 300px !important;
      max-width: 45vw !important;
  }

  #tutorialBox.pos-landscape-top-middle {
      left: 50% !important;
      right: auto !important;
      transform: translateX(-50%) !important;
      top: 15px !important;
      bottom: auto !important;
      width: 300px !important;
      max-width: 50vw !important;
  }
}

/* Portrait Tutorial Box Overrides */
@media (orientation: portrait) {
  #tutorialBox.pos-portrait-top {
      top: 40px !important;
      bottom: auto !important;
  }
}

/* --- Overlays / Modals --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-light);
  color: var(--text-light);
  width: 100%;
  max-width: 360px;
  border-radius: 12px;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.3s ease, background 0.3s, color 0.3s;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.dark .modal-content {
  background: #1a1a1a;
  color: #f0f0f0;
  border: 1px solid #333;
}

/* Custom iFrame Styling */
.iframe-modal {
  padding: 0; 
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 80vh; 
  max-height: 600px;
}

.iframe-modal .modal-close {
  position: absolute;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 10px;
  right: 10px;
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.iframe-modal .modal-close:hover {
  background: rgba(0,0,0,0.9);
}

.iframe-modal iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: var(--bg-dark); 
}

/* --- GUIDED TUTORIAL ENGINE --- */
#tutorialOverlayBlocker {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 9999;
    display: none;
    cursor: default;
}

#tutorialBox {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px; 
    z-index: 10001;
    width: 90%;
    max-width: 400px;
    background: #fff;
    color: #000;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 0 2px var(--brand-green);
    display: none;
    flex-direction: column;
    transition: left 0.4s ease, right 0.4s ease, bottom 0.4s ease;
}

.tutorial-arrow-container {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.tutorial-arrow-left {
    position: absolute;
    top: 50%;
    left: -45px;
    transform: translateY(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.bounce-up-arrow {
    animation: bounceUpArrow 1.5s infinite;
    color: var(--brand-green);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.bounce-left-arrow {
    animation: bounceLeftArrow 1.5s infinite;
    color: var(--brand-green);
    filter: drop-shadow(-2px 2px 4px rgba(0,0,0,0.3));
}

.dark .bounce-up-arrow { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8)); }
.dark .bounce-left-arrow { filter: drop-shadow(-2px 2px 4px rgba(0,0,0,0.8)); }

@keyframes bounceUpArrow {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-12px); }
    60% { transform: translateY(-6px); }
}

@keyframes bounceLeftArrow {
    0%, 20%, 50%, 80%, 100% { transform: translateY(-50%) translateX(0); }
    40% { transform: translateY(-50%) translateX(-12px); }
    60% { transform: translateY(-50%) translateX(-6px); }
}

#tutorialTitle {
    text-align: center !important;
}

.dark #tutorialBox { background: #222; color: #fff; border: 1px solid #444; }

.tutorial-spotlight {
    z-index: 10000 !important;
    box-shadow: 0 0 0 4px var(--brand-green), 0 0 0 9999px rgba(0,0,0,0.85) !important;
    pointer-events: auto !important; /* Forces them to be clickable */
    transition: none !important;
    border-radius: 8px;
    opacity: 1 !important; /* FIXES wifiContainer fading out the overlay shadow */
}

/* Drop the massive screen shadow for readable steps */
.tutorial-spotlight.no-shade {
    box-shadow: 0 0 0 4px var(--brand-green) !important;
}

.dark .tutorial-spotlight {
    box-shadow: 0 0 0 4px var(--brand-green), 0 0 0 9999px rgba(0,0,0,0.85) !important;
    opacity: 1 !important;
}

.dark .tutorial-spotlight.no-shade {
    box-shadow: 0 0 0 4px var(--brand-green) !important;
}