/* ==========================================================================
   GARGANTUA — interface styling
   A restrained instrument-panel aesthetic: hairline borders, monospace
   telemetry, cyan/amber accents, nothing that competes with the image.
   ========================================================================== */

:root {
  --gg-ink: #dfe9f2;
  --gg-dim: #7f93a6;
  --gg-faint: #4b5c6c;
  --gg-cyan: #6fd8ff;
  --gg-amber: #ffb267;
  --gg-red: #ff6a58;
  --gg-panel: rgba(6, 10, 15, 0.62);
  --gg-panel-solid: rgba(6, 10, 15, 0.9);
  --gg-line: rgba(120, 170, 210, 0.18);
  --gg-line-hot: rgba(111, 216, 255, 0.42);
  --gg-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --gg-sans: "Inter", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--gg-ink);
  font-family: var(--gg-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: none;
}

#gg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #000;
  cursor: grab;
}

#gg-canvas:active { cursor: grabbing; }

body.gg-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(111, 216, 255, 0.06), transparent 65%);
  animation: gg-flash 90ms ease-out;
  z-index: 40;
}

@keyframes gg-flash { from { opacity: 1; } to { opacity: 0; } }

/* ------------------------------------------------------------------- HUD -- */

.gg-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 220ms ease;
}

.gg-root.is-hidden { opacity: 0; pointer-events: none; }

.gg-root > * { pointer-events: auto; }

/* --- title ---------------------------------------------------------------- */

.gg-title {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px 12px 18px;
  background: linear-gradient(120deg, rgba(6, 10, 15, 0.72), rgba(6, 10, 15, 0.18));
  border-left: 2px solid var(--gg-cyan);
  backdrop-filter: blur(9px) saturate(120%);
  -webkit-backdrop-filter: blur(9px) saturate(120%);
  border-radius: 2px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}

.gg-title-main {
  font-family: var(--gg-sans);
  font-size: 27px;
  font-weight: 200;
  letter-spacing: 0.42em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 22px rgba(111, 216, 255, 0.45);
}

.gg-title-sub {
  font-family: var(--gg-mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--gg-cyan);
  opacity: 0.85;
}

.gg-title-meta { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

.gg-chip {
  font-family: var(--gg-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 2px 7px;
  border: 1px solid var(--gg-line);
  border-radius: 2px;
  color: var(--gg-amber);
  background: rgba(255, 178, 103, 0.06);
  white-space: nowrap;
}

.gg-chip-dim { color: var(--gg-dim); background: rgba(255, 255, 255, 0.03); }

/* --- panels --------------------------------------------------------------- */

.gg-panels {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 108px 20px 74px 20px;
  gap: 16px;
}

.gg-panel {
  width: 268px;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--gg-panel);
  border: 1px solid var(--gg-line);
  border-radius: 3px;
  backdrop-filter: blur(11px) saturate(125%);
  -webkit-backdrop-filter: blur(11px) saturate(125%);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.5);
  scrollbar-width: thin;
  scrollbar-color: rgba(111, 216, 255, 0.28) transparent;
  font-family: var(--gg-mono);
}

.gg-panel-right { width: 292px; }

.gg-panel::-webkit-scrollbar { width: 5px; }
.gg-panel::-webkit-scrollbar-thumb { background: rgba(111, 216, 255, 0.25); border-radius: 3px; }
.gg-panel::-webkit-scrollbar-track { background: transparent; }

.gg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  font-family: var(--gg-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--gg-dim);
  background: rgba(255, 255, 255, 0.028);
  border: 0;
  border-bottom: 1px solid var(--gg-line);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
  z-index: 2;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease;
}

.gg-head:hover { color: var(--gg-ink); background: rgba(111, 216, 255, 0.07); }

/* Caret: points right when collapsed, down when open. */
.gg-caret {
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  opacity: 0.55;
  transition: transform 160ms ease;
  flex: 0 0 auto;
}

.gg-section.is-open .gg-caret { transform: rotate(90deg); }

/* Collapsible body: grid-rows animation works with auto height. */
.gg-section-body {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
}

.gg-section:not(.is-open) > .gg-section-body {
  display: none;
}

