.graphics-control {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 9000;
  display: grid;
  justify-items: end;
  gap: 6px;
  font: 12px/1.2 var(--font-mono, ui-monospace, SFMono-Regular, Consolas, monospace);
}

@media (min-width: 901px) and (max-height: 800px) {
  .graphics-control {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
  }
}

.graphics-control__bar {
  display: flex;
  align-items: end;
  justify-content: end;
  gap: 6px;
}

.graphics-control__toggle,
.graphics-control__info,
.graphics-control__menu button {
  border: 1px solid rgba(133, 214, 164, 0.46);
  color: rgba(220, 244, 225, 0.95);
  background: rgba(8, 12, 10, 0.78);
  box-shadow: 0 0 18px rgba(54, 170, 112, 0.16);
  cursor: pointer;
}

.graphics-control__info {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
  font-family: ui-serif, Georgia, serif;
  font-style: italic;
  line-height: 1;
}

.graphics-control__toggle {
  min-height: 44px;
  padding: 0 12px;
}

.graphics-control__help {
  width: min(290px, calc(100vw - 24px));
  max-height: min(52vh, 260px);
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid rgba(133, 214, 164, 0.34);
  color: rgba(226, 241, 229, 0.95);
  background: rgba(5, 8, 7, 0.93);
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.48), 0 0 18px rgba(54, 170, 112, 0.12);
}

.graphics-control__help[hidden] {
  display: none;
}

.graphics-control__help p {
  margin: 0;
}

.graphics-control__help p + p {
  margin-top: 7px;
}

.graphics-control__status,
.graphics-control__reason {
  color: rgba(133, 214, 164, 0.96);
}

.graphics-control__reason {
  color: rgba(220, 244, 225, 0.78);
}

.graphics-control__menu {
  display: grid;
  gap: 4px;
  width: 132px;
  padding: 6px;
  border: 1px solid rgba(133, 214, 164, 0.28);
  background: rgba(5, 8, 7, 0.9);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.42);
}

.graphics-control__menu[hidden] {
  display: none;
}

.graphics-control__menu button {
  min-height: 30px;
  text-align: left;
  padding: 0 8px;
}

.graphics-control__menu button[aria-pressed="true"] {
  color: #07100b;
  background: rgba(133, 214, 164, 0.92);
}

.graphics-control__menu button:disabled {
  color: rgba(220, 244, 225, 0.38);
  background: rgba(8, 12, 10, 0.48);
  border-color: rgba(133, 214, 164, 0.18);
  box-shadow: none;
  cursor: not-allowed;
}

.graphics-control__toggle:focus-visible,
.graphics-control__info:focus-visible,
.graphics-control__menu button:focus-visible {
  outline: 2px solid rgba(190, 255, 210, 0.9);
  outline-offset: 2px;
}

.graphics-debug {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 9100;
  max-width: calc(100vw - 20px);
  padding: 5px 7px;
  color: #dcf4e1;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(133, 214, 164, 0.35);
  font: 11px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
}

@media (max-width: 700px) {
  .graphics-control {
    display: none;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 11px;
  }

  body:has(#main.stage.active-section) .graphics-control {
    bottom: max(96px, calc(84px + env(safe-area-inset-bottom, 0px)));
  }

  body:has(#blog.blog-screen.active-section.in-category) .graphics-control {
    top: max(12px, env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: max(12px, env(safe-area-inset-left));
    justify-items: start;
  }

  body:has(#blog.blog-screen.active-section.in-category) .graphics-control__bar {
    justify-content: start;
  }

  .graphics-control__toggle {
    min-height: 44px;
    padding: 0 10px;
  }

  .graphics-control__info {
    min-width: 44px;
    min-height: 44px;
  }

  .graphics-control__help {
    width: min(260px, calc(100vw - 20px));
    max-height: min(58vh, 240px);
    padding: 9px 10px;
  }

  .graphics-control__menu {
    width: 118px;
  }
}

@media (max-width: 360px) {
  .graphics-control {
    max-width: calc(100vw - 20px);
  }

  .graphics-control__help {
    width: calc(100vw - 20px);
  }
}
