.coloring-shell {
  padding: clamp(14px, 3vw, 42px) 0 34px;
  background: url("/assets/riddle-desk-paper.webp") center top / 700px auto, #f8efdd;
}
.coloring-desk {
  display: grid;
  grid-template-columns: minmax(0, .66fr) minmax(0, 1.4fr);
  gap: clamp(12px, 3vw, 42px);
  align-items: start;
}
.coloring-intro h1 {
  margin: 12px 0 16px;
  color: #172638;
  font: 700 clamp(2.8rem, 5.65vw, 6.2rem)/.89 var(--font-editorial);
  letter-spacing: -.055em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.coloring-intro h1::after {
  display: block;
  width: min(88%, 315px);
  height: .14em;
  margin-top: .14em;
  border-top: .065em solid #6a7750;
  border-radius: 50%;
  transform: rotate(-3deg);
  content: "";
}
.coloring-intro h1 span { display: block; margin-top: .12em; font-size: .66em; line-height: 1; }
.coloring-intro p { margin: 0 0 9px; color: #394b3b; max-width: 36ch; }
.coloring-intro img { display: block; width: min(100%, 410px); height: auto; pointer-events: none; }
.coloring-paper {
  min-width: 0;
  padding: clamp(28px, 4.4vw, 55px) clamp(14px, 3vw, 38px) clamp(16px, 3vw, 38px);
  border-radius: 24px 16px 24px 12px;
  background: url("/assets/riddle-card-stack.webp") center / 100% 100% no-repeat;
}
.coloring-paper .game-toolbar { padding: 0 0 10px; border: 0; background: transparent; }
.coloring-paper .game-toolbar .toolbar-group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; border: 0; padding: 0; }
.coloring-paper .tool-btn { min-height: 44px; border-color: #7b7752; color: #203a2c; background: #fff9ec; }
.coloring-paper .tool-btn svg { width: 1em; height: 1em; flex: 0 0 auto; }
.coloring-paper .tool-btn[aria-pressed="true"] { background: #e8ecd2; border-color: #5f7444; }
.coloring-paper .game-board-wrap { position: relative; padding: 0; overflow: hidden; border: 1.5px solid #74674f; border-radius: 13px; background: #fff; }
.coloring-paper canvas, .coloring-paper .coloring-outline { width: 100%; height: auto; display: block; }
.coloring-paper canvas { cursor: crosshair; }
.coloring-paper canvas:focus-visible { outline: 3px solid #47744f; outline-offset: -4px; }
.coloring-key-mark, .coloring-bloom {
  position: absolute;
  width: 19px;
  height: 19px;
  border: 2px solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}
.coloring-key-mark { color: #237960; background: #ffffffcc; }
.coloring-paper canvas:focus-visible + .coloring-key-mark { opacity: 1; }
.coloring-help {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}
.color-palette { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; padding-top: 8px; }
.color-pencil {
  min-height: 45px;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
}
.color-pencil[aria-pressed="true"] { border-color: #62784b; background: #f6f1d4; }
.color-pencil::before {
  width: 70%;
  max-width: 32px;
  aspect-ratio: .51;
  clip-path: polygon(50% 0, 98% 38%, 98% 100%, 3% 100%, 3% 38%);
  background: linear-gradient(90deg,#ffffff33 0 25%,transparent 25% 70%,#17191028 70%),
              linear-gradient(var(--pencil) 0 17%,#e4bb81 17% 38%,var(--pencil) 38%);
  content: "";
}
.coloring-actions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; }
.coloring-actions .tool-btn { width: auto; }
.coloring-actions .btn { min-height: 44px; }
.coloring-print-links { display: flex; justify-content: center; gap: 8px 18px; flex-wrap: wrap; margin: 10px 0 6px; font-size: .9rem; }
.coloring-print-links .tool-btn { width: auto; }
.coloring-paper .game-status-line { padding: 7px 0 0; margin: 0; text-align: center; border: 0; color: #41543f; background: none; }
.coloring-paper .completion-drawer {
  display: none;
  position: relative;
  inset: auto;
  width: auto;
  margin-top: 12px;
  padding: 12px 54px 12px 15px;
  border: 1px solid #aa9569;
  background: #fcf1d9;
  color: #263b30;
  transform: none;
  box-shadow: none;
}
.coloring-paper .completion-drawer.is-visible { display: block; }
.coloring-paper .completion-drawer p { color: inherit; }
.coloring-paper .close-completion {
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: inherit;
}
@media (max-width: 760px) {
  .coloring-desk { grid-template-columns: minmax(0, 1fr); }
  .coloring-intro { position: relative; }
  .coloring-intro h1 { max-width: 80%; margin-top: 8px; font-size: clamp(2.4rem, 8.25vw, 4.2rem); text-wrap: pretty; }
  .coloring-intro img { position: absolute; width: min(24%, 130px); max-height: 122px; object-fit: contain; top: 0; right: 0; }
  .coloring-intro p { max-width: 84%; }
  .coloring-paper { padding: 28px clamp(12px, 3.5vw, 23px) clamp(14px, 3.5vw, 23px); }
  .coloring-paper .game-toolbar .toolbar-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .color-palette { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.coloring-print-masthead,
.coloring-print-footer { display: none; }

@media print {
  [data-coloring-desk] main > :not(.coloring-shell),
  .coloring-intro > :not(h1, .coloring-print-masthead),
  .coloring-paper > :not(.game-board-wrap),
  .coloring-key-mark,
  .coloring-bloom { display: none !important; }

  [data-coloring-desk] .coloring-shell { padding: 0 2.5mm; background: white; }
  [data-coloring-desk] .coloring-desk {
    display: grid;
    grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
    align-items: stretch;
    gap: 3mm;
    height: 252mm;
  }
  .coloring-print-masthead {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 15mm;
    padding-right: 35mm;
    border-bottom: .4pt solid #777165;
    color: #202f36;
    font: 700 17pt/1.1 var(--font-editorial);
  }
  .coloring-print-masthead span::after {
    display: block;
    width: 19mm;
    margin: 1mm auto 0;
    border-top: 1.4pt solid #a7432b;
    border-radius: 50%;
    content: "";
  }
  .coloring-print-masthead::after {
    position: absolute;
    top: 0;
    right: 0;
    width: 34mm;
    height: 14mm;
    background: url("/assets/print/worksheet-olive-branch.webp") right center / contain no-repeat;
    print-color-adjust: exact;
    content: "";
  }
  [data-coloring-desk] .coloring-intro h1 {
    max-width: none;
    margin: 4mm 0 0;
    color: #202f36;
    font-size: 23pt;
    line-height: 1.1;
    letter-spacing: -.035em;
  }
  .coloring-intro h1 span { display: inline; font-size: inherit; }
  .coloring-intro h1::after { display: none; }
  [data-coloring-desk] .coloring-paper { display: grid; min-height: 0; padding: 0; background: none; box-shadow: none; }
  .coloring-paper .game-board-wrap {
    display: grid;
    height: 100%;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    border: 0;
    border-radius: 0;
    break-inside: avoid;
  }
  .coloring-paper :is(canvas, .coloring-outline) {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    outline: 0;
  }
  .coloring-print-footer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4mm;
    align-items: baseline;
    padding-top: 2mm;
    border-top: .4pt solid #777165;
    color: #202f36;
    font: 9pt/1.2 Georgia, serif;
  }
  .coloring-print-footer em { text-align: center; }
  .coloring-print-footer a { color: inherit; font: 8pt/1.2 Arial, sans-serif; text-decoration: none; }
}
