:root {
  color-scheme: light;
  --ink: #29304a;
  --muted: #66708a;
  --cream: #fff9df;
  --shadow: 0 18px 44px rgba(41, 48, 74, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Comic Sans MS", system-ui, sans-serif;
  background:
    radial-gradient(circle at 10% 16%, rgba(255, 220, 82, 0.84) 0 82px, transparent 84px),
    radial-gradient(circle at 89% 12%, rgba(255, 122, 162, 0.48) 0 104px, transparent 106px),
    linear-gradient(135deg, #a8ecff 0%, #d9f7e1 42%, #fff2a5 72%, #ffc8dc 100%);
}

button,
a {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  text-decoration: none;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
  width: min(1280px, 100vw);
  height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 1.7vw, 18px);
}

.topbar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(180px, 242px);
  align-items: center;
  gap: 12px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #277b66;
  font-size: clamp(0.74rem, 1.8vw, 0.9rem);
  font-weight: 950;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: clamp(2rem, 6vw, 4.3rem);
  line-height: 0.93;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.7);
}

.progress-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 8px;
  min-height: 62px;
  padding: 8px 12px;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.progress-icon {
  grid-row: 1 / 3;
  font-size: 1.75rem;
}

.progress-card strong {
  font-size: clamp(0.9rem, 1.8vw, 1.08rem);
  white-space: nowrap;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6e4;
  box-shadow: inset 0 2px 2px rgba(41, 48, 74, 0.12);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef4f5f 0 25%, #2f9de1 25% 50%, #f2bf28 50% 75%, #64b93f 75%);
  transition: width 300ms ease;
}

.laundry-room {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(182px, 32%);
  min-height: 0;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 70%, transparent 70%),
    repeating-linear-gradient(90deg, #fff8df 0 88px, #f6efd9 88px 91px);
  box-shadow: var(--shadow);
}

.laundry-room::after {
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 31%;
  content: "";
  background:
    linear-gradient(90deg, rgba(111, 132, 151, 0.12) 2px, transparent 2px),
    linear-gradient(rgba(111, 132, 151, 0.12) 2px, transparent 2px),
    #eaf3f1;
  background-size: 82px 82px;
  transform: perspective(260px) rotateX(8deg) scale(1.04);
  transform-origin: bottom;
}

