:root {
  color-scheme: dark;
  --panel: rgba(22, 24, 25, 0.68);
  --panel-strong: rgba(18, 19, 20, 0.84);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f5f2ea;
  --muted: #b7b1a7;
  --accent: #d4a84b;
  --cyan: #4ac4d6;
  --danger: #e56868;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #101111;
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#viewport {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: grab;
  touch-action: none;
}

#viewport:active {
  cursor: grabbing;
}

.hud {
  position: fixed;
  inset: 10px auto auto 10px;
  width: min(220px, calc(100vw - 20px));
  display: grid;
  gap: 5px;
  pointer-events: none;
}

.hudContent {
  display: grid;
  gap: 5px;
}

.hud.is-menu-collapsed .hudContent {
  display: none;
}

.brand,
.metrics,
.panel {
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px;
}

.brand > div {
  min-width: 0;
  flex: 1;
}

.brand img {
  width: 70px;
  max-width: 36%;
  height: auto;
  object-fit: contain;
}

.brand h1 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 720;
  letter-spacing: 0;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.iconButton {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.iconButton:hover,
.panelToggle:hover {
  border-color: rgba(212, 168, 75, 0.55);
  background: rgba(212, 168, 75, 0.1);
}

.menuIcon,
.menuIcon::before,
.menuIcon::after {
  display: block;
  width: 13px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease;
}

.menuIcon {
  position: relative;
}

.menuIcon::before,
.menuIcon::after {
  position: absolute;
  left: 0;
  content: "";
}

.menuIcon::before {
  transform: translateY(-5px);
}

.menuIcon::after {
  transform: translateY(5px);
}

.hud:not(.is-menu-collapsed) .menuIcon {
  background: transparent;
}

.hud:not(.is-menu-collapsed) .menuIcon::before {
  transform: rotate(45deg);
}

.hud:not(.is-menu-collapsed) .menuIcon::after {
  transform: rotate(-45deg);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.metrics div {
  min-width: 0;
  padding: 5px 5px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  display: grid;
  gap: 6px;
  padding: 6px;
}

.parametersPanel {
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.panelToggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
}

.parametersPanel.is-collapsed .panelToggle {
  border-bottom: 0;
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.parametersPanel.is-collapsed .chevron {
  transform: rotate(-45deg);
}

.parameterControls {
  display: grid;
  gap: 6px;
  padding: 6px;
}

.parametersPanel.is-collapsed .parameterControls {
  display: none;
}

label {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.historyPanel {
  max-height: 66px;
  overflow: hidden;
  background: var(--panel-strong);
}

.historyPanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.historyPanel header strong {
  color: var(--accent);
  font-size: 13px;
}

#history {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

#history li {
  display: grid;
  grid-template-columns: 22px 1fr 34px;
  gap: 4px;
  align-items: center;
  padding: 4px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

#history li.best {
  outline: 1px solid rgba(212, 168, 75, 0.48);
  color: var(--text);
}

@media (max-width: 700px) {
  .hud {
    inset: 8px auto auto 8px;
    width: min(212px, calc(100vw - 16px));
  }

  .brand img {
    width: 64px;
  }

  .historyPanel {
    max-height: 62px;
  }
}