.gg-head b {
  font-weight: 500;
  color: var(--gg-cyan);
  letter-spacing: 0.12em;
  font-size: 8.5px;
  border: 1px solid var(--gg-line);
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: auto;
}

.gg-body { padding: 8px 12px 12px; }

.gg-group {
  font-size: 8.5px;
  letter-spacing: 0.2em;
  color: var(--gg-faint);
  margin: 10px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(120, 170, 210, 0.12);
}

.gg-group:first-child { margin-top: 2px; }

/* --- sliders -------------------------------------------------------------- */

.gg-row {
  display: grid;
  grid-template-columns: 1fr 22px;
  grid-template-areas: "label value" "slider slider";
  gap: 3px 6px;
  align-items: center;
  margin-bottom: 9px;
}

.gg-row-label {
  grid-area: label;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 10px;
  color: var(--gg-ink);
  opacity: 0.92;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gg-row-label em { font-style: normal; color: var(--gg-faint); font-size: 9px; }

.gg-row-value {
  grid-area: value;
  text-align: right;
  font-size: 10px;
  color: var(--gg-amber);
  font-variant-numeric: tabular-nums;
}

.gg-slider {
  grid-area: slider;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.gg-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(111, 216, 255, 0.55), rgba(111, 216, 255, 0.12));
  border-radius: 2px;
}

.gg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border-radius: 50%;
  background: #d8f3ff;
  border: 1px solid var(--gg-cyan);
  box-shadow: 0 0 9px rgba(111, 216, 255, 0.7);
}

.gg-slider::-moz-range-track {
  height: 2px;
  background: rgba(111, 216, 255, 0.28);
  border-radius: 2px;
}

.gg-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d8f3ff;
  border: 1px solid var(--gg-cyan);
  box-shadow: 0 0 9px rgba(111, 216, 255, 0.7);
}

.gg-slider:focus-visible { outline: 1px solid var(--gg-line-hot); outline-offset: 4px; }

/* --- readout -------------------------------------------------------------- */

.gg-readout { display: flex; flex-direction: column; gap: 5px; }

.gg-ro-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 9.5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(120, 170, 210, 0.07);
}

