:root {
  --logo-w: clamp(220px, min(38vw, 62vh), 560px);   /* logo width: follows the window's width and height */
  --indigo: #3b2fa3;
  --indigo-deep: #2a1f80;
  --tan: #dcb994;
  --tan-lite: #e8cdaa;
  --tan-edge: #b0804f;
  --wood: #8a5630;
  --wood-dark: #5e3519;
  --tray: #2c2270;
  --tray-edge: #1c1450;
  --gum: #ff4f9a;
  --butter: #ffd84a;
  --mint: #62e3d8;
  --ink: #4a2a12;
  --r-card: 14px;
  --r-btn: 999px;
  --display: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

html,
body {
  height: 100%;
  overflow: hidden;   /* the page itself never scrolls; only the cookie tray does */
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--ink);
  font: 500 1rem/1.5 var(--body);
  background: rgb(54, 49, 148);   /* only visible for a moment before the background loads */
}

[hidden] {
  display: none !important;
}

@keyframes pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}

@keyframes drop {
  from {
    transform: translateY(-50px) rotate(-6deg);
    opacity: 0;
  }
}

/* chosen cutscene background */
#scene {
  position: fixed;
  inset: 0;
  z-index: -2;   /* behind the floating toppings (z-index -1) */
  background: center/cover no-repeat;
}

body.has-bg #scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(27, 16, 70, 0.2);
}

/* the folder: a tall sheet on the left, a shorter "Cookie Choice" flap on the right */
.folder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 22vw, 360px);
  align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  max-width: 1920px;
  height: 100%;
  max-height: 1240px;   /* on very tall screens it stops growing and sits centred */
  margin: 0 auto;
  padding: clamp(3.4rem, min(8vw, 12vh), 6.5rem) clamp(16px, 2vw, 2rem) clamp(0.8rem, 3vh, 2rem);
}

/* the folder's shadow: plain box shadows (a drop-shadow filter would repaint the whole
   folder every time one of the cookies animates, which gets slow with hundreds of them) */
.sheet,
.choice {
  /* negative spread keeps the soft shadow underneath, so it can't draw a line where the two meet */
  box-shadow:
    0 7px 0 rgba(20, 10, 60, 0.45),
    0 24px 20px -14px rgba(0, 0, 0, 0.35);
}

.sheet,
.choice {
  background: var(--tan);
  border: 5px solid var(--tan-edge);
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 26px 26px 0 26px;
  padding: clamp(4.2rem, min(9vw, 15vh), 7.2rem) clamp(14px, 2.4vw, 2.2rem) clamp(14px, 2.4vw, 2.2rem);
}

