:root { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, #fbcfe8, #e9d5ff, #bfdbfe);
  color: #6b21a8;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

main {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.back {
  color: #6b21a8;
  font-weight: 800;
  text-decoration: none;
}

h1 {
  margin: 8px 0 16px;
  text-align: center;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.1;
}

h2, h3 { margin: 0 0 12px; }

.card {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 16px 40px rgba(88, 28, 135, 0.16);
  padding: 18px;
}

.display { text-align: center; margin-bottom: 16px; }

.figure svg {
  width: min(300px, 100%);
  height: auto;
}

.labels {
  width: min(420px, 100%);
  margin: 12px auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  margin: 0;
  padding: 10px;
  border-radius: 14px;
  font-weight: 800;
}

.label.accessory { background: #f3e8ff; }
.label.top { background: #fce7f3; color: #9d174d; }
.label.bottom { background: #dbeafe; color: #1e40af; }

.random-wrap { text-align: center; margin: 16px 0; }

.random {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: linear-gradient(90deg, #ec4899, #a855f7);
  color: #fff;
  font: inherit;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(168, 85, 247, 0.35);
}

.random:hover { filter: brightness(0.95); }

.pickers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.choice-grid, .choice-list {
  display: grid;
  gap: 8px;
}

.characters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.accessories { grid-template-columns: 1fr 1fr; }

.choice-list {
  max-height: min(52vh, 460px);
  overflow: auto;
  padding-right: 4px;
}

.choice, .swatch {
  border: 0;
  border-radius: 14px;
  padding: 10px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.choice {
  background: #f3f4f6;
  color: #581c87;
}

.swatch {
  width: 100%;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.accessory-btn {
  background: linear-gradient(90deg, #fef9c3, #fce7f3);
  color: #581c87;
}

.is-on { box-shadow: 0 0 0 4px #a855f7; }

:focus-visible {
  outline: 3px solid #7c3aed;
  outline-offset: 3px;
}

@media (max-width: 800px) {
  .pickers, .characters { grid-template-columns: 1fr; }
  .characters { grid-template-columns: 1fr 1fr; }
}