.gg-ro-label { color: var(--gg-dim); display: flex; flex-direction: column; }
.gg-ro-label em {
  font-style: normal;
  font-size: 8px;
  color: var(--gg-faint);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.gg-ro-value {
  color: var(--gg-cyan);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

/* --- buttons -------------------------------------------------------------- */

.gg-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.gg-btns-col { flex-direction: column; }

.gg-btn {
  flex: 1 1 auto;
  min-width: 62px;
  font-family: var(--gg-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  padding: 6px 8px;
  color: var(--gg-dim);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--gg-line);
  border-radius: 2px;
  cursor: pointer;
  transition: all 140ms ease;
  text-align: center;
}

.gg-btn:hover { color: var(--gg-ink); border-color: var(--gg-line-hot); background: rgba(111, 216, 255, 0.08); }

.gg-btn.is-on {
  color: #061018;
  background: var(--gg-cyan);
  border-color: var(--gg-cyan);
  box-shadow: 0 0 16px rgba(111, 216, 255, 0.45);
  font-weight: 600;
}

.gg-btn-wide {
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-areas: "idx name" "idx note";
  text-align: left;
  gap: 1px 8px;
  padding: 6px 9px;
}

.gg-btn-wide b { grid-area: idx; color: var(--gg-cyan); font-size: 10px; }
.gg-btn-wide span { grid-area: name; font-size: 10px; letter-spacing: 0.08em; }
.gg-btn-wide em { grid-area: note; font-style: normal; font-size: 8px; color: var(--gg-faint); }
.gg-btn-wide.is-on { background: rgba(111, 216, 255, 0.16); color: var(--gg-ink); }
.gg-btn-wide.is-on b { color: #fff; }
.gg-btn-wide.is-on em { color: var(--gg-dim); }

.gg-btn-key { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.gg-btn-key b { font-size: 8.5px; color: var(--gg-amber); border: 1px solid rgba(255, 178, 103, 0.35); padding: 0 4px; border-radius: 2px; }
.gg-btn-key.is-on b { color: #1a1004; background: var(--gg-amber); border-color: var(--gg-amber); }

/* --- debug grid ----------------------------------------------------------- */

.gg-debug { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.gg-dbg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--gg-mono);
  font-size: 9px;
  padding: 5px 6px;
  color: var(--gg-dim);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--gg-line);
  border-radius: 2px;
  cursor: pointer;
  transition: all 130ms ease;
  text-align: left;
  overflow: hidden;
}

.gg-dbg b { color: var(--gg-cyan); font-size: 9.5px; }
.gg-dbg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gg-dbg:hover { color: var(--gg-ink); border-color: var(--gg-line-hot); }
.gg-dbg.is-on { color: #061018; background: var(--gg-amber); border-color: var(--gg-amber); font-weight: 600; }
.gg-dbg.is-on b { color: #1a1004; }

/* --- legend / hint / toast ------------------------------------------------ */

.gg-legend {
  position: absolute;
  left: 20px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-width: min(76vw, 900px);
  font-family: var(--gg-mono);
  font-size: 9px;
  color: var(--gg-faint);
  letter-spacing: 0.06em;
}

.gg-legend b { color: var(--gg-dim); }
.gg-legend i { font-style: normal; }
.gg-legend i::before { content: " "; }

/* --- language switch ------------------------------------------------------ */

.gg-lang {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 20px;
  display: flex;
  border: 1px solid var(--gg-line);
  border-radius: 2px;
  overflow: hidden;
  background: var(--gg-panel);
  backdrop-filter: blur(9px) saturate(120%);
  -webkit-backdrop-filter: blur(9px) saturate(120%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.gg-lang-btn {
  font-family: var(--gg-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 6px 13px;
  color: var(--gg-dim);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--gg-line);
  cursor: pointer;
  transition: all 140ms ease;
}

.gg-lang-btn:last-child { border-right: 0; }
.gg-lang-btn:hover { color: var(--gg-ink); background: rgba(111, 216, 255, 0.08); }

.gg-lang-btn.is-on {
  color: #061018;
  background: var(--gg-cyan);
  font-weight: 600;
}

/* --- settings drawer: reopen pill, mobile tab bar ------------------------- */

.gg-reopen,
.gg-toolbar { display: none; }

/* ==========================================================================
   Narrow viewport (phones / small tablets)
   The full settings tree covers a phone screen, so it becomes a drawer: a slim
   tab bar picks exactly one collapsible block, and a floating pill reopens the
   whole thing. The default state is CLOSED, so the black hole is visible from
   the first frame and the render is never hidden behind a wall of sliders.
   ========================================================================== */

@media (max-width: 900px) {
  .gg-panels {
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    left: 0;
    right: 0;
    top: 52px;
    bottom: 0;
    padding: 44px 10px 12px;
    gap: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    background: linear-gradient(180deg, rgba(4, 7, 11, 0.72), rgba(4, 7, 11, 0.94));
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
  }

  /* Closed drawer: nothing but the tab bar and the render. */
  .gg-root.is-collapsed .gg-panels { display: none; }

  /* On a phone the two desktop columns dissolve into one stack of blocks. */
  .gg-panel {
    width: 100%;
    max-height: none;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .gg-panel-right { width: 100%; }

  .gg-section {
    background: rgba(6, 10, 15, 0.82);
    border: 1px solid var(--gg-line);
    border-radius: 3px;
    margin-bottom: 6px;
    overflow: hidden;
  }

  .gg-section .gg-head { position: static; padding: 12px 12px; font-size: 10.5px; }
  .gg-section .gg-body { padding: 10px 12px 14px; }

  /* The tab bar already says which block is active, so the seven collapsed
     headers are pure dead weight on a phone: hide them and every pixel they
     used goes back to the render. */
  .gg-root.is-tabbed .gg-section:not(.is-open) { display: none; }

  /* An expanded block scrolls on its own, sized so the drawer never takes more
     than about 60 % of the screen — even on a phone held sideways, where 46vh
     alone would swallow the whole viewport. */
  .gg-section.is-open > .gg-section-body {
    max-height: clamp(110px, calc(100vh - 278px), 46vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Floating pill: the only interface element left when the drawer is closed. */
  .gg-reopen {
    display: flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    left: 12px;
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 9px 14px 9px 11px;
    font-family: var(--gg-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--gg-ink);
    background: var(--gg-panel-solid);
    border: 1px solid var(--gg-line-hot);
    border-radius: 18px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    z-index: 6;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
  }

  .gg-reopen i { font-style: normal; font-size: 14px; color: var(--gg-cyan); }
  .gg-reopen:active { background: rgba(111, 216, 255, 0.2); }

  /* The pill only exists while the drawer is closed. */
  .gg-root:not(.is-collapsed) .gg-reopen { display: none; }

  /* Tab bar: one tap switches which block is expanded. */
  .gg-toolbar {
    display: flex;
    gap: 5px;
    position: absolute;
    left: 10px;
    right: 10px;
    top: 52px;
    padding: 5px 5px;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(4, 7, 11, 0.86);
    border: 1px solid var(--gg-line);
    border-radius: 3px;
    z-index: 6;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
  }

  .gg-toolbar::-webkit-scrollbar { display: none; }
  .gg-root.is-collapsed .gg-toolbar { display: none; }

  .gg-tab {
    flex: 0 0 auto;
    font-family: var(--gg-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    padding: 7px 12px;
    color: var(--gg-dim);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 130ms ease;
  }

  .gg-tab.is-on {
    color: #061018;
    background: var(--gg-cyan);
    border-color: var(--gg-cyan);
    font-weight: 600;
  }

  /* The ✕ no longer needs to lead anywhere, so keep it in the tab row. */
  .gg-tab-close {
    color: var(--gg-amber);
    border-color: rgba(255, 178, 103, 0.3);
    padding: 7px 12px;
    font-size: 12px;
  }

  /* Larger touch targets for the controls people actually poke. */
  .gg-slider { height: 26px; }
  .gg-slider::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -8px; }
  .gg-slider::-moz-range-thumb { width: 18px; height: 18px; }
  .gg-btn { padding: 10px 8px; font-size: 11px; }
  .gg-dbg { padding: 9px 8px; font-size: 10.5px; }
  .gg-lang-btn { padding: 9px 12px; }
  .gg-lang { z-index: 6; }

  .gg-legend, .gg-hint { display: none; }
  .gg-debug { grid-template-columns: 1fr 1fr 1fr; }
  .gg-toast { top: auto; bottom: 74px; max-width: 92vw; }
}

.gg-hint {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-family: var(--gg-mono);
  font-size: 9px;
  color: var(--gg-faint);
  letter-spacing: 0.05em;
  text-align: center;
  pointer-events: none;
  animation: gg-fade 16s ease forwards;
  animation-delay: 6s;
  max-width: 46vw;
}

.gg-hint b { color: var(--gg-cyan); }

@keyframes gg-fade { to { opacity: 0; } }

.gg-toast {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translate(-50%, -14px);
  padding: 8px 16px;
  font-family: var(--gg-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--gg-ink);
  background: var(--gg-panel-solid);
  border: 1px solid var(--gg-line-hot);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  max-width: 80vw;
  text-align: center;
}

.gg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* --- overlay (errors / context loss) -------------------------------------- */

.gg-overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  background: rgba(2, 4, 7, 0.94);
  text-align: center;
  font-family: var(--gg-mono);
  z-index: 60;
}

.gg-overlay.is-on { display: flex; }
.gg-overlay h2 { font-size: 15px; letter-spacing: 0.18em; font-weight: 500; color: var(--gg-red); margin: 0; }
.gg-overlay.is-warn h2 { color: var(--gg-amber); }
.gg-overlay p { max-width: 560px; font-size: 11px; line-height: 1.7; color: var(--gg-dim); margin: 0; }

/* --- loading -------------------------------------------------------------- */

.gg-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 80;
  transition: opacity 700ms ease;
}

.gg-loading.is-gone { opacity: 0; pointer-events: none; }

.gg-loading-inner { text-align: center; font-family: var(--gg-mono); }

.gg-loading-mark {
  font-family: var(--gg-sans);
  font-size: 34px;
  font-weight: 200;
  letter-spacing: 0.5em;
  color: #fff;
  text-indent: 0.5em;
  animation: gg-pulse 2.6s ease-in-out infinite;
}

.gg-loading-sub {
  margin-top: 8px;
  font-size: 9px;
  letter-spacing: 0.34em;
  color: var(--gg-cyan);
  opacity: 0.75;
}

.gg-loading-bar {
  margin: 26px auto 12px;
  width: 210px;
  height: 1px;
  background: rgba(111, 216, 255, 0.16);
  overflow: hidden;
}

.gg-loading-bar i {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gg-cyan);
  box-shadow: 0 0 10px var(--gg-cyan);
  animation: gg-sweep 1.5s ease-in-out infinite;
}

.gg-loading-text { font-size: 9.5px; letter-spacing: 0.14em; color: var(--gg-faint); }

@keyframes gg-pulse { 0%, 100% { opacity: 0.62; } 50% { opacity: 1; } }
@keyframes gg-sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

.gg-noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  font-family: var(--gg-mono);
  color: var(--gg-dim);
  background: #000;
  text-align: center;
}

/* --------------------------------------------------------------- responsive */

/* Compact desktop: narrower columns before the phone layout takes over.
   Scoped above the breakpoint so it can never override the drawer layout. */
@media (min-width: 901px) and (max-width: 1180px) {
  .gg-panel { width: 238px; }
  .gg-panel-right { width: 250px; }
  .gg-panels { padding-top: 100px; }
  .gg-lang { right: 12px; }
}

/* The drawer layout itself lives in the block near the top of this file; here
   only the title block and the language switch are re-sized. */
@media (max-width: 900px) {
  /* One row, not a stacked block: the render keeps the space instead. */
  .gg-title {
    top: 8px;
    left: 12px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 9px;
  }
  .gg-title-main { font-size: 14px; letter-spacing: 0.22em; }
  .gg-title-sub { display: none; }
  .gg-title-meta {
    flex-direction: row;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
  }
  .gg-chip {
    padding: 2px 5px;
    font-size: 8.5px;
    white-space: nowrap;
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .gg-lang { top: 8px; right: 10px; }
  .gg-lang-btn { padding: 5px 9px; font-size: 9.5px; }
}

@media (max-width: 560px) {
  .gg-title-main { font-size: 13px; letter-spacing: 0.18em; }
  /* A phone has no room for the debug-view chip next to the title. */
  .gg-title-meta [data-chip="debug"] { display: none; }
  .gg-chip { font-size: 8px; padding: 2px 4px; max-width: 72px; }
  .gg-lang-btn { padding: 5px 8px; font-size: 9px; }
  .gg-debug { grid-template-columns: 1fr 1fr; }
  .gg-row-label { font-size: 9.5px; }
  .gg-tab { padding: 7px 9px; font-size: 10px; }
}

/* Chinese glyphs need a slightly larger optical size than the Latin labels. */
html[lang^="zh"] .gg-row-label { font-size: 10.5px; letter-spacing: 0; }
html[lang^="zh"] .gg-ro-label { font-size: 10px; }
html[lang^="zh"] .gg-head { letter-spacing: 0.12em; }
html[lang^="zh"] .gg-group { letter-spacing: 0.12em; font-size: 9.5px; }
html[lang^="zh"] .gg-btn,
html[lang^="zh"] .gg-dbg { letter-spacing: 0.02em; font-size: 10px; }
html[lang^="zh"] .gg-legend { letter-spacing: 0.02em; }
html[lang^="zh"] .gg-hint { letter-spacing: 0.02em; }
html[lang^="zh"] .gg-toast { letter-spacing: 0.04em; }
html[lang^="zh"] .gg-title-sub { letter-spacing: 0.14em; }
html[lang^="zh"] .gg-btn-wide span { letter-spacing: 0.04em; }

/* Touch devices: the HUD must never trap the orbit gesture. Scoped above the
   breakpoint, because the phone drawer already defines its own surfaces. */
@media (pointer: coarse) and (min-width: 901px) {
  .gg-panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(5, 8, 12, 0.86); }
}

@media (prefers-reduced-motion: reduce) {
  .gg-hint { animation: none; opacity: 0.75; }
  .gg-loading-mark { animation: none; }
}