.choice {
  position: relative;
  z-index: 1;
  margin: clamp(5rem, 9vw, 7.5rem) 0 0 -5px;
  border-left: 0;
  border-radius: 0 26px 26px 0;
  padding: 0 clamp(14px, 1.8vw, 1.6rem) 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.choice::before {
  /* rounded inner corner where the flap meets the sheet */
  content: "";
  position: absolute;
  left: 0;
  top: -27px;
  width: 27px;
  height: 27px;
  background: radial-gradient(circle at 100% 0, transparent 22px, var(--tan-edge) 22.5px 27px, var(--tan) 27.5px);
}

.stick {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  min-height: 0;   /* gives the portrait a known amount of room to fill */
}

.stick > :not(.portrait) {
  flex: none;   /* text and buttons keep their size; only the portrait flexes */
}

/* ribbon logo */
.logo {
  position: absolute;
  left: clamp(-34px, -2vw, -12px);
  top: clamp(-4rem, -6vw, -3rem);
  margin: 0;
  display: grid;
  justify-items: start;
  padding: 0.35em 1.4em 0.5em 1.1em;
  font-weight: 400;
  line-height: 0.86;
  font-family: var(--display);
  transform: rotate(-2deg);
  animation: drop 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.ribbon {
  position: absolute;
  inset: 44% -6% -2% -4%;
  z-index: -1;
  background: linear-gradient(#ff5a78, #e22d55 60%, #b81d42);
  border-radius: 6px;
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35);
}

.l1,
.l2 {
  display: block;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  letter-spacing: -.01em;
}

.l1 {
  font-size: clamp(1.7rem, 3.6vw, 3rem);
  margin-left: 1.6em;
  background-image: linear-gradient(#fff6a8, #ffd23a 45%, #ff9a1f);
  filter:
    drop-shadow(2px 0 0 #6b2c06)
    drop-shadow(-2px 0 0 #6b2c06)
    drop-shadow(0 2px 0 #6b2c06)
    drop-shadow(0 -2px 0 #6b2c06)
    drop-shadow(0 3px 0 #6b2c06);
}

.l2 {
  font-size: clamp(2.6rem, 6vw, 5rem);
  background-image: linear-gradient(#f2fffd, #8ff2ea 40%, #2fb9c6);
  filter:
    drop-shadow(3px 0 0 #1f4f6e)
    drop-shadow(-3px 0 0 #1f4f6e)
    drop-shadow(0 3px 0 #1f4f6e)
    drop-shadow(0 -3px 0 #1f4f6e)
    drop-shadow(0 5px 0 #1f4f6e);
}

.qs {
  position: absolute;
  right: -.2em;
  top: -.25em;
  display: flex;
  gap: 0.05em;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  color: #fff;
}

.qs i {
  font-style: normal;
  -webkit-text-stroke: 5px #1d1030;
  paint-order: stroke fill;
  transform: rotate(14deg);
}

.qs i+i {
  font-size: 0.7em;
  transform: translateY(0.7em) rotate(-10deg);
}

.logoImg {
  display: block;
  width: var(--logo-w);
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.2));
}

.logo.has-img {
  padding: 0;
  transform: none;
}

.logo.has-img > span {
  display: none;
}

/* channel credit, hovering over the sheet's top-right corner */
.yt {
  position: absolute;
  right: -1.1rem;
  top: -1.3rem;
  z-index: 3;
  rotate: 7deg;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  border-radius: var(--r-btn);
  text-decoration: none;
  font: 800 0.95rem/1 var(--body);
  color: var(--wood-dark);
  background: #fff6ea;
  border: 3px solid var(--wood);
  box-shadow: 0 3px 0 var(--wood), 0 10px 14px rgba(20, 10, 60, 0.3);
  animation: hover 3.2s ease-in-out infinite;
}

@keyframes hover {
  50% {
    translate: 0 -6px;
  }
}

.yt svg {
  width: 26px;
  height: auto;
  flex: none;
}

.yt:hover {
  animation-play-state: paused;
}

.yt:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 3px;
}

/* cookie tray */
.trayWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.tray {
  flex: 1;
  border: 4px solid var(--tray-edge);
  /* a darker window onto the page background: the chosen cutscene, or the indigo diamonds */
  /* the same background as the page, lined up with it (fixed) and tinted darker */
  background:
    linear-gradient(var(--tray-tint, rgba(14, 8, 40, 0.4)), var(--tray-tint, rgba(14, 8, 40, 0.4))),
    var(--scene, none) var(--scene-pos, center) / var(--scene-size, cover) var(--scene-repeat, no-repeat) fixed,
    rgb(40, 36, 110);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.35);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;   /* scrollable, but no visible scrollbar */
}

.tray::-webkit-scrollbar {
  display: none;
}

.tray {
  container-type: inline-size;
}

/* 10 cookies a row when there's room; fewer, still roomy tiles on smaller screens */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 12px;   /* wide enough for the background to show between the cookies */
}

@container (min-width:760px) {
  .grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

.card {
  --i: 0;
  position: relative;
  display: block;
  padding: 0;
  border: 2px solid #2c1d33;
  border-radius: var(--r-card);
  background: #2c1d33;
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  color: #fff;
  /* a light ring and a firm shadow so cookies stand out from a bright scene */
  box-shadow:
    0 0 0 2px rgba(255, 246, 234, 0.75),
    0 3px 0 2px rgba(0, 0, 0, 0.35),
    0 8px 16px rgba(10, 5, 40, 0.55);
  transition: transform 0.15s, filter 0.25s, box-shadow 0.15s, opacity 0.25s;
  animation: pop 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  animation-delay: calc(var(--i)*14ms + 0.2s);
}

/* once the cards have popped in, switching between animations must not restart the entrance */
.grid.settled .card {
  animation: none;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.card:hover {
  transform: translateY(-3px);
  z-index: 1;
}

.card .tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 6px 5px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  background: linear-gradient(transparent, rgba(20, 8, 30, 0.85));
  opacity: 0;
  transition: opacity 0.15s;
}

.card:hover .tag,
.card:focus-visible .tag {
  opacity: 1;
}

body[data-mode="pick"] .card[aria-pressed="true"] {
  outline: 4px solid var(--butter);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px var(--gum), 0 8px 18px rgba(0, 0, 0, 0.45);
  transform: translateY(-3px) scale(1.03);
  z-index: 2;
}

body[data-mode="pick"] .card[aria-pressed="true"] .tag {
  opacity: 1;
}

/* ruled-out cookies: still recognisable, but clearly out, with a little background showing through */
body[data-mode="board"] .card[aria-pressed="true"] {
  opacity: 0.55;
  filter: grayscale(1) brightness(0.7);
  transform: scale(0.92);
  box-shadow: none;
  background: rgba(10, 5, 30, 0.6);
  border-color: rgba(255, 255, 255, 0.45);
  border-style: dashed;
}

body[data-mode="board"] .card[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 9px, rgba(0, 0, 0, 0.25) 9px 12px);
}

.emptyMsg {
  padding: 2rem;
  text-align: center;
  color: #fff3e4;
  font-size: 1.05rem;
}

.emptyMsg p {
  max-width: 52ch;
  margin: 0 auto 1.2rem;
}

/* cookie choice flap */
.choiceTitle {
  margin: 0.35rem 0 0.4rem;   /* sits inside the panel, clear of its top edge */
  padding: 0 0.3em;
  font: 400 clamp(2.2rem, 3.4vw, 3.1rem)/1.1 var(--display);
  color: #fff;
  /* outline and spacing grow with the letters, so they never run into each other */
  -webkit-text-stroke: 0.22em var(--wood);
  paint-order: stroke fill;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* medallion: the cookie fills the whole circle, the wooden ring sits on top of it */
.portrait {
  position: relative;
  /* the portrait takes whatever height the panel has left (up to 300px) and stays round */
  flex: 0 1 300px;
  width: auto;
  height: auto;
  min-height: 72px;
  max-height: 300px;
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0.4rem 0 0.9rem;
  background: radial-gradient(circle at 50% 38%, #f1d6b2, #c99a6a 75%);
  box-shadow:
    0 0 0 clamp(2px, 0.45vh, 4px) var(--wood-dark),
    0 clamp(4px, 0.9vh, 8px) 0 clamp(2px, 0.45vh, 4px) rgba(94, 53, 25, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  /* the ring follows the window height: thin on short windows, so the cookie gets more room */
  border: clamp(5px, 1.6vh, 14px) solid #a8723f;
  box-shadow:
    inset 0 0 0 clamp(2px, 0.45vh, 4px) var(--wood-dark),
    inset 0 clamp(5px, 1.4vh, 12px) clamp(8px, 2.3vh, 20px) rgba(0, 0, 0, 0.4),
    inset 0 -6px 14px rgba(255, 235, 200, 0.25);
  background: radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.28), transparent 32%);
}

.portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1) translateY(2%);   /* fully zoomed out; the breathing zooms in a little from here */
}

.unknown {
  position: relative;
  z-index: 1;
  font: 400 7rem/1 var(--display);
  color: #fff;
  -webkit-text-stroke: 10px var(--wood);
  paint-order: stroke fill;
  opacity: 0.85;
}

.portrait.hidden img {
  filter: blur(16px) brightness(0.5);
}

.choiceName {
  margin: 0;
  font: 400 1.5rem/1.15 var(--display);
  color: var(--wood-dark);
}

.choiceName.hidden {
  filter: blur(8px);
}

.hint {
  margin: 0.3rem 0 1rem;
  font-weight: 700;
  color: #6b4426;
}

body[data-mode="board"] .hint {
  font: 400 1.15rem var(--display);
  color: #2a8a86;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
}

.controls + .controls {
  padding-top: 0;   /* same gap between button groups as inside them */
}

/* buttons */
.btn {
  display: inline-block;
  cursor: pointer;
  border: 0;
  border-radius: var(--r-btn);
  padding: 0.8rem 1.6rem;
  font: 400 1.2rem var(--display);
  color: #3a1d00;
  background: linear-gradient(#ffe56b, #ffae2b);
  box-shadow: 0 5px 0 #b86a00, 0 10px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #b86a00;
}

.btn:disabled {
  filter: grayscale(1) brightness(0.85);
  opacity: 0.7;
  cursor: not-allowed;
}

.ghost {
  font: 800 0.9rem var(--body);
  color: var(--wood-dark);
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: var(--r-btn);
  background: var(--tan-lite);
  border: 3px solid var(--tan-edge);
  box-shadow: 0 3px 0 var(--tan-edge);
}

.ghost:hover {
  background: #f3dcbd;
}

.ghost:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--tan-edge);
}

.card:focus-visible,
.btn:focus-visible,
.ghost:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 3px;
}

/* background picker */
#bgDialog {
  width: min(960px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  padding: 0;
  color: var(--ink);
  border: 5px solid var(--tan-edge);
  border-radius: 22px;
  overflow: hidden;
  background: var(--tan);
  box-shadow: 0 7px 0 rgba(20, 10, 60, 0.45), 0 20px 50px rgba(0, 0, 0, 0.5);
}

#bgDialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}

#bgDialog::backdrop {
  background: rgba(16, 10, 60, 0.65);
  backdrop-filter: blur(3px);
}

.dlgHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--tan-lite);
  border-bottom: 4px solid var(--tan-edge);
}

.dlgHead h2 {
  margin: 0;
  font: 400 1.6rem var(--display);
  color: #fff;
  -webkit-text-stroke: 0.2em var(--wood);
  paint-order: stroke fill;
  letter-spacing: 0.04em;
}

#bgList {
  overflow-y: auto;
  padding: 0 1.2rem 1.4rem;
}

#bgList h3 {
  margin: 1.3rem 0 0.6rem;
  font: 400 1.1rem var(--display);
  color: var(--wood-dark);
}

.bgGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 1rem;
}