.room-wall {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.window {
  position: absolute;
  top: 5%;
  left: 5%;
  width: clamp(140px, 19vw, 230px);
  height: clamp(100px, 17vh, 150px);
  overflow: hidden;
  border: 10px solid white;
  border-radius: 8px;
  background: linear-gradient(#75d8ff 0 63%, #97dc72 63%);
  box-shadow: 0 8px 0 rgba(41, 48, 74, 0.12);
}

.window::before,
.window::after {
  position: absolute;
  z-index: 2;
  content: "";
  background: white;
}

.window::before {
  top: 0;
  bottom: 0;
  left: calc(50% - 4px);
  width: 8px;
}

.window::after {
  top: calc(50% - 4px);
  right: 0;
  left: 0;
  height: 8px;
}

.cloud {
  position: absolute;
  width: 48px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.cloud::before,
.cloud::after {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: inherit;
  content: "";
}

.cloud::before {
  left: 8px;
  width: 24px;
  height: 24px;
}

.cloud::after {
  right: 5px;
  width: 18px;
  height: 18px;
}

.cloud-one {
  top: 24px;
  left: 20px;
}

.cloud-two {
  right: 13px;
  bottom: 22px;
  transform: scale(0.72);
}

.shelf {
  position: absolute;
  top: 7%;
  right: 4%;
  width: clamp(160px, 20vw, 240px);
  height: 22px;
  border-radius: 8px;
  background: #b77742;
  box-shadow: inset 0 -6px 0 rgba(41, 48, 74, 0.13), 0 8px 0 rgba(41, 48, 74, 0.12);
}

.bottle {
  position: absolute;
  bottom: 20px;
  width: 36px;
  height: 65px;
  border-radius: 12px 12px 9px 9px;
  background: #ff78a7;
  box-shadow: inset 0 -7px 0 rgba(41, 48, 74, 0.1);
}

.bottle::before {
  position: absolute;
  top: -14px;
  left: 8px;
  width: 20px;
  height: 18px;
  border-radius: 5px 5px 2px 2px;
  background: #7658c8;
  content: "";
}

.bottle-one {
  left: 16px;
}

.bottle-two {
  left: 65px;
  height: 51px;
  background: #77cfde;
}

.folded-clothes {
  position: absolute;
  right: 12px;
  bottom: 20px;
  width: 76px;
  height: 22px;
  border-radius: 8px;
  background: #64b93f;
  box-shadow: 0 -19px 0 #f2bf28, 0 -38px 0 #2f9de1;
}

.washer {
  position: absolute;
  right: 4%;
  bottom: 25%;
  width: clamp(105px, 13vw, 156px);
  aspect-ratio: 1 / 1.05;
  border: 6px solid #d9e5e5;
  border-radius: 8px;
  background: linear-gradient(#ffffff 0 25%, #eef5f4 25%);
  box-shadow: 0 10px 0 rgba(41, 48, 74, 0.13);
}

.washer-dial {
  position: absolute;
  top: 8%;
  right: 12%;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #8797a6;
}

.washer-door {
  position: absolute;
  right: 17%;
  bottom: 8%;
  width: 66%;
  aspect-ratio: 1;
  border: 9px solid #8aa0ad;
  border-radius: 50%;
  background:
    radial-gradient(circle at 62% 34%, rgba(255, 255, 255, 0.74) 0 11%, transparent 12%),
    linear-gradient(135deg, #72cdeb, #334c6d);
  box-shadow: inset 0 0 0 6px #c8d8dc;
}

.play-zone {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.sorting-spot {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  place-items: center;
  justify-self: center;
  width: min(58%, 620px);
  min-height: 0;
}

.instruction {
  align-self: start;
  max-width: 520px;
  margin: 2px auto 0;
  padding: 9px 16px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  color: #684aa8;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 7px 0 rgba(41, 48, 74, 0.1);
  font-size: clamp(0.82rem, 1.7vw, 1.02rem);
  font-weight: 900;
  text-align: center;
}

.garment {
  --drag-x: 0px;
  --drag-y: 0px;
  position: relative;
  z-index: 8;
  display: grid;
  align-content: center;
  justify-items: center;
  width: min(72%, 290px);
  max-height: 96%;
  aspect-ratio: 1.12;
  padding: clamp(8px, 1.5vh, 14px);
  border: 5px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--garment-color) 18%, white) 0 38%, transparent 39%),
    rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 -7px 0 rgba(41, 48, 74, 0.08), 0 12px 0 rgba(41, 48, 74, 0.13), var(--shadow);
  touch-action: none;
  transform: translate(var(--drag-x), var(--drag-y));
  transition: transform 180ms ease, box-shadow 140ms ease, opacity 180ms ease;
}

.garment:hover,
.garment:focus-visible,
.garment.is-selected {
  outline: 6px solid #ffd84a;
  outline-offset: 3px;
  box-shadow: inset 0 -7px 0 rgba(41, 48, 74, 0.08), 0 14px 0 rgba(41, 48, 74, 0.14), 0 22px 46px rgba(41, 48, 74, 0.22);
  transform: translate(var(--drag-x), calc(var(--drag-y) - 5px)) rotate(-1deg);
}

.garment.is-dragging {
  cursor: grabbing;
  opacity: 0.92;
  transition: none;
  transform: translate(var(--drag-x), var(--drag-y)) scale(1.05) rotate(3deg);
}

.garment.is-wrong {
  animation: garment-shake 430ms ease;
}

.garment.is-sorted {
  opacity: 0;
  transform: translateY(80px) scale(0.45) rotate(10deg);
}

.garment-art {
  display: block;
  width: min(100%, 210px);
  min-height: 0;
}

.garment-art svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 9px 0 rgba(41, 48, 74, 0.12));
}

.garment strong {
  margin-top: -7px;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 1000;
}

.garment small {
  margin-top: 2px;
  color: var(--muted);
  font-size: clamp(0.72rem, 1.4vw, 0.88rem);
  font-weight: 850;
}

.sparkles {
  position: absolute;
  z-index: 10;
  top: 52%;
  left: 50%;
  pointer-events: none;
}

.sparkles span {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--sparkle-color);
  clip-path: polygon(50% 0, 62% 35%, 100% 36%, 69% 58%, 79% 100%, 50% 74%, 21% 100%, 31% 58%, 0 36%, 38% 35%);
  animation: sparkle-pop 620ms ease-out forwards;
}

.basket-row {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(125px, 1fr));
  align-items: end;
  gap: clamp(10px, 2vw, 24px);
  padding: 0 clamp(16px, 5vw, 70px) clamp(10px, 2vh, 22px);
}

.basket {
  position: relative;
  display: grid;
  grid-template-rows: minmax(105px, 1fr) auto auto;
  align-items: end;
  justify-items: center;
  min-width: 0;
  min-height: 150px;
  padding: 0 6px 5px;
  background: transparent;
  touch-action: manipulation;
  transition: transform 150ms ease, filter 150ms ease;
}

.basket-shape {
  position: relative;
  display: block;
  align-self: end;
  justify-self: center;
  width: 82%;
  height: 105px;
}

.basket-mouth {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 100%;
  height: 38px;
  border: 8px solid var(--basket-dark);
  border-radius: 50%;
  background: #29394e;
  box-shadow: inset 0 6px 0 rgba(0, 0, 0, 0.16), 0 4px 0 rgba(41, 48, 74, 0.12);
  transform: translateX(-50%);
}

