/**
 * Menu de configurações padrão — NeuroBrincadeiras
 * Botão engrenagem (zona 60×60) + modal em todos os jogos.
 */

:root {
  --nb-gs-navy: #0f2748;
  --nb-gs-navy-deep: #0a1b33;
  --nb-gs-text: #1a3558;
  --nb-gs-muted: #6b7f96;
  --nb-gs-line: #e4eef6;
  --nb-gs-panel: #ffffff;
  --nb-gs-overlay: rgba(8, 22, 44, 0.48);
  --nb-gs-toggle-off: #c5d0dc;
  --nb-gs-toggle-on: #2f7cf6;
  --nb-gs-home: #3b82f6;
  --nb-gs-music: #8b5cf6;
  --nb-gs-sfx: #22c55e;
  --nb-gs-help: #f59e0b;
  --nb-gs-restart: #ef4444;
  --nb-gs-catalog: #6366f1;
  --nb-gs-shadow: 0 24px 64px rgba(15, 39, 72, 0.22);
  --nb-gs-radius: 20px;
  --nb-gs-safe: 60px;
}

html.nb-gs-dark {
  --nb-gs-text: #e8f0fa;
  --nb-gs-muted: #9aadc2;
  --nb-gs-line: #243652;
  --nb-gs-panel: #12263f;
  --nb-gs-overlay: rgba(2, 8, 18, 0.62);
  --nb-gs-toggle-off: #3a4d66;
  --nb-gs-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

/* Zona de segurança + botão */
#nbGameSettingsRoot {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 99980;
  pointer-events: none;
}

.nb-gs-safe {
  width: var(--nb-gs-safe);
  height: var(--nb-gs-safe);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 0 0;
  pointer-events: auto;
}

.nb-gs-gear {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--nb-gs-navy);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(15, 39, 72, 0.28);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.nb-gs-gear:hover {
  background: var(--nb-gs-navy-deep);
  transform: rotate(28deg) scale(1.04);
  box-shadow: 0 10px 28px rgba(15, 39, 72, 0.34);
}

.nb-gs-gear:focus-visible {
  outline: 3px solid #5ba3ff;
  outline-offset: 2px;
}

.nb-gs-gear[aria-expanded="true"] {
  background: #1a4a8c;
}

.nb-gs-gear svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Overlay + painel */
.nb-gs-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: var(--nb-gs-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.nb-gs-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nb-gs-panel {
  width: min(420px, 100%);
  max-height: min(92vh, 720px);
  overflow: auto;
  background: var(--nb-gs-panel);
  color: var(--nb-gs-text);
  border-radius: var(--nb-gs-radius);
  box-shadow: var(--nb-gs-shadow);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease;
  -webkit-overflow-scrolling: touch;
}

.nb-gs-overlay.is-open .nb-gs-panel {
  transform: none;
}

.nb-gs-head {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--nb-gs-line);
  position: sticky;
  top: 0;
  background: var(--nb-gs-panel);
  z-index: 1;
}

.nb-gs-head-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  max-width: calc(100% - 48px);
}

.nb-gs-head-spacer {
  flex: 1 1 auto;
  min-width: 8px;
  height: 1px;
}

.nb-gs-action {
  height: 36px;
  width: auto;
  max-width: 100%;
  padding: 0 14px 0 12px;
  border: 1.5px solid #d5e0ea;
  border-radius: 999px;
  background: #fff;
  color: var(--nb-gs-navy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nb-gs-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
}

.nb-gs-action__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.nb-gs-action:hover {
  background: #f4f8fc;
  color: var(--nb-gs-navy);
  border-color: #c3d2e0;
}

.nb-gs-action:focus-visible {
  outline: 3px solid #5ba3ff;
  outline-offset: 2px;
}

.nb-gs-action--share {
  background: #1ebfb3;
  border-color: #1ebfb3;
  color: #fff;
}

.nb-gs-action--share:hover {
  background: #18aaa0;
  border-color: #18aaa0;
  color: #fff;
}

.nb-gs-action--fav.is-active,
.nb-gs-action--fav[aria-pressed="true"] {
  color: var(--nb-gs-navy);
  border-color: #f0d56a;
  background: #fffdf3;
}

.nb-gs-action--fav.is-active svg,
.nb-gs-action--fav[aria-pressed="true"] svg {
  color: #ffcc00;
  fill: #ffcc00;
  stroke: #e6b800;
}

.nb-gs-action[hidden] {
  display: none !important;
}

.nb-gs-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--nb-gs-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-left: 2px;
}

.nb-gs-close:hover {
  background: var(--nb-gs-line);
  color: var(--nb-gs-text);
}

html.nb-gs-dark .nb-gs-action {
  background: #1a2f4a;
  border-color: #314a66;
  color: var(--nb-gs-text);
}