#bgList h3 + .bgGrid {
  margin-top: 0;
}

.bgOpt {
  padding: 5px;
  border: 3px solid var(--tray-edge);
  border-radius: 12px;
  color: #fff3e4;
  font: inherit;
  cursor: pointer;
  background: var(--tray);
  text-align: left;
  transition: transform 0.15s, border-color 0.15s;
}

.bgOpt:hover {
  transform: translateY(-2px);
}

.bgOpt[aria-pressed="true"] {
  border-color: var(--butter);
  box-shadow: 0 0 0 3px var(--gum);
}

.bgOpt:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

.bgOpt .thumb {
  display: block;
  aspect-ratio: 16/9;
  border-radius: 7px;
  overflow: hidden;
  background: rgb(54, 49, 148);
}

.bgOpt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* desktop: the panel measures itself, so the portrait can never be taller than the panel is wide */
@media (min-width: 861px) {
  .stick {
    container-type: size;
  }

  .portrait {
    max-height: min(300px, 100cqw);
  }
}

/* short windows: a more compact Cookie Choice panel so it fits without scrolling */
@media (min-width: 861px) and (max-height: 820px) {
  .choice {
    margin-top: clamp(3.4rem, 6vw, 4.6rem);
  }

  .portrait {
    margin-bottom: 0.5rem;
  }

  .choiceTitle {
    font-size: clamp(1.8rem, 2.6vw, 2.4rem);
    margin-bottom: 0.2rem;
  }

  .hint {
    margin-bottom: 0.4rem;
  }

  .controls {
    gap: 0.4rem;
    margin-top: 0.4rem;
  }

  .guessBtn {
    padding: 0.7rem 0.8rem;
    font-size: clamp(1rem, 1.45vw, 1.2rem);
    white-space: nowrap;
  }


  .ghost {
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
  }
}

