:root {
  color-scheme: light;
  --drawer-height: 122px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050505;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050505;
}

#wall {
  display: block;
  width: min(100vw, 56.25vh);
  height: min(100vh, 177.7778vw);
  background-color: #8b8b8b;
  background-image: url("concrete.jpg");
  background-repeat: repeat;
  background-size: 420px 420px;
  box-shadow: 0 0 34px rgba(0, 0, 0, 0.5);
  cursor: crosshair;
  touch-action: none;
}

@supports (height: 100dvh) {
  #wall {
    width: min(100vw, 56.25dvh);
    height: min(100dvh, 177.7778vw);
  }
}

.drawer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: calc(var(--drawer-height) + var(--safe-bottom));
  padding: 18px 16px calc(16px + var(--safe-bottom));
  background: rgba(28, 28, 28, 0.86);
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
  transition: transform 180ms ease;
}

.drawer-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.drawer-toggle {
  display: none;
  position: absolute;
  top: -18px;
  left: 50%;
  width: 58px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(28, 28, 28, 0.9);
  transform: translateX(-50%);
}

.drawer-toggle span {
  width: 13px;
  height: 13px;
  border-top: 3px solid #fff;
  border-left: 3px solid #fff;
  transform: translateY(4px) rotate(45deg);
}

.palette,
.sizes {
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.swatch,
.size {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.swatch::before {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--swatch);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.swatch.is-active,
.size.is-active {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.size span {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #f4f4f4;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.history-link {
  grid-column: 1 / -1;
  justify-self: center;
  color: rgba(255, 255, 255, 0.66);
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  letter-spacing: 0;
}

.history-link:focus-visible,
.return-link:focus-visible,
.history-arrow:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.return-link {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  z-index: 2;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(12, 12, 12, 0.28);
  opacity: 0.72;
  backdrop-filter: blur(8px);
}

.return-link span,
.history-arrow span {
  display: block;
  width: 15px;
  height: 15px;
  border-top: 3px solid #fff;
  border-left: 3px solid #fff;
}

.return-link span {
  transform: translateX(3px) rotate(-45deg);
}

.history-drawer {
  min-height: calc(116px + var(--safe-bottom));
}

.history-drawer.is-collapsed {
  transform: translateY(calc(100% + var(--safe-bottom)));
}

.history-drawer .drawer-toggle {
  display: grid;
  place-items: center;
}

.history-drawer.is-collapsed .drawer-toggle {
  top: -52px;
  height: 44px;
  border-radius: 8px;
}

.history-drawer:not(.is-collapsed) .drawer-toggle span {
  transform: translateY(-3px) rotate(225deg);
}

.history-controls {
  display: grid;
  gap: 14px;
  width: min(680px, 100%);
  margin: 0 auto;
}

.history-slider {
  width: 100%;
  accent-color: #f4f4f4;
  touch-action: pan-x;
}

.history-stepper {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 12px;
}

.history-arrow {
  width: 54px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.history-arrow:disabled {
  opacity: 0.38;
}

.history-arrow-left span {
  transform: translateX(4px) rotate(-45deg);
}

.history-arrow-right span {
  transform: translateX(-4px) rotate(135deg);
}

.history-count {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1;
  text-align: center;
}

@media (max-width: 430px) {
  :root {
    --drawer-height: 156px;
  }

  .drawer {
    padding-top: 20px;
  }

  .drawer.is-collapsed {
    transform: translateY(calc(100% + var(--safe-bottom)));
  }

  .drawer-toggle {
    display: grid;
    place-items: center;
  }

  .drawer.is-collapsed .drawer-toggle {
    top: -52px;
    height: 44px;
    border-radius: 8px;
  }

  .drawer:not(.is-collapsed) .drawer-toggle span {
    transform: translateY(-3px) rotate(225deg);
  }

  .drawer-controls {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .palette,
  .sizes {
    justify-content: center;
  }

  .history-drawer {
    min-height: calc(126px + var(--safe-bottom));
  }

  .history-stepper {
    grid-template-columns: 50px 1fr 50px;
  }

  .history-arrow {
    width: 50px;
  }
}
