/* Blue — bin night. Municipal, sodium, not a Shelf cousin. */

:root {
  --bg: #12161c;
  --ink: #e8e4dc;
  --muted: #9aa3ad;
  --paper: #1a212b;
  --bin: #1e5ad4;
  --bin-hi: #3d7cff;
  --sodium: #ffb347;
  --grease: #d4681a;
  --tag: #ff7a1a;
  --asphalt: #2a3038;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background:
    radial-gradient(700px 280px at 50% -8%, #3a2a14 0%, transparent 58%),
    var(--bg);
  color: var(--ink);
  max-width: 440px;
  margin: 0 auto;
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 2px 10px;
}
h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.03em; }
h1 span { font-size: 0.9rem; color: var(--sodium); font-weight: 800; vertical-align: super; }
.header-right { display: flex; gap: 10px; align-items: center; }
#streak { font-weight: 800; }
#help-btn, .x {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.scene {
  position: relative;
  height: 430px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #2a3340;
  background: linear-gradient(#1c2430 0%, #141920 70%);
}
.dawn {
  position: absolute; inset: 0;
  background:
    radial-gradient(90px 50px at 78% 18%, #ffb34744 0%, transparent 70%),
    linear-gradient(#1a2230, #10151c 72%);
}
.house {
  position: absolute;
  left: 16px; top: 70px;
  width: 78px; height: 100px;
  background: #243040;
  border: 2px solid #3a4a5c;
}
.house::before {
  content: '';
  position: absolute;
  left: -10px; top: -22px;
  border-left: 49px solid transparent;
  border-right: 49px solid transparent;
  border-bottom: 24px solid #2c3a4c;
}
.house::after {
  content: '';
  position: absolute;
  right: 12px; top: 18px;
  width: 18px; height: 22px;
  background: #ffb34755;
  box-shadow: 0 0 16px #ffb34766;
}

.truck {
  position: absolute;
  bottom: 84px;
  right: -160px;
  width: 150px;
  height: 62px;
  z-index: 4;
}
.cab {
  position: absolute;
  right: 0; bottom: 10px;
  width: 40px; height: 32px;
  background: #c9b8a0;
  border-radius: 4px 8px 2px 2px;
}
.cab::after {
  content: '';
  position: absolute;
  right: 5px; top: 5px;
  width: 16px; height: 13px;
  background: #8ab4ff88;
}
.hopper {
  position: absolute;
  left: 0; bottom: 10px;
  width: 112px; height: 40px;
  background: #6a7580;
  border-radius: 4px;
}
.hopper::before {
  content: 'CITY';
  position: absolute;
  left: 10px; top: 8px;
  font: 800 9px/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  color: #c9d0d6;
}
.wheel {
  position: absolute;
  bottom: 0;
  width: 16px; height: 16px;
  background: #0d0f12;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px #3a4048;
}
.wheel.a { left: 18px; }
.wheel.b { right: 20px; }

.street {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 84px;
  background: var(--asphalt);
  border-top: 3px solid #3a424c;
}
.street::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 36px;
  height: 4px;
  background: repeating-linear-gradient(90deg, #c9b070 0 16px, transparent 16px 32px);
  opacity: 0.35;
}

.bin {
  position: absolute;
  left: 112px; bottom: 68px;
  width: 196px; height: 156px;
  background: var(--bin);
  border: 3px solid var(--bin-hi);
  border-radius: 8px 8px 4px 4px;
  z-index: 5;
  box-shadow: inset 0 -16px 0 #1548b0;
}
.bin::before {
  content: '';
  position: absolute;
  left: 10px; right: 10px; top: 10px;
  height: 8px;
  background: #1548b0;
  border-radius: 3px;
}
.lid {
  position: absolute;
  left: 8px; top: -10px;
  width: 72px; height: 10px;
  background: var(--bin-hi);
  border-radius: 3px;
  transform-origin: 8px 10px;
  transition: transform 0.2s ease;
}
.bin.open .lid { transform: rotate(-28deg); }
.bin.dump .lid { transform: rotate(-55deg); }
.tag {
  position: absolute;
  right: -6px; top: 38px;
  width: 20px; height: 26px;
  background: var(--tag);
  transform: rotate(8deg);
  opacity: 0;
}
.tag::after {
  content: '';
  position: absolute;
  left: 6px; top: 5px;
  width: 7px; height: 7px;
  border: 2px solid #2a1408;
  border-radius: 50%;
}
.scene.tagged .tag { opacity: 1; }

.item {
  position: absolute;
  z-index: 6;
  cursor: pointer;
  touch-action: manipulation;
  padding: 6px;
  border: none;
  background: transparent;
  border-radius: 0;
}
.item.live:active { transform: scale(0.94) !important; }
.item.gone {
  position: relative;
  display: inline-block;
  margin: 2px;
}

.item .body { display: block; position: relative; pointer-events: none; }

.it-bottle .body {
  width: 20px; height: 42px;
  background: #2fbf71;
  border-radius: 5px 5px 6px 6px;
}
.it-bottle .body::before {
  content: '';
  position: absolute;
  left: 5px; top: -8px;
  width: 10px; height: 10px;
  background: #1a8a4a;
  border-radius: 3px 3px 0 0;
}
.it-jar .body {
  width: 22px; height: 26px;
  background: #d7eef7aa;
  border: 2px solid #8ab4ff;
  border-radius: 3px;
}
.it-can .body {
  width: 20px; height: 26px;
  background: linear-gradient(#d0d5da, #8a9098);
  border-radius: 3px;
}
.it-paper .body {
  width: 32px; height: 16px;
  background: #e8e0d0;
  transform: rotate(-6deg);
}
.it-cardboard .body {
  width: 36px; height: 30px;
  background: #b8894a;
  border: 2px solid #8a6230;
}
.it-cardboard.flat .body {
  width: 42px; height: 9px;
}
.it-pizza .body {
  width: 44px; height: 30px;
  background: #c9a06a;
  border: 2px solid #8a6230;
}
.it-pizza .body::after {
  content: '';
  position: absolute;
  left: 6px; top: 7px;
  width: 16px; height: 11px;
  background: var(--grease);
  border-radius: 40% 60%;
  box-shadow: 12px 4px 0 #a84810;
}
.it-closed .body,
.it-closed-bag .body {
  width: 42px; height: 32px;
  background: #8a6230;
  border: 2px dashed var(--sodium);
  border-radius: 4px;
}
.it-closed-bag .body {
  background: #2a4058;
  border-color: #8ab4ff;
  border-radius: 0 0 12px 12px;
}
.it-closed .body::after,
.it-closed-bag .body::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 15px/1 system-ui, sans-serif;
  color: var(--sodium);
}
.it-closed-bag .body::after { color: #8ab4ff; }
.it-battery .body {
  width: 14px; height: 30px;
  background: #111;
  border-radius: 2px;
}
.it-battery .body::before {
  content: '';
  position: absolute;
  left: 3px; top: -4px;
  width: 8px; height: 6px;
  background: #d4b44a;
}
.it-bag .body {
  width: 28px; height: 32px;
  background: #8ab4ff33;
  border: 2px dashed #8ab4ff;
  border-radius: 0 0 10px 10px;
}
.it-foam .body {
  width: 26px; height: 20px;
  background: #e8e4dc;
  border-radius: 40% 50% 45% 55%;
}

.trash {
  position: absolute;
  left: 10px; bottom: 78px;
  width: 94px;
  min-height: 88px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-end;
  gap: 2px;
}

.flavor {
  min-height: 1.4em;
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

button {
  appearance: none;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 14px 8px;
  border-radius: 14px;
  cursor: pointer;
}
button.primary { background: var(--bin); border-color: var(--bin-hi); color: #fff; }
button:active { transform: translateY(1px); }

#overlay, #help {
  position: fixed;
  inset: 0;
  background: #0a0c10cc;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}
#overlay[hidden], #help[hidden] { display: none; }
#overlay .card, #help .card {
  width: min(400px, 100%);
  background: #1a212b;
  border: 2px solid var(--sodium);
  border-radius: 18px;
  padding: 18px 16px 16px;
  position: relative;
  max-height: min(88vh, 100%);
  overflow: auto;
}
.x { position: absolute; top: 10px; right: 10px; }
.big-score { font-size: 3.2rem; font-weight: 800; letter-spacing: -0.04em; }
.tier { font-size: 1.25rem; font-weight: 800; color: var(--sodium); }
.next-grade, .best, .streak-line { color: var(--muted); margin-top: 4px; font-size: 0.92rem; }
.day-emojis { font-size: 1.25rem; letter-spacing: 0.04em; margin: 10px 0; }
.explain, .near { margin-top: 10px; line-height: 1.4; }
.near { color: var(--muted); }
.help-list { padding-left: 0; list-style: none; }
.help-list li { margin: 0.55rem 0; line-height: 1.4; }

.confetti {
  position: fixed;
  top: -20px;
  animation: fall 2.4s linear forwards;
  pointer-events: none;
  z-index: 40;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(240deg); opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .lid, .confetti { transition: none; animation: none; }
}
