:root {
  color-scheme: dark;
  font-family: "Segoe UI", sans-serif;
  color: #fff;
  background: #111;
  --accent: #f3a65a;
  --white: #fff;
  --dark: #191919;
}

* {
  box-sizing: border-box;
}

body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
  min-height: 360px;
  margin: 0;
  overflow: hidden;
  background: #111;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 100%;
  height: 54px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.ad-banner {
  width: min(468px, 100vw);
  height: 42px;
  display: grid;
  place-items: center;
  margin-top: 6px;
  border-radius: 10px;
  color: #fff;
  background: #1b1b1b;
  pointer-events: auto;
}

.ad-banner svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
  opacity: .4;
}

.workspace,
.canvas-area {
  position: absolute;
  inset: 0;
}

.canvas-area {
  overflow: hidden;
  background: #111;
}

#pixel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.timeline {
  position: fixed;
  z-index: 4;
  top: 50%;
  left: 17px;
  width: 54px;
  height: min(42vh, 340px);
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 11px 0 13px;
  border-radius: 28px;
  background: #1c1c1cf2;
  transform: translateY(-50%);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.icon-button:hover {
  background: #ffffff1a;
}

.icon-button:active,
.earn-button:active,
.color-button:active {
  transform: scale(.94);
}

.icon-button:focus-visible,
button:focus-visible,
input:focus-visible,
.color-wheel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-button svg,
.earn-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.timeline-live {
  width: 34px;
  height: 34px;
}

.timeline-live svg {
  width: 19px;
  height: 19px;
}

.timeline-track-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 120px;
  display: grid;
  place-items: center;
}

.timeline-track-wrap::before {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  background: #505050;
  content: "";
}

.timeline-slider {
  position: absolute;
  z-index: 1;
  left: 50%;
  width: 2px;
  height: 100%;
  max-height: 270px;
  margin: 0;
  border-radius: 5px;
  outline: none;
  background: transparent;
  cursor: ns-resize;
  transform: translateX(-50%);
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: none;
}

.timeline-slider::-webkit-slider-runnable-track {
  width: 2px;
  border-radius: 2px;
  background: #555;
}

.timeline-slider::-moz-range-track {
  width: 2px;
  border-radius: 2px;
  background: #555;
}

.timeline-slider::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #1c1c1c;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--white);
  appearance: none;
}

.timeline-slider::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid #1c1c1c;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--white);
}

.toolbar {
  position: fixed;
  z-index: 4;
  right: 0;
  bottom: max(17px, env(safe-area-inset-bottom));
  left: 0;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
}

.toolbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.earn-button,
.color-button {
  position: relative;
  height: 66px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 19px;
  background: #1b1b1bf5;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}

.earn-button {
  width: 78px;
  grid-auto-flow: column;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 10px;
}

.earn-button:hover,
.color-button:hover {
  background: #292929;
}

.earn-icon {
  display: grid;
  place-items: center;
  color: #fff;
}

.earn-icon svg {
  width: 24px;
  height: 24px;
}

.balance {
  display: grid;
  place-items: center;
  min-width: 24px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.collect-float {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 6px);
  left: 50%;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.collect-float.is-visible {
  animation: collect-float .65s ease-out both;
}

.balance.bump {
  animation: balance-bump .34s ease-out;
}

.earn-button.empty {
  animation: earn-pulse 1.15s ease-in-out infinite;
}

.color-control {
  position: relative;
  width: 78px;
  height: 66px;
  flex: 0 0 auto;
}

.color-button {
  width: 100%;
  height: 66px;
  display: block;
  border-radius: 16px;
}

.recent-colors {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 11.75px;
  height: 30px;
  width: 18px;
  display: grid;
  grid-template-rows: 1fr 1fr;
  justify-items: center;
  align-items: center;
  pointer-events: none;
  transform: translateY(-50%);
}

.recent-color-button {
  width: 18px;
  height: 15px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.recent-color-button:disabled {
  cursor: default;
}

.recent-color-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.recent-color {
  width: 12px;
  height: 12px;
  border: 1px solid #ffffffa8;
  border-radius: 50%;
  background: #555;
}

.recent-color-button:not(:disabled):hover .recent-color {
  transform: scale(1.12);
}

.color-button {
  display: block;
}

.color-swatch {
  position: absolute;
  top: 50%;
  left: calc(50% - 9.75px);
  transform: translate(-50%, -50%);
}

.color-swatch {
  width: 29px;
  height: 29px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #242424;
}

.color-dialog {
  width: min(240px, calc(100vw - 48px));
  max-width: none;
  max-height: none;
  justify-items: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 18px;
  background: #1b1b1b;
  box-shadow: none;
}

.color-dialog::backdrop {
  background: #080808b8;
  backdrop-filter: blur(4px);
}

.color-wheel {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@keyframes balance-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes collect-float {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -28px) scale(1);
  }
}

@keyframes earn-pulse {
  50% { box-shadow: 0 0 0 5px #ffffff26, 0 0 18px #ffffff80; }
}

@media (max-width: 600px) {
  .topbar {
    height: 42px;
  }

  .ad-banner {
    width: 100vw;
    height: 42px;
    margin-top: 0;
    border-radius: 0;
  }

  .timeline {
    left: 9px;
    width: 48px;
    height: min(40vh, 300px);
    min-height: 170px;
  }

  .toolbar {
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .toolbar-inner {
    gap: 10px;
  }

  .earn-button {
    width: 76px;
    height: 62px;
  }

  .color-control {
    width: 76px;
    height: 62px;
  }

  .color-button {
    height: 62px;
  }

  .recent-colors {
    right: 10.75px;
  }
}
