:root {
  color-scheme: light;
  --bg: #fbf7ea;
  --ink: #20262d;
  --muted: #5e6873;
  --panel: #ffffff;
  --panel-soft: #fff8df;
  --line: #e3d9bf;
  --line-strong: #cbbd99;
  --blue: #2f80ed;
  --green: #19a974;
  --yellow: #f4b942;
  --red: #ec5d57;
  --violet: #7d5fff;
  --teal: #00a7a5;
  --shadow: 0 18px 36px rgba(79, 60, 26, 0.14);
  --radius: 8px;
  --font: "Aptos", "Segoe UI", "Noto Sans", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(47, 128, 237, 0.12), rgba(47, 128, 237, 0.12)) 6% 116px / 96px 10px no-repeat,
    linear-gradient(90deg, rgba(25, 169, 116, 0.16), rgba(25, 169, 116, 0.16)) 12% 154px / 54px 10px no-repeat,
    linear-gradient(90deg, rgba(236, 93, 87, 0.14), rgba(236, 93, 87, 0.14)) 92% 140px / 86px 10px no-repeat,
    linear-gradient(90deg, rgba(244, 185, 66, 0.18), rgba(244, 185, 66, 0.18)) 86% 188px / 64px 10px no-repeat,
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 4px solid rgba(47, 128, 237, 0.55);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 18px;
  z-index: 30;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 14px;
}

.skip-link:focus {
  top: 14px;
}

.page-shell {
  width: min(1180px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  border: 2px solid rgba(203, 189, 153, 0.74);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo,
.city-logo {
  flex: 0 0 auto;
  border-radius: var(--radius);
  object-fit: cover;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 900;
}

.brand-subtitle,
.eyebrow,
.assistive-copy,
.source-line,
.feedback-line,
.score-pill span,
.final-score span,
.result-grid dt {
  color: var(--muted);
}

.brand-subtitle {
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.icon-button.small {
  width: 38px;
  height: 38px;
  font-size: 1.25rem;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.bin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(69, 54, 27, 0.15);
}

.game-main {
  display: grid;
  gap: 16px;
  padding-top: 16px;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.score-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border: 2px solid rgba(203, 189, 153, 0.66);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px 16px;
}

.score-pill span {
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-pill strong {
  font-size: 1.45rem;
  font-weight: 950;
}

.timer-pill.warning strong {
  color: #bf3a31;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(480px, 1.08fr);
  gap: 16px;
  align-items: stretch;
}

.stage-panel,
.bins-panel {
  border: 2px solid rgba(203, 189, 153, 0.7);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.stage-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

.stage-heading {
  display: grid;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.84rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 13ch;
  font-size: 2.1rem;
  line-height: 1.08;
}

.feedback-line {
  min-height: 28px;
  font-size: 1rem;
  font-weight: 800;
}

.feedback-line.good {
  color: #137957;
}

.feedback-line.bad {
  color: #bf3a31;
}

.item-card {
  display: grid;
  place-items: center;
  position: relative;
  width: min(100%, 460px);
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  border: 3px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(47, 128, 237, 0.09), transparent 30%),
    linear-gradient(315deg, rgba(25, 169, 116, 0.1), transparent 34%),
    #fffdf6;
  box-shadow: inset 0 0 0 8px rgba(255, 248, 223, 0.86);
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.item-card::before,
.item-card::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--yellow);
}

.item-card::before {
  left: 18px;
  top: 18px;
  transform: rotate(13deg);
}

.item-card::after {
  right: 20px;
  bottom: 18px;
  background: var(--teal);
  transform: rotate(-11deg);
}

.item-card.dragging {
  opacity: 0.78;
  transform: scale(0.98) rotate(-1deg);
}

.item-card.correct {
  animation: pop-correct 420ms ease;
  border-color: var(--green);
}

.item-card.wrong {
  animation: shake-wrong 360ms ease;
  border-color: var(--red);
}

.item-card img {
  z-index: 1;
  width: min(92%, 384px);
  height: auto;
  max-height: 88%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  padding: 10px 16px;
  font-weight: 950;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.secondary-button {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.assistive-copy {
  max-width: 46ch;
  font-size: 0.92rem;
  font-weight: 700;
}

.keyboard-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.keyboard-choice {
  min-height: 42px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
}

.bins-panel {
  padding: 18px;
}

.bin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  height: 100%;
}

.bin-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  min-height: 178px;
  border: 3px solid color-mix(in srgb, var(--bin-color), #000 8%);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bin-color), #fff 74%), #fff);
  color: var(--ink);
  padding: 14px;
  text-align: center;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.bin-card.active {
  filter: saturate(1.1);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--bin-color), transparent 64%);
}

.bin-lid,
.bin-body {
  width: 86px;
  background: var(--bin-color);
}

.bin-lid {
  height: 16px;
  border-radius: 6px 6px 3px 3px;
}

.bin-body {
  display: grid;
  place-items: center;
  height: 74px;
  border-radius: 6px 6px 12px 12px;
  color: #fff;
  font-size: 1.7rem;
  font-weight: 950;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.1);
}

.bin-name {
  font-size: 1.08rem;
  font-weight: 950;
}

.bin-short {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.source-line {
  justify-self: center;
  font-size: 0.86rem;
  font-weight: 800;
}

.modal {
  width: min(560px, calc(100vw - 36px));
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 0;
}

.modal::backdrop {
  background: rgba(32, 38, 45, 0.42);
}

.modal-panel {
  display: grid;
  gap: 18px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-heading h2,
.result-hero h2 {
  font-size: 1.7rem;
  line-height: 1.1;
}

.option-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.option-group legend {
  font-weight: 950;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segment-button {
  min-height: 44px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
}

.segment-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.result-modal {
  width: min(720px, calc(100vw - 36px));
}

.result-hero {
  display: grid;
  gap: 10px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(47, 128, 237, 0.13), rgba(244, 185, 66, 0.18));
  padding: 18px;
}

.final-score {
  display: grid;
  gap: 4px;
}

.final-score strong {
  font-size: 3rem;
  line-height: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.result-grid div {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.result-grid dt {
  font-size: 0.82rem;
  font-weight: 900;
}

.result-grid dd {
  margin: 4px 0 0;
  font-size: 1.3rem;
  font-weight: 950;
}

@keyframes pop-correct {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.035) rotate(1deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake-wrong {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-5px);
  }
}

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

@media (max-width: 980px) {
  .page-shell {
    width: min(960px, calc(100vw - 24px));
  }

  .game-board {
    grid-template-columns: 1fr;
  }

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

  .bin-card {
    min-height: 150px;
  }

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