:root {
  --nb-game-safe-top: max(8px, env(safe-area-inset-top));
  --nb-game-safe-right: max(8px, env(safe-area-inset-right));
  --nb-game-safe-bottom: max(8px, env(safe-area-inset-bottom));
  --nb-game-safe-left: max(8px, env(safe-area-inset-left));
  --nb-game-dock-height: 44px;
  --nb-game-accent: #f3cc72;
  --nb-game-panel: rgba(7, 11, 22, .94);
}

html[data-nb-game-mode="active"],
html[data-nb-game-mode="active"] body {
  width: 100%;
  min-height: 100%;
  background: #070912;
}

html[data-nb-game-mode="active"] body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

html[data-nb-game-mode="active"][data-nb-game-profile="arcade"] body,
html[data-nb-game-mode="active"][data-nb-game-profile="adventure"] body,
html[data-nb-game-mode="active"][data-nb-game-profile="strategy"] body {
  overflow: hidden;
  overscroll-behavior: none;
}

html[data-nb-game-mode="active"][data-nb-game-profile="narrative"] body {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
}

html[data-nb-game-mode="active"] :where(
  .nb-titor-v2,
  .nb-titor-trigger-v2,
  .nb-titor-panel-v2,
  .titor-fab,
  .titor-launcher,
  .titor-global,
  #titorWidget,
  [data-titor-root],
  [data-titor-launcher],
  [data-games-titor],
  .favorite-floating,
  .favorite-toast,
  .nb-consent-dialog,
  [data-nb-consent-dialog],
  [data-nb-promo],
  [data-nb-banner],
  body > footer.site-footer,
  body > .site-footer
) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html[data-nb-game-mode="active"] :where([data-nb-game-surface], [data-nb-game-control], #game) {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html[data-nb-game-mode="active"] :where(button, a, [role="button"], [data-nb-game-control]) {
  touch-action: manipulation;
}

html[data-nb-game-mode="active"] :where(input, select, textarea, [contenteditable="true"], [data-nb-game-scroll]) {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

html[data-nb-game-mode="active"][data-nb-game-profile="narrative"] :where([data-nb-game-surface], #game) {
  touch-action: pan-y;
  overscroll-behavior-y: auto;
}

html[data-nb-game-mode="active"]:not([data-nb-game-profile="narrative"]) :where([data-nb-game-surface], #game) {
  touch-action: none;
  overscroll-behavior: contain;
}

.nb-game-dock {
  position: fixed;
  z-index: 2147482000;
  top: var(--nb-game-safe-top);
  left: var(--nb-game-safe-left);
  right: var(--nb-game-safe-right);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  font: 800 12px/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.nb-game-dock button {
  min-height: var(--nb-game-dock-height);
  max-width: min(46vw, 190px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 0 14px;
  color: #fff;
  background: rgba(7, 11, 22, .78);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
}

.nb-game-dock button:hover,
.nb-game-dock button:focus-visible {
  border-color: var(--nb-game-accent);
  background: rgba(18, 24, 40, .95);
  outline: none;
}

.nb-game-layer {
  position: fixed;
  z-index: 2147483000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  color: #f7f8fc;
  background: rgba(3, 6, 14, .76);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.nb-game-layer[hidden] { display: none !important; }

.nb-game-panel {
  width: min(100%, 560px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 22px;
  padding: clamp(18px, 4vw, 30px);
  background: var(--nb-game-panel);
  box-shadow: 0 24px 80px rgba(0,0,0,.56);
  touch-action: pan-y;
}

.nb-game-panel h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1.05;
}

.nb-game-panel p {
  margin: 0 0 18px;
  color: rgba(255,255,255,.72);
  line-height: 1.5;
}

.nb-game-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.nb-game-actions button,
.nb-game-actions a {
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  background: rgba(255,255,255,.08);
  font: 800 13px/1.2 system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.nb-game-actions .is-primary {
  border-color: color-mix(in srgb, var(--nb-game-accent), transparent 24%);
  color: #111522;
  background: var(--nb-game-accent);
}

.nb-game-setting-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.nb-game-setting {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
}

.nb-game-setting > span {
  color: rgba(255,255,255,.78);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.nb-game-setting input[type="range"],
.nb-game-setting select { width: 100%; min-width: 0; }

.nb-game-setting select {
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  padding: 0 9px;
  color: #fff;
  background: #161b2a;
}

.nb-game-toggle {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.nb-game-toggle input { width: 22px; height: 22px; accent-color: var(--nb-game-accent); }

.nb-game-loading-card { text-align: center; }
.nb-game-loading-logo { display: block; margin-bottom: 14px; color: var(--nb-game-accent); font-weight: 950; letter-spacing: .13em; }
.nb-game-progress { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.nb-game-progress > span { display: block; width: 8%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--nb-game-accent), #fff2bd); transition: width .25s ease; }
.nb-game-progress-value { margin-top: 9px; color: rgba(255,255,255,.66); font-size: 12px; }

html[data-nb-game-paused="true"] :where([data-nb-game-surface], #game) { pointer-events: none; }

@media (max-width: 600px) {
  .nb-game-dock { font-size: 11px; }
  .nb-game-dock button { min-height: 40px; padding-inline: 11px; }
  .nb-game-setting-grid { grid-template-columns: 1fr; }
  .nb-game-actions { grid-template-columns: 1fr; }
  .nb-game-panel { max-height: 86dvh; border-radius: 18px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .nb-game-dock { right: auto; width: min(100%, 360px); }
  .nb-game-panel { max-height: calc(100dvh - 20px); padding: 16px; }
  .nb-game-panel h2 { font-size: 24px; }
  .nb-game-setting-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (display-mode: standalone) {
  html[data-nb-game-mode="active"] body { min-height: 100svh; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-nb-game-mode="active"] *,
  html[data-nb-game-mode="active"] *::before,
  html[data-nb-game-mode="active"] *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
