:root {
  --ink: #2E2350;
  --lilac: #EDE3FF;
  --lilac-dot: #DCCBFF;
  --pink: #FF4F9A;
  --sun: #FFD23F;
  --sun-soft: #FFE680;
  --mint: #3DD9A8;
  --sky: #5BC0FF;
  --grape: #7B4DFF;
  --white: #FFFFFF;
  --soft-border: #E4DAFA;
  --font: 'Baloo 2', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --chunky: 0 6px 0 var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--ink);
  background: radial-gradient(var(--lilac-dot) 2.5px, transparent 3px) 0 0 / 26px 26px, var(--lilac);
  min-height: 100vh;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 4px solid var(--grape);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Masthead: the wordmark wobbles like a row of jelly sweets. */
.masthead {
  text-align: center;
  padding: 28px 16px 8px;
}

.logo {
  margin: 0;
  font-size: clamp(3.2rem, 11vw, 6.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
}

.logo span {
  display: inline-block;
  -webkit-text-stroke: 0.09em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--ink);
}

.logo span:nth-child(5n + 1) { color: var(--pink); transform: rotate(-6deg); }
.logo span:nth-child(5n + 2) { color: var(--sun); transform: translateY(-0.06em) rotate(4deg); }
.logo span:nth-child(5n + 3) { color: var(--mint); transform: rotate(-3deg); }
.logo span:nth-child(5n + 4) { color: var(--sky); transform: translateY(0.04em) rotate(6deg); }
.logo span:nth-child(5n + 5) { color: var(--grape); transform: rotate(-4deg); }
.logo .logo-gap { width: 0.3em; }

.tagline {
  margin: 10px auto 0;
  max-width: 44ch;
  font-size: 1.25rem;
  font-weight: 500;
}

/* Main layout */
.lab {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

@media (min-width: 900px) {
  .lab {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: start;
  }
  .stage { position: sticky; top: 16px; }
}

/* Stage: a sunburst for the squishy to show off on. */
.stage {
  background:
    repeating-conic-gradient(from 0deg at 50% 52%, var(--sun-soft) 0deg 12deg, #FFDA55 12deg 24deg);
  border: 5px solid var(--ink);
  border-radius: 44px;
  box-shadow: 0 10px 0 var(--ink);
  padding: 22px 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.name-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 460px;
}

.name-input {
  flex: 1;
  min-width: 0;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 800;
  text-align: center;
  padding: 4px 12px;
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--chunky);
  transform: rotate(-1.5deg);
}

.icon-button {
  flex: none;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  background: var(--pink);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--chunky);
  transition: transform 0.08s, box-shadow 0.08s;
}
.icon-button svg { width: 30px; height: 30px; }
.icon-button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.icon-button-sky { background: var(--sky); }
.icon-button-small { width: 44px; height: 44px; border-width: 3px; box-shadow: 0 4px 0 var(--ink); }
.icon-button-small svg { width: 24px; height: 24px; }
.icon-button[aria-pressed="true"] .sound-off,
.icon-button[aria-pressed="false"] .sound-on { display: none; }

.squishy {
  position: relative;
  width: min(430px, 100%);
  aspect-ratio: 1;
  margin: 8px 0 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 40px;
}
.squishy:active { cursor: grabbing; }
.squishy-art { display: block; width: 100%; height: 100%; }

/* iPhone only makes a haptic tick when a real tap lands on a switch's label,
   so an invisible label covers the squishy. */
.squish-haptic { position: absolute; inset: 0; border-radius: inherit; }
.squish-haptic input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.squishy svg { display: block; width: 100%; height: 100%; overflow: visible; }