/* very short windows: squeeze the board controls a bit more */
@media (min-width: 861px) and (max-height: 700px) {
  .choiceTitle {
    font-size: 1.7rem;
  }

  .portrait {
    min-height: 60px;
    margin: 0.2rem 0 0.3rem;
  }

  .choiceName {
    font-size: 1.2rem;
  }

  .hint {
    margin: 0 0 0.3rem;
    font-size: 0.9rem;
  }

  body[data-mode="board"] .hint {
    font-size: 1rem;
  }

  .guessBtn {
    padding: 0.55rem 0.8rem;
  }

  .controls {
    gap: 0.35rem;
    margin-top: 0.35rem;
  }

  .ghost {
    padding: 0.28rem 0.7rem;
    font-size: 0.78rem;
  }
}

/* very short windows (e.g. a laptop with the browser zoomed in): everything around the portrait shrinks */
@media (min-width: 861px) and (max-height: 580px) {
  .choice {
    margin-top: 2.6rem;
    padding-bottom: 0.9rem;
  }

  .choiceTitle {
    font-size: 1.45rem;
    margin: 0.2rem 0 0.1rem;
  }

  .portrait {
    min-height: 104px;
    margin: 0.2rem 0 0.25rem;
  }

  .choiceName {
    font-size: 1.05rem;
  }

  .hint,
  body[data-mode="board"] .hint {
    margin: 0 0 0.2rem;
    font-size: 0.85rem;
  }

  .guessBtn {
    padding: 0.45rem 0.8rem;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
  }

  .btn {
    padding: 0.5rem 1.1rem;
    font-size: 1rem;
  }

  .ghost {
    padding: 0.22rem 0.65rem;
    font-size: 0.74rem;
  }

  .controls {
    gap: 0.3rem;
    margin-top: 0.3rem;
  }
}

/* extremely short windows: the portrait sits beside the name instead of above it */
@media (min-width: 861px) and (max-height: 500px) {
  .stick {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    align-content: start;
    gap: 0 0.6rem;
    text-align: left;
  }

  .portrait {
    width: min(112px, 46cqw);
    min-height: 0;   /* width decides, so it stays a circle */
    max-height: none;
    margin: 0.2rem 0;
  }

  /* picking has fewer buttons, so the portrait can be bigger */
  body[data-mode="pick"] .portrait {
    width: min(150px, 56cqw);
  }

  .who {
    min-width: 0;
  }

  .stick > .controls {
    grid-column: 1 / -1;
  }
}

/* phones: the folder becomes one sheet, Cookie Choice a bar pinned to the bottom */
@media(max-width:860px) {
  .yt {
    right: -.4rem;
    font-size: 0.8rem;
  }

  .folder {
    display: flex;
    flex-direction: column;
    max-height: none;
    padding-top: 4.5rem;
    padding-bottom: 1rem;
  }

  .sheet {
    flex: 1;
  }

  .sheet {
    min-height: 0;
    border-radius: 26px 26px 0 0;
    border-bottom: 0;
    padding-top: clamp(4.4rem, 13vw, 5.6rem);
  }

  .choice {
    flex: none;
    margin: 0;
    border: 5px solid var(--tan-edge);
    border-top-width: 4px;
    border-radius: 0 0 26px 26px;
    padding: 0.6rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
  }

  .choice::before,
  .choiceTitle {
    display: none;
  }

  .stick {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.2rem 0.8rem;
    text-align: left;
  }

  .portrait {
    flex: none;
    width: 76px;
    min-height: 0;
    margin: 0;
    grid-row: span 2;
    box-shadow: 0 0 0 3px var(--wood-dark);
  }

  .portrait::after {
    border-width: 6px;
    box-shadow: inset 0 0 0 2px var(--wood-dark), inset 0 4px 8px rgba(0, 0, 0, 0.35);
  }

  .unknown {
    font-size: 2.6rem;
    -webkit-text-stroke: 6px var(--wood);
  }

  .choiceName {
    font-size: 1.15rem;
  }

  .hint {
    margin: 0;
    font-size: 0.85rem;
  }

  body[data-mode="board"] .hint {
    font-size: 0.95rem;
  }

  .controls {
    grid-column: 1/-1;
    justify-content: flex-start;
    margin-top: 0.3rem;
  }

  .controls + .controls {
    padding-top: 0;
    margin-top: 0;
  }

  .btn {
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
  }

  .ghost {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}

@media(max-width:560px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}


/* =========================================================
   Life & motion (see fx.js)
   ========================================================= */

/* particles and emoji pops fly above everything */
.fxLayer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.fxSprite {
  position: absolute;
  height: auto;
  will-change: transform, opacity;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.25));
}

/* toppings drifting up behind the folder */
.floaters {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.floaters span {
  position: absolute;
  left: var(--x);
  bottom: -80px;
  animation: rise var(--dur) linear var(--delay) infinite;
}

.floaters img {
  display: block;
  width: var(--size);
  opacity: var(--alpha);
  filter: blur(var(--blur)) drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25));
  animation: sway calc(var(--dur) / 6) ease-in-out var(--delay) infinite alternate;
}

@keyframes rise {
  to {
    transform: translateY(calc(-100vh - 160px));
  }
}

@keyframes sway {
  from {
    transform: translateX(calc(var(--sway) * -1)) rotate(calc(var(--spin) * -18deg));
  }
  to {
    transform: translateX(var(--sway)) rotate(calc(var(--spin) * 18deg));
  }
}

/* the logo floats gently */
.logo {
  animation:
    drop 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) both,
    bob 4.5s ease-in-out 1s infinite;
  cursor: pointer;
}

@keyframes bob {
  50% {
    translate: 0 -5px;
  }
}