.basket-body {
  position: absolute;
  z-index: 2;
  top: 19px;
  left: 50%;
  display: block;
  width: 90%;
  height: 86px;
  overflow: hidden;
  border: 7px solid var(--basket-dark);
  border-top: 0;
  border-radius: 8px 8px 22px 22px;
  background:
    repeating-linear-gradient(0deg, transparent 0 13px, rgba(255, 255, 255, 0.34) 13px 18px),
    var(--basket-color);
  box-shadow: inset 0 -8px 0 rgba(41, 48, 74, 0.12), 0 8px 0 rgba(41, 48, 74, 0.13);
  transform: translateX(-50%);
}

.basket-body::before,
.basket-body::after,
.basket-body i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5px;
  background: rgba(255, 255, 255, 0.38);
  content: "";
  transform: rotate(7deg);
}

.basket-body::before {
  left: 18%;
}

.basket-body::after {
  right: 18%;
  transform: rotate(-7deg);
}

.basket-body i:nth-child(1) {
  left: 38%;
}

.basket-body i:nth-child(2) {
  right: 38%;
  transform: rotate(-7deg);
}

.basket-body i:nth-child(3) {
  display: none;
}

.basket strong {
  margin-top: 6px;
  font-size: clamp(1rem, 2.1vw, 1.35rem);
  font-weight: 1000;
}

.basket small {
  color: var(--basket-dark);
  font-size: clamp(0.72rem, 1.5vw, 0.88rem);
  font-weight: 950;
}

.basket:hover,
.basket:focus-visible,
.basket.is-hovered {
  z-index: 5;
  filter: saturate(1.12);
  outline: 5px solid rgba(255, 255, 255, 0.95);
  outline-offset: 0;
  transform: translateY(-7px) scale(1.04);
}

.basket.is-correct {
  animation: basket-happy 520ms ease;
}

.basket.is-wrong {
  animation: basket-no 450ms ease;
}

.finish-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(41, 48, 74, 0.42);
  backdrop-filter: blur(8px);
}

.finish-overlay.hidden {
  display: none;
}

.finish-panel {
  width: min(530px, 100%);
  padding: clamp(26px, 6vw, 48px);
  border: 6px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 216, 74, 0.55) 0 54px, transparent 56px),
    radial-gradient(circle at 88% 80%, rgba(100, 185, 63, 0.35) 0 66px, transparent 68px),
    #ffffff;
  box-shadow: 0 28px 80px rgba(41, 48, 74, 0.32);
  text-align: center;
  animation: finish-pop 360ms ease both;
}

.finish-laundry {
  margin-bottom: 12px;
  font-size: 4rem;
}

.finish-panel h2 {
  margin-top: 5px;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 0.96;
}

.finish-panel > p:not(.eyebrow) {
  margin-top: 13px;
  color: var(--muted);
  font-weight: 800;
}

.finish-panel button {
  min-width: 190px;
  min-height: 58px;
  margin-top: 24px;
  padding: 12px 24px;
  border-radius: 8px;
  color: #ffffff;
  background: #7658c8;
  box-shadow: inset 0 -6px 0 #543b9e, 0 8px 0 rgba(41, 48, 74, 0.15);
  font-size: 1.08rem;
  font-weight: 1000;
}

.finish-panel button:hover,
.finish-panel button:focus-visible {
  outline: 5px solid #ffd84a;
  outline-offset: 3px;
  transform: translateY(-2px);
}

@keyframes garment-shake {
  20%, 60% { transform: translateX(-14px) rotate(-4deg); }
  40%, 80% { transform: translateX(14px) rotate(4deg); }
}

@keyframes basket-happy {
  35% { transform: translateY(-15px) rotate(-4deg) scale(1.08); }
  70% { transform: translateY(-4px) rotate(3deg) scale(1.04); }
}

@keyframes basket-no {
  25%, 75% { transform: translateX(-8px) rotate(-3deg); }
  50% { transform: translateX(8px) rotate(3deg); }
}

@keyframes sparkle-pop {
  from { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  to { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(180deg) scale(1); }
}

@keyframes finish-pop {
  from { opacity: 0; transform: scale(0.78) rotate(-2deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    min-height: 100svh;
  }

  .topbar {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .progress-card {
    grid-column: 1 / -1;
  }

  .laundry-room {
    grid-template-rows: 430px auto;
    min-height: 720px;
  }

  .play-zone {
    grid-template-columns: minmax(0, 1fr);
  }

  .instruction {
    max-width: 94%;
    padding: 7px 10px;
  }

  .garment {
    width: min(92%, 250px);
  }

  .sorting-spot {
    width: min(94%, 440px);
  }

  .washer,
  .shelf {
    display: none;
  }

  .basket-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }

  .basket {
    min-height: 145px;
  }
}

@media (max-height: 650px) and (min-width: 761px) {
  .game-shell {
    padding: 8px;
  }

  .laundry-room {
    grid-template-rows: minmax(0, 1fr) 174px;
  }

  .window {
    height: 92px;
  }

  .garment {
    width: min(62%, 230px);
  }

  .basket {
    min-height: 144px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
