:root {
  color-scheme: light;
  --background: #fff3be;
  --ink: #43384d;
  --muted: #685a63;
  --paper: #fff9df;
  --selected: #ead9f0;
  --accent: #523c60;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
}
button:disabled { opacity: .52; cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
p, h1 { margin: 0; }

#draw:not([hidden]) {
  width: 100%; height: 100svh; height: 100dvh; margin-inline: auto;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(.4rem, 1.4vh, .8rem);
  padding: max(.7rem, env(safe-area-inset-top)) max(.7rem, env(safe-area-inset-right))
    max(.25rem, env(safe-area-inset-bottom)) max(.7rem, env(safe-area-inset-left));
  overflow: clip;
}
@media (min-width: 600px) {
  #draw:not([hidden]) { max-width: max(24rem, 56.25dvh); }
}
.editor-bar, .dialog-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
#shape-picker {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .35rem .9rem .35rem .5rem; min-height: 3rem; text-align: start;
}
#current-preview { width: 2.2rem; height: 2.2rem; }
#shape-picker small, #shape-picker strong { display: block; }
#shape-picker small { font-size: .75rem; line-height: 1.15; color: var(--muted); }
#shape-picker strong { font-size: .95rem; line-height: 1.35; }
.chevron { width: .48rem; height: .48rem; margin-inline: .25rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.quiet { padding: .5rem .85rem; min-height: 2.75rem; font-size: .875rem; white-space: nowrap; }
.quiet span { font-size: 1.25rem; vertical-align: -.06em; }

.drawing {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0;
  container-type: size; border-radius: 1.3rem; background: #fff8d8;
}
.drawing.freehand::before {
  content: ''; position: absolute; width: 100cqmin; height: 100cqmin; border-radius: .7rem;
  background: repeating-conic-gradient(#fffbee 0 25%, #f7f1e3 0 50%) 0 0 / 1rem 1rem;
}
#canvas {
  position: relative; display: block; width: min(100%, calc(100svh - 14rem)); height: auto;
  aspect-ratio: 1; touch-action: none; cursor: crosshair;
}
@supports (width: 1cqmin) { #canvas { width: 100cqmin; height: 100cqmin; } }
.drawing.sending { z-index: 2; pointer-events: none; }
.editor-tools { display: grid; gap: .15rem; }
.palette-row:not([hidden]) { display: grid; grid-template-columns: 3.75rem 1fr; align-items: center; gap: .25rem; }
.palette-row > span { font-size: .875rem; font-weight: 650; }
.colors { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.colors button { display: grid; place-items: center; height: 2.6rem; background: transparent; padding: 0; }
.colors button::before {
  content: ''; width: min(1.65rem, 80%); aspect-ratio: 1; border-radius: 50%;
  background: var(--swatch); box-shadow: inset 0 0 0 1px #49374620;
}
.colors button[aria-pressed="true"]::before { outline: 2px solid var(--accent); outline-offset: 2px; }
.ink-row { display: grid; grid-template-columns: minmax(0, 1fr) 2.5rem; align-items: center; }
#ink-more { display: grid; place-items: center; height: 2.6rem; padding: 0; background: transparent; }
#ink-more span {
  display: grid; place-items: center; width: 1.85rem; height: 1.85rem;
  border-radius: 50%; border: .25rem solid transparent; font: bold 1rem/1 system-ui, sans-serif;
  background: linear-gradient(var(--paper), var(--paper)) padding-box,
    var(--ink-ring, conic-gradient(#ce4d58, #f0be54, #71ae6b, #59acbb, #a683bf, #ce4d58)) border-box;
}
#ink-options { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .25rem; }
#ink-options button { min-height: 2.9rem; }
#ink-options button::before { width: min(2.15rem, 80%); }
.primary { width: 100%; min-height: 3rem; margin-block-start: .35rem; background: var(--accent); color: #fff9ef; font-weight: 750; }
.feedback { text-align: center; min-height: 1.35rem; line-height: 1.35rem; font-size: .875rem; color: var(--muted); }

.picker-dialog {
  width: min(27rem, calc(100% - 1.5rem)); max-height: 90dvh; overflow: auto;
  padding: 1rem; border: 0; border-radius: 1.6rem; background: #fff9e4; color: var(--ink);
}
.picker-dialog::backdrop { background: #35233766; }
.dialog-bar { margin-bottom: .8rem; }
.dialog-bar h2 { margin: 0; font-size: 1.15rem; }
.dialog-close { width: 2.75rem; height: 2.75rem; background: #f5ecd5; font-size: 1.5rem; line-height: 1; }
.shapes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.shapes button {
  display: grid; place-items: center; align-content: center; gap: .25rem;
  min-height: 4.6rem; padding: .35rem .12rem; border-radius: .9rem;
  background: #f7f0d9; line-height: 1.25; font-size: .875rem;
}
.shapes canvas { width: 2.5rem; height: 2.5rem; }
.shapes button[aria-pressed="true"] { background: #eadcf0; box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
@media (orientation: landscape) and (max-height: 600px) {
  #draw:not([hidden]) { max-width: 64rem; grid-template: auto 1fr / minmax(0, 1fr) minmax(15rem, .75fr); }
  .drawing { grid-area: 1 / 1 / 3 / 2; }
  .editor-bar, .editor-tools { grid-column: 2; }
  .editor-tools { align-self: end; }
}
#wall:not([hidden]) {
  min-height: 100svh;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 3vw, 2.5rem);
  overflow: hidden;
  background: var(--background);
}
.sky { position: absolute; inset: 0; pointer-events: none; }
.sky i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #c49c70;
  animation: twinkle 6s var(--delay) infinite alternate;
}
@keyframes twinkle { from { opacity: .08; } to { opacity: .42; } }
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; } }
#gallery { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#gallery img { position: absolute; top: 0; left: 0; aspect-ratio: 1; object-fit: contain; }
#gallery.sweeping img { will-change: transform, opacity; }
#gallery img.arriving { z-index: 1; }
.wall-title {
  position: relative;
  z-index: 2;
  text-align: center;
  margin: clamp(.35rem, 2vh, 1.5rem) 0 .5rem;
  font: 700 clamp(1.9rem, min(4.8vw, 8.3vh), 4.5rem)/.96 Georgia, serif;
  letter-spacing: -.055em;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px var(--background);
  text-shadow: 0 0 8px var(--background);
  pointer-events: none;
}
.wall-title em { font-weight: 400; color: #8d4f60; font-size: .72em; }
#join:not([hidden]) { position: absolute; z-index: 3; right: clamp(1rem, 3vw, 2.5rem); bottom: clamp(1rem, 3vw, 2.5rem); }
#join img { display: block; width: clamp(4.5rem, 8vw, 6rem); border-radius: .45rem; image-rendering: pixelated; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