/* "Cookie Choice" letters jump in a wave */
.choiceTitle .word > span {
  display: inline-block;
}

/* animated titles are split into words (which may wrap) made of letters (which animate) */
.word {
  white-space: nowrap;
}

.choiceTitle.wave .word > span {
  animation: letter 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) calc(var(--n) * 45ms);
}

@keyframes letter {
  35% {
    transform: translateY(-12px) rotate(-6deg) scale(1.12);
  }
}

/* the empty portrait's question mark keeps wondering */
.unknown {
  animation: ponder 2.4s ease-in-out infinite;
}

@keyframes ponder {
  0%, 100% {
    transform: rotate(-8deg) translateY(0);
  }
  50% {
    transform: rotate(8deg) translateY(-8px);
  }
}

/* the chosen cookie breathes inside the frame */
.portrait img {
  animation: breathe 3.6s ease-in-out infinite;   /* fx.js pops the frame when the cookie changes */
}

@keyframes breathe {
  50% {
    transform: scale(1.06) translateY(1.5%);
  }
}

/* a slow shine sweeps across the wooden ring */
.portrait::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
  animation: sweep 5s ease-in-out infinite;
}

@keyframes sweep {
  0%, 60% {
    transform: translateX(-70%);
  }
  100% {
    transform: translateX(70%);
  }
}

/* cookies wiggle when you hover them */
.card:hover img {
  animation: wiggle 0.5s ease-in-out;
}

@keyframes wiggle {
  25% {
    transform: rotate(-4deg) scale(1.04);
  }
  75% {
    transform: rotate(3deg) scale(1.04);
  }
}

/* the picked cookie shimmers */
body[data-mode="pick"] .grid .card[aria-pressed="true"] {
  animation: picked 1.6s ease-in-out infinite;
}

@keyframes picked {
  50% {
    box-shadow: 0 0 0 6px var(--gum), 0 0 24px 6px rgba(255, 216, 74, 0.7);
  }
}

/* "Lock in" calls for attention once it can be pressed */
.btn:not(:disabled) {
  animation: nudge 2.2s ease-in-out infinite;
}

@keyframes nudge {
  0%, 70%, 100% {
    scale: 1;
  }
  80% {
    scale: 1.07;
  }
  90% {
    scale: 0.98;
  }
}

.ghost {
  transition: transform 0.15s, background 0.15s;
}

.ghost:hover {
  transform: rotate(-2deg) translateY(-1px);
}

/* background thumbnails zoom a little on hover */
.bgOpt img {
  transition: transform 0.4s ease;
}

.bgOpt:hover img {
  transform: scale(1.08);
}


/* =========================================================
   The big guess
   ========================================================= */

.guessBtn {
  width: 100%;
  margin-bottom: 0.3rem;   /* room for its thick shadow, so the row below isn't glued to it */
  padding: 1rem 1.2rem;
  font-size: clamp(1.25rem, 1.8vw, 1.6rem);
  letter-spacing: 0.04em;
  color: #fff;
  -webkit-text-stroke: 0.22em #8c1238;
  paint-order: stroke fill;
  background: linear-gradient(#ff7aa8, #ff3d7f 55%, #e0215f);
  box-shadow:
    0 6px 0 #9c1440,
    0 12px 20px rgba(140, 20, 60, 0.35),
    inset 0 3px 0 rgba(255, 255, 255, 0.45);
  animation: guessCall 2.4s ease-in-out infinite;
}

.guessBtn:active {
  box-shadow: 0 1px 0 #9c1440;
}

@keyframes guessCall {
  0%, 65%, 100% {
    scale: 1;
    rotate: 0deg;
  }
  72% {
    scale: 1.06;
    rotate: -2deg;
  }
  80% {
    scale: 1.04;
    rotate: 2deg;
  }
  88% {
    scale: 1.02;
    rotate: 0deg;
  }
}

/* while guessing: cancel style on the button, the tray lights up */
.guessBtn[aria-pressed="true"] {
  color: var(--wood-dark);
  -webkit-text-stroke: 0;
  background: var(--tan-lite);
  box-shadow: 0 5px 0 var(--tan-edge);
  animation: none;
}

body[data-guessing="true"] .tray {
  animation: trayCall 1.2s ease-in-out infinite;
}

@keyframes trayCall {
  50% {
    box-shadow:
      inset 0 4px 10px rgba(0, 0, 0, 0.35),
      0 0 0 5px var(--butter),
      0 0 34px 8px rgba(255, 79, 154, 0.7);
  }
}

body[data-guessing="true"] .card:not([aria-pressed="true"]):hover {
  transform: translateY(-6px) scale(1.06);
  outline: 4px solid var(--butter);
  outline-offset: -2px;
}

body[data-guessing="true"] .card[aria-pressed="true"] {
  cursor: not-allowed;
}

/* ---------- the reveal stage ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(circle at 50% 45%, rgba(60, 30, 140, 0.75), rgba(10, 5, 35, 0.92) 70%);
}

.stage.leaving {
  animation: stageOut 0.38s ease-in forwards;
}

@keyframes stageOut {
  to {
    opacity: 0;
  }
}

/* spinning light rays behind the card */
.stageRays {
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.09) 0deg 9deg, transparent 9deg 24deg);
  mask-image: radial-gradient(circle, #000 15%, transparent 55%);
  -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 55%);
  animation: spin 18s linear infinite;
  pointer-events: none;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