.squishy .squish-body,
.squishy .squishy-shadow {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
.squishy .squishy-shadow { transform-origin: 50% 50%; transition: transform 0.12s; }
.squishy .squish-body { animation: breathe 3.2s ease-in-out infinite alternate; }

.squishy.is-squished .squish-body {
  animation: none;
  transform: scale(calc(1 + var(--give) * 0.7), calc(1 - var(--give)));
  transition: transform 0.1s ease-out;
}
.squishy.is-squished .squishy-shadow { transform: scaleX(calc(1 + var(--give))); }
.squishy.is-squished .eyes-normal { display: none; }
.squishy.is-squished .eyes-squeeze { display: inline; }
.squishy.is-jiggling .squish-body { animation: jiggle 0.75s ease-out; }
.squishy.is-popping svg { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.squishy .is-glowing .glow-halo { animation: glow 1.6s ease-in-out infinite alternate; }

@keyframes breathe {
  from { transform: scale(1, 1); }
  to { transform: scale(1.015, 0.985); }
}

@keyframes jiggle {
  0% { transform: scale(calc(1 + var(--give) * 0.7), calc(1 - var(--give))); }
  30% { transform: scale(calc(1 - var(--give) * 0.35), calc(1 + var(--give) * 0.45)); }
  55% { transform: scale(calc(1 + var(--give) * 0.18), calc(1 - var(--give) * 0.2)); }
  78% { transform: scale(calc(1 - var(--give) * 0.07), calc(1 + var(--give) * 0.08)); }
  100% { transform: scale(1, 1); }
}

@keyframes pop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

@keyframes glow {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 16px;
}

.hint {
  margin: 0;
  text-align: center;
  font-weight: 700;
  background: var(--white);
  border-radius: 999px;
  padding: 2px 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.btn {
  font-size: 1.15rem;
  font-weight: 800;
  padding: 10px 22px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--chunky);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn-pink { background: var(--pink); color: var(--white); font-size: 1.3rem; }
.btn-mint { background: var(--mint); }
.btn-sky { background: var(--sky); }
.btn-sun { background: var(--sun); }

.status {
  min-height: 1.5em;
  overflow-wrap: anywhere;
  margin: 14px 0 0;
  font-weight: 700;
  text-align: center;
}

/* Workshop: tabs of choices */
.workshop {
  background: var(--white);
  border: 5px solid var(--ink);
  border-radius: 32px;
  box-shadow: 0 10px 0 var(--ink);
  padding: 18px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

[role="tab"] {
  flex: 1 1 auto;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 8px 14px;
  background: var(--lilac);
  border: 3px solid transparent;
  border-radius: 999px;
}
[role="tab"]:hover { border-color: var(--grape); }
[role="tab"][aria-selected="true"] {
  background: var(--grape);
  color: var(--white);
  border-color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}

.group + .group { margin-top: 22px; }

.group h3 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
}

.options { display: grid; gap: 10px; }
.options-thumb { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.options-swatch { display: flex; flex-wrap: wrap; gap: 12px; }
.options-chip { display: flex; flex-wrap: wrap; gap: 10px; }

.option {
  background: var(--white);
  border: 3px solid var(--soft-border);
  transition: transform 0.08s;
}
.option:hover { border-color: var(--grape); }
.option:active { transform: scale(0.95); }

.option-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px 8px;
  border-radius: 22px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.15;
}
.option-thumb .thumb { display: block; width: 100%; aspect-ratio: 1; }
.option-thumb .thumb svg { display: block; width: 100%; height: 100%; }
.option-thumb[aria-pressed="true"] {
  background: #FFF0F7;
  border-color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}

.option-swatch {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--swatch);
  border: 4px solid var(--ink);
}
.option-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 4px var(--white), 0 0 0 8px var(--pink);
  transform: scale(1.08);
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
}
.option-chip[aria-pressed="true"] {
  background: var(--sky);
  border-color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.chip-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid var(--ink);
}

/* Shelf of saved squishies */
.shelf {
  max-width: 1180px;
  margin: 16px auto 48px;
  padding: 0 16px;
}

.shelf h2 {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  margin: 0 0 12px;
}

.shelf-empty {
  margin: 0;
  max-width: 50ch;
  font-weight: 500;
}

.shelf-list {
  list-style: none;
  margin: 0;
  padding: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  border-top: 10px solid var(--ink);
  border-radius: 6px;
}
.shelf-list:empty { display: none; }

.shelf-item { position: relative; }

.shelf-load {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 8px 10px;
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 26px;
  box-shadow: var(--chunky);
  transition: transform 0.08s, box-shadow 0.08s;
}
.shelf-load:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.shelf-art { display: block; width: 100%; aspect-ratio: 1; }
.shelf-art svg { display: block; width: 100%; height: 100%; }
.shelf-name {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.shelf-remove {
  position: absolute;
  top: -10px;
  right: -8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  background: var(--pink);
  color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .squishy .squish-body,
  .squishy.is-jiggling .squish-body,
  .squishy.is-popping svg,
  .squishy .is-glowing .glow-halo { animation: none; }
  .squishy.is-squished .squish-body { transition: none; }
}
