﻿/* Layout only — chrome UI is image assets (see assets/). */

:root {
  --ink: #17313a;
  --muted: #5e747a;
  --green-dark: #1f8a5d;
  --orange-dark: #d96742;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Nunito", ui-rounded, "Segoe UI", sans-serif;
  background: #cfeef5;
}

button {
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

.app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.phone {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  max-width: 540px;
  max-height: 960px;
  overflow: hidden;
  background: #dff4ff;
  box-shadow: 0 24px 70px rgba(31, 85, 99, 0.34);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: clamp(16px, 4.5vw, 28px);
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* Never let a board class force a screen to show without .active */
.screen:not(.active) {
  display: none !important;
}

.img-btn {
  display: grid;
  place-items: center;
  transition: transform 120ms ease, filter 120ms ease;
}

.img-btn:active {
  transform: translateY(6px) scale(0.98);
  filter: brightness(0.96);
}

.img-btn img {
  width: 100%;
  height: auto;
}

/* —— Home —— */
.home {
  padding: 0;
  justify-content: space-between;
  background: #8fd8ef;
}

.home-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}

.home-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 18%),
    linear-gradient(180deg, transparent 64%, rgba(30, 70, 95, 0.42) 100%);
}

.home-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: clamp(16px, 4.5vw, 26px) clamp(12px, 3.5vw, 18px) 0;
}

.title-logo {
  width: min(62%, 280px);
  height: auto;
  animation: logoFloat 3.8s ease-in-out infinite;
}

.best-chip {
  position: relative;
  width: clamp(108px, 30vw, 132px);
  height: clamp(44px, 12vw, 54px);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 6px;
}

.best-chip-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.best-chip-coin {
  position: relative;
  z-index: 1;
  width: clamp(24px, 7vw, 30px);
  height: auto;
}

.best-chip-meta {
  position: relative;
  z-index: 1;
  text-align: left;
  line-height: 1;
}

.best-chip-label {
  display: block;
  color: #7a8f98;
  font-size: clamp(10px, 2.4vw, 12px);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.best-chip-value {
  display: block;
  margin-top: 1px;
  color: #ff5f98;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 800;
}

.home-spacer {
  flex: 1;
  min-height: 0;
}

.home-cta {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  padding: 0 10% clamp(24px, 6vw, 42px);
}

.start-btn {
  width: min(78%, 320px);
  animation: ctaPulse 2.2s ease-in-out infinite;
}

.start-btn:active {
  animation: none;
}

/* —— Modes —— */
.modes {
  padding: clamp(14px, 3.8vw, 22px);
  gap: 10px;
}

.modes-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.modes-header,
.mode-grid {
  position: relative;
  z-index: 1;
}

.modes-header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.back-btn {
  width: clamp(48px, 13vw, 58px);
}

.modes-title-img {
  width: min(100%, 280px);
  height: auto;
}

.mode-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  overflow-y: auto;
  padding-bottom: 8px;
}

.mode-card {
  min-height: 0;
  width: 100%;
  height: 100%;
}

.mode-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mode-toast {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 4vw, 26px);
  z-index: 5;
  width: min(70%, 240px);
  min-height: 52px;
  display: grid;
  place-items: center;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.mode-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mode-toast-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.mode-toast-text {
  position: relative;
  z-index: 1;
  color: #d96742;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(20px, 5.2vw, 28px);
  font-weight: 800;
}