.stageInner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.stageCard {
  width: min(62vmin, 340px);
  padding: 14px 14px 10px;
  border: 6px solid var(--tan-edge);
  border-radius: 28px;
  background: var(--tan);
  box-shadow:
    0 8px 0 var(--wood),
    0 0 0 4px var(--wood-dark),
    0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.stageCard img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 18px;
}

.stageName {
  margin: 0.5rem 0 0;
  font: 400 clamp(1.4rem, 3vw, 2rem) / 1.1 var(--display);
  color: var(--wood-dark);
}

.stageCard.drumroll {
  animation: drumroll 0.95s ease-in;
}

@keyframes drumroll {
  0% {
    transform: none;
  }
  20% {
    transform: translateX(-3px) rotate(-1deg);
  }
  40% {
    transform: translateX(5px) rotate(1.5deg) scale(1.02);
  }
  60% {
    transform: translateX(-7px) rotate(-2deg) scale(1.04);
  }
  80% {
    transform: translateX(8px) rotate(2.5deg) scale(1.06);
  }
  100% {
    transform: scale(0.94);
  }
}

.stagePanel {
  text-align: center;   /* app.js pops it in */
}

.stageTitle,
.winTitle {
  margin: 0 0 1rem;
  font: 400 clamp(1.8rem, 4.5vw, 3rem) / 1.15 var(--display);
  color: #fff;
  -webkit-text-stroke: 0.2em var(--wood);
  paint-order: stroke fill;
  letter-spacing: 0.04em;
}

.stageButtons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}

.stageButtons .btn {
  font-size: 1.4rem;
  padding: 0.9rem 2rem;
}

.btn.nope {
  color: #fff;
  background: linear-gradient(#9aa3c7, #6b74a3);
  box-shadow: 0 5px 0 #454c76, 0 10px 16px rgba(0, 0, 0, 0.25);
}

/* wrong: everything goes grey for a moment */
.stage.wrong .stageCard {
  filter: grayscale(0.8) brightness(0.8);
  transition: filter 0.3s;
}

/* win: golden rays, the cookie spins, letters tumble in */
.stage.win {
  background: radial-gradient(circle at 50% 45%, rgba(255, 190, 60, 0.55), rgba(120, 40, 120, 0.85) 55%, rgba(20, 8, 50, 0.95) 80%);
}

.stage.win .stageRays {
  background: repeating-conic-gradient(from 0deg, rgba(255, 230, 120, 0.28) 0deg 10deg, transparent 10deg 22deg);
  animation-duration: 7s;
}

.stage.win .stageCard {
  animation: champion 2.4s ease-in-out infinite;
  box-shadow:
    0 8px 0 var(--wood),
    0 0 0 4px var(--wood-dark),
    0 0 50px 14px rgba(255, 216, 74, 0.8);
}

@keyframes champion {
  0%, 100% {
    transform: translateY(0) rotateY(0deg);
  }
  25% {
    transform: translateY(-16px) rotateY(180deg);
  }
  50% {
    transform: translateY(0) rotateY(360deg);
  }
  75% {
    transform: translateY(-8px) rotateY(360deg) rotate(-3deg);
  }
}

.winTitle {
  color: var(--butter);
  -webkit-text-stroke: 0.22em #8c1238;
}

.winTitle .word > span {
  display: inline-block;
  animation: tumble 0.7s cubic-bezier(0.3, 1.7, 0.5, 1) calc(var(--n) * 40ms) both;
}

@keyframes tumble {
  from {
    transform: translateY(-120px) rotate(-30deg) scale(0.4);
    opacity: 0;
  }
}

.winTitle.done .word > span {
  animation: shine 1.6s ease-in-out calc(var(--n) * 50ms) infinite;
}

@keyframes shine {
  50% {
    transform: translateY(-8px);
    color: #fff3b0;
  }
}


/* =========================================================
   Big boards: search, hiding ruled-out cookies, scroll hints
   ========================================================= */

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin: -3.3rem 0 0.7rem auto;   /* tucked into the space to the right of the logo */
  max-width: min(600px, calc(100% - var(--logo-w) + 0.5rem));   /* never under the logo */
  width: 100%;
}

.find {
  flex: 1;
  min-width: 8.5rem;   /* always wide enough to read "Find a cookie…" */
  padding: 0.55rem 1rem 0.55rem 2.3rem;
  font: 700 0.95rem var(--body);
  color: var(--wood-dark);
  border: 3px solid var(--tan-edge);
  border-radius: var(--r-btn);
  background:
    no-repeat 0.85rem 50% / 1rem
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235e3519' stroke-width='3' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='m15 15 6 6'/%3E%3C/svg%3E"),
    var(--tan-lite);
  box-shadow: inset 0 2px 4px rgba(94, 53, 25, 0.2);
}

.find::placeholder {
  color: rgba(94, 53, 25, 0.6);
}

.find:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

