/* ==========================================================================
   Penny Canvas — theme
   Modern tool chrome with pixel-native details: a bitmap wordmark and coin,
   square swatches on a dot-grid stage, floating dock and toolbars, soft
   elevation, one copper accent (money) and one gold accent (Plus).
   No external fonts or assets.
   ========================================================================== */

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --stage: #e9ecef;
  --ink: #15191d;
  --ink-2: #5b6470;
  --ink-3: #98a1ab;
  --line: #e4e7ea;
  --line-2: #cdd3d9;
  --copper: #c2612f;        /* brand accent: marks, borders, backgrounds under white bold text */
  --copper-2: #a9522a;      /* copper for text and links (5.5:1 on white) */
  --copper-3: #8f4523;
  --copper-soft: #fbeee6;
  --patina: #1f9d8a;        /* accent for marks/borders */
  --patina-ink: #167a6b;    /* patina for text and filled chips (4.9:1 with white) */
  --patina-soft: #e2f4f0;
  --gold: #d99a2b;
  --gold-ink: #2b1f06;      /* text on gold */
  --gold-soft: #fdf3df;
  --danger: #c93b3b;
  --danger-soft: #fdebeb;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(21, 25, 29, .06), 0 2px 8px rgba(21, 25, 29, .06);
  --shadow-2: 0 4px 12px rgba(21, 25, 29, .08), 0 16px 40px rgba(21, 25, 29, .12);
  --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
body.is-canvas { height: 100vh; height: 100dvh; overflow: hidden; }

