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

body {
  background: #0A0A0A;
  color: #fff;
  font-family: monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

canvas#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease;
}

canvas#draw {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.scene {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}

h1 {
  font-size: clamp(1rem, 5vw, 3rem);
  font-weight: normal;
  position: relative;
  z-index: 10;
  padding: 0.4rem 0.8rem;
  border-radius: 16px;
  backdrop-filter: blur(16px);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#text::after {
  content: '|';
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.orbit {
  position: absolute;
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,calc(0.18 - var(--depth, 0) * 0.025));
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  z-index: 1;
}
.orbit.visible {
  opacity: 1;
  animation: orbitPulse var(--pdur, 4s) ease-in-out var(--pdelay, 0.8s) infinite;
}
@keyframes orbitPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.planet {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #5E5E5E;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 0; left: 0;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.5s ease;
  cursor: pointer;
  text-decoration: none;
  pointer-events: all;
}
.planet.visible { opacity: 1; }

.planet::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  letter-spacing: 0.05em;
}
.planet:hover::after { opacity: 1; }

.planet img {
  width: 55%;
  height: 55%;
  filter: invert(1);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .orbit { animation: none !important; }
  #text::after { animation: none; opacity: 1; }
}

.achievement {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  background: rgba(15,15,15,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-left: 3px solid #32dc64;
  border-radius: 10px;
  padding: 0.9rem 1.2rem;
  max-width: 280px;
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  user-select: none;
}
.achievement.show { opacity: 1; transform: translateX(0); }
.ach-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.ach-icon   { width: 18px; height: 18px; }
.ach-title  { font-family: monospace; font-size: 1rem; color: #fff; }
.ach-desc   { font-family: monospace; font-size: 0.72rem; color: rgba(255,255,255,0.5); }

#profile-btn {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 200;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(20,20,20,0.9);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, background 0.2s;
  backdrop-filter: blur(8px);
  user-select: none;
}
#profile-btn svg { width: 18px; height: 18px; }
#profile-btn.visible { opacity: 1; pointer-events: all; }
#profile-btn:hover { background: rgba(255,255,255,0.1); }

#reset-btn {
  position: fixed;
  top: 5rem;
  left: 1.5rem;
  z-index: 200;
  background: rgba(255,40,40,0.1);
  color: rgba(255,80,80,0.8);
  border: 1px solid rgba(255,40,40,0.2);
  font-family: monospace;
  font-size: 0.7rem;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  letter-spacing: 0.04em;
}
#reset-btn.visible { opacity: 1; pointer-events: all; }
#reset-btn:hover { background: rgba(255,40,40,0.2); color: #ff6060; }

#profile-panel {
  position: fixed;
  top: 4.5rem;
  left: 1.5rem;
  z-index: 200;
  background: rgba(15,15,15,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  min-width: 220px;
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  
}
#profile-panel.open { opacity: 1; pointer-events: all; transform: translateY(0); }
#profile-header { font-family: monospace; font-size: 0.8rem; color: rgba(255,255,255,0.4); margin-bottom: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
#ach-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; user-select: none; }
#ach-list li { font-family: monospace; font-size: 0.85rem; color: #fff; display: flex; align-items: center; gap: 0.5rem; }
#ach-list li.done { color: rgba(255,255,255,0.35); text-decoration: line-through; }
#ach-list li.done::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #32dc64; flex-shrink: 0; }
#ach-list li:not(.done)::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0; }

#home-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-family: monospace;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  letter-spacing: 0.05em;
}
#home-btn.visible {
  opacity: 1;
  pointer-events: all;
}
#home-btn:hover { background: rgba(255,255,255,0.15); }

#beverages-btn {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  z-index: 100;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  font-family: monospace;
  font-size: 0.75rem;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  text-decoration: none;
  letter-spacing: 0.05em;
  user-select: none;
}
#beverages-btn.visible { opacity: 1; pointer-events: all; }
#beverages-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

#clear-btn {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 100;
  background: rgba(255, 60, 60, 0.15);
  color: #ff4444;
  border: 1px solid rgba(255, 60, 60, 0.3);
  font-family: monospace;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
#clear-btn::after {
  content: 'Delete all';
  font-size: 0.75rem;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-width 0.2s ease;
  white-space: nowrap;
}
#clear-btn:hover::after { opacity: 1; max-width: 80px; }
#clear-btn.visible { opacity: 1; pointer-events: all; }
#clear-btn:hover { background: rgba(255, 60, 60, 0.3); }

#toolbar {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(20,20,20,0.9);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px 10px;
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  /* needed for color-panel absolute positioning */
  isolation: isolate;
}
#toolbar.visible { opacity: 1; pointer-events: all; }

.tool-btn, .size-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 6px;
}
.tool-btn svg { width: 100%; height: 100%; }
.tool-btn:hover, .size-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.tool-btn.active, .size-btn.active { background: rgba(255,255,255,0.15); color: #fff; }

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  margin: 0 4px;
}

#colors {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

#fill-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  width: 44px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: background 0.15s, color 0.15s;
}
#fill-btn svg { width: 100%; height: 100%; }
#fill-btn:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }
#fill-btn.active { color: #32dc64; }
#fill-btn.active #fill-knob { transform: translateX(10px); }

#color-btn {  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: background 0.15s;
}
#color-btn:hover { background: rgba(255,255,255,0.08); }

#color-panel {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(12px);
  z-index: 101;
}
#color-panel.open { opacity: 1; pointer-events: all; }

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: block;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}
.color-swatch.active { outline-color: rgba(255,255,255,0.7); }
.color-swatch:hover { outline-color: rgba(255,255,255,0.3); }

/* ── mobile responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
  #toolbar {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    transform: none;
    overflow-x: auto;
    gap: 2px;
    padding: 5px 8px;
    border-radius: 10px;
    /* hide scrollbar visually */
    scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }

  #home-btn {
    bottom: 1rem;
    right: 1rem;
    font-size: 0.72rem;
    padding: 0.45rem 0.8rem;
  }

  #beverages-btn {
    bottom: 4.5rem;
    right: 1rem;
    font-size: 0.68rem;
  }

  #clear-btn {
    bottom: 1rem;
    left: 1rem;
  }
  /* hide "Delete all" text label on mobile to save space */
  #clear-btn::after { display: none; }

  #profile-btn {
    top: 1rem;
    left: 1rem;
  }

  #reset-btn {
    top: 4rem;
    left: 1rem;
  }

  #profile-panel {
    top: 3.8rem;
    left: 1rem;
    min-width: 180px;
    max-height: 60vh;
    overflow-y: auto;
  }

  .achievement {
    top: auto;
    bottom: 5rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }

  #color-panel {
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
  }

  .tool-btn, .size-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }

  #fill-btn {
    width: 38px;
    height: 30px;
    flex-shrink: 0;
  }
}