/* —— Group Sort board —— */
.sortboard {
  gap: 8px;
  padding: clamp(12px, 3.5vw, 18px);
  background: linear-gradient(180deg, #f4fbf7 0%, #eef6fb 100%);
}

.sort-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.sort-timer {
  min-width: 88px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(40, 80, 100, 0.12);
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(20px, 5.2vw, 26px);
  font-weight: 800;
  color: #1d5a4a;
}

.food-pool {
  flex: 1.35;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow: hidden;
}

.food-tile {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border: 0;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #f3f7f9;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08), 0 8px 16px rgba(30, 70, 90, 0.1);
  touch-action: none;
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.food-tile.selected {
  outline: 3px solid #3db8ef;
  transform: translateY(-2px);
}

.food-tile.placed {
  opacity: 0.28;
  pointer-events: none;
  filter: grayscale(0.2);
}

.food-tile.dragging {
  position: fixed;
  width: 88px;
  height: 100px;
  z-index: 80;
  opacity: 0.95;
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.05);
  pointer-events: none;
}

.food-tile-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.sort-bins {
  flex: 0.8;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sort-bin {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 8px 18px rgba(30, 70, 90, 0.1);
  transition: filter 120ms ease, transform 120ms ease;
}

.sort-bin.active {
  filter: brightness(1.04);
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 3px #3db8ef, 0 8px 18px rgba(30, 70, 90, 0.12);
}

.sort-bin[data-bin="healthy"] {
  background: linear-gradient(180deg, #e9fbee, #dff5e8);
}

.sort-bin[data-bin="unhealthy"] {
  background: linear-gradient(180deg, #f4f4f4, #e9e9e9);
}

.sort-bin-head {
  display: grid;
  justify-items: center;
  gap: 2px;
  font-family: "Nunito", sans-serif;
  font-size: clamp(14px, 3.6vw, 17px);
  font-weight: 800;
  color: #24383f;
}

.sort-bin-head img {
  width: 34px;
  height: 34px;
}

.sort-bin-slots {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 5px;
}

.sort-slot {
  min-height: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(120, 140, 150, 0.25);
  overflow: hidden;
}

.sort-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #f3f7f9;
}

.submit-btn {
  width: min(72%, 280px);
  align-self: center;
  flex: 0 0 auto;
  opacity: 1;
}

.submit-btn:disabled {
  opacity: 0.42;
  filter: grayscale(0.35);
  pointer-events: none;
}

/* —— Quiz —— */
.quiz {
  gap: 10px;
  background: #ffffff;
}

.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.quiz-progress {
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #f2f6f8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(18px, 4.6vw, 22px);
  font-weight: 700;
  color: #2a3d45;
}

.quiz-question {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
}

.quiz-photo-wrap {
  position: relative;
  width: min(68%, 280px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: #f5f8fa;
  overflow: hidden;
}

.quiz-photo {
  width: 92%;
  height: 92%;
  object-fit: contain;
  object-position: center;
}

.quiz-mark {
  position: absolute;
  width: 42%;
  height: auto;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transform: scale(0.4) translateY(-24px);
}

.quiz-mark.show-wrong {
  animation: quizMarkWrong 700ms ease forwards;
}

.quiz-mark.show-correct {
  animation: quizMarkCorrect 650ms ease forwards;
}

@keyframes quizMarkWrong {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(-40px) rotate(-18deg);
  }
  35% {
    opacity: 1;
    transform: scale(1.18) translateY(0) rotate(8deg);
  }
  55% {
    transform: scale(0.92) translateY(4px) rotate(-6deg);
  }
  75% {
    transform: scale(1.08) translateY(-2px) rotate(4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0deg);
  }
}

@keyframes quizMarkCorrect {
  0% {
    opacity: 0;
    transform: scale(0.2) translateY(-30px);
  }
  45% {
    opacity: 1;
    transform: scale(1.15) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.quiz-name {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: clamp(28px, 7.5vw, 40px);
  font-weight: 600;
  color: #1f2f36;
  line-height: 1;
}

.quiz-choices {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: min(78%, 320px);
  align-self: center;
  min-height: min(18vh, 140px);
  max-height: 150px;
  padding-bottom: 8px;
}

.quiz-choice {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.quiz-choice img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.quiz-choice:disabled {
  pointer-events: none;
  filter: brightness(0.92);
}

/* —— Open the Box —— */
.boxboard {
  gap: 10px;
  background: #ffffff;
  position: relative;
}

#boxScreen.active {
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: #8fd8ef transparent;
}

#boxScreen.active::-webkit-scrollbar {
  width: 8px;
}

#boxScreen.active::-webkit-scrollbar-track {
  background: transparent;
}

#boxScreen.active::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #8fd8ef;
}

.box-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding-bottom: 10px;
  background: #ffffff;
}

.box-progress {
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #f2f6f8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(18px, 4.6vw, 22px);
  font-weight: 700;
  color: #2a3d45;
}

.box-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: clamp(6px, 2vw, 10px);
  align-content: start;
  justify-items: stretch;
  overflow: visible;
  touch-action: pan-y;
  padding: 0 0 28px;
  cursor: grab;
}