a { color: var(--copper-2); text-decoration: none; }
a:hover { color: var(--copper-3); text-decoration: underline; text-underline-offset: 2px; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mt { margin-top: 16px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.pos { color: var(--patina-ink); }
.neg { color: var(--danger); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; border-radius: var(--radius-sm); }
.skip:focus { left: 8px; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand-mark .body { fill: #d9733f; }
.brand-mark .shine { fill: #f0b07e; }
.brand-mark .shade { fill: var(--copper-2); }
.brand-mark .ink { fill: var(--ink); }
.brand-word { height: 13px; width: auto; fill: var(--ink); }
.brand:hover .brand-word { fill: var(--copper); }

.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  color: var(--ink-2);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.credits-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 6px 8px;
  border: 1px solid #efc9b2;
  background: var(--copper-soft);
  color: var(--ink);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
}
.credits-chip strong { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.credits-chip:hover { background: var(--copper); color: #fff; border-color: var(--copper); text-decoration: none; }
.credits-chip:hover .coin { box-shadow: inset -3px -3px 0 #fff, inset 3px 3px 0 #ffe1cf; }
.credits-chip .chip-plus { font-weight: 700; margin-left: 2px; color: var(--copper); }
.credits-chip:hover .chip-plus { color: #fff; }
.credits-chip.bump strong { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.25); color: var(--copper); } 100% { transform: scale(1); } }
.coin {
  width: 14px; height: 14px;
  background: #d9733f;
  box-shadow: inset -3px -3px 0 var(--copper-2), inset 3px 3px 0 #efa36b;
  border-radius: 2px;
}
.plus-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  background: var(--gold-soft); color: #8a5a0a;
  border: 1px solid #f1d9a6; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
}
.plus-chip:hover { text-decoration: none; background: var(--gold); color: #fff; border-color: var(--gold); }
.plus-chip .spark { width: 8px; height: 8px; background: var(--gold); border-radius: 1px; transform: rotate(45deg); }
.plus-chip:hover .spark { background: #fff; }

.menu { position: relative; }
.menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px; font-size: 14px; border-radius: 999px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  border-radius: 7px;
}
.menu[open] summary .avatar { background: var(--copper); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px;
  z-index: 50;
}
.menu-panel a, .menu-panel .linklike { display: block; width: 100%; text-align: left; padding: 9px 12px; color: var(--ink); text-decoration: none; font-size: 14px; border-radius: var(--radius-sm); }
.menu-panel a:hover, .menu-panel .linklike:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu-panel form { margin: 4px 0 0; border-top: 1px solid var(--line); padding-top: 4px; }

.linklike { background: none; border: 0; padding: 0; color: var(--copper-2); cursor: pointer; }
.linklike:hover { text-decoration: underline; text-underline-offset: 2px; }
.inline-form { display: inline; }

.menu-nav { display: none; }
.menu-nav summary { width: 40px; height: 40px; justify-content: center; border: 1px solid var(--line-2); border-radius: 9px; }
.burger { width: 16px; height: 2px; background: var(--ink); border-radius: 1px; box-shadow: 0 -5px 0 var(--ink), 0 5px 0 var(--ink); }
.menu-nav[open] summary { background: var(--ink); border-color: var(--ink); }
.menu-nav[open] .burger { background: #fff; box-shadow: 0 -5px 0 #fff, 0 5px 0 #fff; }
.menu-nav .menu-panel { left: 0; right: auto; }
@media (max-width: 1000px) {
  .nav { display: none; }
  .menu-nav { display: block; }
}
@media (max-width: 760px) {
  .menu-name, .chip-label { display: none; }
  /* Guests: the burger menu carries Plans and Log in; keep only Sign up in the bar. */
  .topbar-right .plus-chip, .topbar-right > .btn-ghost { display: none; }
  /* The menu drops down across the whole width, wherever the burger sits. */
  .menu-nav .menu-panel { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) - 4px); width: auto; min-width: 0; }
  .topbar { gap: 8px; padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right)); }
  .btn-sm { padding: 7px 10px; }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  border-radius: 8px;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--copper-2); border-color: var(--copper-2); color: #fff; box-shadow: 0 1px 2px rgba(194, 97, 47, .3); }
.btn-primary:hover { background: var(--copper-3); border-color: var(--copper-3); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { background: #e3a93f; border-color: #c2871f; color: var(--gold-ink); }
.btn-ghost { background: var(--surface); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b93838; border-color: #b93838; color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 13px 22px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn .price { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.22); }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.form > .btn:not(.btn-block) { align-self: flex-start; }

/* --------------------------------------------------------------------------
   Toasts / announcements
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--copper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 11px 12px 11px 14px;
  font-size: 14px;
}
.toast-success { border-left-color: var(--patina); }
.toast-error { border-left-color: var(--danger); }
.toast-close { margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 8px; min-width: 32px; min-height: 32px; margin-top: -6px; margin-bottom: -6px; }
.toast-close:hover { color: var(--ink); }
.toast.hide { opacity: 0; transition: opacity .25s; }

.announce {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 9px 20px;
  background: var(--ink); color: #fff;
  font-size: 14px;
  flex: 0 0 auto;
}
.announce .linklike { color: #ffd0b5; }
.announce-tag { font-family: var(--mono); font-size: 11px; background: var(--copper); padding: 2px 7px; border-radius: 4px; }
.announce-warn { background: var(--copper-soft); color: var(--ink); border-bottom: 1px solid #efc9b2; }
.announce-warn .linklike { color: var(--copper); }

/* --------------------------------------------------------------------------
   Canvas page
   -------------------------------------------------------------------------- */
.main-canvas { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.canvas-app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; position: relative; }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background-color: var(--stage);
  background-image: radial-gradient(rgba(21, 25, 29, .18) 1px, transparent 1.2px);
  background-size: 24px 24px;
  background-position: 12px 12px;
}
#board {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}
#board.panning { cursor: grabbing; }
#board.brush { cursor: cell; }

.hud {
  position: absolute;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  font-size: 12px;
}
.hud-tl { top: 14px; left: 14px; display: flex; gap: 14px; padding: 7px 14px; color: var(--ink-2); }
.hud-tl .stat strong { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.hud-tr { top: 14px; right: max(14px, env(safe-area-inset-right)); display: flex; flex-direction: column; padding: 4px; border-radius: 12px; }
.hud-bl { top: 54px; left: 14px; padding: 6px 12px; font-size: 13px; }
.dot { display: inline-block; width: 7px; height: 7px; background: var(--patina); border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.dot.live { animation: pulse 2.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.tools .tool {
  width: 38px; height: 38px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}
.tools .tool:hover { background: var(--surface-2); color: var(--copper); }
.tools .tool[aria-pressed="true"] { background: var(--ink); color: #fff; }

.pixel-info {
  position: absolute;
  z-index: 6;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 9px 12px;
  font-size: 13px;
  max-width: 260px;
  pointer-events: none;
  line-height: 1.45;
}
.pixel-info .who { font-weight: 600; }
.pixel-info .swatch { width: 12px; height: 12px; display: inline-block; vertical-align: -1px; margin-right: 6px; background: var(--c); border: 1px solid rgba(21,25,29,.25); border-radius: 3px; }

.stencil-bar {
  position: absolute; z-index: 6;
  top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-1);
  padding: 7px 14px; font-size: 13px;
}
.stencil-bar input[type="range"] { width: 90px; accent-color: var(--copper); }
.stencil-bar input[type="number"] { width: 56px; padding: 2px 6px; border: 1px solid var(--line-2); border-radius: 6px; }

/* Welcome + help cards float over the stage */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.welcome, .help {
  position: absolute;
  z-index: 11;
  left: 14px; top: 64px;
  width: min(400px, calc(100% - 28px));
  max-height: calc(100% - 78px);
  overflow: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 22px 22px 18px;
}
.welcome-title { font-size: 24px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; }
.welcome p { margin: 0 0 12px; color: var(--ink-2); }
.welcome-steps { margin: 0 0 16px; padding-left: 20px; }
.welcome-steps li { margin: 4px 0; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.help h2 { margin: 0 0 10px; font-size: 17px; }
.help-list { margin: 0 0 14px; }
.help-list > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.help-list dt { font-family: var(--mono); font-weight: 700; }
.help-list dd { margin: 0; color: var(--ink-2); }

/* Area popover, Your-art panel */
.area-pop {
  position: absolute; z-index: 11;
  border-radius: 12px; box-shadow: var(--shadow-2);
  padding: 14px 16px; width: min(340px, calc(100% - 28px));
  max-height: calc(100% - 20px); overflow: auto;
}
.area-pop h3 { margin: 0 0 8px; font-size: 15px; }
.area-pop .field { margin-bottom: 10px; }
.area-pop .field input, .area-pop .field select { padding: 8px 10px; width: 100%; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
.area-pop .field select { -webkit-appearance: none; appearance: none; }
.report-form { margin-top: 4px; }
.art-panel {
  position: absolute; z-index: 11; right: 66px; top: 14px;
  width: min(380px, calc(100% - 90px)); max-height: calc(100% - 120px); overflow: auto;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 18px;
}
.art-panel h2 { margin: 0 0 4px; font-size: 17px; }
.art-item { border-top: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.art-item:first-child { border-top: 0; }
.art-item .art-name { font-weight: 600; }
.art-item .art-meta { color: var(--ink-2); font-size: 12px; }
.art-item .art-damage { font-family: var(--mono); font-weight: 700; color: var(--patina-ink); }
.art-item .art-damage.bad { color: var(--danger); }
.art-item .art-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.pixel-info { pointer-events: auto; }
.pixel-info .history { margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); max-height: 180px; overflow: auto; font-size: 12px; }
.pixel-info .history div { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.pixel-info .linklike { font-size: 12px; }

/* Dock */
.tray {
  flex: 0 0 auto;
  margin: 0 auto 14px;
  width: min(1180px, calc(100% - 28px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  z-index: 10;
}
.tray-status { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.tray-msg { font-weight: 600; }
.tray-msg.warn { color: var(--danger); }
.free-chip {
  align-self: flex-start;
  font-family: var(--mono); font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  border-radius: 999px;
}
.free-chip.ready { background: var(--patina-ink); border-color: var(--patina-ink); color: #fff; font-weight: 700; }
.tray-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.palette {
  display: grid;
  grid-template-columns: repeat(17, 26px);
  gap: 5px;
  justify-content: center;
}
.swatch-btn {
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid rgba(21, 25, 29, .18);
  background: var(--c);
  cursor: pointer;
  position: relative;
  border-radius: 5px;
  transition: transform .08s;
}
.swatch-btn:hover { transform: scale(1.1); }
.swatch-btn[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); transform: scale(1.06); }
.swatch-btn .key {
  position: absolute; right: 2px; bottom: 0;
  font-family: var(--mono); font-size: 9px; line-height: 1;
  color: rgba(0,0,0,.5);
  mix-blend-mode: multiply;
}
.swatch-custom {
  grid-row: 1 / span 2;
  width: 26px; height: 57px;
  background: conic-gradient(from 90deg, #ff4d4d, #ffb800, #7bed56, #00ccc0, #3690ea, #b44ac0, #ff4d4d);
  border: 1px solid rgba(21, 25, 29, .18);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}
.swatch-custom[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch-custom.locked { filter: saturate(.3) brightness(1.1); }
.swatch-custom .lock {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; color: rgba(21,25,29,.75);
}
.swatch-custom .cur {
  position: absolute; left: 4px; right: 4px; bottom: 4px; height: 20px;
  background: var(--c, transparent); border-radius: 3px; border: 1px solid rgba(255,255,255,.8);
}

.colour-pop {
  position: absolute; z-index: 12;
  bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: 300px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2);
  padding: 14px;
  font-size: 13px;
}
.colour-pop h3 { margin: 0 0 8px; font-size: 14px; }
.colour-pop p { margin: 0 0 10px; color: var(--ink-2); }
.colour-row { display: flex; align-items: center; gap: 8px; }
.colour-row input[type="color"] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; background: none; cursor: pointer; }
.colour-row input[type="text"] { flex: 1; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 6px; }
.recent { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.recent button { width: 24px; height: 24px; border-radius: 5px; border: 1px solid rgba(21,25,29,.18); background: var(--c); cursor: pointer; padding: 0; }
.recent button:hover { transform: scale(1.1); }

@media (max-width: 1240px) {
  .tray { grid-template-columns: 1fr 1fr; grid-template-areas: "status actions" "palette palette"; gap: 10px; padding: 10px 14px; width: min(760px, calc(100% - 28px)); }
  .tray-status { grid-area: status; }
  .tray-actions { grid-area: actions; }
  .palette { grid-area: palette; grid-template-columns: repeat(17, minmax(0, 1fr)); max-width: 680px; margin: 0 auto; width: 100%; }
  .swatch-btn { width: 100%; height: auto; aspect-ratio: 1; }
  .swatch-custom { width: 100%; height: 100%; }
  .swatch-btn .key { display: none; }
}
@media (max-width: 560px) {
  .tray {
    width: 100%; margin: 0; border-radius: 16px 16px 0 0; border-bottom: 0;
    grid-template-columns: 1fr; grid-template-areas: "status" "palette" "actions";
    gap: 8px; padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    touch-action: manipulation;
  }
  .tray-status { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
  .tray-msg { font-size: 13px; line-height: 1.3; }
  .free-chip { align-self: center; white-space: nowrap; }
  /* Two rows of finger-sized swatches, scrolling sideways. */
  .palette {
    display: grid; grid-auto-flow: column; grid-template-columns: none;
    grid-template-rows: repeat(2, 34px); grid-auto-columns: 34px; gap: 6px;
    max-width: none; width: 100%; justify-content: start;
    overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px; scrollbar-width: thin;
  }
  .swatch-btn { width: 34px; height: 34px; aspect-ratio: auto; }
  .swatch-custom { width: 34px; height: 74px; grid-row: 1 / span 2; grid-column: 1; }
  .tray-actions { justify-content: stretch; }
  .tray-actions .btn { flex: 1 1 auto; min-height: 42px; }
  .tray-actions .btn[data-tool="brush"], .tray-actions .btn[data-tool="cancel"], .tray-actions .btn[data-tool="undo"] { flex: 0 0 auto; }
  .welcome, .help { left: 10px; top: 10px; width: calc(100% - 20px); padding: 16px; max-height: calc(100% - 20px); }
  .welcome-title { font-size: 21px; }
  .hud-tl, .hud-bl { display: none; }
  .hud-tr { top: 10px; right: max(10px, env(safe-area-inset-right)); }
  .tools .tool { width: 40px; height: 40px; }
  .colour-pop { width: calc(100vw - 20px); }
  .art-panel { right: 10px; left: 10px; width: auto; max-height: calc(100% - 20px); }
}
/* Phones held sideways: keep most of the height for the board. */
@media (max-height: 500px) and (max-width: 1000px) {
  .tray { grid-template-columns: minmax(120px, 1fr) auto auto; grid-template-areas: none; gap: 8px; padding: 6px 12px; width: calc(100% - 20px); margin: 0 auto 6px; border-radius: 12px; }
  .tray-status, .tray-actions, .palette { grid-area: auto; }
  .tray-status { flex-direction: column; }
  .palette { display: grid; grid-auto-flow: column; grid-template-columns: none; grid-template-rows: 30px; grid-auto-columns: 30px; gap: 5px; overflow-x: auto; max-width: 42vw; margin: 0; justify-content: start; }
  .swatch-btn { width: 30px; height: 30px; }
  .swatch-custom { width: 30px; height: 30px; grid-row: auto; grid-column: 1; }
  .swatch-custom .cur { height: 10px; }
  .hud-tl, .hud-bl { display: none; }
  .hud-tr { flex-direction: row; top: 6px; right: 6px; }
  .tools .tool { width: 34px; height: 34px; }
  .welcome, .help, .art-panel { top: 6px; max-height: calc(100% - 12px); padding: 12px 14px; }
  .welcome-title { font-size: 18px; }
}
/* Touch devices: 16px inputs stop iOS from zooming into forms. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px; }
  .colour-row input[type="text"] { font-size: 16px; }
}

/* --------------------------------------------------------------------------
   Content pages
   -------------------------------------------------------------------------- */
.main-page { flex: 1 0 auto; }
.page { width: min(1040px, 100% - 40px); margin: 0 auto; padding: 44px 0 64px; }
.page-narrow { width: min(620px, 100% - 40px); }
.eyebrow { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.025em;
  margin: 0 0 14px;
  max-width: 24ch;
}
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; margin: 36px 0 12px; }
.card > h2:first-child, section > h2:first-child { margin-top: 0; }
h3 { font-size: 16px; font-weight: 700; margin: 10px 0 6px; }
.lead { font-size: 17px; line-height: 1.55; color: var(--ink-2); max-width: 62ch; margin: 0 0 26px; }
.prose { max-width: 68ch; }
.prose p, .prose li { line-height: 1.65; }
.prose ol, .prose ul { padding-left: 22px; }
.prose li { margin: 8px 0; }
.notice { border-color: #efc9b2; background: var(--copper-soft); margin-bottom: 20px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.stat-label { font-size: 13px; color: var(--ink-2); }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-sub { font-size: 13px; color: var(--ink-2); }
.stat-card .btn { margin-top: 8px; }
.card-gold { border-color: #f1d9a6; background: linear-gradient(180deg, #fffaf0, #fff); }

.steps .step { position: relative; padding-top: 18px; }
.step-n { position: absolute; top: -12px; left: 16px; background: var(--ink); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.step h3 { margin-top: 2px; }
.step p { margin: 0; color: var(--ink-2); }

.pricing .price-card { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.pack-price { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.pack-tag { font-size: 12px; font-weight: 600; color: var(--copper-3); background: var(--copper-soft); padding: 2px 8px; border-radius: 999px; }

.faq dt { font-weight: 600; margin-top: 18px; }
.faq dd { margin: 4px 0 0; color: var(--ink-2); max-width: 68ch; }

/* Membership plans */
.tiers-form { display: block; }
.billing-switch { position: relative; display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--surface); margin: 0 0 22px; }
.billing-switch input { position: absolute; opacity: 0; pointer-events: none; }
.billing-switch label { padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.billing-switch input:checked + label { background: var(--ink); color: #fff; }
.billing-switch input:focus-visible + label { outline: 2px solid var(--copper); outline-offset: 2px; }
.billing-switch .save { font-size: 11px; color: var(--patina-ink); margin-left: 4px; }
.billing-switch input:checked + label .save { color: #bfeee4; }
.tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.tier { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px 22px 20px; display: flex; flex-direction: column; gap: 6px; }
.tier-highlight { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.tier-current { border-color: var(--patina); box-shadow: 0 0 0 3px var(--patina-soft); }
.tier-ribbon { position: absolute; top: -11px; left: 18px; background: var(--gold); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.tier-ribbon-current { background: var(--patina); }
.tier-name { margin: 0; font-size: 22px; }
.tier-tagline { margin: 0; color: var(--ink-2); font-size: 14px; min-height: 1.5em; }
.tier-price { margin: 10px 0 8px; }
.tier-price strong { font-size: 32px; letter-spacing: -.02em; }
.tier-price small { color: var(--ink-2); margin-left: 2px; }
.tier-price em { display: block; font-style: normal; font-size: 12px; color: var(--ink-2); }
.price-yearly { display: none; }
.tiers-form:has(#bill-yearly:checked) .price-yearly, .tiers-form.is-yearly .price-yearly { display: block; }
.tiers-form:has(#bill-yearly:checked) .price-monthly, .tiers-form.is-yearly .price-monthly { display: none; }
.tier-perks { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.tier-perks li { padding-left: 18px; position: relative; }
.tier-perks li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); border-radius: 1px; }
.tier .btn-block { margin-top: auto; }
@media (max-width: 900px) { .tiers { grid-template-columns: 1fr; } }

/* PayPal SDK v6 buttons */
.paypal-host { max-width: 340px; margin-bottom: 8px; }
.tier .paypal-sub { margin-top: auto; }
.tier .paypal-sub:not([hidden]) + .btn-block { margin-top: 0; }
#ppStatus:empty { display: none; }
paypal-button { display: block; --paypal-button-border-radius: 8px; --paypal-mark-border-radius: 8px; }
body.pp-busy paypal-button { opacity: .55; pointer-events: none; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-compact { gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--ink-2); font-size: 13px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field input[type="search"], .searchbar input {
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  width: 100%;
  border-radius: 8px;
}
.field input:focus { border-color: var(--copper); outline: 2px solid var(--copper-soft); outline-offset: 0; }
.field input:user-invalid { border-color: var(--danger); }
.field-check label { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; }
.field-check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--copper); }
.field-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-foot { margin: 0; font-size: 14px; color: var(--ink-2); }
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-row img { border: 1px solid var(--line-2); border-radius: 8px; image-rendering: pixelated; }

/* Packs */
.packs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pack {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  padding: 24px 18px 16px;
}
.pack input { position: absolute; opacity: 0; pointer-events: none; }
.pack:hover { border-color: var(--ink-3); }
.pack:has(input:checked), .pack.is-selected { border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-soft); }
.pack:has(input:focus-visible) { outline: 2px solid var(--copper); outline-offset: 2px; }
.pack .pack-tag { position: absolute; top: -11px; left: 14px; }
.pack-credits { font-size: 17px; }
.pack-sub { font-size: 13px; color: var(--ink-2); }
.packs-cta { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 8px; }
@media (max-width: 860px) { .packs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .packs { grid-template-columns: 1fr; } }

/* Lists & tables */
.c0{--c:#FFFFFF} .c1{--c:#D4D7D9} .c2{--c:#898D90} .c3{--c:#515252} .c4{--c:#000000} .c5{--c:#6D001A} .c6{--c:#BE0039} .c7{--c:#FF4500}
.c8{--c:#FFA800} .c9{--c:#FFD635} .c10{--c:#FFF8B8} .c11{--c:#00A368} .c12{--c:#00CC78} .c13{--c:#7EED56} .c14{--c:#00756F} .c15{--c:#009EAA}
.c16{--c:#00CCC0} .c17{--c:#2450A4} .c18{--c:#3690EA} .c19{--c:#51E9F4} .c20{--c:#493AC1} .c21{--c:#6A5CFF} .c22{--c:#94B3FF} .c23{--c:#811E9F}
.c24{--c:#B44AC0} .c25{--c:#E4ABFF} .c26{--c:#DE107F} .c27{--c:#FF3881} .c28{--c:#FF99AA} .c29{--c:#6D482F} .c30{--c:#9C6926} .c31{--c:#FFB470}
.pixel-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.pixel-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.swatch { width: 16px; height: 16px; background: var(--c); border: 1px solid rgba(21,25,29,.25); border-radius: 4px; flex: 0 0 auto; }
.table-wrap { overflow-x: auto; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table-sm th, .table-sm td { padding: 7px 10px; font-size: 13px; }
.row-banned td { color: var(--ink-3); }
.status { display: inline-block; font-size: 12px; font-family: var(--mono); padding: 1px 7px; border: 1px solid currentColor; border-radius: 999px; }
.status-completed, .status-active { color: var(--patina); }
.status-created, .status-approved { color: var(--ink-2); }
.status-failed, .status-expired { color: var(--danger); }
.status-refunded, .status-cancelled, .status-suspended { color: var(--copper); }
.badge { font-size: 11px; font-family: var(--mono); padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 999px; }
.badge-supporter { font-size: 11px; font-weight: 600; color: var(--copper); background: var(--copper-soft); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.badge-plus { font-size: 11px; font-weight: 700; color: #8a5a0a; background: var(--gold-soft); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.badge-tier-pro { color: #4a2a8f; background: #ece6fb; }
.badge-tier-studio { color: #fff; background: var(--ink); }
.badge-official { font-size: 11px; font-weight: 600; color: var(--patina); background: var(--patina-soft); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.board { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.board li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.board li:last-child { border-bottom: 0; }
.board li:nth-child(1) .rank { background: var(--copper); color: #fff; }
.board .rank { font-weight: 700; display: inline-block; min-width: 28px; text-align: center; padding: 1px 0; border-radius: 6px; background: var(--surface-2); }
.board .n { font-weight: 700; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.subnav { display: flex; gap: 2px; margin: 0 0 24px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--copper); }
.filters { display: flex; gap: 14px; font-size: 14px; }
.filters a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.searchbar { display: flex; gap: 8px; margin: 0 0 16px; max-width: 460px; }
.pager { display: flex; gap: 16px; align-items: center; }

/* Timelapse */
.snapshot { display: block; width: auto; max-width: 100%; height: auto; max-height: 72vh; margin: 0 auto; image-rendering: pixelated; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; }
.timelapse { padding: 12px; }
.tl-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.tl-controls input[type="range"] { flex: 1; accent-color: var(--copper); }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: auto; }
.footer-inner { width: min(1040px, 100% - 40px); margin: 0 auto; padding: 22px 0; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.footer-brand { margin: 0; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--ink-2); }
.footer-links a:hover { color: var(--copper); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
