  :root { --cw: min(94vw, 900px, calc((100svh - 150px) * 1.35)); }
  @supports not (height: 1svh) { :root { --cw: min(94vw, 900px); } }
  html { background: #000; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  /* Real Comic Sans first (Mac, Windows). Comic Neue only fills in where it is missing (iPhone, Android, Linux). */
  @font-face { font-family: "Comic Neue"; font-weight: 700; font-display: block; src: url(assets/comic-neue-700.woff2) format("woff2"); }
  @font-face { font-family: "Comic Neue"; font-weight: 400; font-display: block; src: url(assets/comic-neue-400.woff2) format("woff2"); }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  body { margin: 0; min-height: 100vh; min-height: 100dvh; background: #000; color: #fff; overflow-x: hidden; text-align: center;
    font: 700 clamp(22px, 6.2vw, 44px)/1.2 "Comic Sans MS", "Comic Sans", "Comic Neue", "Chalkboard SE", cursive;
    padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  #curtain { position: fixed; inset: 0; background: #000; z-index: 100; }
  /* "loading..." shows only if loading takes longer than a blink (so a fast load never flashes it), in a font every device already has */
  #loading { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; color: #fff;
    font: 700 clamp(22px, 6.2vw, 44px)/1.2 "Comic Sans MS", "Chalkboard SE", sans-serif; visibility: hidden; animation: late 1ms 250ms forwards; }
  @keyframes late { to { visibility: visible; } }

  /* phase 1: downloading */
  #p1 { min-height: calc(100dvh - 56px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; }
  #bar { position: relative; width: min(92vw, 720px); aspect-ratio: 1000 / 160; --p: 0%; --fc: #000; }
  .frame { position: absolute; inset: 0; visibility: hidden; }
  .frame.on { visibility: visible; }
  .clip { position: absolute; inset: 0; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
  .fill { height: 100%; width: var(--p); background: var(--fc); }
  .outline { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

  /* phase 2: done */
  #p2 { display: none; flex-direction: column; align-items: center; gap: 22px; }
  #p2.on { display: flex; }
  #done .emoji { height: 1em; width: 1em; vertical-align: -0.12em; margin-left: .08em; }
  #cert { width: var(--cw); position: relative; }
  #cert canvas { width: 100%; height: auto; display: block; }
  #cert #shot { position: absolute; inset: 0; width: 100%; height: 100%; display: block; -webkit-touch-callout: default; -webkit-user-drag: none; user-drag: none; }
  #cert #overlay { position: absolute; inset: 0; height: 100%; pointer-events: none; }
  #cert { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  html, body { overscroll-behavior: none; }
  #cert.draw { cursor: none; -webkit-user-select: none; user-select: none; }
  #brush { position: fixed; left: 0; top: 0; display: none; border-radius: 50%; border: 2px solid #000; box-shadow: 0 0 0 1px #fff; pointer-events: none; z-index: 60; will-change: transform; }
  /* the row under the certificate: everything is sized as a share of the row's own width, so nothing can overlap on any screen */
  #shareRow { width: var(--cw); position: relative; height: calc(var(--cw) * .17); }
  #copy { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: calc(var(--cw) * .364); background: none; border: 0; padding: 0; margin: 0; cursor: pointer; line-height: 0; }
  #copy img { display: block; width: 100%; height: auto; }
  #copy .copied { position: absolute; inset: 0; opacity: 0; }
  #copy.done img:not(.copied) { opacity: 0; }
  #copy.on .copied { opacity: 1; }
  #leftCol { display: contents; }
  #stack { position: absolute; left: 16.6%; top: 0; display: flex; flex-direction: column; align-items: flex-start; gap: calc(var(--cw) * .016); }
  #clear { visibility: hidden; opacity: .5; background: none; border: 0; color: #fff; font: inherit; font-size: clamp(14px, calc(var(--cw) * .043), 27px); line-height: 1; padding: 0; margin: 0; cursor: pointer; }
  #clear.show { visibility: visible; }
  #sign { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; line-height: 0; display: block; }
  #sign img { width: calc(var(--cw) * .094); height: auto; display: block; }
  #share { display: block; line-height: 0; position: absolute; right: 16.6%; top: 0; }
  #share img { width: calc(var(--cw) * .112); height: auto; display: block; }

  #confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
  #confetti img { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
  .clip.m1 { -webkit-mask-image: url(assets/bar-1-mask.png); mask-image: url(assets/bar-1-mask.png); }
  .clip.m2 { -webkit-mask-image: url(assets/bar-2-mask.png); mask-image: url(assets/bar-2-mask.png); }
  .clip.m3 { -webkit-mask-image: url(assets/bar-3-mask.png); mask-image: url(assets/bar-3-mask.png); }
