:root {
  color-scheme: dark;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #121212;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#app {
  position: fixed;
  inset: 0;
  touch-action: none;
}
#controls {
  position: fixed;
  bottom: 122px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(18, 18, 18, 0.82);
  border: 1px solid #3a3a3a;
  padding: 8px 12px;
  border-radius: 8px;
  color: #e8e8e8;
  font-size: 12px;
}
#controls label {
  display: flex;
  align-items: center;
  gap: 6px;
}
#stats {
  min-width: 0;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
input[type="range"] {
  width: 110px;
  accent-color: #d6d6d6;
}
button {
  background: #3a3a3a;
  color: #e8e8e8;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}
button:hover {
  filter: brightness(1.2);
}
button:active {
  filter: brightness(1.4);
}
.gallery-item:active {
  filter: brightness(1.3);
}
#spin {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  background: rgba(18, 18, 18, 0.82);
  border-color: #3a3a3a;
  font-size: 12px;
}
#spin:hover {
  filter: brightness(1.2);
}
#spin.spin-on {
  border-color: #d6d6d6;
  color: #d6d6d6;
}
#spin.spin-off {
  opacity: 0.6;
}
#menu {
  display: none;
}
#drop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 18, 0.85);
  color: #d6d6d6;
  font-size: 20px;
  border: 2px dashed #3a3a3a;
  border-radius: 12px;
}
#drop.over {
  display: flex;
}
#gallery {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: rgba(18, 18, 18, 0.85);
  border-top: 1px solid #3a3a3a;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
#gallery-strip {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
}
#gallery-strip:empty {
  display: none;
}
body.no-gallery #gallery {
  display: none;
}
body.no-gallery #controls {
  bottom: 14px;
}
.gallery-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  background: transparent;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 5px 6px 6px;
  cursor: pointer;
  color: #e8e8e8;
  touch-action: manipulation;
}
.gallery-item:hover {
  filter: brightness(1.15);
}
.gallery-item.active {
  border-color: #d6d6d6;
}
.gallery-item img.thumb {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
  background: #3a3a3a;
  display: block;
}
.gallery-item span {
  font-size: 9px;
  max-width: 72px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 700px) {
  #spin {
    top: 10px;
    right: 10px;
    font-size: 12px;
    min-height: 40px;
    min-width: 44px;
    z-index: 6;
  }

  #menu {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 7;
    width: 22px;
    height: 44px;
    padding: 0;
    background: transparent;
    border-color: transparent;
    border-radius: 8px 0 0 8px;
    font-size: 14px;
    color: #909090;
  }
  #menu.open {
    background: transparent;
    color: #d6d6d6;
  }
  #controls {
    left: 0;
    right: 0;
    bottom: var(--gallery-h, 96px);
    transform: translateY(8px) scale(0.98);
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 0;
    border-bottom: none;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition:
      opacity 0.16s ease,
      transform 0.16s ease;
  }
  body.controls-open #controls {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  body.no-gallery #controls {
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
  input[type="range"] {
    width: 96px;
  }
  #stats {
    font-size: 10px;
  }

  #gallery {
    bottom: env(safe-area-inset-bottom, 0);
  }
  #gallery-strip {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 10px;
  }
  .gallery-item {
    padding: 6px;
    min-height: 52px;
  }
  .gallery-item img.thumb {
    width: 56px;
    height: 56px;
  }
  .gallery-item span {
    max-width: 64px;
    font-size: 8px;
  }

  #drop {
    font-size: 16px;
    padding: 12px;
    text-align: center;
  }
}