.box-grid.drag-scrolling {
  cursor: grabbing;
}

.box-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  min-height: 0;
  border: 0;
  border-radius: clamp(10px, 3vw, 14px);
  padding: 0;
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: clamp(17px, 5vw, 24px);
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  overflow: hidden;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-appearance: none;
  appearance: none;
  transform: translateY(0) scale(1);
  animation: boxAppear 460ms cubic-bezier(0.2, 1.2, 0.28, 1) both;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.box-tile:active:not(.opened):not(:disabled) {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.box-tile:not(.opened):not(:disabled):hover {
  filter: brightness(1.04);
  transform: translateY(-3px) scale(1.02);
}

.box-tile:disabled {
  cursor: default;
}

.box-tile .box-num {
  position: relative;
  z-index: 1;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.box-tile .box-open-content {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: #fff;
  overflow: hidden;
}

.box-tile .box-open-content::after {
  content: "";
  position: absolute;
  inset: -35%;
  background: linear-gradient(120deg, transparent 36%, rgba(255, 255, 255, 0.78) 50%, transparent 64%);
  transform: translateX(-80%) rotate(12deg);
  animation: boxShine 760ms ease 120ms both;
  pointer-events: none;
}

.box-tile.opened .box-num {
  display: none;
}

.box-tile.opened .box-open-content {
  display: grid;
  animation: boxFlipOpen 420ms cubic-bezier(0.2, 1.1, 0.24, 1) both;
}

.box-tile .box-thumb {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  background: #f5f8fa;
  padding: 4px;
}

.box-tile .box-status {
  position: absolute;
  inset: 0;
  width: 58%;
  height: 58%;
  margin: auto;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  animation: statusPop 580ms cubic-bezier(0.18, 1.35, 0.28, 1) both;
}

.box-tile.wrong .box-thumb {
  filter: brightness(0.72) saturate(0.85);
}

.box-tile.correct {
  animation: boxCorrectPulse 760ms ease both;
}

.box-tile.wrong {
  animation: boxWrongShake 560ms ease both;
}

.box-tile.correct .box-status,
.box-tile.wrong .box-status {
  z-index: 2;
}

.box-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 14px 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
}

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

.box-overlay-card {
  width: min(100%, 340px);
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.box-food-card {
  position: relative;
  width: min(56%, 190px);
  flex: 0 1 auto;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 5px #ff9f4a, 0 10px 22px rgba(40, 80, 100, 0.14);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.box-food-photo-wrap {
  position: relative;
  aspect-ratio: 1;
  max-height: min(28vh, 180px);
  display: grid;
  place-items: center;
  background: #fff;
}

.box-food-photo {
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.box-food-name {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 4px 8px;
  background: #ff9f4a;
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 700;
}

.box-overlay-choices {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(82%, 280px);
  height: min(14vh, 112px);
  max-height: 112px;
}

.box-overlay-choices .quiz-choice img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

/* —— Spin the Wheel —— */
#spinScreen.spinboard {
  display: none;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  z-index: 5;
}

#spinScreen.spinboard.active {
  display: flex !important;
}

.spin-top {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.spin-progress {
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #f2f6f8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(18px, 4.6vw, 22px);
  font-weight: 700;
  color: #2a3d45;
}

.spin-stage {
  position: relative;
  z-index: 2;
  flex: 1 1 0%;
  min-height: 220px;
  width: 100%;
  background: #ffffff;
}

.spin-pointer {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  width: 0;
  height: 0;
  transform: translate(-50%, calc(-1 * var(--spin-radius, 130px) - 2px));
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid #8a93a0;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
  pointer-events: none;
}

.spin-wheel-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 260px;
  height: 260px;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 10px 28px rgba(40, 80, 100, 0.18);
  overflow: hidden;
  background: #ffffff;
}

.spin-canvas {
  display: block;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  transition: none;
}

.spin-canvas.spinning {
  transition: transform 4.2s cubic-bezier(0.12, 0.75, 0.08, 1);
}

.spin-go-btn {
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
  align-self: center;
  min-width: min(56%, 200px);
  padding: 14px 28px;
  border-radius: 12px;
  border: 3px solid #9aa3ad;
  background: linear-gradient(180deg, #f7f8fa, #e8ebf0);
  color: #2a3d45;
  font-family: "Nunito", sans-serif;
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 800;
  box-shadow: 0 4px 0 #8d96a1;
  margin-bottom: 6px;
}

.spin-go-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8d96a1;
}

.spin-go-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.spin-overlay {
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
}

.spin-overlay.hidden {
  display: none !important;
}

.spin-popup {
  animation: spinPopupIn 280ms ease-out;
}

.spin-guess-hint {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: 700;
  color: #2a3d45;
  text-align: center;
}

@keyframes spinPopupIn {
  from {
    opacity: 0;
    transform: scale(0.86) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* —— Anagram —— */
#anagramScreen.anagramboard {
  display: none;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  min-height: 0;
  overflow: hidden;
}

#anagramScreen.anagramboard.active {
  display: flex !important;
}

.anagram-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.anagram-progress {
  min-width: 88px;
  padding: 6px 14px 8px;
  border-radius: 16px;
  background: #f2f6f8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  color: #2a3d45;
  display: grid;
  gap: 0;
  line-height: 1.05;
}

.anagram-score-label {
  font-size: 11px;
  font-weight: 700;
  color: #5e747a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#anagramProgress {
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 800;
}

.anagram-pool {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  margin-top: clamp(28px, 8vh, 56px);
  padding: 4px 2px;
  max-width: 100%;
  overflow-x: auto;
}

.anagram-answer {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: hidden;
}

.anagram-slots {
  width: min(100%, 360px);
  min-height: 88px;
  padding: 18px 14px 16px;
  border: 2px solid #d5dee5;
  border-radius: 18px;
  background: #fff;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.anagram-slots.anagram-size-sm {
  gap: 5px;
  padding: 16px 10px 14px;
}

.anagram-slots.anagram-size-xs {
  gap: 4px;
  padding: 14px 8px 12px;
}

.anagram-slots.anagram-size-xxs {
  gap: 3px;
  padding: 12px 6px 10px;
}

.anagram-pool.anagram-size-sm {
  gap: 6px;
}

.anagram-pool.anagram-size-xs {
  gap: 5px;
}

.anagram-pool.anagram-size-xxs {
  gap: 4px;
}

.anagram-slots.correct {
  border-color: #2f9e63;
  box-shadow: 0 0 0 3px rgba(47, 158, 99, 0.2);
}

.anagram-slots.wrong {
  border-color: #d64545;
  animation: wrongShake 420ms ease;
}

.anagram-tile {
  width: clamp(36px, 9vw, 46px);
  height: clamp(42px, 10.5vw, 52px);
  border: 0;
  border-radius: 10px;
  background: #4a5560;
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 800;
  text-transform: lowercase;
  box-shadow: 0 3px 0 #2f3640;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-appearance: none;
  appearance: none;
}

.anagram-size-sm .anagram-tile {
  width: clamp(32px, 7.5vw, 40px);
  height: clamp(38px, 9vw, 46px);
  font-size: clamp(18px, 4.8vw, 24px);
  border-radius: 9px;
}

.anagram-size-xs .anagram-tile {
  width: clamp(28px, 6.5vw, 34px);
  height: clamp(34px, 8vw, 40px);
  font-size: clamp(16px, 4.2vw, 20px);
  border-radius: 8px;
}

.anagram-size-xxs .anagram-tile {
  width: clamp(24px, 5.5vw, 30px);
  height: clamp(30px, 7vw, 36px);
  font-size: clamp(14px, 3.6vw, 18px);
  border-radius: 7px;
}

.anagram-tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #2f3640;
}