/* rarity filter: a pill like the search box */
.rarity {
  flex: none;
  max-width: 11rem;
  padding: 0.55rem 2rem 0.55rem 0.9rem;
  font: 800 0.9rem var(--body);
  color: var(--wood-dark);
  border: 3px solid var(--tan-edge);
  border-radius: var(--r-btn);
  background:
    no-repeat right 0.75rem center / 0.7rem
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235e3519' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"),
    var(--tan-lite);
  box-shadow: 0 3px 0 var(--tan-edge);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.rarity:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

.toolbar .ghost {
  flex: none;
  white-space: nowrap;
}

/* filtered by the search, or ruled out while "Hide ruled out" is on */
.card.filtered,
.card.gone {
  display: none;
}

/* "more" pills over the tray, since its scrollbar is hidden */
.moreHint {
  position: absolute;
  left: 50%;
  z-index: 3;
  translate: -50% 0;
  padding: 0.35rem 1rem;
  border: 3px solid var(--wood);
  border-radius: var(--r-btn);
  font: 800 0.85rem/1 var(--body);
  color: var(--wood-dark);
  background: var(--tan-lite);
  box-shadow: 0 3px 0 var(--wood), 0 8px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.moreHint.down {
  bottom: 10px;
  animation: nudgeDown 1.6s ease-in-out infinite;
}

.moreHint.up {
  top: 10px;
}

@keyframes nudgeDown {
  50% {
    translate: -50% 4px;
  }
}

@media (max-width: 1100px) {
  .toolbar {
    margin-top: 0;
    max-width: none;
  }
}

/* the red ✕ stamp that slams onto a ruled-out cookie (fx.js) */
.fxStamp {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--display);
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 4px #7a0f2c;
  paint-order: stroke fill;
  background: radial-gradient(circle at 40% 35%, #ff6b8a, #e0244f 60%, #b0153a);
  border: 4px solid #fff3e4;
  box-shadow: 0 0 0 3px #7a0f2c, 0 6px 14px rgba(0, 0, 0, 0.45);
  will-change: transform, opacity;
}


/* =========================================================
   Phones: logo and YouTube badge stacked, search on its own row,
   board buttons in a tidy two-column grid
   ========================================================= */
@media (max-width: 860px) {
  .folder {
    padding-top: 2.4rem;
  }

  .sheet {
    padding-top: 0;
  }

  /* the logo sits in the flow, centred, poking over the top edge; the badge goes right under it */
  .logo {
    position: relative;
    left: auto;
    top: auto;
    align-self: center;
    margin: -2.2rem 0 0;
  }

  .logo.has-img {
    margin-top: -2.4rem;
  }

  .logoImg {
    width: min(78vw, 330px);
  }

  .yt {
    position: relative;
    right: auto;
    top: auto;
    align-self: center;
    margin: 0.35rem 0 0.7rem;
    rotate: -2deg;
    font-size: 0.85rem;
  }

  /* search gets the whole width; rarity and "Hide ruled out" share the row below */
  .toolbar {
    flex-wrap: wrap;
    justify-content: stretch;
    margin: 0 0 0.6rem;
    max-width: none;
  }

  .find {
    flex: 1 1 100%;
    min-width: 0;
  }

  .rarity {
    flex: 1 1 auto;
    max-width: none;
  }

  /* buttons: two equal columns, the big guess button across both */
  .stick > .controls:not([hidden]) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .stick > .controls .guessBtn {
    grid-column: 1 / -1;
    margin-bottom: 0.2rem;
    padding: 0.6rem 1rem;   /* slimmer on phones, so the board keeps more room */
    font-size: 1.15rem;
  }

  .stick > .controls .btn,
  .stick > .controls .ghost {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* picking: "Lock in my cookie" takes the room it needs, Background the rest */
  #pickCtl:not([hidden]) {
    grid-template-columns: 1fr 1fr;
  }

  #pickCtl #lock {
    grid-column: 1 / -1;
  }

  #pickCtl .btn {
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
  }
}

/* small or short phones: everything around the board gets more compact */
@media (max-width: 860px) and (max-height: 700px), (max-width: 360px) {
  .folder {
    padding-top: 2rem;
  }

  .logoImg {
    width: min(64vw, 270px);
  }

  .yt {
    margin: 0.2rem 0 0.45rem;
    padding: 0.25rem 0.7rem 0.25rem 0.4rem;
    font-size: 0.78rem;
  }

  .yt svg {
    width: 22px;
  }

  .toolbar {
    gap: 0.35rem;
    margin-bottom: 0.45rem;
  }

  .find {
    padding-block: 0.4rem;
    font-size: 0.88rem;
  }

  .rarity {
    padding: 0.4rem 1.7rem 0.4rem 0.7rem;
    font-size: 0.8rem;
  }

  .toolbar .ghost {
    padding: 0.35rem 0.6rem;
    font-size: 0.74rem;
  }

  .portrait {
    width: 62px;
  }

  .choiceName {
    font-size: 1rem;
  }

  .hint,
  body[data-mode="board"] .hint {
    font-size: 0.8rem;
  }

  .stick > .controls:not([hidden]) {
    gap: 0.3rem;
  }

  .stick > .controls .guessBtn {
    padding: 0.45rem 0.8rem;
    font-size: 1.05rem;
  }

  .stick > .controls .ghost {
    padding: 0.3rem 0.5rem;
    font-size: 0.74rem;
  }

  #pickCtl .btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
  }
}

/* "Stats" link in the toolbar (only shown once stats-config.js has a Worker address) */
.statsLink {
  flex: none;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* =========================================================
   Board codes: the Board window
   ========================================================= */

/* the "Board 7Q4M-40" tag under the cookie name; tap it to share the code */
.boardTag {
  margin: 0.15rem 0 0.2rem;
  padding: 0.12rem 0.6rem;
  border: 2px dashed var(--tan-edge);
  border-radius: var(--r-btn);
  background: transparent;
  font: 800 0.78rem var(--body);
  letter-spacing: 0.06em;
  color: var(--wood);
  cursor: pointer;
}

.boardTag:hover {
  background: var(--tan-lite);
}

.boardTag:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 2px;
}

.boardDialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(90vh, 760px);
  padding: 0;
  color: var(--ink);
  border: 5px solid var(--tan-edge);
  border-radius: 22px;
  overflow: hidden;
  background: var(--tan);
  box-shadow: 0 7px 0 rgba(20, 10, 60, 0.45), 0 20px 50px rgba(0, 0, 0, 0.5);
}

.boardDialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.boardDialog::backdrop {
  background: rgba(16, 10, 60, 0.65);
  backdrop-filter: blur(3px);
}

.boardBody {
  overflow-y: auto;
  padding: 0.9rem 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.boardBody h3 {
  margin: 0 0 0.5rem;
  font: 400 1.1rem var(--display);
  color: var(--wood-dark);
}

.boardIntro {
  margin: 0;
  font-weight: 700;
  color: #6b4426;
}

/* the current board: a big, easy-to-read code */
.boardNow {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  padding: 0.8rem;
  border-radius: 16px;
  border: 3px solid var(--tan-edge);
  background: var(--tan-lite);
  text-align: center;
}

.boardLabel {
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(94, 53, 25, 0.7);
}

.boardCode {
  font: 400 clamp(1.8rem, 7vw, 2.4rem) / 1.1 var(--display);
  color: #fff;
  -webkit-text-stroke: 0.18em var(--wood);
  paint-order: stroke fill;
  letter-spacing: 0.08em;
}

.boardCount {
  font-weight: 800;
  color: #2a8a86;
}

.boardCopy {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

/* size choices as pills */
.sizes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.sizes input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sizes span {
  display: block;
  padding: 0.5rem 0.3rem;
  border: 3px solid var(--tan-edge);
  border-radius: var(--r-btn);
  background: var(--tan-lite);
  box-shadow: 0 3px 0 var(--tan-edge);
  text-align: center;
  font: 400 1.05rem var(--display);
  color: var(--wood-dark);
  cursor: pointer;
  white-space: nowrap;
}

.sizes input:checked + span {
  border-color: var(--wood);
  background: linear-gradient(#ffe56b, #ffae2b);
  box-shadow: 0 3px 0 #b86a00;
}

.sizes input:focus-visible + span {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

/* Custom: how many cookies */
.customRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin: -0.2rem 0 0.7rem;
  font-weight: 800;
  color: var(--wood-dark);
}

.customSize {
  width: 6.5rem;
  padding: 0.45rem 0.8rem;
  border: 3px solid var(--tan-edge);
  border-radius: var(--r-btn);
  background: var(--tan-lite);
  font: 400 1.1rem var(--display);
  color: var(--wood-dark);
  text-align: center;
}

.customSize:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

.boardBody .btn {
  width: 100%;
}

.joinRow {
  display: flex;
  gap: 0.5rem;
}

.joinRow .btn {
  width: auto;
  flex: none;
}

.joinCode {
  padding-left: 1rem;
  background: var(--tan-lite);   /* no search icon here */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.joinMsg {
  margin: 0.4rem 0 0;
  min-height: 1.2em;
  font-weight: 700;
  font-size: 0.9rem;
  color: #6b4426;
}

.boardWarn {
  margin: 0;
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
  background: rgba(224, 33, 95, 0.12);
  color: #8c1238;
  font-weight: 800;
  font-size: 0.9rem;
  text-align: center;
}

.allBoard {
  align-self: center;
}

/* =========================================================
   Question log: End turn and earlier questions
   ========================================================= */

/* lights up once there's something to save this turn */
.endTurn.ready {
  border-color: #2a8a86;
  background: #d8f4ef;
  color: #135a57;
  box-shadow: 0 3px 0 #2a8a86;
}

.turnNowText {
  margin: 0 0 0.5rem;
  font-weight: 700;
  color: #6b4426;
}

.turnQ {
  padding-left: 1rem;
  background: var(--tan-lite);   /* no search icon here */
}

/* small cookie thumbnails */
.turnPics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.6rem;
}

.turnPics:empty {
  display: none;
}

.turnPics img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 2px solid #2c1d33;
  object-fit: cover;
  background: var(--tray);
}

.turnMore {
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 0.3rem;
  border-radius: 8px;
  background: var(--tan-edge);
  color: #fff;
  font: 400 0.95rem var(--display);
  border: 0;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}

.turnMore:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.turnMore:focus-visible {
  outline: 4px solid var(--mint);
  outline-offset: 2px;
}

/* "View all": every cookie of one list, bigger and with names */
.allPicsDialog {
  width: min(720px, calc(100vw - 32px));
}

.allPicsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.6rem;
}

.allPicsGrid figure {
  margin: 0;
  display: grid;
  gap: 0.25rem;
  text-align: center;
}

.allPicsGrid img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 3px solid #2c1d33;
  object-fit: cover;
  background: var(--tray);
}

.allPicsGrid figcaption {
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 1.15;
  color: #6b4426;
  overflow-wrap: anywhere;
}

.turnLog {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.turnItem {
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: 3px solid var(--tan-edge);
  background: var(--tan-lite);
}

.turnItem.isBack {
  opacity: 0.6;
}

.turnHead {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.turnNum {
  flex: none;
  font: 400 1rem var(--display);
  color: #2a8a86;
}

.turnQText {
  font-weight: 800;
  color: var(--wood-dark);
  overflow-wrap: anywhere;
}

.turnActions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.removeQ {
  color: #8c1238;
}

.turnItem .ghost:disabled {
  opacity: 0.6;
  cursor: default;
}

.turnEmpty {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
  color: rgba(94, 53, 25, 0.75);
}

/* phones: End turn gets its own full-width row under the guess button */
@media (max-width: 860px) {
  .stick > .controls .endTurn {
    grid-column: 1 / -1;
  }
}