html.nb-gs-dark .nb-gs-action:hover {
  background: #223a58;
  border-color: #3d5a7a;
  color: var(--nb-gs-text);
}

html.nb-gs-dark .nb-gs-action--share {
  background: #1ebfb3;
  border-color: #1ebfb3;
  color: #fff;
}

html.nb-gs-dark .nb-gs-action--fav.is-active,
html.nb-gs-dark .nb-gs-action--fav[aria-pressed="true"] {
  background: #2a2818;
  border-color: #c9a820;
  color: var(--nb-gs-text);
}

.nb-gs-list {
  list-style: none;
  margin: 0;
  padding: 8px 10px 14px;
}

.nb-gs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

button.nb-gs-item:hover,
a.nb-gs-item:hover,
.nb-gs-item:focus-visible {
  background: color-mix(in srgb, var(--nb-gs-line) 70%, transparent);
  outline: none;
}

.nb-gs-item[hidden] {
  display: none !important;
}

.nb-gs-list > li[hidden] {
  display: none !important;
}

.nb-gs-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.nb-gs-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.nb-gs-icon--home { background: var(--nb-gs-home); }
.nb-gs-icon--music { background: var(--nb-gs-music); }
.nb-gs-icon--sfx { background: var(--nb-gs-sfx); }
.nb-gs-icon--help { background: var(--nb-gs-help); }
.nb-gs-icon--restart { background: var(--nb-gs-restart); }
.nb-gs-icon--catalog { background: var(--nb-gs-catalog); }

.nb-gs-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.nb-gs-copy strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.25;
}

.nb-gs-copy span {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--nb-gs-muted);
  line-height: 1.35;
}

.nb-gs-trail {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--nb-gs-muted);
}

.nb-gs-chevron {
  width: 18px;
  height: 18px;
}

.nb-gs-warn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--nb-gs-restart);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Toggle */
.nb-gs-switch {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--nb-gs-toggle-off);
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.18s ease;
}

.nb-gs-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.nb-gs-switch[aria-checked="true"] {
  background: var(--nb-gs-toggle-on);
}

.nb-gs-switch[aria-checked="true"]::after {
  transform: translateX(18px);
}

.nb-gs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 10px;
  border-radius: 14px;
}

.nb-gs-row .nb-gs-copy {
  pointer-events: none;
}

/* Confirmação reinício */
.nb-gs-confirm {
  position: fixed;
  inset: 0;
  z-index: 99995;
  background: var(--nb-gs-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.nb-gs-confirm.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nb-gs-confirm-card {
  width: min(360px, 100%);
  background: var(--nb-gs-panel);
  color: var(--nb-gs-text);
  border-radius: 18px;
  box-shadow: var(--nb-gs-shadow);
  padding: 28px 22px 18px;
  text-align: center;
}

.nb-gs-confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #fff3e0;
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
}

html.nb-gs-dark .nb-gs-confirm-icon {
  background: #3a2a12;
}

.nb-gs-confirm-card p {
  margin: 0 0 18px;
  font-size: 1rem;
  line-height: 1.45;
}

.nb-gs-confirm-actions {
  display: flex;
  gap: 10px;
}

.nb-gs-confirm-actions button {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nb-gs-btn-cancel {
  background: #e8eef5;
  color: var(--nb-gs-text);
}

html.nb-gs-dark .nb-gs-btn-cancel {
  background: #243652;
  color: var(--nb-gs-text);
}

.nb-gs-btn-restart {
  background: var(--nb-gs-restart);
  color: #fff;
}

@media (max-width: 520px) {
  .nb-gs-panel {
    width: min(100%, 440px);
    max-height: 88vh;
    border-radius: 18px;
  }

  .nb-gs-head {
    gap: 6px;
    padding: 12px 10px 10px;
  }

  .nb-gs-head-actions {
    gap: 6px;
    max-width: calc(100% - 42px);
  }

  .nb-gs-head-spacer {
    min-width: 4px;
  }

  .nb-gs-action {
    height: 32px;
    padding: 0 10px 0 9px;
    gap: 5px;
    font-size: 0.78rem;
  }

  .nb-gs-action svg {
    width: 14px;
    height: 14px;
  }

  .nb-gs-close {
    width: 34px;
    height: 34px;
  }

  .nb-gs-safe {
    margin-top: max(6px, env(safe-area-inset-top, 0px));
    margin-right: max(6px, env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 360px) {
  .nb-gs-action {
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .nb-gs-action__label {
    max-width: 7.2ch;
  }
}

/* Em embed, engrenagem fica dentro do iframe; top bar do portal continua fora */
html.nb-embed #nbGameSettingsRoot {
  z-index: 99980;
}