.anagram-tile.used {
  visibility: hidden;
  pointer-events: none;
}

.anagram-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: clamp(36px, 9vw, 46px);
  height: clamp(52px, 12.5vw, 62px);
  gap: 5px;
  flex: 0 0 auto;
}

.anagram-size-sm .anagram-slot {
  width: clamp(32px, 7.5vw, 40px);
  height: clamp(48px, 11vw, 56px);
  gap: 4px;
}

.anagram-size-xs .anagram-slot {
  width: clamp(28px, 6.5vw, 34px);
  height: clamp(44px, 10vw, 50px);
  gap: 4px;
}

.anagram-size-xxs .anagram-slot {
  width: clamp(24px, 5.5vw, 30px);
  height: clamp(40px, 9vw, 46px);
  gap: 3px;
}

.anagram-slot-line {
  width: 100%;
  height: 3px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: #c5d0d8;
}

.anagram-slot .anagram-tile {
  flex: 0 0 auto;
  box-shadow: 0 3px 0 #2f3640;
}

.anagram-slot-empty {
  width: clamp(36px, 9vw, 46px);
  height: clamp(42px, 10.5vw, 52px);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  position: relative;
}

.anagram-size-sm .anagram-slot-empty {
  width: clamp(32px, 7.5vw, 40px);
  height: clamp(38px, 9vw, 46px);
}

