:root {
  --bg: #1c1c1c;         /* Dark background */
  --c1: #ab9ff2;         /* Accent purple */
  --c2: #fffdf8;         /* Light soft white */
  --text-dark: #fffdf8;  /* Light text on dark */
  --text-light: #1c1c1c; /* Dark text on light */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-dark);
  font-family: Inter, sans-serif;
  text-align: center;
}

header {
  padding: 2rem 1rem 1rem;
}

.title {
  font-family: Bungee, Inter, sans-serif;
  font-size: 2rem;
  margin: 0;
  color: var(--c2);
}

.subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin: 0.3rem 0 2rem;
  color: var(--c1);
}

.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  padding: 0 1rem 2rem;
}

.preview {
  flex: 1 1 360px;
  max-width: 420px;
  position: relative;
}

canvas {
  width: 100%;
  height: auto;
  background: var(--bg);
  border: 3px solid var(--c1);
  border-radius: 12px;
  box-shadow: 0 8px 0 #00000040;
}

.buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

.btn {
  flex: 1;
  margin: 0 4px;
  padding: 10px 12px;
  font-family: Bungee;
  font-size: 0.95rem;
  background: var(--c1);
  color: var(--text-dark);
  border: 2px solid var(--text-dark);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.btn.primary {
  background: var(--c2);
  color: var(--text-light);
}
.btn:hover {
  transform: translateY(-2px);
  background: var(--c2);
  color: var(--text-light);
}

/* Base color selector */
.base-colors {
  margin-top: 1.5rem;
}
.base-colors h3 {
  font-family: Bungee;
  font-size: 1rem;
  color: var(--c2);
  margin-bottom: 0.5rem;
}
.swatches {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--text-dark);
  transition: transform 0.15s ease;
}
.swatch:hover,
.swatch.active {
  transform: scale(1.1);
  border-color: var(--c1);
}

/* Controls layout */
.controls {
  flex: 1 1 480px;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  align-items: stretch;
}

.layer-group {
  background: #2c2c2e;
  border: 3px solid var(--c1);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 6px 0 #00000050;
  transition: background 0.3s ease;
}

/* Dropdown functionality */
.dropdown {
  cursor: pointer;
}
.dropdown-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: Bungee;
  font-size: 1.15rem;
  margin: 0;
  color: var(--c2);
}
.dropdown-title:after {
  content: "+";
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}
.dropdown.open .dropdown-title:after {
  content: "−";
  transform: rotate(180deg);
}
.dropdown-content {
  display: none;
  margin-top: 0.5rem;
}
.dropdown.open .dropdown-content {
  display: grid;
}

/* Thumbnail grid */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
}
.thumbs img {
  width: 100%;
  max-width: 60px;
  height: auto;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  background: var(--bg);
}
.thumbs img:hover,
.thumbs img.active {
  border-color: var(--c1);
  transform: scale(1.05);
}

footer {
  padding: 1rem;
  font-size: 0.9rem;
  opacity: 0.7;
  color: var(--c2);
}

@media (max-width: 600px) {
  .title {
    font-size: 1.6rem;
  }
  .layer-group h2 {
    font-size: 1.1rem;
  }
  .thumbs {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }
  .thumbs img {
    max-width: 48px;
  }
}
