:root {
  --gap: .75rem;
  --slot-size: clamp(58px, 13vw, 82px);
  --playground-header-height: 64px;
  --game-bg: #fffaf4;
  --game-blue: #4d8dff;
  --game-blue-soft: #eef5ff;
  --game-yellow: #fff3b5;
  --game-pink: #ffe6ef;
  --game-green: #e7f8ee;
  --game-purple: #f0e9ff;
  --game-text: #334155;
  --game-muted: #758195;
}

html, body {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, #fff7d9 0, transparent 28%),
    radial-gradient(circle at top right, #eaf4ff 0, transparent 30%),
    var(--game-bg);
}

body {
  margin: 0;
  color: var(--game-text);
  -webkit-tap-highlight-color: transparent;
}

#shared-playground-header {
  position: sticky;
  top: 0;
  z-index: 1100;
}

.app {
  min-height: calc(100dvh - var(--playground-header-height, 64px));
  display: flex;
  flex-direction: column;
}

.eyebrow,
.challenge-kicker,
.chip-label {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #7c8ba1;
}

/* Picker */
.picker {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 28px);
  background:
    radial-gradient(circle at 20% 10%, #fff1bd 0, transparent 30%),
    radial-gradient(circle at 80% 20%, #dcecff 0, transparent 32%),
    rgba(255, 255, 255, .96);
}

.picker-card-shell {
  width: min(780px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid #e8edf4;
  border-radius: 24px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 20px 60px rgba(65, 79, 106, .14);
}

.picker .grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
}

.pick-card {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 2px solid #e8edf4;
  border-radius: 18px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: transform .15s ease, box-shadow .18s ease, border-color .18s ease;
}

.pick-card:nth-child(4n+1) { background: #fff9e8; }
.pick-card:nth-child(4n+2) { background: #eef7ff; }
.pick-card:nth-child(4n+3) { background: #f4eeff; }
.pick-card:nth-child(4n+4) { background: #effaf3; }

.pick-card:hover,
.pick-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--game-blue);
  box-shadow: 0 10px 26px rgba(77,141,255,.16);
}

.pick-emoji {
  font-size: clamp(42px, 8vw, 66px);
  line-height: 1;
}

.pick-label {
  margin-top: .45rem;
  font-weight: 700;
  color: #667085;
}

/* Score + challenge */
.game-info {
  max-width: 900px;
}

.score-row {
  display: flex;
  justify-content: center;
  gap: .65rem;
  flex-wrap: wrap;
}

.score-chip {
  min-width: 92px;
  padding: .65rem .9rem;
  text-align: center;
  border: 1px solid #e5ebf3;
  border-radius: 16px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 20px rgba(83, 97, 124, .06);
}

.score-chip strong {
  display: block;
  margin-top: .1rem;
  font-size: 1.25rem;
}

.combo-chip.combo-hot {
  background: #fff2d9;
  border-color: #ffd990;
  transform: scale(1.04);
}

.challenge-card {
  max-width: 720px;
  margin: .9rem auto 0;
  padding: 1rem 1.1rem;
  text-align: center;
  border: 1px solid #e4eaf2;
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 28px rgba(68, 82, 107, .07);
}

.challenge-text {
  margin-top: .15rem;
  font-size: clamp(.92rem, 2.5vw, 1.05rem);
  color: var(--game-muted);
}

.challenge-color {
  margin-top: .35rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
}

.feedback {
  min-height: 28px;
  margin-top: .35rem;
  font-weight: 800;
}

.feedback.correct { color: #1b9c59; }
.feedback.wrong { color: #e46d53; }

/* Palette */
.topbar {
  position: sticky;
  top: var(--playground-header-height, 64px);
  z-index: 5;
  margin-top: .8rem;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88));
  backdrop-filter: blur(8px);
  border-top: 1px solid #edf0f5;
  border-bottom: 1px solid #e9edf3;
}

.title {
  font-weight: 800;
  letter-spacing: .01em;
}

.palette-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: .55rem var(--gap) 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.palette-wrap::-webkit-scrollbar { display: none; }

.palette {
  display: flex;
  justify-content: center;
  gap: var(--gap);
  padding-bottom: .75rem;
  min-width: max-content;
  margin: 0 auto;
}

.slot {
  scroll-snap-align: start;
  flex: 0 0 var(--slot-size);
  width: var(--slot-size);
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255,255,255,.92);
  outline: 2px solid #e2e7ee;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(58, 73, 101, .09);
  transition: transform .13s ease, box-shadow .15s ease, outline-color .15s ease;
  user-select: none;
  cursor: pointer;
}

.slot .sample {
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1;
  filter: var(--f, none);
  pointer-events: none;
}

.slot:hover,
.slot.active {
  outline-color: var(--game-blue);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 22px rgba(77,141,255,.18);
}

.slot.correct-pop {
  outline-color: #39b86f;
  animation: correctPop .35s ease;
}

.slot.wrong-shake {
  outline-color: #ef8a72;
  animation: wrongShake .25s ease;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

/* Stage */
.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem var(--gap) calc(env(safe-area-inset-bottom) + 88px);
}

.stage-inner {
  text-align: center;
}

.icon {
  font-size: clamp(92px, 24vw, 155px);
  line-height: 1;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform .12s ease, filter .12s ease;
  filter: var(--icon-filter, none);
}

.icon:active {
  cursor: grabbing;
  transform: scale(1.04);
}

.icon.dragging {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform: scale(1.06);
}

.stage-hint {
  margin-top: .8rem;
  color: #8a94a6;
  font-size: .84rem;
}

/* Toolbar */
.toolbar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: .75rem clamp(.75rem, 4vw, 1rem) calc(env(safe-area-inset-bottom) + .5rem);
  display: flex;
  gap: .5rem;
  justify-content: center;
  background: linear-gradient(0deg, rgba(255,255,255,.97), rgba(255,255,255,.90));
  backdrop-filter: blur(8px);
  border-top: 1px solid #e9edf3;
}

/* Filters */
.f-0   { --f: hue-rotate(0deg)    saturate(1.3) brightness(1.05); }
.f-30  { --f: hue-rotate(30deg)   saturate(1.4) brightness(1.05); }
.f-60  { --f: hue-rotate(60deg)   saturate(1.4) brightness(1.05); }
.f-90  { --f: hue-rotate(90deg)   saturate(1.5) brightness(1.05); }
.f-120 { --f: hue-rotate(120deg)  saturate(1.5) brightness(1.06); }
.f-150 { --f: hue-rotate(150deg)  saturate(1.6) brightness(1.06); }
.f-180 { --f: hue-rotate(180deg)  saturate(1.6) brightness(1.07); }
.f-210 { --f: hue-rotate(210deg)  saturate(1.6) brightness(1.08); }
.f-240 { --f: hue-rotate(240deg)  saturate(1.7) brightness(1.08); }
.f-300 { --f: hue-rotate(300deg)  saturate(1.7) brightness(1.09); }

.icon.f-0   { --icon-filter: hue-rotate(0deg)    saturate(1.3) brightness(1.05); }
.icon.f-30  { --icon-filter: hue-rotate(30deg)   saturate(1.4) brightness(1.05); }
.icon.f-60  { --icon-filter: hue-rotate(60deg)   saturate(1.4) brightness(1.05); }
.icon.f-90  { --icon-filter: hue-rotate(90deg)   saturate(1.5) brightness(1.05); }
.icon.f-120 { --icon-filter: hue-rotate(120deg)  saturate(1.5) brightness(1.06); }
.icon.f-150 { --icon-filter: hue-rotate(150deg)  saturate(1.6) brightness(1.06); }
.icon.f-180 { --icon-filter: hue-rotate(180deg)  saturate(1.6) brightness(1.07); }
.icon.f-210 { --icon-filter: hue-rotate(210deg)  saturate(1.6) brightness(1.08); }
.icon.f-240 { --icon-filter: hue-rotate(240deg)  saturate(1.7) brightness(1.08); }
.icon.f-300 { --icon-filter: hue-rotate(300deg)  saturate(1.7) brightness(1.09); }

@media (max-width: 767.98px) {
  .picker .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pick-card {
    min-height: 112px;
  }

  .palette {
    justify-content: flex-start;
  }
}

@media (max-width: 575.98px) {
  .title { font-size: .95rem; }
  .game-info { padding-top: .7rem !important; }
  .challenge-card { padding: .85rem .9rem; }
  .score-chip { min-width: 82px; padding: .55rem .75rem; }
}
