:root {
  --body: #b8e6c8;
  --belly: #e0f2e6;
  --wing: #b8e6c8;
  --wing-belly: #e0f2e6;
  --eye: #f5c878;
  --horn: #e0f2e6;
  --claw: #4a3a5c;
  --tooth: #ffffff;
  --outline: #4a3a5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #ffe5f0 0%, #e5e8ff 50%, #e5fff0 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

h1 {
  font-size: 2.5rem;
  color: var(--outline);
  margin: 10px 0 20px;
  text-shadow: 3px 3px 0 white;
  letter-spacing: 1px;
}

.app {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 1100px;
}

.stage {
  background: white;
  border: 6px solid var(--outline);
  border-radius: 24px;
  padding: 16px;
  box-shadow: 8px 8px 0 var(--outline);
  flex: 1 1 460px;
  max-width: 600px;
}

.stage svg {
  width: 100%;
  height: auto;
  display: block;
}

.picker {
  background: white;
  border: 6px solid var(--outline);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 8px 8px 0 var(--outline);
  flex: 1 1 320px;
  max-width: 420px;
}

/* Accordion-style groups */
.group {
  background: white;
  border: 3px solid var(--outline);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
.group:last-child {
  margin-bottom: 0;
}

.group-header {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}
.group-header::-webkit-details-marker {
  display: none;
}
.group-header::marker {
  content: "";
}

.group-title {
  flex: 1;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.95rem;
  color: var(--outline);
}

.group-header::after {
  content: "\25b6";
  color: var(--outline);
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.group[open] .group-header::after {
  transform: rotate(90deg);
}

.current {
  display: flex;
  align-items: center;
}
.current .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  display: inline-block;
}
.current .label {
  font-weight: 700;
  text-transform: capitalize;
  font-size: 0.9rem;
  color: var(--outline);
}

.group > .swatches,
.group > .choices {
  padding: 4px 18px 16px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid var(--outline);
  cursor: pointer;
  transition: transform 0.1s;
  padding: 0;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch.active {
  box-shadow:
    0 0 0 4px white,
    0 0 0 8px var(--outline);
  transform: scale(1.1);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  padding: 10px 16px;
  border: 4px solid var(--outline);
  background: white;
  color: var(--outline);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition:
    transform 0.1s,
    background 0.1s,
    color 0.1s;
}

.choice:hover {
  transform: scale(1.05);
}

.choice.active {
  background: var(--outline);
  color: white;
}

.hidden {
  display: none;
}

/* Library / saved dragons */
.library {
  padding: 4px 18px 16px;
}
.save-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
#dragon-name {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 4px solid var(--outline);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--outline);
  outline: none;
  background: white;
}
#dragon-name::placeholder {
  color: rgba(74, 58, 92, 0.5);
}
#save-dragon {
  padding: 12px 18px;
  border: 4px solid var(--outline);
  background: var(--outline);
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}
#save-dragon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.saved-list:empty::before {
  content: "No saved dragons yet \2014 name yours and tap Save.";
  color: rgba(74, 58, 92, 0.6);
  font-size: 0.9rem;
  font-style: italic;
}
.saved-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.load-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 3px solid var(--outline);
  background: white;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--outline);
}
.load-btn .swatch-preview {
  display: inline-flex;
  gap: 3px;
}
.load-btn .swatch-preview .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--outline);
}
.load-btn .name {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delete-btn {
  width: 36px;
  height: 36px;
  border: 3px solid var(--outline);
  background: white;
  color: var(--outline);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  flex-shrink: 0;
}

.dragon-fill {
  fill: var(--body);
}
.dragon-belly {
  fill: var(--belly);
}
.dragon-stroke {
  stroke: var(--outline);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dragon-eye-color {
  fill: var(--eye);
}

/* Wings use their own color variables (so wings can be a different color from the body) */
#wings-layer .dragon-fill {
  fill: var(--wing);
}
#wings-layer .dragon-belly {
  fill: var(--wing-belly);
}
/* Horns use their own color variable */
#horns-layer .dragon-belly {
  fill: var(--horn);
}
/* Stubby claws follow the claw color (override the body/wing scoping above) */
#dragon [data-variant="stubby"] .dragon-fill {
  fill: var(--claw);
}

.scale-detail {
  stroke: var(--outline);
  stroke-width: 1.5;
  fill: none;
  opacity: 0.45;
  stroke-linecap: round;
}
.belly-detail {
  stroke: var(--outline);
  stroke-width: 2;
  fill: none;
  opacity: 0.55;
}