.anagram-size-xs .anagram-slot-empty {
  width: clamp(28px, 6.5vw, 34px);
  height: clamp(34px, 8vw, 40px);
}

.anagram-size-xxs .anagram-slot-empty {
  width: clamp(24px, 5.5vw, 30px);
  height: clamp(30px, 7vw, 36px);
}

.anagram-reject {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
  animation: quizMarkWrong 520ms ease both;
}

.anagram-slot.reject .anagram-slot-line {
  background: #d64545;
}

.anagram-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-bottom: 4px;
}

.anagram-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eef3f6;
  color: #2a3d45;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 0 #c9d4dc;
}

.anagram-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.anagram-nav-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 #c9d4dc;
}

.anagram-nav-label {
  min-width: 88px;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: 700;
  color: #5e747a;
}

/* —— Matching pairs —— */
#matchScreen.matchboard {
  display: none;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
  min-height: 0;
  overflow: hidden;
}

#matchScreen.matchboard.active {
  display: flex !important;
}

.match-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 8px;
}

.match-timer {
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 16px;
  background: #fff3e8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(18px, 4.6vw, 22px);
  font-weight: 800;
  color: #c45a20;
}

.match-progress {
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 16px;
  background: #f2f6f8;
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: 700;
  color: #2a3d45;
}

.match-grid {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
  padding-bottom: 6px;
  overflow-y: auto;
  touch-action: pan-y;
  align-content: start;
}

.match-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 800px;
  cursor: pointer;
  isolation: isolate;
  -webkit-appearance: none;
  appearance: none;
}

.match-card:disabled {
  cursor: default;
}

.match-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 420ms ease;
}

.match-card.flipped .match-card-inner,
.match-card.matched .match-card-inner {
  transform: rotateY(180deg);
}

.match-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

.match-card-back {
  z-index: 1;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #5b9fd8, #3b6fd6);
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
}

.match-card-front {
  z-index: 2;
  transform: rotateY(180deg);
  background: #f5f8fa;
  box-sizing: border-box;
  border: 3px dashed transparent;
}

.match-card-front img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
}

.match-card.flipped .match-card-front,
.match-card.matched .match-card-front {
  border-color: #2f9e63;
  box-shadow: none;
}

.match-card.matched .match-card-front {
  background: #f3fbf6;
}

.match-card.mismatch .match-card-inner {
  animation: matchWiggle 360ms ease;
}

