*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  /* 100% fallback, then small/large dynamic viewport so mobile browser chrome
     collapsing never clips or stretches the canvas. */
  height: 100%;
  height: 100svh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #000000;
  color: #ffffff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  font-family: "SF Mono", "Menlo", "Consolas", "Liberation Mono", "Courier New", monospace;
}

#wallpaper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  display: block;
  background-color: #000000;
}

/* ------------------------------------------------------------------ */
/* One-shot gesture hint (pure CSS timing; any interaction dismisses)  */
/* ------------------------------------------------------------------ */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 9;
  max-width: calc(100vw - 32px);
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(12, 13, 17, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(226, 232, 246, 0.62);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  animation: hint-fade 4.9s ease forwards;
}

.hint.is-hidden {
  animation: none;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

@keyframes hint-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  11%,
  92% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
}

/* ------------------------------------------------------------------ */
/* Floating frosted-glass HUD (bottom centre, auto-hiding)             */
/* ------------------------------------------------------------------ */
.hud {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  max-width: calc(100vw - 20px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(13, 14, 18, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.hud::-webkit-scrollbar {
  display: none;
}

.hud.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.hud button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 0.22s ease, background-color 0.22s ease, opacity 0.22s ease;
}

.hud button:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
  border-radius: 999px;
}

.hud-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 17px;
  display: grid;
  place-items: center;
}

.hud-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
}

.hud-dots {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 3px;
  flex: 0 0 auto;
}

.hud-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.42);
}

.hud-dot:hover {
  color: rgba(255, 255, 255, 0.85);
}

.hud-dot.is-active {
  color: #05060a;
  background: rgba(240, 244, 255, 0.9);
  font-weight: 600;
}

.hud-div {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
}

.hud-chip {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.hud-chip:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.hud-chip[aria-pressed="true"] {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.1);
}

.hud-chip.is-off {
  color: rgba(255, 255, 255, 0.34);
  background: transparent;
}

/* Tablets / phones: compact pill with 36px tap targets, never overflows */
@media (max-width: 640px) {
  .hint {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    font-size: 8.5px;
    letter-spacing: 0.07em;
    padding: 6px 11px;
  }

  .hud {
    gap: 1px;
    padding: 4px 7px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .hud button {
    min-height: 36px;
  }

  .hud-btn {
    width: 26px;
    height: 36px;
    font-size: 16px;
  }

  .hud-dot {
    width: 20px;
    height: 36px;
    font-size: 8.5px;
  }

  .hud-div {
    margin: 0 2px;
    height: 14px;
  }

  .hud-chip {
    padding: 0 7px;
    font-size: 8.5px;
    letter-spacing: 0.05em;
    height: 36px;
    border-radius: 999px;
  }
}

/* Very narrow phones (360-390px): trim the pill further, keep tap targets */
@media (max-width: 400px) {
  .hud {
    gap: 0;
    padding: 3px 5px;
  }

  .hud-dots {
    gap: 0;
    padding: 0 1px;
  }

  .hud-chip {
    padding: 0 6px;
    font-size: 8px;
    letter-spacing: 0.03em;
  }

  .hud-dot {
    width: 18px;
    font-size: 8px;
  }

  .hud-btn {
    width: 24px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .hud,
  .hint {
    background: rgba(10, 11, 14, 0.92);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
