/* Level picker, block builder, stickers. Same Gugu tokens as style.css. */

.levels-title { font-weight: 700; font-size: 18px; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 24px; }
.chip {
  min-width: 56px; min-height: 56px; padding: 0 14px; border: 4px solid var(--ink); border-radius: 18px;
  background: #fff; color: var(--ink); font: 800 26px var(--display); box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--sun); }
.chip.bigkid { border-style: dashed; }
.chip-tag { font-weight: 700; font-size: 15px; padding: 0 4px 0 10px; color: var(--slate-2); }
.chip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.big strong { margin-left: 10px; font-size: 26px; }

/* block builder */
.build { margin-bottom: 8px; }
.piles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.fig { margin: 0; }
.piles .fig { flex: 1 1 0; min-width: 0; max-width: 340px; }
.matbox .fig { max-width: 460px; margin-bottom: 4px; }
.fig .blocks { display: block; width: 100%; height: auto; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 4px; }
.matbox .blocks { border-width: 4px; border-radius: 20px; }
.fig figcaption { margin-top: 2px; font-size: 15px; font-weight: 700; color: var(--slate-2); }
.guide { min-height: 28px; margin: 8px 0 6px; font-size: 20px; font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; min-height: 64px; margin-bottom: 8px; }
.ctl {
  min-width: 60px; min-height: 60px; padding: 8px 16px; border: 3px solid var(--ink); border-radius: 20px;
  background: #fff; color: var(--ink); font: 700 18px var(--body); box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
.ctl-push { background: var(--sun); }
.ctl-trade { background: var(--sky); }
.ctl-take { background: var(--coral); }
.ctl-break { background: var(--mint); }
.ctl:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.choice:disabled:not(.miss) { opacity: 0.45; box-shadow: none; cursor: default; }

/* stickers */
.new-sticker { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 10px 16px; background: #fff; border: 4px solid var(--ink); border-radius: 24px; width: fit-content; }
.new-sticker[hidden] { display: none; }
.new-sticker-art .sticker { width: 72px; height: 72px; display: block; }
.new-sticker strong { font-family: var(--display); font-size: 26px; }
.sticker-grid { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; background: #fff; border: 4px solid var(--ink); border-radius: 24px; font-weight: 700; }
.slot .sticker { width: 76px; height: 76px; }
.slot.locked { border-style: dashed; color: var(--slate-2); }
.slot.locked .sticker { filter: grayscale(1); opacity: 0.25; }

/* Phones, portrait: the two block pictures share whatever height the header,
   question, buttons and answers leave (svh = height while the browser bars show). */
@media (max-width: 560px) {
  .build { --fig-h: max(52px, calc((100vh - 410px) / 2)); }
  @supports (height: 1svh) { .build { --fig-h: max(52px, calc((100svh - 410px) / 2)); } }
  .piles { gap: 8px; margin-bottom: 4px; }
  .fig .blocks { width: auto; max-width: 100%; max-height: var(--fig-h); }
  .fig figcaption { margin-top: 0; font-size: 13px; line-height: 1.3; }
  .guide { min-height: 22px; font-size: 16px; line-height: 1.3; margin: 2px 0 4px; }
  /* up to four buttons: one row, equal widths, labels wrap inside the button */
  .controls { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; min-height: 56px; margin-bottom: 4px; }
  .ctl { min-width: 0; min-height: 56px; font-size: 14px; line-height: 1.15; padding: 4px 6px; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip:active, .ctl:active { transform: none; }
}

/* Phones on their side, block levels: question and pictures on the left; guide,
   buttons, feedback and the four answers on the right. Levels without blocks keep
   the layout from style.css. */
@media (orientation: landscape) and (max-height: 520px) {
  [data-screen="play"]:has(> #build:not([hidden])) {
    grid-template-areas: "progress guide" "qrow controls" "piles feedback" "matbox choices";
    row-gap: 0;
  }
  [data-screen="play"]:has(> #build:not([hidden])) > .build { display: contents; }
  [data-screen="play"]:has(> #build:not([hidden])) > .progress { grid-area: progress; }
  [data-screen="play"]:has(> #build:not([hidden])) > .qrow { grid-area: qrow; }
  [data-screen="play"]:has(> #build:not([hidden])) > .feedback { grid-area: feedback; }
  [data-screen="play"]:has(> #build:not([hidden])) > .choices {
    grid-area: choices; align-self: start; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
  }
  [data-screen="play"]:has(> #build:not([hidden])) .choice { min-height: 60px; font-size: 30px; border-radius: 20px; }
  .piles { grid-area: piles; gap: 8px; margin-bottom: 4px; }
  .matbox { grid-area: matbox; }
  .guide { grid-area: guide; align-self: end; min-height: 22px; font-size: 16px; line-height: 1.3; margin: 0 0 4px; }
  .controls {
    grid-area: controls; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    gap: 8px; min-height: 56px; margin-bottom: 4px;
  }
  .ctl { min-width: 0; min-height: 56px; font-size: 14px; line-height: 1.15; padding: 4px 6px; border-radius: 16px; }
  /* 252px = what the header, question and caption take, plus slack so a different
     font (another OS) cannot push the last picture off the bottom */
  .build { --fig-h: max(52px, calc((100vh - 252px) / 2)); }
  @supports (height: 1svh) { .build { --fig-h: max(52px, calc((100svh - 252px) / 2)); } }
  .fig .blocks { width: auto; max-width: 100%; max-height: var(--fig-h); }
  .fig figcaption { margin-top: 0; font-size: 13px; line-height: 1.3; }
}

/* Sideways tablets: keep the block pictures a little smaller so they fit above the buttons. */
@media (min-width: 900px) and (max-height: 900px) {
  .piles .fig { max-width: 240px; }
  .matbox .fig { max-width: 340px; }
  .guide { margin: 4px 0; }
  .controls { margin-bottom: 4px; }
}