@keyframes matchWiggle {
  0%, 100% { transform: rotateY(180deg) translateX(0); }
  25% { transform: rotateY(180deg) translateX(-6px); }
  75% { transform: rotateY(180deg) translateX(6px); }
}

/* —— Result —— */
.result {
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 214, 107, 0.35), transparent 35%),
    linear-gradient(160deg, #e7fbf1, #dff4ff 55%, #fff1d5);
}

.result-panel {
  position: relative;
  width: min(86%, 360px);
  padding: clamp(22px, 5.5vw, 34px) clamp(16px, 4vw, 24px) clamp(18px, 4.5vw, 26px);
  display: grid;
  justify-items: center;
  gap: 6px;
}

.result-panel-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.result-title-img,
.score-big,
.result-copy,
.result-stats {
  position: relative;
  z-index: 1;
}

.result-title-img {
  width: min(58%, 180px);
  height: auto;
}

.score-big {
  margin: 2px 0;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(48px, 13vw, 78px);
  font-weight: 800;
  line-height: 0.9;
  color: var(--green-dark);
}

.result-copy {
  margin: 0;
  color: var(--muted);
  font-family: "Nunito", sans-serif;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  line-height: 1.1;
}

.result-stats {
  width: 100%;
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-stat {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.result-stat img {
  width: 28px;
  height: 28px;
}

.result-stat-label {
  font-family: "Nunito", sans-serif;
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 700;
  color: #5e747a;
}

.result-stat-value {
  font-family: "Nunito", sans-serif;
  font-size: clamp(20px, 5.2vw, 26px);
  font-weight: 800;
  color: #1f2f36;
  line-height: 1;
}

.result-stat.healthy .result-stat-value {
  color: #1f8a5d;
}

.result-stat.unhealthy .result-stat-value {
  color: #c44747;
}

.result-best {
  width: clamp(110px, 30vw, 136px);
  height: clamp(42px, 11vw, 52px);
}

.again-btn {
  width: min(58%, 230px);
}

.share-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 16px rgba(40, 80, 100, 0.08);
}

.share-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(30, 60, 80, 0.16);
}

.share-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.share-toast {
  min-height: 18px;
  color: #1f8a5d;
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 160ms ease;
}

.share-toast.show {
  opacity: 1;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes ctaPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes correctPop {
  0% { transform: scale(1); opacity: 1; }
  48% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.72); opacity: 0; }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-11px); }
  44% { transform: translateX(10px); }
  66% { transform: translateX(-7px); }
  82% { transform: translateX(5px); }
}

@keyframes boxAppear {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.86);
  }
  65% {
    opacity: 1;
    transform: translateY(-3px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes boxFlipOpen {
  0% {
    opacity: 0;
    transform: rotateY(78deg) scale(0.88);
  }
  58% {
    opacity: 1;
    transform: rotateY(-8deg) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
  }
}

@keyframes statusPop {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-18deg);
  }
  48% {
    opacity: 1;
    transform: scale(1.2) rotate(8deg);
  }
  72% {
    transform: scale(0.92) rotate(-4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes boxShine {
  0% {
    transform: translateX(-80%) rotate(12deg);
  }
  100% {
    transform: translateX(80%) rotate(12deg);
  }
}

@keyframes boxCorrectPulse {
  0%, 100% {
    filter: brightness(1);
  }
  42% {
    filter: brightness(1.14) saturate(1.12);
  }
}

@keyframes boxWrongShake {
  0%, 100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-6px) rotate(-2deg);
  }
  38% {
    transform: translateX(6px) rotate(2deg);
  }
  58% {
    transform: translateX(-4px) rotate(-1deg);
  }
  76% {
    transform: translateX(3px) rotate(1deg);
  }
}

@media (max-height: 680px) {
  .screen {
    padding: 12px;
  }

  .home {
    padding: 0;
  }

  .food-pool {
    gap: 6px;
  }

  .sort-bin-head img {
    width: 28px;
    height: 28px;
  }
}
