:root {
  --bg: #ebe8f4;
  --panel: #ffffff;
  --ink: #2a2440;
  --muted: #8a83a3;
  --line: #e4e0f0;
  --press: #d9d4ea;
  --accent: #7b5cff;
  --accent-d: #5a3ee0;
  --green: #22c070;
  --green-d: #179456;
  --orange: #ff9f1c;
  --orange-d: #d97f00;
  --red: #ff4d5e;
  --red-d: #cf2f40;
  --shadow: 0 12px 32px rgba(42, 36, 64, 0.16), 0 2px 6px rgba(42, 36, 64, 0.06);
  --checker: repeating-conic-gradient(#e6e3ef 0 25%, #fff 0 50%) 0 0 / 14px 14px;
  --font: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }
.ic { width: 26px; height: 26px; flex: none; }

/* ---------------------------------------------------------------- stage */
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#stage[data-tool='pen'], #stage[data-tool='eraser'], #stage[data-tool='stamp'] { cursor: none; }
#stage[data-tool='fill'] { cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cg%20stroke%3D%22%23fff%22%20stroke-width%3D%224.2%22%3E%3Cpath%20d%3D%22M17%2011L10%204%203.3%2010.7a1.8%201.8%200%20000%202.6l4.4%204.4a1.8%201.8%200%20002.6%200z%22/%3E%3Cpath%20d%3D%22M3.4%2012.2h13.2%22/%3E%3Cpath%20d%3D%22M8%202.2l2.4%202.4%22/%3E%3Cpath%20d%3D%22M17%2011c1.7.5%202.6%201.8%202.6%203.6%22/%3E%3Cpath%20d%3D%22M19.6%2015.4c-1.2%201.5-1.8%202.6-1.8%203.4a1.8%201.8%200%20003.6%200c0-.8-.6-1.9-1.8-3.4z%22%20fill%3D%22%23fff%22/%3E%3C/g%3E%3Cg%20stroke%3D%22%232a2440%22%20stroke-width%3D%222%22%3E%3Cpath%20d%3D%22M17%2011L10%204%203.3%2010.7a1.8%201.8%200%20000%202.6l4.4%204.4a1.8%201.8%200%20002.6%200z%22/%3E%3Cpath%20d%3D%22M3.4%2012.2h13.2%22/%3E%3Cpath%20d%3D%22M8%202.2l2.4%202.4%22/%3E%3Cpath%20d%3D%22M17%2011c1.7.5%202.6%201.8%202.6%203.6%22/%3E%3Cpath%20d%3D%22M19.6%2015.4c-1.2%201.5-1.8%202.6-1.8%203.4a1.8%201.8%200%20003.6%200c0-.8-.6-1.9-1.8-3.4z%22%20fill%3D%22%232a2440%22/%3E%3C/g%3E%3C/svg%3E") 26 27, cell; }
#stage[data-tool='lasso'] { cursor: crosshair; }
#stage[data-tool='cursor'] { cursor: default; }
#stage.picking { cursor: copy; }
#stage.grab { cursor: grab; }
#stage.panning { cursor: grabbing; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 18px;
  background: var(--panel);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--press), 0 8px 20px rgba(42, 36, 64, 0.1);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--press), 0 3px 8px rgba(42, 36, 64, 0.1); }
.btn:disabled { opacity: 0.45; }
.btn.icon-btn { width: 56px; padding: 0; }
.btn.small { min-height: 44px; width: 44px; border-radius: 14px; }
.btn.small .ic { width: 22px; height: 22px; }
.btn.big { min-height: 64px; font-size: 20px; border-radius: 22px; width: 100%; }
.btn.big .ic { width: 28px; height: 28px; }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d), 0 8px 20px rgba(34, 192, 112, 0.3); }
.btn-green:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-d); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d), 0 8px 20px rgba(123, 92, 255, 0.3); }
.btn-accent:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent-d); }
.btn-orange { background: var(--orange); color: #fff; box-shadow: 0 4px 0 var(--orange-d), 0 8px 20px rgba(255, 159, 28, 0.3); }
.btn-orange:active:not(:disabled) { box-shadow: 0 1px 0 var(--orange-d); }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-d); }
.btn.ghost { background: rgba(255, 255, 255, 0.5); box-shadow: none; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 24px;
  background: #f1eff8;
  color: var(--muted);
  font-size: 16px;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.pill:active { transform: scale(0.96); }
.pill.on { background: var(--accent); color: #fff; }

.seg {
  display: inline-flex;
  background: #f1eff8;
  border-radius: 18px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  min-width: 48px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.seg button .ic { width: 20px; height: 20px; }
.seg button.on { background: #fff; color: var(--accent); box-shadow: 0 2px 0 var(--press), 0 3px 10px rgba(42, 36, 64, 0.1); }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; padding: 0 6px; }

.switch {
  width: 64px;
  height: 38px;
  border-radius: 19px;
  background: #dcd8ea;
  position: relative;
  flex: none;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(42, 36, 64, 0.25);
  transition: transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(26px); }

/* ---------------------------------------------------------------- sliders */
.hslider, .vslider { position: relative; touch-action: none; cursor: pointer; }
.hslider { height: 46px; }
.hslider .sl-track {
  position: absolute;
  inset: 7px 0;
  border-radius: 16px;
  background: #ece9f5;
  box-shadow: inset 0 0 0 1px rgba(42, 36, 64, 0.08);
}
.sl-thumb {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.22);
  display: grid;
  place-items: center;
  transition: transform 0.12s;
  pointer-events: none;
}
.hslider .sl-thumb { top: 0; left: calc(var(--f, 0) * (100% - 46px)); }
.sl-thumb span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}
.hslider.active .sl-thumb, .vslider.active .sl-thumb { transform: scale(1.12); }
.set-slider .sl-track { background: linear-gradient(90deg, #ece9f5, #cfc4ff); }

/* ---------------------------------------------------------------- rail */
.rail {
  position: fixed;
  left: calc(14px + var(--sl));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.size-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s, transform 0.25s;
}
.rail.nosize .size-wrap { opacity: 0; transform: scale(0.85); pointer-events: none; height: 0; margin-bottom: -12px; overflow: hidden; }
.size-slider {
  width: 58px;
  height: min(240px, 32vh);
  border-radius: 29px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}
.size-slider .sl-track {
  position: absolute;
  left: 50%;
  top: 14px;
  bottom: 14px;
  width: 26px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #d8cffd, #f1eff8);
  clip-path: polygon(0 0, 100% 0, 62% 100%, 38% 100%);
  border-radius: 6px;
}
.vslider .sl-thumb { left: 6px; top: calc((1 - var(--f, 0)) * (100% - 46px)); width: 46px; height: 46px; }
.size-slider .sl-thumb span { width: calc(10px + var(--f, 0) * 22px); height: calc(10px + var(--f, 0) * 22px); background: var(--ink); }
.size-slider .sl-thumb span.eraser-dot { background: #fff; box-shadow: inset 0 0 0 2.5px var(--ink); }
.size-label {
  min-width: 44px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}
.rail .btn.icon-btn { width: 58px; min-height: 58px; border-radius: 20px; }

/* ---------------------------------------------------------------- dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--sb));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 28px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.tool-btn {
  width: 68px;
  height: 66px;
  border-radius: 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.15s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.15s;
}
.tool-btn .ic { width: 30px; height: 30px; }
.tool-btn:active { transform: scale(0.94); }
.tool-btn.on { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d); transform: translateY(-3px); }

/* ---------------------------------------------------------------- tool options */
.toolopts {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--sb));
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toolopts.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.opts {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 26px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.opts.show { display: flex; }
.opt-label { padding-left: 12px; color: var(--muted); font-size: 15px; }
.opts .xf-apply { background: var(--green); }
@media (max-width: 480px) { .opts[data-for='transform'] .pill span { display: none; } .opts[data-for='transform'] .pill { padding: 0 14px; } }

/* ---------------------------------------------------------------- pen & stamp options */
.seg button .ic + span { margin-left: 6px; }
.opts.classic .ink-only { display: none; }
.pill.icon-pill { padding: 0 13px; }
.pill.icon-pill .ic { width: 22px; height: 22px; }
.stamp-pick { padding: 0 16px 0 10px; color: var(--ink); }
.stamp-pick .stamp-ic { display: grid; place-items: center; width: 28px; height: 28px; color: var(--accent); }
.stamp-pick .stamp-ic .ic { width: 25px; height: 25px; }
.stamp-pick.on .stamp-ic { color: #fff; }

.pop-card {
  position: fixed;
  left: 50%;
  bottom: calc(176px + var(--sb));
  z-index: 12;
  transform: translate(-50%, 10px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 26px;
  box-shadow: var(--shadow);
  transition: opacity 0.16s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.pop-card.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pen-tune { width: min(360px, calc(100vw - 24px)); padding: 12px 16px 14px; }
.tune-preview { display: block; width: 100%; height: 86px; border-radius: 16px; background: #faf9fd; box-shadow: inset 0 0 0 2px #f1eff8; margin-bottom: 6px; }
.tune-row { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.tune-row > span { width: 86px; flex: none; color: #4d466a; }
.tune-row .set-slider { flex: 1; }
.pen-tune:not(.is-chisel) .chisel-only { display: none; }
.tune-note { margin: 6px 2px 0; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.35; }
.stamp-grid { display: grid; grid-template-columns: repeat(6, 52px); gap: 6px; padding: 10px; }
.stamp-grid button { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: var(--ink); background: #f6f4fb; transition: transform 0.1s, background 0.15s, color 0.15s; }
.stamp-grid button .ic { width: 30px; height: 30px; }
.stamp-grid button.on { background: var(--accent); color: #fff; }
.stamp-grid button:active { transform: scale(0.92); }
body.ws-anim .pop-card { bottom: calc(256px + var(--sb)); }

/* hidden tools (four-finger tap / Tab) */
.ui-back { position: fixed; top: calc(14px + var(--st)); right: calc(14px + var(--sr)); z-index: 11; display: none; opacity: 0.8; }
body.ui-hidden.drawing .ui-back { display: inline-flex; }
body.ui-hidden .rail, body.ui-hidden .dock, body.ui-hidden .toolopts, body.ui-hidden .topbar, body.ui-hidden .palette,
body.ui-hidden .anim-bar, body.ui-hidden .pop-card { opacity: 0 !important; pointer-events: none !important; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed;
  top: calc(14px + var(--st));
  right: calc(14px + var(--sr));
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 10;
}
.done-btn { padding: 0 20px 0 16px; }
.chip {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 14px;
  color: var(--muted);
}

.game-chip {
  position: fixed;
  top: calc(14px + var(--st));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 340px));
  padding: 8px 8px 8px 18px;
  border-radius: 26px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 9;
}
.game-chip.pop { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.gc-label { color: var(--muted); font-size: 14px; flex: 0 1 auto; }
.gc-prompt { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 3em; }
.gc-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.gc-time {
  flex: none;
  min-width: 64px;
  height: 40px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--chip, var(--orange));
  color: #fff;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.game-chip.urgent .gc-time { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

/* ---------------------------------------------------------------- palette */
.palette {
  position: fixed;
  left: calc(14px + var(--sl));
  top: calc(14px + var(--st));
  z-index: 20;
  --wheel: 292px;
  transition: opacity 0.18s, transform 0.2s;
}
.palette.hidden { opacity: 0; transform: translate(-8px, -8px) scale(0.9); pointer-events: none; }
.pal-handle {
  position: relative;
  z-index: 2;
  width: 76px;
  height: 76px;
  display: block;
  filter: drop-shadow(0 4px 0 var(--press)) drop-shadow(0 8px 14px rgba(42, 36, 64, 0.2));
  transition: transform 0.15s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.pal-handle:active { transform: scale(0.93); }
@media (hover: hover) and (pointer: fine) { .pal-handle:hover { transform: rotate(-8deg) scale(1.05); } }
.pal-handle svg { width: 100%; height: 100%; overflow: visible; }
.pal-wood { fill: #fff; }
.pal-cur-ring { fill: #fff; stroke: rgba(42, 36, 64, 0.12); stroke-width: 1; }
.palette.open .pal-handle { filter: none; }
.palette.open .pal-wood { fill: #f4f2fa; }

.pal-panel {
  position: absolute;
  left: -8px;
  top: -8px;
  padding: 90px 22px 22px;
  background: #fff;
  border-radius: 34px;
  box-shadow: 0 24px 60px rgba(42, 36, 64, 0.22), 0 2px 8px rgba(42, 36, 64, 0.08);
  transform-origin: 34px 34px;
  transform: scale(0.25);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.25, 1.35, 0.45, 1), opacity 0.16s;
}
.palette.open .pal-panel { transform: none; opacity: 1; pointer-events: auto; }
.pal-main { display: flex; flex-direction: column; gap: 16px; }

/* the turnstile */
.wheel { position: relative; width: var(--wheel); height: var(--wheel); --R: calc(var(--wheel) * 0.36); --s: 64px; touch-action: none; }
.wheel-rotor { position: absolute; inset: 0; transform: rotate(var(--rot, 0deg)); }
.wheel-rotor.spin { transition: transform 0.55s cubic-bezier(0.3, 1.35, 0.45, 1); }
.wheel-ring {
  position: absolute;
  inset: calc(50% - var(--R) - 24px);
  border-radius: 50%;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 48px), #000 calc(100% - 47px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 48px), #000 calc(100% - 47px));
  opacity: 0.32;
  transition: opacity 0.2s;
}
.wheel-ticks {
  position: absolute;
  inset: calc(50% - var(--R) - 33px);
  border-radius: 50%;
  background: repeating-conic-gradient(from -1.5deg, rgba(42, 36, 64, 0.22) 0 3deg, transparent 3deg 15deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}
.palette.sliding .wheel-ring { opacity: 1; }
.splotch {
  position: absolute;
  width: var(--s);
  height: var(--s);
  left: calc(50% + var(--x) * var(--R) - var(--s) / 2);
  top: calc(50% + var(--y) * var(--R) - var(--s) / 2);
  filter: drop-shadow(0 3px 0 rgba(42, 36, 64, 0.16));
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s;
}
.splotch svg { width: 100%; height: 100%; overflow: visible; transform: rotate(calc(-1 * var(--rot, 0deg))); }
.splotch.pressed { transform: scale(1.15); }
.splotch.on { transform: scale(1.16); }
@media (hover: hover) and (pointer: fine) { .splotch:hover { transform: scale(1.1); } }
.palette.sliding .splotch { transform: scale(0.72); opacity: 0.6; }
.wheel-pointer {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--R) - 46px);
  width: 30px;
  height: 22px;
  margin-left: -15px;
  background: var(--cur);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 0 0 #fff);
  pointer-events: none;
  z-index: 3;
}
.wheel-pointer::after { content: ''; position: absolute; inset: 0; }
.wheel::before {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(50% - var(--R) - 50px);
  width: 40px;
  height: 30px;
  margin-left: -20px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
}
.wheel-arrows { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); fill: none; stroke: rgba(42, 36, 64, 0.22); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; transition: stroke 0.2s, opacity 0.2s; }
.wheel-arrows .ah { fill: rgba(42, 36, 64, 0.22); stroke: none; transition: fill 0.2s; }
.palette.sliding .wheel-arrows { stroke: var(--accent); }
.palette.sliding .wheel-arrows .ah { fill: var(--accent); }
@media (hover: hover) and (pointer: fine) { .wheel:hover .wheel-arrows { stroke: rgba(123, 92, 255, 0.55); } .wheel:hover .wheel-arrows .ah { fill: rgba(123, 92, 255, 0.55); } }
.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 6px #fff, 0 0 0 8px var(--line), 0 6px 16px rgba(42, 36, 64, 0.18);
  z-index: 2;
}
.wheel-center span { position: absolute; inset: 0; }
.checker { background: var(--checker); }

.pal-side { display: flex; flex-direction: column; gap: 6px; width: var(--wheel); }
.pal-row { display: flex; align-items: center; gap: 8px; }
.pal-row > div { flex: 1; }
.pal-ic { width: 30px; display: grid; place-items: center; color: var(--muted); flex: none; }
.pal-alpha .sl-track { background-color: #fff; }
.pal-bottom { display: flex; gap: 10px; align-items: stretch; padding-top: 8px; }
.pal-swatches { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.12), 0 3px 0 var(--press);
  transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.12s;
}
.swatch.static { border-radius: 50%; }
.swatch.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--accent); }
@media (hover: hover) and (pointer: fine) { .swatch:hover { transform: translateY(-2px) scale(1.06); } }
.swatch:active { transform: scale(0.9); }
.pal-dropper {
  width: 56px;
  border-radius: 18px;
  background: #f1eff8;
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--press);
  transition: transform 0.12s, background 0.15s;
}
.pal-dropper .ic { width: 26px; height: 26px; }
@media (hover: hover) and (pointer: fine) { .pal-dropper:hover { background: #e6e1f7; transform: rotate(-10deg); } }
.pal-dropper:active { transform: scale(0.92); }

@media (max-height: 640px) and (min-width: 560px) {
  .palette { --wheel: 240px; }
  .pal-panel { padding: 18px 18px 18px 94px; }
  .pal-main { flex-direction: row; align-items: center; }
  .pal-side { width: 240px; }
}
@media (max-width: 480px) { .palette { --wheel: 258px; } .pal-panel { padding: 88px 16px 16px; } }

/* ---------------------------------------------------------------- popups */
.toast {
  position: fixed;
  left: 50%;
  top: calc(80px + var(--st));
  transform: translate(-50%, -12px);
  padding: 12px 20px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  max-width: min(560px, calc(100vw - 40px));
  width: max-content;
  text-align: center;
  text-wrap: balance;
  line-height: 1.35;
  transition: opacity 0.18s, transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.flash {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  border-radius: 20px;
  background: rgba(42, 36, 64, 0.82);
  color: #fff;
  font-size: 20px;
  pointer-events: none;
  opacity: 0;
  z-index: 85;
}
.flash.show { animation: flash 0.75s ease-out; }
@keyframes flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.menu-backdrop { position: fixed; inset: 0; z-index: 50; }
.popmenu {
  position: fixed;
  z-index: 51;
  min-width: 210px;
  padding: 8px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(42, 36, 64, 0.28), 0 2px 6px rgba(42, 36, 64, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* a long menu on a short screen scrolls instead of running off the edge */
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  transform: scale(0.6);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.12s;
}
.popmenu::-webkit-scrollbar { display: none; }
.popmenu.show { transform: none; opacity: 1; }
.popmenu .pm-item { flex: none; }
.pm-item {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 18px 0 14px;
  border-radius: 16px;
  font-size: 18px;
  text-align: left;
}
.pm-item:hover:not(:disabled) { background: #f4f2fa; }
.pm-item:active:not(:disabled) { background: #ebe7f8; transform: scale(0.98); }
.pm-item:disabled { opacity: 0.32; }
.pm-item.danger { color: var(--red-d); }
.pm-item.cancel { color: var(--muted); border-top: 2px solid #f1eff8; border-radius: 0 0 16px 16px; }
@media (max-height: 520px) { .pm-item { height: 46px; font-size: 16px; } }

/* ---------------------------------------------------------------- sheets */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(42, 36, 64, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.sheet.show { opacity: 1; pointer-events: auto; }
.sheet-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  touch-action: pan-y;
  padding: 20px;
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.sheet.show .sheet-card { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 24px; font-weight: 900; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.btn.tile { flex-direction: column; gap: 6px; min-height: 92px; font-size: 15px; padding: 10px; }
.btn.tile .ic { width: 30px; height: 30px; color: var(--accent); }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-top: 2px solid #f4f2fa;
  font-size: 16px;
}
.set-row > span { flex: 1; }
.set-row .set-slider { flex: 1.2; }
.set-head { margin: 16px 2px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 900; }
.set-row .seg button { min-width: 0; padding: 0 12px; }
.set-select { font: inherit; font-size: 15px; color: var(--ink); background: #f1eff8; border: 0; border-radius: 14px; height: 42px; padding: 0 12px; max-width: 55%; }
.set-note { margin: 2px 2px 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.4; }
body.native-shell .web-only, body:not(.native-shell) .shell-only { display: none; }
.confirm-card { width: min(380px, 100%); text-align: center; }
.confirm-card h3 { margin: 4px 0 8px; font-size: 24px; font-weight: 900; }
.confirm-card p { margin: 0 0 20px; color: var(--muted); font-weight: 700; line-height: 1.4; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tips { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-weight: 700; line-height: 1.4; color: #4d466a; }
.tips b { color: var(--ink); font-weight: 900; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(12px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl));
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 159, 28, 0.28), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(43, 192, 107, 0.24), transparent 38%),
    radial-gradient(circle at 82% 88%, rgba(47, 125, 255, 0.24), transparent 42%),
    radial-gradient(circle at 12% 88%, rgba(255, 59, 79, 0.2), transparent 40%),
    #ece8f6;
  opacity: 0;
  pointer-events: none;
  transform: translateX(48px);
  transition: opacity 0.28s ease, transform 0.42s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.screen[data-dir='back'] { transform: translateX(-48px); }
.screen[data-dir='fade'] { transform: scale(0.98); }
.screen.show { opacity: 1; pointer-events: auto; transform: none; }
.screen.leaving { opacity: 0; pointer-events: none; transform: translateX(-48px); }
.screen.leaving[data-dir='back'] { transform: translateX(48px); }
.screen.leaving[data-dir='fade'] { transform: scale(1.02); }
#screens .screen.leaving { z-index: 69; }
.home-card, .finish-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  transform: translateY(16px);
  transition: transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.screen.show .home-card, .screen.show .finish-card { transform: none; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo-mark { width: 74px; height: 74px; filter: drop-shadow(0 4px 0 var(--press)) drop-shadow(0 8px 16px rgba(42, 36, 64, 0.18)); }
.logo h1 { margin: 0; font-size: clamp(40px, 11vw, 56px); font-weight: 900; letter-spacing: -1.5px; }
.logo h1 span { color: var(--accent); }
.tagline { margin: -8px 0 6px; text-align: center; color: var(--muted); font-size: 18px; }
.home-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.6);
}
.hint { margin: -2px 0 2px; text-align: center; color: var(--muted); font-size: 14px; }

.finish-card h2 { margin: 0; text-align: center; font-size: 36px; font-weight: 900; }
.finish-prompt { margin: -8px 0 0; text-align: center; color: var(--muted); font-size: 18px; min-height: 0; }
.finish-prompt:empty { display: none; }
.preview {
  border-radius: 26px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(42, 36, 64, 0.06);
  height: min(42vh, 360px);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}
.preview img { max-width: 100%; max-height: calc(min(42vh, 360px) - 32px); object-fit: contain; display: block; }
.preview p { color: var(--muted); font-size: 18px; }
.export-opts { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.export-opts .pill { background: #fff; }
.export-opts .pill.on { background: var(--accent); }
.export-opts .seg { background: #fff; }
.export-opts .seg button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.dims { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.finish-actions { display: flex; gap: 12px; }
.finish-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 480px) {
  .dock { gap: 2px; padding: 6px; border-radius: 24px; }
  .tool-btn { width: 49px; height: 58px; border-radius: 17px; font-size: 9.5px; }
  .tool-btn .ic { width: 26px; height: 26px; }
  .toolopts { bottom: calc(92px + var(--sb)); }
  .opts { gap: 6px; }
  .opts .seg button { min-width: 44px; padding: 0 10px; }
  .pop-card { bottom: calc(160px + var(--sb)); }
  body.ws-anim .pop-card { bottom: calc(300px + var(--sb)); }
  .stamp-grid { grid-template-columns: repeat(6, 46px); gap: 5px; padding: 8px; }
  .stamp-grid button { width: 46px; height: 46px; }
  .rail { left: calc(10px + var(--sl)); }
  .size-slider { width: 52px; height: min(200px, 28vh); }
  .vslider .sl-thumb { left: 3px; }
  .rail .btn.icon-btn { width: 52px; min-height: 52px; }
  .done-btn span { display: none; }
  .done-btn { padding: 0; width: 56px; }
  .game-chip { top: calc(84px + var(--st)); max-width: calc(100vw - 28px); }
}
@media (max-width: 380px) {
  .tool-btn { width: 46px; }
  .tool-btn span { display: none; }
}
@media (max-width: 360px) {
  .opts .seg button span, #trailBtn span { display: none; }
}
@media (max-height: 520px) {
  .size-slider { height: min(150px, 30vh); }
  /* keep the rail clear of the palette in the top-left corner */
  .rail { gap: 8px; top: max(50%, calc(228px + var(--st))); }
  .rail .btn.icon-btn { min-height: 48px; width: 52px; }
}
@media (max-height: 520px) and (min-width: 560px) {
  /* phones on their side: pen settings spread out sideways so they fit above the tool bar */
  body .pop-card.pen-tune {
    width: min(660px, calc(100vw - 40px));
    padding: 8px 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 2px;
  }
  .pen-tune .tune-preview, .pen-tune .tune-note { display: none; }
  .pen-tune .tune-row { gap: 8px; }
  .pen-tune .tune-row > span { width: 72px; font-size: 13.5px; }
}

/* ================================================================ app states */
body:not(.drawing) #stage, body:not(.drawing) .rail, body:not(.drawing) .dock, body:not(.drawing) .toolopts,
body:not(.drawing) .topbar, body:not(.drawing) .palette, body:not(.drawing) .game-chip { visibility: hidden; }
body.kind-solo .party-only, body.kind-party .solo-only, body.kind-skin .solo-only, body.kind-skin .party-only { display: none !important; }
body:not(.kind-skin) .skin-only { display: none !important; }
.rail.no-undo #undoBtn, .rail.no-undo #redoBtn { display: none; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 300; pointer-events: none; }

/* ================================================================ juicy buttons */
.fx { position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent; }
.fx::after {
  /* a soft, blurred sheen that glides across, like light over glossy plastic */
  content: '';
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: 0;
  width: 70%;
  background: linear-gradient(100deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.05) 22%,
    rgba(255, 255, 255, 0.22) 38%,
    rgba(255, 255, 255, 0.42) 50%,
    rgba(255, 255, 255, 0.22) 62%,
    rgba(255, 255, 255, 0.05) 78%,
    rgba(255, 255, 255, 0) 100%);
  filter: blur(10px);
  opacity: 0;
  transform: translateX(-130%) skewX(-12deg);
  pointer-events: none;
  z-index: 3;
}
.fx:not(.badge)::before {
  /* faint top-edge gloss that brightens on hover */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 2;
}
.mega, .pick-card, .gal-card, .badge, .round-btn, .fx.btn {
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.2s, filter 0.2s;
}
@media (hover: hover) and (pointer: fine) {
  .fx:hover:not(:disabled):not(.locked) { transform: translateY(-4px) scale(1.015); filter: brightness(1.06) saturate(1.06); }
  .fx:hover:not(:disabled):not(.locked)::after { animation: glimmer 1.25s cubic-bezier(0.35, 0.1, 0.25, 1); }
  .fx:not(.badge):hover:not(:disabled):not(.locked)::before { opacity: 1; }
  .mega:hover .mega-art .art, .pick-card:hover .pick-art .art { animation: wiggle 0.6s ease-in-out; }
  .mega:hover .mega-go { transform: translateX(4px); background: rgba(255, 255, 255, 0.4); }
  .pick-card:hover:not(:disabled), .gal-card:hover { box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.35), 0 6px 0 var(--press), 0 18px 34px rgba(123, 92, 255, 0.25); }
  .round-btn:hover { box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.25), 0 4px 0 var(--press), 0 10px 22px rgba(42, 36, 64, 0.14); }
}
.fx:active:not(:disabled):not(.locked) {
  transform: translateY(5px) scale(0.975) !important;
  box-shadow: 0 1px 0 var(--shade, var(--press)), 0 4px 10px rgba(42, 36, 64, 0.12) !important;
  transition-duration: 0.06s;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0, rgba(255, 255, 255, 0) 62%);
  transform: scale(0);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
@keyframes glimmer {
  0% { opacity: 0; transform: translateX(-130%) skewX(-12deg); }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(190%) skewX(-12deg); }
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.07); } 55% { transform: rotate(6deg) scale(1.07); } 80% { transform: rotate(-2deg); } }
.shake { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-9px) rotate(-2deg); }
  40%, 60% { transform: translateX(9px) rotate(2deg); }
}
@keyframes breathe { 0%, 100% { box-shadow: 0 6px 0 var(--shade), 0 10px 26px var(--glow, rgba(34, 192, 112, 0.35)); } 50% { box-shadow: 0 6px 0 var(--shade), 0 10px 40px 6px var(--glow, rgba(34, 192, 112, 0.55)); } }
@media (prefers-reduced-motion: reduce) {
  .fx::after, .doodle, .logo-big .logo-mark { animation: none !important; }
  .screen { transition: opacity 0.2s; transform: none !important; }
}

/* ================================================================ menu layout */
.menu-top {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  position: relative;
  z-index: 2;
}
.menu-title { margin: 0; font-size: 22px; font-weight: 900; text-align: center; flex: 1; }
.round-btn, .round-spacer { width: 52px; height: 52px; flex: none; }
.round-btn {
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  --shade: var(--press);
  box-shadow: 0 4px 0 var(--press), 0 8px 18px rgba(42, 36, 64, 0.12);
}
.round-btn .ic { width: 24px; height: 24px; }
.menu-body {
  flex: 1;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 20px;
  position: relative;
  z-index: 1;
}
.wide-body { width: min(920px, 100%); }
.menu-lead { margin: 0 0 4px; text-align: center; font-size: 18px; color: var(--muted); }
.big-title { margin: 0; text-align: center; font-family: 'Luckiest Guy', var(--font); font-weight: 400; letter-spacing: 1px; font-size: clamp(34px, 8vw, 48px); color: var(--ink); }

/* ---- title */
.title-body { align-items: stretch; }
.logo-big { flex-direction: column; gap: 4px; }
.logo-big .logo-mark { width: 96px; height: 96px; animation: bob 3.2s ease-in-out infinite; }
.logo-big h1 { font-size: clamp(50px, 14vw, 80px); line-height: 0.95; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.title-body .tagline { margin: 2px 0 14px; font-size: 20px; }
.doodles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.doodle { position: absolute; width: 90px; height: 90px; opacity: 0.55; animation: drift 9s ease-in-out infinite; }
.doodle.d0 { left: 4%; top: 14%; }
.doodle.d1 { right: 6%; top: 9%; animation-delay: -2s; width: 70px; }
.doodle.d2 { left: 8%; bottom: 12%; animation-delay: -4s; }
.doodle.d3 { right: 5%; bottom: 18%; animation-delay: -6s; width: 110px; }
.doodle.d4 { left: 44%; top: 4%; animation-delay: -3s; width: 70px; }
.doodle.d5 { right: 30%; bottom: 4%; animation-delay: -5s; width: 60px; }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(0); } 33% { transform: translate(12px, -14px) rotate(8deg); } 66% { transform: translate(-10px, 8px) rotate(-6deg); } }
@media (max-width: 600px) { .doodle { width: 60px; height: 60px; opacity: 0.4; } .doodle.d4, .doodle.d5 { display: none; } }

/* ---- mega buttons */
.mega-stack { display: flex; flex-direction: column; gap: 18px; }
.mega {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 116px;
  padding: 14px 18px 14px 14px;
  border-radius: 30px;
  color: #fff;
  text-align: left;
  --shade: #4b2bb8;
  background: linear-gradient(135deg, #9a63ff, #6a3df0);
  box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(106, 61, 240, 0.3);
}
.mega-art { width: 92px; height: 92px; border-radius: 24px; background: rgba(255, 255, 255, 0.92); display: grid; place-items: center; box-shadow: inset 0 -4px 0 rgba(42, 36, 64, 0.08); }
.mega-art .art { width: 80px; height: 80px; }
.mega-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mega-text b { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 30px; letter-spacing: 0.8px; line-height: 1.05; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); }
.mega-text small { font-size: 15px; opacity: 0.92; font-weight: 800; text-wrap: balance; }
.mega-go { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.24); display: grid; place-items: center; transition: transform 0.2s, background 0.2s; }
.mega-party { --shade: #c4245e; background: linear-gradient(135deg, #ff8a3d, #ff3b8d); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 59, 141, 0.3); }
.mega-draw { --shade: #14874c; background: linear-gradient(135deg, #3bd889, #18a85f); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(34, 192, 112, 0.3); }
.mega-gallery { --shade: #1d55c4; background: linear-gradient(135deg, #4f9bff, #2f6cf0); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(47, 108, 240, 0.3); }
.mega-irl { --shade: #c2580a; background: linear-gradient(135deg, #ffb13b, #ff7a1f); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 122, 31, 0.3); }
.mega-online { --shade: #0b7f86; background: linear-gradient(135deg, #2fd1c5, #1497b8); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(20, 151, 184, 0.3); }
@media (max-width: 480px) {
  .mega { min-height: 100px; gap: 12px; border-radius: 26px; }
  .mega-art { width: 76px; height: 76px; border-radius: 20px; }
  .mega-art .art { width: 66px; height: 66px; }
  .mega-text b { font-size: 25px; }
  .mega-text small { font-size: 13.5px; }
  .mega-go { width: 38px; height: 38px; }
}

/* ---- pick cards */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.pick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px 16px;
  border-radius: 26px;
  background: #fff;
  --shade: var(--press);
  box-shadow: 0 6px 0 var(--press), 0 14px 26px rgba(42, 36, 64, 0.1);
  text-align: center;
}
.pick-card b { font-size: 21px; font-weight: 900; margin-top: 6px; }
.pick-card small { color: var(--muted); font-size: 14px; text-wrap: balance; }
.pick-art .art { width: 104px; height: 104px; }
.paper-swatch { width: 100%; aspect-ratio: 16 / 11; border-radius: 16px; overflow: hidden; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.08), 0 3px 8px rgba(42, 36, 64, 0.12); }
.paper-swatch canvas { width: 100%; height: 100%; display: block; }
@media (max-width: 480px) {
  .pick-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .pick-card { padding: 14px 10px 12px; border-radius: 22px; }
  .pick-art .art { width: 78px; height: 78px; }
  .pick-card b { font-size: 18px; }
  .pick-card small { font-size: 12.5px; }
}

/* ---- finish / export */
.finish-screen .menu-body { gap: 14px; }
.finish-screen .preview { background-color: #fff; }
/* Phones: everything on one screen, no scrolling to reach the buttons. */
@media (max-width: 480px) {
  .finish-screen .menu-body { gap: 11px; padding-bottom: 8px; }
  .finish-screen .preview { height: min(34vh, 300px); }
  .finish-screen .preview img { max-height: calc(min(34vh, 300px) - 32px); }
  .export-opts { gap: 8px; }
  .export-opts .pill { height: 42px; padding: 0 13px 0 10px; font-size: 14.5px; gap: 6px; }
  .export-opts .pill .ic { width: 22px; height: 22px; }
  .export-opts .seg button { height: 34px; min-width: 40px; padding: 0 10px; }
  .finish-screen .btn.big { min-height: 56px; font-size: 18px; }
  .finish-screen .row2 { gap: 10px; }
  .finish-screen .row2 .btn { padding: 0 10px; gap: 7px; font-size: 15.5px; min-height: 50px; white-space: nowrap; }
  .finish-screen .row2 .btn .ic { width: 22px; height: 22px; }
}
/* Phones on their side: the picture on the left, the choices beside it. */
@media (max-height: 520px) and (min-width: 560px) {
  .finish-screen .menu-body {
    width: min(940px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-auto-flow: row dense;
    column-gap: 22px;
    row-gap: 0;
    align-content: center;
    padding: 4px 0 8px;
  }
  .finish-screen .menu-body > * { grid-column: 2; margin-bottom: 8px; }
  .finish-screen .menu-body > p { font-size: 12.5px; line-height: 1.3; }
  .finish-screen .seg button { white-space: nowrap; padding: 0 10px; font-size: 14px; }
  .finish-screen .menu-body > .preview {
    grid-column: 1;
    grid-row: 1 / span 12;
    align-self: center;
    margin: 0;
    height: calc(100vh - 44px - var(--st) - var(--sb));
  }
  .finish-screen .preview img { max-height: calc(100vh - 76px - var(--st) - var(--sb)); }
  .finish-screen .big-title { font-size: 28px; }
  .finish-screen .btn.big { min-height: 48px; font-size: 17px; border-radius: 18px; }
  .finish-screen .btn { min-height: 46px; }
  .finish-screen .row2 .btn { white-space: nowrap; padding: 0 12px; }
  .export-opts { gap: 8px; }
  .export-opts .pill { height: 40px; padding: 0 11px 0 9px; font-size: 13.5px; gap: 6px; }
  .export-opts .pill .ic { width: 20px; height: 20px; }
  .export-opts .seg button { height: 32px; }
}
@media (max-height: 520px) and (min-width: 560px) and (max-width: 720px) {
  .finish-screen .menu-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
  .finish-screen .menu-body > * { margin-bottom: 8px; }
  .finish-screen .big-title { font-size: 26px; }
  .finish-screen .row2 .btn { font-size: 15px; gap: 6px; padding: 0 8px; }
  .finish-screen .row2 .btn .ic { width: 22px; height: 22px; }
}
.btn.saved { background: var(--green-d); }
.btn-red-soft { background: #ffe9ec; color: var(--red-d); box-shadow: 0 4px 0 #f6c9cf; }
.btn-danger-soft { color: var(--red-d); }
.choice-col { display: flex; flex-direction: column; gap: 10px; }

/* ---- gallery */
.gallery-body { width: min(1000px, 100%); justify-content: flex-start; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.gal-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 12px;
  border-radius: 24px;
  background: #fff;
  --shade: var(--press);
  box-shadow: 0 6px 0 var(--press), 0 14px 26px rgba(42, 36, 64, 0.1);
  text-align: left;
  animation: popin 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  animation-delay: calc(var(--i) * 40ms);
}
.gal-thumb { aspect-ratio: 1; border-radius: 16px; background: #f1eff8; display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; }
.gal-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.gal-card b { font-size: 15px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-card small { color: var(--muted); font-size: 12.5px; padding: 0 4px; }
@keyframes popin { from { opacity: 0; transform: scale(0.85) translateY(10px); } }
.gal-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--muted); font-size: 18px; margin: auto; width: min(380px, 100%); }
.gal-empty .art { width: 150px; height: 150px; }
@media (max-width: 480px) { .gal-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
.gal-thumb img { opacity: 0; transition: opacity 0.25s; }
.gal-thumb img.in { opacity: 1; }
.gal-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 2px 2px 6px; }
@media (max-width: 600px) {
  /* phones: one swipeable row that fades out at the edge */
  .gal-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; margin-right: -16px; padding-right: 24px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
}
.gal-filters::-webkit-scrollbar { display: none; }
.gal-filter {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px;
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.85);
  color: #4d466a;
  font-size: 15px;
  box-shadow: 0 3px 0 var(--press);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.gal-filter .ic { width: 20px; height: 20px; }
.gal-filter small { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ece9f5; color: var(--muted); font-size: 12.5px; display: grid; place-items: center; }
.gal-filter.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
.gal-filter.on small { background: rgba(255, 255, 255, 0.25); color: #fff; }
.gal-filter:active { transform: translateY(2px); }
@media (hover: hover) and (pointer: fine) { .gal-filter:not(.on):hover { background: #fff; color: var(--ink); } }
.viewer-card { width: min(760px, 100%); }
.viewer-name { flex: 1; min-width: 0; font: inherit; font-size: 22px; font-weight: 900; color: var(--ink); border: 0; background: #f4f2fa; border-radius: 14px; padding: 8px 12px; margin-right: 10px; }
.viewer-name:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); background: #fff; }
.viewer-img { position: relative; border-radius: 20px; overflow: hidden; display: grid; place-items: center; max-height: 62vh; touch-action: pan-y; }
.viewer-img img { max-width: 100%; max-height: 62vh; display: block; }
.viewer-step {
  position: absolute;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--press), 0 6px 16px rgba(42, 36, 64, 0.16);
  transition: opacity 0.15s, transform 0.1s;
}
.viewer-step.prev { left: 10px; }
.viewer-step.next { right: 10px; }
.viewer-step:disabled { opacity: 0; pointer-events: none; }
.viewer-step:active { transform: scale(0.92); }
.viewer-meta { margin: 10px 2px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.viewer-actions { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.viewer-actions .btn { padding: 0 14px; gap: 8px; }
@media (max-width: 600px) {
  .viewer-actions { grid-template-columns: repeat(3, 1fr); }
  .viewer-actions .btn-green { grid-column: 1 / -1; }
  .viewer-actions .btn:not(.btn-green) { flex-direction: column; gap: 3px; min-height: 64px; font-size: 14px; padding: 6px; }
  .viewer-actions .btn:not(.btn-green) .ic { width: 22px; height: 22px; }
  .viewer-step { width: 40px; height: 40px; margin-top: -20px; }
}
/* Phones on their side: picture on the left, name and buttons beside it. */
@media (max-height: 520px) and (min-width: 560px) {
  .viewer-card { width: min(880px, 100%); display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); column-gap: 16px; align-items: start; padding: 16px; }
  .viewer-card .sheet-head { grid-column: 1 / -1; margin-bottom: 10px; }
  .viewer-card .viewer-name { font-size: 19px; padding: 6px 12px; }
  .viewer-img { grid-column: 1; grid-row: 2 / span 2; max-height: calc(100vh - 120px - var(--st) - var(--sb)); }
  .viewer-img img { max-height: calc(100vh - 120px - var(--st) - var(--sb)); }
  .viewer-meta { grid-column: 2; grid-row: 2; margin: 2px 0 0; text-align: left; }
  .viewer-actions { grid-column: 2; grid-row: 3; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
  .viewer-actions .btn { min-height: 46px; font-size: 16px; justify-content: flex-start; padding: 0 16px; }
}

/* ---- canvas menu extras */
.tile-wide { grid-column: 1 / -1; min-height: 64px !important; flex-direction: row !important; }
.paper-row { flex-wrap: wrap; }
.paper-row small { display: block; color: var(--muted); font-size: 13px; }
.paper-pick { display: grid; grid-template-columns: repeat(4, 34px); gap: 9px 10px; justify-content: end; }
.paper-dot { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.14); transition: transform 0.15s; }
.paper-dot.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--accent); transform: scale(1.06); }
.p-white { background: #fff; }
.p-sketch { background: #fbf5e6; }
.p-kraft { background: #caa679; }
.p-grid { background: #fff linear-gradient(rgba(80, 110, 255, 0.35) 1px, transparent 1px) 0 0 / 8px 8px, #fff linear-gradient(90deg, rgba(80, 110, 255, 0.35) 1px, transparent 1px) 0 0 / 8px 8px; }
.p-dots { background: #fffdf8 radial-gradient(rgba(60, 60, 90, 0.5) 1.2px, transparent 1.6px) 0 0 / 8px 8px; }
.p-lined { background: #fffef7 repeating-linear-gradient(transparent 0 7px, rgba(70, 140, 230, 0.5) 7px 8px); }
.p-chalk { background: #2e3a34; }
.p-clear { background: var(--checker); }

/* ================================================================ party: setup */
.soon {
  position: absolute; top: 10px; right: -30px; transform: rotate(35deg);
  background: var(--ink); color: #fff; font-style: normal; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 34px; z-index: 4;
}
.online-body { align-items: center; text-align: center; }
.online-art .art { width: 150px; height: 150px; animation: bob 3s ease-in-out infinite; }
.room-code { font-family: 'Luckiest Guy', var(--font); letter-spacing: 3px; color: var(--accent); }
.online-actions { display: grid; gap: 12px; width: 100%; }
.btn.locked { opacity: 0.6; filter: grayscale(0.4); }

.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 10px; }
.count-btn {
  aspect-ratio: 1; border-radius: 28px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  --shade: var(--press); box-shadow: 0 6px 0 var(--press), 0 14px 24px rgba(42, 36, 64, 0.1);
}
.count-btn b { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: clamp(38px, 10vw, 56px); line-height: 1; color: var(--ink); }
.count-btn.on { box-shadow: 0 0 0 4px var(--accent), 0 6px 0 var(--press); }
.count-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 70%; }
.count-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); }
.count-grid .count-btn:last-child { grid-column: span 1; }
@media (max-width: 480px) { .count-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } }

.names-body { justify-content: flex-start; padding-top: 6px; }
.name-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.name-list li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 22px; padding: 8px 10px 8px 8px; box-shadow: 0 4px 0 var(--press); }
.name-list input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 20px; font-weight: 900; color: var(--ink); padding: 8px 4px; outline: none; }
.name-list li:focus-within { box-shadow: 0 0 0 3px var(--pc), 0 4px 0 var(--press); }
.name-list.shuffled li { animation: popin 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.name-list.shuffled li:nth-child(2n) { animation-delay: 0.05s; }
.name-list.shuffled li:nth-child(3n) { animation-delay: 0.1s; }

.avatar {
  --sz: 44px; width: var(--sz); height: var(--sz); flex: none; border-radius: 50%; background: var(--pc, var(--accent)); color: #fff;
  display: inline-grid; place-items: center; font-weight: 900; font-size: calc(var(--sz) * 0.45);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15), 0 3px 0 rgba(42, 36, 64, 0.15);
}
.avatar.sm { --sz: 30px; }
.avatar.lg { --sz: 64px; }
.avatar.xl { --sz: 112px; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.15), 0 0 0 8px #fff, 0 14px 30px rgba(42, 36, 64, 0.2); }
.avatar.bob { animation: bob 2.6s ease-in-out infinite; }
.name-tag { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 22px; background: #fff; font-size: 17px; box-shadow: 0 3px 0 var(--press); color: var(--ink); }

.players-strip {
  align-self: center; display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px 6px 8px; border-radius: 28px;
  background: #fff; box-shadow: 0 4px 0 var(--press); color: var(--muted); --shade: var(--press);
}
.players-strip .avatar { margin-right: -10px; box-shadow: 0 0 0 3px #fff; }
.players-strip span:not(.avatar) { margin-left: 18px; color: var(--ink); }
.players-strip .ic { width: 18px; height: 18px; margin-left: 4px; }

/* ---- badges */
.games-body { width: min(1000px, 100%); justify-content: flex-start; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.badge {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 16px 10px 14px;
  border-radius: 30px; background: #fff; --shade: color-mix(in srgb, var(--gc) 70%, #000);
  box-shadow: 0 6px 0 var(--shade), 0 16px 28px color-mix(in srgb, var(--gc) 30%, transparent);
  animation: popin 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both; animation-delay: calc(var(--i) * 50ms);
}
.badge::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--gc) 22%, transparent), transparent 70%); z-index: -1; }
.badge-art { width: 112px; height: 112px; display: block; transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }
.badge-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 0 rgba(42, 36, 64, 0.15)); }
.badge b { font-family: 'Luckiest Guy', var(--font); font-weight: 400; letter-spacing: 0.6px; font-size: 22px; margin-top: 8px; color: var(--ink); }
.badge small { color: var(--muted); font-size: 13px; }
@media (hover: hover) and (pointer: fine) {
  .badge:not(.locked):hover .badge-art { animation: jiggle 0.55s ease-in-out; }
  .badge:not(.locked):hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gc) 55%, transparent), 0 6px 0 var(--shade), 0 22px 40px color-mix(in srgb, var(--gc) 45%, transparent); }
}
.badge:active:not(.locked) .badge-art { transform: scale(0.92) rotate(-4deg); }
@keyframes jiggle { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-10deg) scale(1.08); } 40% { transform: rotate(8deg) scale(1.1); } 60% { transform: rotate(-5deg) scale(1.08); } 80% { transform: rotate(3deg) scale(1.04); } }
.badge.locked { filter: grayscale(1); opacity: 0.5; box-shadow: 0 6px 0 #cfcbdc; cursor: not-allowed; }
.badge.locked small { color: var(--red-d); font-weight: 900; }
@media (max-width: 760px) { .badge-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } .badge-art { width: 92px; height: 92px; } .badge b { font-size: 19px; } }

/* ---- rules */
.rules-card { width: min(560px, 100%); border-top: 10px solid var(--gc); }
.rules-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.rules-hero .badge-art { width: 104px; height: 104px; flex: none; animation: jiggle 0.7s ease-in-out 0.15s; }
.rules-hero h3 { margin: 0; font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 32px; letter-spacing: 0.6px; }
.rules-hero p { margin: 2px 0 8px; color: #4d466a; font-weight: 700; line-height: 1.35; }
.chip-sm { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 14px; background: color-mix(in srgb, var(--gc) 16%, #fff); font-size: 14px; }
.chip-sm .ic { width: 16px; height: 16px; }
.rules-steps { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: st; }
.rules-steps li { display: flex; gap: 12px; align-items: center; font-weight: 700; line-height: 1.35; color: #3a3356; animation: popin 0.4s both; animation-delay: calc(0.15s + var(--i) * 70ms); }
.step-ic { position: relative; width: 44px; height: 44px; flex: none; border-radius: 14px; background: color-mix(in srgb, var(--gc) 18%, #fff); color: color-mix(in srgb, var(--gc) 80%, #000); display: grid; place-items: center; counter-increment: st; }
.step-ic::after { content: counter(st); position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; display: grid; place-items: center; }
.step-ic .ic { width: 24px; height: 24px; }
.rules-note { margin: 4px 0 0; padding: 10px 14px; border-radius: 16px; background: #f6f4fb; color: var(--muted); font-size: 14px; font-weight: 700; }
.rules-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.rules-actions .btn { min-width: 130px; }
.cta-breathe { --shade: var(--green-d); animation: breathe 2.2s ease-in-out infinite; }

/* ================================================================ party: in-game */
.game-panel { --panel-bg: none; }
.game-panel .menu-body { align-items: stretch; text-align: center; }
.pass, .ready, .cover, .choose, .secret, .scores, .game-over, .text-round { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.pass-kicker { margin: 0; color: var(--muted); font-size: 18px; text-transform: uppercase; letter-spacing: 2px; }
.pass-name { margin: 6px 0 0; font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: clamp(42px, 12vw, 72px); letter-spacing: 1px; color: var(--pc); text-shadow: 0 4px 0 rgba(42, 36, 64, 0.15); line-height: 1; }
.pass-sub { margin: 0; color: #4d466a; font-size: 18px; font-weight: 700; line-height: 1.4; max-width: 440px; }
.pass-note { margin: 0; color: var(--muted); font-size: 14px; }
.pass .btn { margin-top: 12px; }

.ready-panel { background: linear-gradient(160deg, #8c4dff, #ff3b8d); color: #fff; }
.ready-panel .round-btn { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.ready-label { margin: 0; font-size: 20px; text-transform: uppercase; letter-spacing: 3px; opacity: 0.9; }
.ready-text { margin: 0; font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: clamp(40px, 11vw, 80px); line-height: 1.05; letter-spacing: 1px; text-shadow: 0 5px 0 rgba(0, 0, 0, 0.2); animation: stamp 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); overflow-wrap: anywhere; }
.ready-panel .pass-sub { color: #fff; }
.ready-bar { width: min(360px, 80%); height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.3); overflow: hidden; margin-top: 10px; }
.ready-bar span { display: block; height: 100%; background: #fff; transform-origin: left; animation: drain var(--ms) linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes stamp { from { transform: scale(2.2) rotate(-6deg); opacity: 0; } }

.cover-panel { background: repeating-linear-gradient(-45deg, #2a2440 0 26px, #342c50 26px 52px); color: #fff; transition-duration: 0.12s !important; }
.cover-title { margin: 0; font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: clamp(54px, 15vw, 110px); letter-spacing: 2px; color: #ffd21f; text-shadow: 0 6px 0 #c4245e; animation: stamp 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.cover-panel .pass-sub { color: #d9d3f2; }
.cover-panel .round-btn { background: rgba(255, 255, 255, 0.92); color: var(--ink); }

.text-round { gap: 12px; }
.tr-top { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; }
.timer-pill { position: relative; overflow: hidden; min-width: 96px; height: 44px; border-radius: 22px; background: #ffe2c2; display: grid; place-items: center; font-variant-numeric: tabular-nums; font-size: 19px; }
.timer-pill .tp-fill { position: absolute; inset: 0; background: var(--orange); transform-origin: left; transform: scaleX(var(--f, 1)); transition: transform 0.1s linear; }
.timer-pill b { position: relative; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.timer-pill.urgent { background: #ffd0d5; animation: pulse 0.5s infinite; }
.timer-pill.urgent .tp-fill { background: var(--red); }
.tr-title { margin: 0; font-size: 26px; font-weight: 900; }
.tr-image { width: 100%; background: #fff; border-radius: 22px; box-shadow: var(--shadow); display: grid; place-items: center; padding: 10px; min-height: 160px; max-height: 46vh; }
.tr-image img { max-width: 100%; max-height: calc(46vh - 20px); display: block; object-fit: contain; }
.tr-empty { color: var(--muted); font-size: 18px; }
.tr-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.tr-input { width: 100%; font: inherit; font-size: 24px; font-weight: 900; text-align: center; padding: 16px; border-radius: 20px; border: 3px solid #e2ddf2; background: #fff; color: var(--ink); outline: none; }
.tr-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.2); }

.choose-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; width: 100%; margin-top: 6px; }
.choose-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 110px; padding: 14px;
  border-radius: 26px; background: #fff; --shade: var(--press); box-shadow: 0 6px 0 var(--press), 0 14px 24px rgba(42, 36, 64, 0.1);
}
.choose-btn b { font-size: 22px; font-weight: 900; }
.choose-btn small { color: var(--muted); font-size: 14px; }
.timer-opt .tm { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 48px; color: var(--orange-d); line-height: 1; }
.timer-choose .choose-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .timer-choose .choose-grid { grid-template-columns: 1fr 1fr; } }
.pick-players .choose-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.pick-players .choose-btn b { font-size: 18px; margin-top: 4px; }
.tie-av { --pc: #a39cbd; }
.happy-end .choose-grid { grid-template-columns: 1fr; }
.reveal-cta { background: linear-gradient(135deg, #3bd889, #18a85f); color: #fff; --shade: var(--green-d); box-shadow: 0 7px 0 var(--green-d), 0 18px 40px rgba(34, 192, 112, 0.4); min-height: 120px; animation: breathe 2s ease-in-out infinite; --glow: rgba(34, 192, 112, 0.5); }
.reveal-cta b { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 34px; letter-spacing: 1px; }
.cta-ic { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); display: grid; place-items: center; }
.cta-ic .ic { width: 30px; height: 30px; }
.happy-end .big-title { color: var(--accent); animation: stamp 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }

.secret-card { position: relative; width: min(420px, 100%); aspect-ratio: 4 / 3; border-radius: 28px; perspective: 900px; background: none; }
.secret-card > span { position: absolute; inset: 0; border-radius: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; backface-visibility: hidden; transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.5, 1); }
.sc-back { background: linear-gradient(135deg, #8c4dff, #2f7dff); color: #fff; box-shadow: 0 7px 0 #4b2bb8; }
.sc-back .ic { width: 54px; height: 54px; }
.sc-back b { font-size: 26px; }
.sc-back small { opacity: 0.85; font-size: 15px; }
.sc-front { background: #fff; box-shadow: 0 7px 0 var(--press), var(--shadow); transform: rotateY(180deg); }
.secret-card.flipped .sc-back { transform: rotateY(180deg); }
.secret-card.flipped .sc-front { transform: none; }
.secret-word { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: clamp(34px, 9vw, 56px); letter-spacing: 1px; color: var(--accent); line-height: 1.05; }
.secret-label { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 2px; }

.score-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.score-list li { display: grid; grid-template-columns: auto minmax(70px, 140px) 1fr auto; align-items: center; gap: 10px; background: #fff; border-radius: 20px; padding: 8px 14px 8px 8px; box-shadow: 0 4px 0 var(--press); animation: popin 0.4s both; animation-delay: calc(var(--i) * 80ms); text-align: left; }
.sl-name { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-bar { height: 14px; border-radius: 7px; background: #f1eff8; overflow: hidden; }
.sl-bar span { display: block; height: 100%; width: calc(var(--w) * 100%); background: var(--pc); border-radius: 7px; animation: grow 0.9s cubic-bezier(0.3, 1.2, 0.5, 1) both; animation-delay: calc(0.2s + var(--i) * 80ms); transform-origin: left; }
.score-list b { font-size: 20px; min-width: 32px; text-align: right; }
@keyframes grow { from { transform: scaleX(0); } }

.game-over .go-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 8px; }
.crown-wrap { position: relative; margin-top: 30px; }
.crown { position: absolute; top: -40px; left: 0; right: 0; margin: 0 auto; width: 60px; height: 60px; border-radius: 50%; background: #ffd21f; color: var(--ink); display: grid; place-items: center; box-shadow: 0 4px 0 #c79a00; animation: bob 2s ease-in-out infinite; }
.crown .ic { width: 34px; height: 34px; }

/* ================================================================ reveal */
.reveal-panel { background: radial-gradient(ellipse at 50% 35%, #4a2f8a 0%, #241a46 60%, #150f2b 100%); color: #fff; overflow: hidden; }
.reveal-panel .round-btn { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.reveal { position: relative; flex: 1; width: 100%; min-height: 70vh; display: flex; flex-direction: column; align-items: center; }
.rv-top { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; }
.rv-rewind { display: inline-flex; align-items: center; font-family: 'Luckiest Guy', var(--font); font-weight: 400; letter-spacing: 2px; font-size: 22px; color: #ff5a7a; text-shadow: 0 0 12px rgba(255, 90, 122, 0.7); animation: blink 1s steps(2) infinite; }
.rv-rewind .ic { width: 22px; height: 22px; margin-right: -10px; stroke-width: 3.5; }
.rv-rewind .ic + .ic { margin-right: 6px; }
.rv-count { font-size: 15px; color: #cfc6ef; letter-spacing: 1px; text-transform: uppercase; }
@keyframes blink { 50% { opacity: 0.35; } }
.rv-stage { position: relative; flex: 1; width: 100%; min-height: 56vh; }
.rv-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  transform: translateX(-130vw) rotate(-8deg); filter: blur(6px); opacity: 0;
  transition: transform 0.9s cubic-bezier(0.2, 0.9, 0.25, 1), filter 0.9s, opacity 0.6s;
}
.rv-card.in { transform: none; filter: none; opacity: 1; }
.rv-card.out { transform: translateX(130vw) rotate(8deg); filter: blur(6px); opacity: 0; transition: transform 0.8s cubic-bezier(0.6, 0, 0.8, 0.4), filter 0.8s, opacity 0.8s; }
.rv-card.fade { opacity: 0; transform: scale(0.85); filter: blur(3px); transition: opacity 1.6s, transform 1.6s, filter 1.6s; }
.rv-head { display: flex; align-items: center; gap: 10px; font-size: 20px; color: #e8e2ff; }
.rv-polaroid { background: #fff; padding: 12px 12px 34px; border-radius: 10px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); transform: rotate(-2deg); max-width: min(560px, 92vw); }
.rv-polaroid img { display: block; max-width: 100%; max-height: 50vh; object-fit: contain; }
.rv-polaroid .tr-empty { color: #8a83a3; padding: 40px; margin: 0; }
.cell {
  min-width: min(320px, 80vw); max-width: min(560px, 92vw); padding: 26px 30px; border-radius: 26px; background: #fff; color: var(--ink);
  font-family: 'Luckiest Guy', var(--font); font-weight: 400; letter-spacing: 1px; font-size: clamp(30px, 7vw, 56px); line-height: 1.1; text-align: center;
  box-shadow: 0 8px 0 #c9bff0, 0 20px 50px rgba(0, 0, 0, 0.45); overflow-wrap: anywhere;
}
.cell i { font-family: var(--font); font-size: 0.6em; color: var(--muted); }
.rv-card.is-final .cell { box-shadow: 0 8px 0 #ffb13b, 0 0 0 6px #ffd21f, 0 20px 50px rgba(0, 0, 0, 0.45); }
.rv-bar { width: min(420px, 80%); height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; margin: 10px 0 4px; }
.rv-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff5a7a, #ffd21f); }
.vhs { position: absolute; inset: -20px; pointer-events: none; opacity: 0; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 5px); mix-blend-mode: screen; }
.reveal.rewinding .vhs { animation: vhs 0.7s steps(7); }
@keyframes vhs { 0% { opacity: 1; transform: translateY(0) skewX(0); } 30% { transform: translateY(-14px) skewX(-4deg); } 60% { transform: translateY(10px) skewX(3deg); } 100% { opacity: 0; transform: none; } }

.finale { position: absolute; inset: 70px 0 120px; display: flex; align-items: center; justify-content: center; gap: 3vw; }
.fin-slot { flex: 1 1 0; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 12px; transition: transform 3s cubic-bezier(0.15, 0.8, 0.3, 1), opacity 1s; opacity: 0; }
.fin-slot.left { transform: translateX(-90vw); }
.fin-slot.right { transform: translateX(90vw); }
.fin-slot.in { transform: none; opacity: 1; }
.fin-slot { container-type: inline-size; }
.fin-cell { --fpad: 30px; min-width: 0; width: 100%; min-height: 150px; display: grid; place-items: center; padding-left: var(--fpad); padding-right: var(--fpad); font-size: min(clamp(24px, 5vw, 48px), calc((100cqw - 2 * var(--fpad)) / (var(--n, 8) * 0.8))); overflow-wrap: break-word; }
.reveal-panel .menu-body { width: min(1000px, 100%); }
.rv-skip { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.45); letter-spacing: 1px; }
.fin-label { font-size: 15px; letter-spacing: 4px; color: rgba(255, 255, 255, 0.55); }
.fin-who { font-size: 13px; color: rgba(255, 255, 255, 0.4); margin-top: -8px; }
.fin-vs { font-family: 'Luckiest Guy', var(--font); font-size: 28px; color: rgba(255, 255, 255, 0.35); opacity: 0; transition: opacity 1s 5s; }
.finale .right.in ~ .fin-vs, .finale.drumroll .fin-vs, .finale.revealed .fin-vs { opacity: 1; }
.start-cell { position: relative; }
.start-cell .ans { display: none; }
.start-cell .q { font-size: 1.6em; color: #c9bff0; }
.finale.drumroll .start-cell { animation: rumble 0.12s linear infinite; }
.finale.drumroll .start-cell .q { animation: pulse 0.25s infinite; color: var(--accent); }
.finale.revealed .start-cell .q { display: none; }
.finale.revealed .start-cell .ans { display: block; animation: stamp 0.55s cubic-bezier(0.3, 1.6, 0.5, 1); }
.finale.revealed .start-cell { box-shadow: 0 8px 0 #ffb13b, 0 0 0 6px #ffd21f, 0 0 80px 20px rgba(255, 210, 31, 0.5); }
.finale.match .fin-cell { box-shadow: 0 8px 0 #18a85f, 0 0 0 6px #3bd889, 0 0 80px 20px rgba(59, 216, 137, 0.5); }
@keyframes rumble { 0% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-3px, 2px) rotate(-1deg); } 50% { transform: translate(3px, -2px) rotate(1deg); } 75% { transform: translate(-2px, -3px); } }
.fin-verdict { position: absolute; bottom: 70px; left: 0; right: 0; margin: 0; text-align: center; font-family: 'Luckiest Guy', var(--font); font-size: clamp(24px, 6vw, 44px); letter-spacing: 1px; color: #ffd21f; text-shadow: 0 4px 0 #c4245e; animation: stamp 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); padding: 0 12px; }
.fin-next { position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; width: min(360px, 90%) !important; animation: popin 0.5s both; }
.reveal.finale-mode .rv-rewind { animation: none; color: #ffd21f; text-shadow: 0 0 14px rgba(255, 210, 31, 0.7); }
@media (max-width: 560px) {
  .finale { gap: 8px; inset: 60px 0 130px; }
  .fin-cell { min-height: 110px; padding: 16px 10px; --fpad: 10px; }
  .fin-vs { font-size: 18px; }
}
/* Upright phones: the two cards stack, so each gets the full width (and bigger type). */
@media (max-width: 560px) and (min-height: 600px) {
  .finale { flex-direction: column; gap: 4px; inset: 44px 0 150px; }
  .fin-slot { flex: none; width: 100%; gap: 6px; }
  .fin-cell { min-height: 92px; font-size: min(clamp(28px, 8vw, 40px), calc((100cqw - 2 * var(--fpad)) / (var(--n, 8) * 0.8))); }
}

/* ================================================================ party: canvas extras */
body.no-palette .palette { visibility: hidden; }
/* Long prompts (Draw-Off, Dirty Doodles) wrap instead of being cut off. */
body.kind-party .gc-label { max-width: 12em; }
/* Phones: who's drawing sits above the prompt, so neither gets squeezed. */
@media (max-width: 600px), (max-height: 520px) {
  body.kind-party .game-chip { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label time' 'prompt time'; column-gap: 10px; row-gap: 0; padding: 6px 8px 6px 16px; border-radius: 22px; }
  body.kind-party .gc-label { grid-area: label; max-width: none; font-size: 12px; }
  body.kind-party .gc-prompt { grid-area: prompt; }
  body.kind-party .gc-time { grid-area: time; align-self: center; }
}
body.kind-party .gc-prompt { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-height: 1.15; overflow-wrap: break-word; padding: 2px 0; }
.game-chip.is-secret { cursor: pointer; touch-action: none; }
.game-chip.is-secret .gc-prompt { color: var(--accent); }
.game-chip.peeking { box-shadow: 0 0 0 4px var(--accent), var(--shadow); }
/* Hot Potato: the chip (and the host's kicker) jolt with every tick of the fuse. */
.game-chip.tick { animation: fuse-tick 0.22s ease-out; }
@keyframes fuse-tick { 0% { transform: scale(1.06); box-shadow: 0 0 0 5px rgba(255, 90, 79, 0.55), var(--shadow); } 100% { transform: none; } }
.live-host .pass-kicker.tick { animation: fuse-kick 0.22s ease-out; }
@keyframes fuse-kick { 0% { transform: scale(1.12); color: var(--red); } }
.game-actions {
  position: fixed; right: calc(14px + var(--sr)); top: 50%; transform: translateY(-50%); z-index: 11;
  display: flex; flex-direction: column; gap: 12px;
}
.game-actions .btn { min-width: 150px; justify-content: flex-start; }
body:not(.drawing) .game-actions { display: none; }
@media (max-width: 600px) {
  /* above the pen options row, not on top of it */
  .game-actions { top: auto; transform: none; bottom: calc(156px + var(--sb)); right: 10px; flex-direction: row; }
  .game-actions .btn { min-width: 0; min-height: 50px; padding: 0 16px; }
}
.btn-blue { background: var(--accent); color: #fff; --shade: var(--accent-d); box-shadow: 0 4px 0 var(--accent-d), 0 8px 20px rgba(123, 92, 255, 0.3); }

.gallery-panel .menu-body { width: min(1000px, 100%); }
.gpick { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; width: 100%; }
.g-item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: #fff; border-radius: 22px; padding: 12px;
  min-height: 160px; --shade: var(--press); box-shadow: 0 6px 0 var(--press), 0 14px 24px rgba(42, 36, 64, 0.1); animation: popin 0.45s both; animation-delay: calc(var(--i) * 60ms);
}
.g-item img { max-width: 100%; max-height: 30vh; object-fit: contain; display: block; border-radius: 10px; }
.g-num { position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 15px; z-index: 2; }
.g-item.chosen { box-shadow: 0 0 0 5px var(--green), 0 6px 0 var(--press); transform: scale(1.04); }
.g-item.revealed { box-shadow: 0 0 0 3px var(--pc), 0 6px 0 var(--press); }
.g-item.win { box-shadow: 0 0 0 6px #ffd21f, 0 8px 0 #c79a00, 0 0 40px rgba(255, 210, 31, 0.6); transform: scale(1.03); z-index: 1; }
.g-crown { position: absolute; top: -16px; right: -10px; width: 46px; height: 46px; border-radius: 50%; background: #ffd21f; display: grid; place-items: center; box-shadow: 0 3px 0 #c79a00; animation: bob 2s ease-in-out infinite; z-index: 3; }
.g-cap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.g-cap b { font-size: 22px; font-weight: 900; color: var(--ink); }
@media (max-width: 480px) { .g-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .g-item { min-height: 120px; padding: 8px; } }

/* ---- per-game bits */
.team-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.team-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.team-row b { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin-right: 4px; }
.choose-go { background: linear-gradient(135deg, #3bd889, #18a85f); color: #fff; --shade: var(--green-d); box-shadow: 0 6px 0 var(--green-d), 0 14px 30px rgba(34, 192, 112, 0.35); }
.choose-go small { color: rgba(255, 255, 255, 0.85); }
.dirty-read .big-title { font-size: clamp(28px, 6vw, 44px); line-height: 1.15; color: #c4245e; }
.dirty-read .choose-grid { grid-template-columns: 1fr; }

.turn-blocker { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(236, 232, 246, 0.6); animation: fadein 0.2s; }
.tb-card { background: #fff; border-radius: 30px; padding: 24px; width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; box-shadow: var(--shadow); animation: popin 0.35s cubic-bezier(0.3, 1.5, 0.5, 1); }
.tb-card h3 { margin: 4px 0 0; font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 32px; letter-spacing: 0.6px; }
.tb-card p { margin: 0 0 6px; color: #4d466a; font-weight: 700; }
@keyframes fadein { from { opacity: 0; } }
.secret-word.con { color: var(--red); }
.secret-hint { color: var(--muted); font-size: 14px; }
.go-art { background: #fff; border-radius: 20px; padding: 10px; box-shadow: var(--shadow); max-width: min(480px, 100%); }
.go-art img { display: block; max-width: 100%; max-height: 34vh; margin: 0 auto; }
.go-art.tall img { max-height: 46vh; }

.memo-panel { background: linear-gradient(160deg, #18b5a6, #2f7dff); color: #fff; }
.memo-panel .big-title, .memo-panel .pass-kicker { color: #fff; }
.memo-panel .round-btn { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.memo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.memo-img { position: relative; background: #fff; border-radius: 26px; padding: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); animation: stamp 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }
.memo-img img { display: block; width: min(56vh, 80vw); height: min(56vh, 80vw); }
.memo-ring { position: absolute; top: -16px; right: -16px; width: 56px; height: 56px; transform: rotate(-90deg); }
.memo-ring circle { fill: #ffd21f; stroke: #2a2440; stroke-width: 4; stroke-dasharray: 107; stroke-dashoffset: 0; animation: ring var(--ms) linear forwards; }
@keyframes ring { to { stroke-dashoffset: 107; } }

.unroll { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.unroll-frame { background: #fff; border-radius: 16px; padding: 10px; box-shadow: var(--shadow); clip-path: inset(0 0 100% 0 round 16px); transition: clip-path 3.2s cubic-bezier(0.4, 0, 0.3, 1); }
.unroll-frame.open { clip-path: inset(0 0 0 0 round 16px); }
.unroll-frame img { display: block; max-height: 62vh; max-width: 88vw; }

.cover-panel.boom { background: radial-gradient(circle at 50% 45%, #ffd21f 0, #ff7a1f 30%, #e8202f 70%, #6b0a14 100%); animation: boomshake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.cover-panel.boom .cover-title { color: #fff; text-shadow: 0 6px 0 #6b0a14; font-size: clamp(70px, 22vw, 160px); }
.cover-panel.boom .pass-sub { color: #fff; }
@keyframes boomshake { 10%, 50%, 90% { transform: translate(-10px, 6px) rotate(-1deg); } 30%, 70% { transform: translate(10px, -6px) rotate(1deg); } }

/* ---- big screens (the host's TV or laptop): readable from across the room */
@media (min-width: 1200px) and (min-height: 760px) {
  .score-list li { padding: 10px 18px 10px 10px; }
  .score-list .avatar.sm { --sz: 40px; }
  .sl-name { font-size: 21px; }
  .score-list b { font-size: 26px; }
  .wait-chip { font-size: 18px; min-width: 124px; }
  .g-cap b { font-size: 26px; }
  .live-host .lh-log { font-size: 22px; }
}

/* ---- short screens (phones held sideways): keep the main button on screen */
@media (max-height: 520px) {
  .game-panel .menu-body { gap: 10px; padding-bottom: 10px; }
  .game-panel .avatar.xl { --sz: 76px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15), 0 0 0 5px #fff, 0 8px 20px rgba(42, 36, 64, 0.2); }
  .pass, .ready, .cover, .choose, .secret, .scores, .game-over, .text-round { gap: 8px; }
  .pass-name { font-size: clamp(32px, 11vh, 52px); margin-top: 2px; }
  .pass-kicker { font-size: 15px; }
  .pass-sub { font-size: 16px; }
  .pass .btn { margin-top: 4px; }
  .ready-text { font-size: clamp(32px, 12vh, 60px); }
  .cover-title { font-size: clamp(48px, 20vh, 90px); }
  .tr-image { max-height: 40vh; min-height: 110px; padding: 6px; }
  .tr-image img { max-height: calc(40vh - 12px); }
  .tr-form { flex-direction: row; }
  .tr-form .tr-input { flex: 1; min-width: 0; padding: 10px 14px; font-size: 20px; }
  .tr-form .btn { flex: none; width: auto; padding: 0 22px; }
  .crown-wrap { margin-top: 22px; }
  .crown { top: -30px; width: 46px; height: 46px; }
  .crown .ic { width: 26px; height: 26px; }
  .game-over .go-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .game-over .go-actions .btn.big { grid-column: 1 / -1; }
  .score-list { gap: 6px; }
  .score-list li { padding: 4px 12px 4px 4px; }
  .choose-btn { min-height: 84px; }
  .timer-opt .tm { font-size: 38px; }
  .secret-card { width: min(360px, 100%); aspect-ratio: 2.3 / 1; }
  .secret-card > span { padding: 10px; gap: 4px; }
  .secret-word { font-size: clamp(28px, 10vh, 44px); }
  .memo-img img { width: min(62vh, 80vw); height: min(62vh, 80vw); }
  .reveal { min-height: calc(100vh - 100px); }
  .rv-stage { min-height: 0; }
  .rv-polaroid { padding: 8px 8px 22px; }
  .rv-polaroid img { max-height: 46vh; }
  .rv-head { font-size: 16px; }
  .cell { padding: 14px 20px; font-size: clamp(24px, 9vh, 40px); }
  .finale { inset: 36px 0 104px; }
  .fin-cell { min-height: 0; padding: 12px 10px; --fpad: 10px; font-size: min(clamp(20px, 8vh, 34px), calc((100cqw - 20px) / (var(--n, 8) * 0.8))); }
  .fin-label { font-size: 12px; letter-spacing: 2px; }
  .fin-verdict { bottom: 62px; font-size: clamp(18px, 6vh, 26px); }
  .unroll-frame img { max-height: 56vh; }
}
/* Phones held sideways have width to spare: spread out instead of scrolling. */
@media (max-height: 520px) and (min-width: 640px) {
  .game-panel .menu-body { width: min(820px, 100%); }
  .score-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
  .pick-players .choose-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .pick-players .choose-btn { min-height: 0; padding: 10px 6px; }
  .game-over { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; align-items: center; justify-items: center; }
  .game-over > :not(.go-actions) { grid-column: 1; }
  .game-over > .go-actions { grid-column: 2; grid-row: 1 / span 8; display: flex; flex-direction: column; margin-top: 0; }
  .game-over .big-title { font-size: clamp(26px, 8vh, 36px); }
  .go-art img, .go-art.tall img { max-height: 44vh; }
  /* the word chip keeps clear of the palette and the buttons in the corner */
  body.kind-party .game-chip { left: calc(84px + var(--sl)); right: calc(272px + var(--sr)); max-width: calc(100vw - 356px - var(--sl) - var(--sr)); }
}

/* ================================================================ controls guide */
.controls-card { width: min(980px, 100%); }
.ctl-lead { margin: -6px 0 12px; color: var(--muted); font-weight: 700; font-size: 14px; }
.ctl-cols { columns: 300px 3; column-gap: 22px; }
.ctl-group { break-inside: avoid; margin-bottom: 16px; }
.ctl-group h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1.5px solid #f4f2fa; font-size: 15px; font-weight: 700; }
.ctl-keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.kbd { min-width: 30px; height: 30px; padding: 0 9px; border-radius: 9px; background: #f4f2fa; box-shadow: inset 0 -2px 0 #dcd6ee; font-size: 13px; font-weight: 900; color: var(--ink); display: inline-grid; place-items: center; white-space: nowrap; }
button.kbd:not(:disabled):hover { background: #ebe5ff; box-shadow: inset 0 -2px 0 #c9bdf7, 0 0 0 2px rgba(123, 92, 255, 0.35); }
.kbd.custom { background: #ece6ff; color: var(--accent-d); }
.kbd.listening { background: var(--accent); color: #fff; box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.35); animation: pulse 0.8s infinite; }
.kbd.empty { color: var(--muted); font-style: italic; }
.kbd.gesture { font-weight: 800; color: #5b547a; font-size: 12px; }
.ctl-row.fixed span:first-child { color: #5b547a; }
.ctl-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }

/* ================================================================ animation workspace */
.anim-bar {
  position: fixed; z-index: 10; left: calc(88px + var(--sl)); right: calc(14px + var(--sr)); bottom: calc(100px + var(--sb));
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
body:not(.drawing) .anim-bar { display: none; }
.ab-controls { display: flex; align-items: center; gap: 4px; flex: none; }
.ab-btn, .ab-chip, .ab-add { height: 44px; min-width: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--ink); position: relative; transition: background 0.15s, transform 0.12s; }
.ab-btn .ic, .ab-add .ic { width: 22px; height: 22px; }
.ab-btn:hover, .ab-chip:hover, .ab-add:hover { background: #f1eff8; }
.ab-btn:active, .ab-add:active { transform: scale(0.92); }
.ab-play { background: var(--accent); color: #fff; width: 52px; box-shadow: 0 3px 0 var(--accent-d); }
.ab-play:hover { background: var(--accent-d); }
.ab-play.on { background: var(--red); box-shadow: 0 3px 0 var(--red-d); }
.ab-chip { display: flex; flex-direction: column; gap: 0; line-height: 1; padding: 0 8px; background: #f1eff8; }
.ab-chip b { font-size: 16px; }
.ab-chip small { font-size: 10px; color: var(--muted); }
.ab-tog { color: var(--muted); }
.ab-tog.on { color: var(--accent); background: #efeaff; }
.ab-n { position: absolute; right: 3px; top: 2px; font-style: normal; font-size: 10px; font-weight: 900; }
.ab-tog[data-mode='pingpong'] .ic { transform: scaleX(-1); }
.ab-strip { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; scrollbar-width: thin; touch-action: pan-x; }
.af { position: relative; flex: none; border-radius: 10px; padding: 0; background: #fff; box-shadow: 0 0 0 2px #e4e0f0; overflow: hidden; transition: box-shadow 0.15s, transform 0.15s; }
.af canvas { display: block; width: 72px; height: auto; }
.af.on { box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.af.drop { box-shadow: -5px 0 0 0 var(--green), 0 0 0 2px #e4e0f0; }
.af-n { position: absolute; left: 3px; bottom: 2px; font-size: 10px; font-weight: 900; color: var(--muted); background: rgba(255, 255, 255, 0.85); border-radius: 6px; padding: 0 4px; }
.af-hold { position: absolute; right: 3px; top: 2px; font-size: 10px; font-weight: 900; color: #fff; background: var(--orange); border-radius: 6px; padding: 0 4px; }
.af-hold:empty { display: none; }
.ab-strip.reordering .af { cursor: grabbing; }
.ab-adds { display: flex; gap: 4px; flex: none; }
.ab-add { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-d); }
.ab-add:hover { background: var(--green-d); }
.ab-dup { background: #f1eff8; color: var(--ink); box-shadow: 0 3px 0 var(--press); }
.ab-dup:hover { background: #e6e1f7; }
body.ws-anim .toolopts { bottom: calc(184px + var(--sb)); }
.anim-player { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 8; cursor: pointer; }
.anim-player.hidden { display: none; }
body.anim-playing .dock, body.anim-playing .rail, body.anim-playing .palette, body.anim-playing .toolopts { opacity: 0.35; pointer-events: none; }
@media (max-width: 600px) {
  .anim-bar { left: 8px; right: 8px; bottom: calc(84px + var(--sb)); gap: 6px; padding: 6px; border-radius: 20px; flex-wrap: wrap; }
  .ab-controls { order: 1; }
  .ab-adds { order: 2; margin-left: auto; }
  .ab-strip { order: 3; flex-basis: 100%; }
  .ab-btn, .ab-chip, .ab-add { height: 40px; min-width: 40px; }
  .af canvas { width: 56px; }
  body.ws-anim .toolopts { bottom: calc(230px + var(--sb)); }
  body.ws-anim .rail { top: 40%; }
}
/* the animation timeline itself (.anim-tl; Pixel Art shares the .ab-* pieces) */
.anim-tl .ab-strip { padding: 6px 8px; overscroll-behavior-x: contain; }
.anim-tl .af { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: pan-x; }
.anim-tl .af canvas { width: auto; }
.anim-tl .af:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.45); }
.anim-tl .af.on:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.anim-tl .af.drop { box-shadow: -7px 0 0 -2px var(--green), 0 0 0 2px #e4e0f0; }
.anim-tl .af.drop-end { box-shadow: 7px 0 0 -2px var(--green), 0 0 0 2px #e4e0f0; }
.anim-tl .af.lifted { transform: translateY(-4px) scale(1.07); box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(42, 36, 64, 0.22); z-index: 1; }
.anim-tl .af.dragging { opacity: 0.45; }
.anim-tl .ab-strip.reordering { scroll-behavior: auto; }
.anim-tl .ab-lp { position: absolute; right: 3px; top: 1px; font-style: normal; font-size: 10px; font-weight: 900; }
.anim-tl .ab-tog[data-mode='pingpong'] .ic { transform: none; }
.anim-tl .ab-btn:disabled { opacity: 0.4; }
/* frame and fps menus fit short screens (phones on their side) */
body.ws-anim .popmenu { max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-height: 520px) { body.ws-anim .popmenu .pm-item { height: 46px; font-size: 16px; } }
/* tool options and pop-up cards ride just above the timeline (its top is measured into --ab-top) */
body.ws-anim .toolopts { bottom: calc(var(--ab-top, calc(184px + var(--sb))) + 10px); }
body.ws-anim .pop-card { bottom: calc(var(--ab-top, calc(184px + var(--sb))) + 82px); }
@media (max-height: 520px) {
  .anim-tl { padding: 5px; gap: 6px; border-radius: 20px; }
  .anim-tl .ab-btn, .anim-tl .ab-chip, .anim-tl .ab-add { height: 38px; min-width: 38px; border-radius: 12px; }
  .anim-tl .ab-play { width: 46px; }
  .anim-tl .ab-strip { padding: 5px 8px; }
}
.anim-preview canvas { max-width: 100%; max-height: calc(min(42vh, 360px) - 32px); display: block; border-radius: 8px; }
.anim-preview:not(.checker) { background: #f4f2fa; }
.anim-preview:not(.checker) canvas { box-shadow: 0 2px 12px rgba(42, 36, 64, 0.14); }
.anim-finish .ap-note { margin-top: -8px; min-height: 1.3em; }
@media (max-width: 600px), (max-height: 880px) {
  .anim-finish .anim-preview { height: min(34vh, 320px); }
  .anim-finish .anim-preview canvas { max-height: calc(min(34vh, 320px) - 32px); }
}
.anim-finish.busy .ap-fmt, .anim-finish.busy .ap-scale, .anim-finish.busy .ap-paper { pointer-events: none; opacity: 0.6; }

.mega-project { --shade: #c2580a; background: linear-gradient(135deg, #ffb13b, #ff6a3d); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 106, 61, 0.3); }
.kind-grid { display: flex; flex-wrap: wrap; justify-content: center; }
.kind-grid .pick-card { flex: 0 1 calc((100% - 32px) / 3); min-width: 0; }
@media (max-width: 560px) { .kind-grid { display: grid; grid-template-columns: 1fr; } .kind-grid .pick-card { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 0; text-align: left; align-items: center; } .kind-grid .pick-art { grid-row: span 2; } .kind-grid .pick-card b { margin-top: 0; align-self: end; } .kind-grid .pick-card small { align-self: start; } .kind-grid .pick-art .art { width: 64px; height: 64px; } }
.gal-thumb { position: relative; }
.gal-kind { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; font-style: normal; }
.gal-kind .ic { width: 18px; height: 18px; }

/* ================================================================ 3D workspace */
.ws3d { position: fixed; inset: 0; z-index: 5; background: var(--bd); }
.w3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
body.ws3d-on .ws3d .rail, body.ws3d-on .ws3d .dock, body.ws3d-on .ws3d .toolopts, body.ws3d-on .ws3d .topbar, body.ws3d-on .ws3d .palette { visibility: visible; }
.ws3d .w3-opts { bottom: calc(104px + var(--sb)); }
.ws3d .w3-opts .pill.danger { color: var(--red-d); padding: 0 14px; }
.ws3d .w3-rail .w3-snap.on { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d); }
.w3-viewchip { cursor: pointer; }
.w3-hint { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); width: max-content; max-width: min(440px, calc(100vw - 48px)); text-align: center; padding: 14px 22px; border-radius: 20px; background: rgba(255, 255, 255, 0.85); color: var(--muted); font-size: 18px; pointer-events: none; box-shadow: var(--shadow); }
.w3-panel { position: fixed; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 250px; max-height: calc(100vh - 230px); z-index: 10; display: flex; flex-direction: column; }
.w3-panel-tab { display: none; }
.w3-panel-body { background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: 22px; box-shadow: var(--shadow); padding: 12px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.w3-panel h4 { margin: 2px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.w3-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.w3-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 12px; cursor: pointer; font-size: 14px; }
.w3-list li:hover { background: #f4f2fa; }
.w3-list li.on { background: #ece6ff; color: var(--accent-d); }
.w3-list .w3-empty { color: var(--muted); cursor: default; }
.w3-sw { width: 16px; height: 16px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.15); flex: none; }
.w3-nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w3-rename { flex: 1; min-width: 0; font: inherit; font-size: 14px; border: 2px solid var(--accent); border-radius: 8px; padding: 2px 6px; }
.w3-eye { width: 28px; height: 28px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.w3-eye .ic { width: 18px; height: 18px; }
.w3-eye.off { opacity: 0.35; }
.w3-props { border-top: 2px solid #f1eff8; padding-top: 10px; }
.w3-props:empty { display: none; }
.w3-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px; font-size: 14px; }
.w3-row > span { flex: none; width: 74px; }
.w3-row .w3-sl { flex: 1; }
.w3-row .switch { transform: scale(0.8); transform-origin: right; }
.w3-xyz { display: flex; justify-content: space-between; padding: 6px 4px; font-size: 13px; color: var(--muted); }
.w3-xyz b { color: var(--ink); font-variant-numeric: tabular-nums; }
.w3-tip { color: var(--muted); font-size: 13px; margin: 2px 4px; }
.shape-menu { display: grid; grid-template-columns: 1fr 1fr; min-width: 300px; }
.w3-bdsw { width: 24px; height: 24px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.18); }
.popmenu .pm-item.w3-cur { color: var(--accent-d); background: #f1edff; }
/* the 3D menus are long: tighter rows on phones held sideways */
@media (max-height: 500px) {
  body.ws3d-on .pm-item { height: 44px; font-size: 16px; }
  body.ws3d-on .shape-menu { grid-template-columns: repeat(3, 1fr); min-width: 420px; }
  body.ws3d-on .shape-menu .pm-item { height: 44px; }
}
.shape-menu .pm-item { height: 50px; font-size: 16px; }
.bd-swatch { position: relative; display: block; }
.bd-floor { position: absolute; left: 10%; right: 10%; bottom: 14%; height: 18%; border-radius: 50%; background: rgba(42, 36, 64, 0.14); }
.bd-cube { position: absolute; left: 50%; bottom: 24%; width: 30%; aspect-ratio: 1; transform: translateX(-50%) rotate(8deg); border-radius: 8px; background: linear-gradient(135deg, #b48bff, #6a3df0); box-shadow: 0 4px 0 #4b2bb8; }
@media (max-width: 760px) {
  .w3-panel { top: auto; bottom: calc(160px + var(--sb)); right: 10px; width: min(280px, calc(100vw - 20px)); max-height: 46vh; align-items: flex-end; }
  .w3-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin-top: 8px; order: 2; }
  .w3-panel-tab .ic { width: 18px; height: 18px; }
  .w3-panel-body { display: none; width: 100%; }
  .w3-panel.open .w3-panel-body { display: block; }
  .ws3d .w3-opts .pill span { display: none; }
  .ws3d .w3-opts .pill { padding: 0 12px; }
  .ws3d .w3-opts .opts { gap: 6px; }
  .w3-viewchip { display: none; }
  .w3-hint { max-width: calc(100vw - 150px); font-size: 16px; }
}
/* phones held sideways: little height, so the Scene list folds into a tab at the top */
@media (max-height: 500px) {
  .w3-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(10px + var(--sr)); width: min(270px, calc(100vw - 20px)); max-height: calc(100vh - 86px - var(--st) - var(--sb)); align-items: flex-end; }
  .w3-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin: 0 0 8px; order: 0; flex: none; }
  .w3-panel-tab .ic { width: 18px; height: 18px; }
  .w3-panel-body { display: none; width: 100%; }
  .w3-panel.open .w3-panel-body { display: block; }
  .w3-hint { top: 50%; }
}
@media (max-height: 500px) and (max-width: 1000px) {
  .ws3d .w3-opts .pill span { display: none; }
  .ws3d .w3-opts .pill { padding: 0 12px; }
  .ws3d .w3-opts .opts { gap: 6px; }
}

/* ================================================================ online */
.mega-host { --shade: #0b7f86; background: linear-gradient(135deg, #2fd1c5, #1497b8); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(20, 151, 184, 0.3); }
.mega-join { --shade: #c4245e; background: linear-gradient(135deg, #ff8a3d, #ff3b8d); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 59, 141, 0.3); }
.join-form { display: flex; flex-direction: column; gap: 10px; }
.join-lbl { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 6px; }
.join-lbl small { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--accent); }
.join-form input { font: inherit; border: 3px solid #e2ddf2; border-radius: 22px; background: #fff; color: var(--ink); outline: none; padding: 14px 18px; font-size: 22px; font-weight: 900; }
.join-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.2); }
.join-code { font-family: 'Luckiest Guy', var(--font) !important; font-weight: 400 !important; font-size: 52px !important; letter-spacing: 14px; text-align: center; text-transform: uppercase; }
.join-form .btn { margin-top: 10px; }

.lobby-body { width: min(1000px, 100%); justify-content: flex-start; }
.room-card { position: relative; text-align: center; background: #fff; border-radius: 30px; padding: 18px 20px 20px; box-shadow: var(--shadow); }
.room-big { font-family: 'Luckiest Guy', var(--font); font-size: clamp(64px, 14vw, 120px); letter-spacing: 0.18em; line-height: 1; color: var(--accent); text-shadow: 0 6px 0 #d9cffd; margin: 4px 0 8px; padding-left: 0.18em; }
.room-how { margin: 0; color: #4d466a; font-weight: 700; font-size: 17px; }
.room-qr { width: 132px; height: 132px; margin: 2px auto 10px; padding: 6px; border-radius: 16px; background: #fff; box-shadow: 0 0 0 3px #d9cffd; }
.room-qr svg { display: block; width: 100%; height: 100%; }
@media (max-height: 640px) { .room-qr { width: 96px; height: 96px; } }
.room-how b { color: var(--ink); }
.net-badge { position: absolute; top: 14px; right: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(255, 159, 28, 0.2); }
.net-badge[data-st='open'] { background: var(--green); box-shadow: 0 0 0 4px rgba(34, 192, 112, 0.2); }
.net-badge[data-st='reconnecting'] { background: var(--red); animation: pulse 1s infinite; }
.lobby-players { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.lp { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 20px; background: #fff; box-shadow: 0 4px 0 var(--press); font-size: 14px; animation: popin 0.4s cubic-bezier(0.3, 1.5, 0.5, 1); min-width: 0; }
.lp b { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp.empty { background: rgba(255, 255, 255, 0.5); box-shadow: none; color: var(--muted); animation: none; }
.lp.empty .avatar { background: #e4e0f0; box-shadow: none; }
.lp.off { opacity: 0.5; }
.lp-kick { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: #f1eff8; color: var(--muted); display: grid; place-items: center; opacity: 0; transition: opacity 0.15s; }
.lp-kick .ic { width: 14px; height: 14px; }
.lp:hover .lp-kick, .lp-kick:focus-visible { opacity: 1; }
@media (hover: none) { .lp-kick { opacity: 0.85; } }
.invite-btn { margin: 12px auto 0; min-height: 46px; font-size: 16px; }
@media (max-width: 760px) { .lobby-players { grid-template-columns: repeat(4, 1fr); } }
.lobby-tip { margin-top: 4px; }
.close-room { align-self: center; }

.player-panel .menu-body { justify-content: flex-start; }
.pl-top { display: flex; justify-content: space-between; align-items: center; position: relative; min-height: 36px; }
.pl-top .net-badge { position: static; }
.pl-lobby, .pl-wait { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin: auto 0; padding: 20px 0; }
.pl-roster { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pl-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 20px; background: #fff; box-shadow: 0 3px 0 var(--press); font-size: 15px; }
.pl-chip.off { opacity: 0.45; }
.look-up { width: 110px; height: 110px; border-radius: 50%; background: #fff; display: grid; place-items: center; color: var(--accent); box-shadow: var(--shadow); animation: bob 2.4s ease-in-out infinite; }
.look-up .ic { width: 56px; height: 56px; }
.mirror-word { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 1.6em; color: var(--accent); letter-spacing: 0.5px; }
.pl-big { font-size: 22px; }
.guess-live .gl-status { color: var(--muted); font-size: 15px; }
.gl-log { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.gl-log span { padding: 4px 10px; border-radius: 12px; background: #f1eff8; color: var(--muted); font-size: 14px; text-decoration: line-through; }
.gl-log span.ok { background: var(--green); color: #fff; text-decoration: none; font-weight: 900; }
.look-up.done { color: var(--green); animation: popin 0.4s cubic-bezier(0.3, 1.5, 0.5, 1); }
.host-gone-bar {
  position: fixed; z-index: 120; left: 50%; top: calc(10px + var(--st)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 20px);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; border-radius: 24px; background: var(--ink); color: #fff;
  box-shadow: 0 10px 30px rgba(42, 36, 64, 0.35); font-size: 15px; animation: popin 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.hg-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }
.hg-text { line-height: 1.25; }
.hg-leave { min-height: 38px; padding: 0 14px; font-size: 14px; }
.host-panel .menu-body { width: min(900px, 100%); }
.waiting { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.host-bar { width: min(520px, 90%); background: rgba(123, 92, 255, 0.15); }
.host-bar span { background: var(--accent); }
.wait-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.wait-chip { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 14px; min-width: 104px; border-radius: 22px; background: #fff; box-shadow: 0 4px 0 var(--press); font-size: 15px; }
.wait-chip .avatar { animation: bob 1.6s ease-in-out infinite; }
.wait-chip i { position: absolute; top: -8px; right: -8px; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; transform: scale(0); transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); font-style: normal; }
.wait-chip i .ic { width: 18px; height: 18px; }
.wait-chip.done i { transform: scale(1); }
.wait-chip.done .avatar { animation: none; }
.wait-chip em { display: none; font-style: normal; font-size: 12px; color: var(--red-d); text-transform: uppercase; letter-spacing: 1px; }
.wait-chip.off:not(.done) { opacity: 0.6; }
.wait-chip.off:not(.done) em { display: block; }
.wait-chip.off .avatar { animation: none; filter: grayscale(0.8); }
.live-host { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.live-host .tr-image { max-height: 58vh; min-height: 280px; }
.live-host .tr-image img { max-height: calc(58vh - 20px); }
.lh-log { margin: 0; min-height: 22px; color: var(--green-d); font-size: 18px; }
.waiting .wait-img { width: auto; max-width: 100%; min-height: 0; max-height: 44vh; }
.waiting .wait-img img { max-height: calc(44vh - 20px); }
.choose-pic { display: grid; width: 100%; min-height: 0; margin: 0 0 10px; max-height: 32vh; }
.choose-pic img { max-height: calc(32vh - 20px); }

/* ---------------------------------------------------------------- controls mode */
body:not(.adv) .adv-only { display: none !important; }
body.adv .simple-only { display: none !important; }
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.mode-chip .ic { width: 18px; height: 18px; }
.mode-chip.is-adv { color: #fff; background: linear-gradient(135deg, #7b5cff, #b04dff); }
.mode-chip:active { transform: scale(0.95); }
body.kind-party .topbar .mode-chip { display: none; }
@media (max-width: 560px) {
  .mode-chip { padding: 0 11px; }
  .mode-chip span { display: none; }
}

/* ---------------------------------------------------------------- sound popover */
.vol-pop {
  position: fixed;
  z-index: 120;
  width: min(320px, calc(100vw - 20px));
  padding: 14px 16px 6px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(40, 20, 90, 0.25), 0 2px 0 rgba(255, 255, 255, 0.8) inset;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}
.vol-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.vol-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.vol-head b { font-size: 20px; font-weight: 900; }
.vol-mute { display: inline-flex; align-items: center; gap: 6px; }
.vol-mute .ic { width: 18px; height: 18px; }
.vp-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 2px solid #f4f2fa; font-size: 15px; }
.vp-row > span, .vol-row > span { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; min-width: 128px; }
.vp-row > span .ic, .vol-row > span .ic { width: 18px; height: 18px; color: var(--accent); transition: color 0.15s; }
.vol-row.is-off > span .ic { color: #b9b3cc; }
.vp-row .set-slider { flex: 1; }
.vol-row .set-slider { outline: none; border-radius: 999px; }
.vol-row .set-slider:focus-visible { box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.35); }

/* ---------------------------------------------------------------- 3D: lights, skins, posing */
.ws3d .w3-opts .opts { max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; }
/* more pills than fit: fade the edge so it reads as scrollable */
.ws3d .w3-opts .opts.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
.ws3d .w3-opts .opts::-webkit-scrollbar { display: none; }
.ws3d .w3-opts .pill { flex: none; }
.ws3d .w3-opts .pill.on { background: var(--accent); color: #fff; }
.ws3d .w3-opts .pill.hl { background: #ffe9a8; color: #6b4a00; }
.ws3d .w3-rail .w3-sunbtn { color: #ff9f1c; }
/* on the dark stage a half-faded white button turns muddy gray: keep it light */
.ws3d[data-bd='night'] .w3-rail .btn:disabled { opacity: 1; background: #b9b3cf; color: #7d7697; box-shadow: 0 4px 0 #8d86a8; }
.ws3d.dragging .w3-canvas { cursor: grabbing !important; }
.ws3d .w3-top .mode-chip { order: 0; }
.w3-tipline {
  position: fixed; left: 50%; bottom: calc(184px + var(--sb)); transform: translate(-50%, 8px);
  max-width: min(560px, calc(100vw - 32px)); padding: 9px 16px; border-radius: 16px;
  background: rgba(42, 36, 64, 0.82); color: #fff; font-size: 14px; text-align: center; line-height: 1.35;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 9;
}
.w3-tipline.show { opacity: 1; transform: translate(-50%, 0); }
.ws3d.panel-open .w3-tipline { opacity: 0; }
.w3-tipline b { color: #ffd76a; }
.w3-ic { width: 18px; height: 18px; display: grid; place-items: center; color: var(--accent); flex: none; }
.w3-ic .ic { width: 18px; height: 18px; }
.w3-tag { font-style: normal; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: #ffe9a8; color: #6b4a00; margin-left: 4px; vertical-align: 1px; }
.w3-skinrow .pill.small { height: 34px; padding: 0 12px; font-size: 13px; gap: 6px; }
.w3-skinrow .pill .ic { width: 16px; height: 16px; }
.w3-num { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 0; }
.w3-nrow { display: grid; grid-template-columns: 66px repeat(3, 1fr); gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.w3-nrow input { width: 100%; min-width: 0; font: inherit; font-size: 12.5px; font-weight: 800; color: var(--ink); text-align: center; border: 2px solid #ece9f5; border-radius: 8px; padding: 3px 2px; background: #fff; font-variant-numeric: tabular-nums; }
.w3-nrow input:focus { outline: none; border-color: var(--accent); }
.w3-nrow input:nth-of-type(1) { box-shadow: inset 0 -2px 0 #ff4d5e55; }
.w3-nrow input:nth-of-type(2) { box-shadow: inset 0 -2px 0 #22c07055; }
.w3-nrow input:nth-of-type(3) { box-shadow: inset 0 -2px 0 #2f7dff55; }

/* floating panels (skin + pose capture) */
.sk-panel, .pc-panel {
  position: fixed; z-index: 60; top: calc(84px + var(--st)); left: calc(14px + var(--sl));
  width: min(340px, calc(100vw - 28px)); max-height: calc(100vh - 272px - var(--st) - var(--sb)); overflow: auto; overscroll-behavior: contain;
  padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 18px 50px rgba(40, 20, 90, 0.22);
  opacity: 0; transform: translateX(-12px); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  touch-action: pan-y;
}
.sk-panel.show, .pc-panel.show { opacity: 1; transform: none; }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pc-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 900; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-head b .ic { width: 20px; height: 20px; color: var(--accent); flex: none; }
.pc-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; border-top: 2px solid #f4f2fa; }
.pc-row > span { flex: 0 0 92px; }
.pc-row .set-slider { flex: 1; }
.pc-row .seg { flex: 1; }
.pc-row .seg button { flex: 1; }
.pc-row.pc-src { flex-wrap: wrap; border-top: 0; }
.pc-row .pill { height: 38px; padding: 0 12px; font-size: 13.5px; gap: 6px; }
.pc-row .pill .ic { width: 17px; height: 17px; }
.pc-row .switch { margin-left: auto; }
.pc-view { position: relative; border-radius: 16px; overflow: hidden; background: #f4f2fa; aspect-ratio: 16 / 11; display: grid; place-items: center; }
.pc-cv { width: 100%; height: 100%; object-fit: contain; display: none; }
.pc-view.has-src .pc-cv { display: block; }
.pc-view.has-src .pc-empty { display: none; }
.pc-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.pc-empty .ic { width: 40px; height: 40px; color: var(--accent); }
.pc-status { margin: 8px 2px; min-height: 18px; font-size: 13px; color: #4d466a; line-height: 1.35; }
.pc-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 10px -14px -14px; padding: 10px 14px 14px; position: sticky; bottom: -14px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); }
.pc-actions .btn { height: 48px; font-size: 15px; }
.pc-actions .btn .ic { width: 18px; height: 18px; }
.sk-top { display: flex; gap: 12px; align-items: stretch; }
.sk-thumb { width: 104px; flex: none; aspect-ratio: 1; border-radius: 16px; background: var(--checker); display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 2px #ece9f5; }
.sk-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sk-thumb span { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; background: rgba(255, 255, 255, 0.85); padding: 8px; border-radius: 12px; }
.sk-thumb .ic { width: 26px; height: 26px; color: var(--accent); }
.sk-actions { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.sk-actions .pill { height: 36px; padding: 0 12px; font-size: 13.5px; gap: 6px; justify-content: flex-start; }
.sk-actions .pill .ic { width: 17px; height: 17px; color: var(--accent); }
.sk-lbl { margin: 12px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.sk-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sk-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border-radius: 14px; background: #f6f4fc; text-align: left; transition: background 0.15s, box-shadow 0.15s; }
.sk-mode b { font-size: 14px; }
.sk-mode small { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.sk-mode:hover { background: #efebfb; }
.sk-mode.on { background: #ece6ff; box-shadow: inset 0 0 0 2px var(--accent); }
.sk-mode.on b { color: var(--accent-d); }
.sk-fit { margin-top: 8px; transition: opacity 0.2s; }
.sk-fit.off { opacity: 0.4; pointer-events: none; }
.sk-btns { display: flex; gap: 8px; padding-top: 8px; }
.sk-btns .pill { flex: 1; height: 38px; font-size: 13.5px; gap: 6px; }
.sk-btns .pill .ic { width: 16px; height: 16px; }
.sk-btns .pill.danger { color: var(--red-d); }
.sk-tip { margin: 10px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.ws3d.capturing .w3-panel, .ws3d.capturing .w3-opts { display: none; }
@media (max-width: 760px) {
  .sk-panel, .pc-panel { top: auto; bottom: calc(10px + var(--sb)); left: 10px; right: 10px; width: auto; max-height: 52vh; transform: translateY(14px); z-index: 60; }
  .ws3d.capturing .w3-dock, .ws3d.capturing .w3-opts { display: none; }
  .pc-view { aspect-ratio: 16 / 10; max-height: 22vh; }
  .w3-tipline { bottom: calc(218px + var(--sb)); font-size: 13px; }
}
@media (max-height: 500px) {
  .sk-panel, .pc-panel { top: calc(10px + var(--st)); bottom: auto; left: calc(10px + var(--sl)); right: auto; width: min(340px, calc(100vw - 20px)); max-height: calc(100vh - 20px - var(--st) - var(--sb)); transform: translateX(-12px); }
  .pc-view { max-height: 34vh; }
  /* tips sit up under the top bar, clear of the model in the short middle band */
  .w3-tipline { top: calc(72px + var(--st)); bottom: auto; transform: translate(-50%, -8px); max-width: calc(100vw - 380px); font-size: 13px; }
}

/* ================================================================ canvas workspaces (Photo Editor, Pixel Art) */
.wsx { position: fixed; inset: 0; z-index: 5; background: radial-gradient(ellipse at 50% 35%, #f7f5fc 0%, #e9e6f3 70%, #dedaeb 100%); }
.wsx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.wsx-canvas.grab { cursor: grab !important; }
body.wsx-on .wsx .rail, body.wsx-on .wsx .dock, body.wsx-on .wsx .toolopts, body.wsx-on .wsx .topbar, body.wsx-on .wsx .palette { visibility: visible; }
body.wsx-on .wsx .anim-bar { display: flex; }
.wsx .wsx-opts { bottom: calc(104px + var(--sb)); }
.wsx .wsx-opts .opts { max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.wsx .wsx-opts .opts::-webkit-scrollbar { display: none; }
.wsx .wsx-opts .pill, .wsx .wsx-opts .seg { flex: none; }
.wsx .wsx-opts .pill.danger { color: var(--red-d); }
.wsx .wsx-opts .seg button { padding: 0 12px; gap: 6px; }
.wsx .wsx-opts .seg button span { font-size: 14px; }
.wsx .wsx-dock { max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
.wsx .wsx-dock::-webkit-scrollbar { display: none; }
.wsx .wsx-dock .tool-btn { flex: none; }
.wsx.empty .wsx-dock, .wsx.empty .wsx-rail, .wsx.empty .wsx-opts, .wsx.empty .wsx-pal, .wsx.empty .wsx-panel, .wsx.empty .wsx-zoom, .wsx.empty .done-btn { visibility: hidden !important; }
.wsx-zoom { cursor: pointer; font-variant-numeric: tabular-nums; min-width: 64px; }
.ph-optsl { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; font-size: 14px; color: var(--muted); flex: none; }
.ph-optsl .w3-sl { width: 120px; }
.ph-optsl .hslider { height: 40px; }
.ph-optsl .hslider .sl-thumb { width: 40px; height: 40px; }
.ph-optsl .hslider .sl-thumb { left: calc(var(--f, 0) * (100% - 40px)); }

/* the panel on the right (layers / adjust / looks) */
.wsx-panel { position: fixed; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 272px; max-height: calc(100vh - 236px - var(--st) - var(--sb)); z-index: 10; display: flex; flex-direction: column; }
.wsx-panel-tab { display: none; }
.wsx-panel-body { background: rgba(255, 255, 255, 0.95); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: 22px; box-shadow: var(--shadow); padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.ph-tabs { flex: none; }
.ph-tabs button { height: 40px; gap: 6px; font-size: 13.5px; padding: 0 6px; }
.ph-tabs button .ic { width: 17px; height: 17px; }
.ph-tab { display: none; flex-direction: column; gap: 6px; min-height: 0; }
.ph-tab.show { display: flex; }
.ph-llist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 300px; overflow: auto; }
.ph-llist li { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 2px; border-radius: 14px; cursor: pointer; font-size: 14px; position: relative; }
.ph-llist li:hover { background: #f4f2fa; }
.ph-llist li.on { background: #ece6ff; color: var(--accent-d); }
.ph-llist li.dragging { opacity: 0.6; }
.ph-llist li.drop { box-shadow: inset 0 3px 0 var(--green); }
.ph-grip { width: 16px; color: #c5bfd9; font-size: 12px; letter-spacing: -2px; cursor: grab; touch-action: none; text-align: center; flex: none; user-select: none; }
.ph-lthumb-wrap { position: relative; flex: none; display: grid; place-items: center; }
.ph-lthumb { width: 48px; height: auto; border-radius: 8px; background: var(--checker); box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.12); display: block; }
.ph-tbadge { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 6px; background: var(--accent); color: #fff; font-style: normal; font-size: 11px; font-weight: 900; display: grid; place-items: center; }
.ph-lprops { border-top: 2px solid #f1eff8; padding-top: 4px; }
.ph-lprops .w3-row b, .ph-adjrow b { flex: none; width: 34px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ph-lbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-lbtns .pill { height: 38px; padding: 0 11px; font-size: 13.5px; gap: 5px; }
.ph-lbtns .pill .ic { width: 17px; height: 17px; }
.ph-lbtns .pill.danger { color: var(--red-d); margin-left: auto; }
.ph-rmbg { height: 38px; font-size: 13.5px; gap: 6px; justify-content: center; }
.ph-rmbg .ic { width: 17px; height: 17px; color: var(--accent); }
.pill.small { height: 34px; padding: 0 12px; font-size: 13px; }
.ph-adj { display: flex; flex-direction: column; }
.ph-adjrow { padding: 1px 4px; }
.ph-adjrow > span { width: 80px; font-size: 13px; }
.w3-sl.bipolar .sl-track { background: linear-gradient(90deg, #ece9f5, #ece9f5 49.4%, #b9acf5 49.5%, #b9acf5 50.5%, #ece9f5 50.6%); }
.ph-target { margin: 2px 4px 0; }
.ph-target b { color: var(--ink); }
.ph-adjfoot, .ph-lookfoot { display: none; grid-template-columns: 1fr 1.3fr; gap: 8px; position: sticky; bottom: -10px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); padding: 8px 0 2px; }
.ph-adjfoot.show, .ph-lookfoot.show { display: grid; }
.ph-adjfoot .btn, .ph-lookfoot .btn { height: 44px; font-size: 14px; }
.ph-adjfoot .btn .ic, .ph-lookfoot .btn .ic { width: 18px; height: 18px; }
.ph-looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph-look { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; font-size: 12.5px; font-weight: 800; color: var(--ink); transition: background 0.15s, box-shadow 0.15s, transform 0.12s; }
.ph-look canvas { width: 100%; aspect-ratio: 1; border-radius: 10px; display: block; }
.ph-look:hover { background: #f4f2fa; }
.ph-look:active { transform: scale(0.96); }
.ph-look.on { background: #ece6ff; box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent-d); }
.ph-lookk.hidden { display: none; }

/* start card, text editor, busy */
.ph-start { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 12; }
.ph-start.hidden { display: none; }
.ph-start-card { width: min(420px, 100%); background: #fff; border-radius: 32px; box-shadow: 0 24px 60px rgba(42, 36, 64, 0.18); padding: 26px 22px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; animation: popin 0.45s cubic-bezier(0.3, 1.4, 0.5, 1); }
.ph-start-card h3 { margin: 0 0 4px; font-size: 24px; font-weight: 900; }
.ph-start-art { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2fd1c5, #2f7dff); box-shadow: 0 6px 0 #1d5fd0; }
.ph-start-art .ic { width: 42px; height: 42px; }
.ph-start-card .btn.big { width: 100%; }
.ph-or { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.ph-blank { width: 100%; }
.ph-blank button { font-size: 13.5px; }
.ph-hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.ph-texted { position: absolute; z-index: 9; min-width: 8px; white-space: pre; outline: none; color: transparent; caret-color: #7b5cff; padding: 0; margin: 0; background: transparent; }
.ph-texted::selection { background: rgba(123, 92, 255, 0.28); color: transparent; }
.ph-busy { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(255, 255, 255, 0.25); cursor: progress; }
.ph-busy.hidden { display: none; }
.ph-busy span { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(123, 92, 255, 0.25); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ph-font span { font-size: 16px; }

/* photo editor: the options bar wraps (in groups) instead of hiding controls off screen.
   The bar spans the screen (centring its row) so it isn't squeezed to half the width. */
.ws-photo .wsx-opts { left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); display: flex; justify-content: center; transform: translateY(10px); pointer-events: none; }
.ws-photo .wsx-opts.show { transform: none; pointer-events: none; }
.ws-photo .wsx-opts.show .opts { pointer-events: auto; }
.ws-photo .wsx-opts .opts { flex-wrap: wrap; justify-content: center; white-space: normal; row-gap: 6px; max-width: calc(100vw - 168px - var(--sl) - var(--sr)); }
.ws-photo .ph-grp { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 8px; flex: none; max-width: 100%; }
.ws-photo .ph-optv { flex: none; min-width: 46px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ws-photo .wsx-panel { max-height: calc(100vh - 84px - var(--ph-pfloor, 152px) - var(--st)); }
.ws-photo .ph-lbtns { flex-wrap: nowrap; gap: 5px; }
.ws-photo .ph-lbtns .pill { flex: 1 1 auto; justify-content: center; padding: 0 8px; gap: 4px; font-size: 13px; min-width: 0; }
.ws-photo .ph-lbtns .pill.danger { margin-left: 0; }
.ph-look.on canvas { box-shadow: 0 0 0 2px #fff; }
.ph-cmp { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ph-cmp.on { background: var(--accent); color: #fff; box-shadow: 0 1px 0 var(--accent-d); }
.ph-adjfoot.cmp3, .ph-lookfoot.cmp3 { grid-template-columns: auto 1fr 1.3fr; }
.ph-adjfoot .ph-cmp, .ph-lookfoot .ph-cmp { width: 44px; padding: 0; }
.ws-photo.comparing .wsx-canvas { cursor: default; }
.ph-before { position: fixed; z-index: 9; left: 50%; top: calc(80px + var(--st)); transform: translateX(-50%); padding: 7px 14px; border-radius: 14px; background: rgba(42, 36, 64, 0.82); color: #fff; font-size: 13px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; pointer-events: none; }
.ph-before.hidden { display: none; }

@media (max-width: 760px) {
  .wsx-panel { top: auto; bottom: calc(160px + var(--sb)); right: 10px; width: min(330px, calc(100vw - 20px)); max-height: 56vh; align-items: flex-end; }
  .wsx-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin-top: 8px; order: 2; }
  .wsx-panel-tab .ic { width: 18px; height: 18px; }
  .wsx-panel-body { display: none; width: 100%; }
  .wsx-panel.open .wsx-panel-body { display: flex; }
  .wsx .wsx-opts .pill:not(.txt) span { display: none; }
  .wsx .wsx-opts .pill { padding: 0 13px; }
  .wsx .wsx-opts .seg button span { display: none; }
  .wsx .wsx-opts .ph-optsl > span { display: none; }
  .wsx .wsx-opts .ph-optsl .w3-sl { width: 96px; }
  .wsx .wsx-opts .opt-label { display: none; }
  .wsx-zoom { display: none; }
  .wsx .wsx-dock .tool-btn { width: 58px; }
}
/* photo editor on phones: the panel sits just above the (wrapping) options bar; sliders keep their names */
@media (max-width: 760px) {
  .ws-photo .wsx-panel { bottom: calc(112px + var(--ph-optsh, 56px) + var(--sb)); max-height: min(60vh, calc(100vh - 196px - var(--ph-optsh, 56px) - var(--st) - var(--sb))); }
  .ws-photo .wsx-opts .ph-optsl { padding: 0 2px 0 8px; gap: 6px; }
  .ws-photo .wsx-opts .ph-optsl span { display: inline; font-size: 13px; }
  .ws-photo .wsx-opts .ph-optsl .w3-sl { width: 88px; }
  .ws-photo .wsx-opts .ph-optv { min-width: 0; }
  .ws-photo .wsx-opts .opts { gap: 6px; padding: 6px; max-width: calc(100vw - 16px); }
  .ws-photo .wsx-opts .ph-grp { gap: 6px; }
  .ws-photo .ph-start-card { padding: 22px 16px 16px; }
}
/* photo editor on a phone held sideways: tools bottom left, options beside them, layers behind a button */
@media (max-height: 500px) and (min-width: 561px) {
  .ws-photo .wsx-rail { top: calc(50% + 34px); }
  .ws-photo .wsx-rail .size-slider { height: min(150px, calc(100vh - 290px)); }
  .ws-photo .wsx-dock { left: calc(84px + var(--sl)); transform: none; gap: 3px; padding: 6px; border-radius: 24px; }
  .ws-photo .wsx-dock .tool-btn { width: 50px; height: 50px; border-radius: 17px; }
  .ws-photo .wsx-dock .tool-btn .ic { width: 27px; height: 27px; }
  .ws-photo .wsx-dock .tool-btn span { display: none; }
  .ws-photo .wsx-dock .tool-btn.on { transform: translateY(-2px); box-shadow: 0 3px 0 var(--accent-d); }
  .ws-photo .wsx-opts { left: calc(var(--ph-dockr, 420px) + 10px); right: calc(14px + var(--sr)); bottom: calc(14px + var(--sb)); }
  .ws-photo .wsx-opts .opts { max-width: 100%; padding: 5px; gap: 6px; border-radius: 22px; }
  .ws-photo .wsx-opts .ph-grp { gap: 6px; }
  .ws-photo .wsx-opts .pill { height: 42px; padding: 0 12px; font-size: 14px; }
  .ws-photo .wsx-opts .pill:not(.txt) span { display: none; }
  .ws-photo .wsx-opts .seg button { height: 36px; min-width: 40px; padding: 0 9px; font-size: 13.5px; }
  .ws-photo .wsx-opts .seg button .ic + span { display: none; }
  .ws-photo .wsx-opts .ph-optsl { padding: 0 2px 0 6px; gap: 6px; font-size: 13px; }
  .ws-photo .wsx-opts .ph-optsl .w3-sl { width: 84px; }
  .ws-photo .wsx-opts .opt-label { display: none; }
  .ws-photo .wsx-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(10px + var(--sr)); width: min(300px, calc(100vw - 20px)); max-height: calc(100vh - 86px - var(--st) - var(--sb)); align-items: flex-end; }
  .ws-photo .wsx-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin: 0 0 6px; flex: none; }
  .ws-photo .wsx-panel-tab .ic { width: 18px; height: 18px; }
  .ws-photo .wsx-panel-body { display: none; width: 100%; }
  .ws-photo .wsx-panel.open .wsx-panel-body { display: flex; }
}
.pixelated img, img.pixelated, .pixelated canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.px-size-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .px-size-grid { grid-template-columns: repeat(2, 1fr); } }

.wsx-panel .hslider { height: 36px; }
.wsx-panel .hslider .sl-thumb { width: 36px; height: 36px; left: calc(var(--f, 0) * (100% - 36px)); }
.wsx-panel .hslider .sl-thumb span { transform: scale(0.8); }

/* pixel art */
.ws-pixel .wsx-opts { bottom: calc(178px + var(--sb)); }
.ws-pixel .wsx-panel { max-height: calc(100vh - 300px - var(--st) - var(--sb)); }
.ws-pixel .px-frames { left: calc(92px + var(--sl)); right: calc(300px + var(--sr)); }
.px-frames .af canvas { image-rendering: pixelated; image-rendering: crisp-edges; background: var(--checker); }
.px-show-phone { display: none !important; }
.px-cur { display: flex; align-items: center; gap: 10px; padding: 2px 2px 4px; }
.px-cursw { width: 40px; height: 40px; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.15), 0 3px 0 var(--press); flex: none; }
.px-curhex { flex: 1; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }
.px-palname { height: 36px; font-size: 13.5px; gap: 6px; justify-content: flex-start; }
.px-palname .ic { width: 17px; height: 17px; color: var(--accent); }
.px-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.px-sw { aspect-ratio: 1; border-radius: 7px; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.14); transition: transform 0.12s, box-shadow 0.12s; }
.px-sw:hover { transform: scale(1.12); }
.px-sw.on { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--accent); transform: scale(1.06); z-index: 1; }
.ws-pixel .wsx-panel-body > * { flex-shrink: 0; } /* a short panel scrolls; its rows never squash to nothing */
.px-layers { border-top: 2px solid #f1eff8; padding-top: 6px; }
.px-layers h4 { margin: 2px 4px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.px-layers .ph-lthumb { width: 36px; height: 36px; object-fit: contain; }
.px-col { display: none; }
.px-shade button { padding: 0 12px; font-size: 13.5px; }
@media (max-width: 760px) {
  .ws-pixel .px-frames { left: 8px; right: 8px; bottom: calc(84px + var(--sb)); flex-wrap: nowrap; gap: 6px; padding: 6px; }
  .ws-pixel .px-frames .ab-strip { order: 0; flex-basis: auto; }
  .ws-pixel .px-frames .ab-controls { order: -1; }
  .ws-pixel .wsx-panel { right: calc(62px + var(--sr)); width: min(300px, calc(100vw - 80px)); }
  .ws-pixel .px-frames .ab-adds { order: 0; margin-left: 0; }
  .px-hide-phone { display: none !important; }
  .px-show-phone { display: grid !important; }
  .ws-pixel .wsx-opts { bottom: calc(170px + var(--sb)); }
  .ws-pixel .wsx-panel { bottom: calc(244px + var(--sb)); max-height: calc(100vh - 340px - var(--st) - var(--sb)); }
  .ws-pixel .wsx-panel-tab { display: none; }
  .ws-pixel .wsx-panel.open .wsx-panel-tab { display: inline-flex; }
  .px-col { display: flex; flex-direction: column; gap: 5px; position: fixed; z-index: 10; right: calc(8px + var(--sr)); top: calc(84px + var(--st)); bottom: calc(244px + var(--sb)); width: 46px; padding: 5px; overflow-y: auto; border-radius: 18px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); scrollbar-width: none; }
  .px-col::-webkit-scrollbar { display: none; }
  .px-col .px-sw { width: 36px; height: 36px; flex: none; }
  .wsx.empty .px-col { visibility: hidden; }
}
.px-colbtn { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: #f1eff8; }
.px-colbtn .ic { width: 20px; height: 20px; }
.px-rot90 .ic { transform: rotate(90deg); }
/* sideways phone (and short windows): the frames bar sits beside a compact dock,
   tool options go up top between the palette and the top bar, swatches run down the right */
@media (max-height: 520px) and (orientation: landscape) {
  .ws-pixel .wsx-zoom, .ws-pixel .wsx-top [data-a=help] { display: none; }
  .ws-pixel .wsx-rail { top: calc(96px + var(--st)); transform: none; }
  .ws-pixel .wsx-dock { left: auto; right: calc(62px + var(--sr)); bottom: calc(8px + var(--sb)); transform: none; gap: 2px; padding: 5px; border-radius: 22px; }
  .ws-pixel .wsx-dock .tool-btn { width: 50px; height: 50px; border-radius: 16px; }
  .ws-pixel .wsx-dock .tool-btn span { display: none; }
  .ws-pixel .wsx-dock .tool-btn .ic { width: 26px; height: 26px; }
  .ws-pixel .wsx-dock .tool-btn.on { transform: translateY(-2px); box-shadow: 0 3px 0 var(--accent-d); }
  .ws-pixel .px-frames { left: calc(70px + var(--sl)); right: calc(70px + var(--sr) + var(--px-dockw, 320px)); bottom: calc(8px + var(--sb)); flex-wrap: nowrap; gap: 4px; padding: 5px; border-radius: 20px; }
  .ws-pixel .px-frames .ab-controls, .ws-pixel .px-frames .ab-strip, .ws-pixel .px-frames .ab-adds { order: 0; flex-basis: auto; margin-left: 0; }
  .ws-pixel .px-frames .ab-strip { padding: 2px; gap: 4px; }
  .ws-pixel .px-frames .ab-btn, .ws-pixel .px-frames .ab-add { height: 40px; min-width: 40px; }
  .ws-pixel .px-frames .ab-play { width: 44px; }
  .ws-pixel .px-frames .af canvas { width: 40px !important; height: 40px !important; object-fit: contain; }
  .ws-pixel .px-hide-phone { display: none !important; }
  .ws-pixel .px-show-phone { display: grid !important; }
  .ws-pixel .wsx-opts { left: calc(100px + var(--sl)); top: calc(14px + var(--st)); bottom: auto; transform: translateY(-8px); }
  .ws-pixel .wsx-opts.show { transform: none; }
  .ws-pixel .wsx-opts .opts { max-width: calc(100vw - 124px - var(--sl) - var(--sr) - var(--px-topw, 320px)); padding: 4px; gap: 6px; border-radius: 24px; }
  .ws-pixel .wsx-opts .pill { height: 42px; padding: 0 12px; }
  .ws-pixel .wsx-opts .pill:not(.txt) span, .ws-pixel .wsx-opts .seg button span, .ws-pixel .wsx-opts .opt-label { display: none; }
  .ws-pixel .wsx-opts .seg { padding: 3px; }
  .ws-pixel .wsx-opts .seg button { height: 36px; }
  .ws-pixel .wsx-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(62px + var(--sr)); width: min(300px, calc(100vw - 160px)); max-height: calc(100vh - 160px - var(--st) - var(--sb)); }
  .ws-pixel .wsx-panel-tab { display: none !important; }
  .ws-pixel .wsx-panel-body { display: none; }
  .ws-pixel .wsx-panel.open .wsx-panel-body { display: flex; }
  .ws-pixel .px-col { display: flex; flex-direction: column; gap: 5px; position: fixed; z-index: 10; right: calc(8px + var(--sr)); top: calc(78px + var(--st)); bottom: calc(8px + var(--sb)); width: 46px; padding: 5px; overflow-y: auto; border-radius: 18px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); scrollbar-width: none; }
  .ws-pixel .px-col::-webkit-scrollbar { display: none; }
  .ws-pixel .px-col .px-sw { width: 36px; height: 36px; flex: none; }
  .wsx.ws-pixel.empty .px-col { visibility: hidden; }
}

/* voxel builder */
.ws-voxel .vx-info { font-variant-numeric: tabular-nums; min-width: 92px; cursor: pointer; }
.ws-voxel .wsx-panel { max-height: calc(100vh - 250px - var(--st) - var(--sb)); }
.ws-voxel .vx-mx.on { background: #ece6ff; color: var(--accent-d); }
.ws-voxel .vx-seg button { white-space: nowrap; }
.ws-voxel .vx-swempty { grid-column: 1 / -1; margin: 4px 4px 6px; font-size: 13px; color: var(--muted); }
.ws-voxel .vx-addcol[hidden] { display: none; }
/* three sizes on a two-column phone grid: the last one sits centred under the others */
@media (max-width: 560px) { .vx-size-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px); } }
/* the long ⋯ menu scrolls on short screens (landscape phones couldn't reach Main menu) */
/* a short panel scrolls rather than squashing its rows (the palette button used to vanish) */
.ws-voxel .wsx-panel-body > * { flex-shrink: 0; }
@media (max-height: 500px) and (min-width: 761px) {
  .ws-voxel .wsx-opts .opt-label { display: none; }
  .ws-voxel .wsx-panel { width: 240px; max-height: calc(100vh - 250px - var(--st) - var(--sb)); }
  .ws-voxel .px-cursw { width: 32px; height: 32px; border-radius: 10px; }
}
@media (max-width: 760px) {
  .ws-voxel .wsx-panel { right: calc(62px + var(--sr)); bottom: calc(160px + var(--sb)); width: min(300px, calc(100vw - 80px)); max-height: 52vh; }
  .ws-voxel .wsx-panel-tab { display: none; }
  .ws-voxel .wsx-panel.open .wsx-panel-tab { display: inline-flex; }
  .ws-voxel .px-col { bottom: calc(160px + var(--sb)); }
  .ws-voxel .vx-info { display: none; }
  /* Box and Extrude modes and the camera views keep their words: icons alone would be guesswork */
  .ws-voxel .wsx-opts .vx-seg button span, .ws-voxel .wsx-opts .pill.vx-lbl span { display: inline; }
  .ws-voxel .wsx-opts .vx-seg button { padding: 0 11px; }
  .ws-voxel .wsx-opts .pill.vx-lbl .ic { display: none; }
}
.v-fmt button { white-space: nowrap; }
@media (max-width: 480px) { .v-fmt .v-long { display: none; } .v-fmt button { padding: 0 11px; } }
@media (max-width: 480px) {
  /* every tool fits across the phone, no hidden scrolling */
  .ws-voxel .wsx-dock { width: calc(100vw - 16px - var(--sl) - var(--sr)); }
  .ws-voxel .wsx-dock .tool-btn { flex: 1 1 0; width: auto; min-width: 0; }
  .ws-voxel .wsx-opts .vx-seg button .ic { display: none; }
}

/* pattern maker */
.pt-style-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .pt-style-grid { grid-template-columns: repeat(2, 1fr); } }
.menu-note { margin: 14px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.pt-tsize { margin: 12px auto 0; width: max-content; }
.ws-pattern .pt-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 800; color: var(--ink); }
.ws-pattern .pt-chip .ic { width: 18px; height: 18px; color: var(--accent); }
.ws-pattern .pt-chip.on { background: #ece6ff; color: var(--accent-d); }
.pt-bgsw { width: 26px; height: 26px; border-radius: 9px; display: block; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.18); }
.pt-shapes button { padding: 0 9px; }
.pt-shapes button .ic { width: 20px; height: 20px; }
.pt-brushes button { padding: 0 14px; font-size: 14px; }
.pt-preview img { box-shadow: 0 4px 18px rgba(42, 36, 64, 0.16); border-radius: 6px; }
.pt-short { display: none; }
@media (max-width: 480px) { .pt-long { display: none; } .pt-short { display: inline; } }
.ws-pattern .ph-optsl .pt-slic { display: none; width: 20px; height: 20px; color: var(--muted); }
@media (max-width: 760px) {
  .ws-pattern .ph-optsl .pt-slic { display: block; }
  .ws-pattern .pt-chip span { display: none; }
  .ws-pattern .pt-chip { padding: 0 11px; }
  .ws-pattern .wsx-top [data-a=help], .ws-pattern .pt-bg { display: none; }
}
/* sideways phone: the rail starts under the palette (the background color is in the menu) */
@media (max-height: 520px) and (orientation: landscape) {
  .ws-pattern .wsx-rail { top: calc(96px + var(--st)); transform: none; }
  .ws-pattern .pt-bg { display: none; }
  .ws-pattern .wsx-opts .opts { max-width: calc(100vw - 2 * (78px + max(var(--sl), var(--sr)))); }
}
/* colors in Pixel Art are solid and Pattern Maker sets opacity per tool, so the wheel's opacity row would do nothing */
.ws-pixel .wsx-pal .pal-row:has(.pal-alpha), .ws-pattern .wsx-pal .pal-row:has(.pal-alpha) { display: none; }
/* long menus scroll on a phone held sideways instead of running off the screen */
.px-layers .pill:disabled { opacity: 0.4; }
/* greyed-out undo / redo stay solid, so the busy picture behind doesn't show through them */
.ws-pixel .wsx-rail .btn:disabled, .ws-pattern .wsx-rail .btn:disabled { opacity: 1; background: #f7f5fc; color: #cbc6da; box-shadow: 0 2px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.06); }

/* ================================================================ 3D: Blender-style navigation and modal transforms */
.w3-navgiz { position: fixed; top: calc(84px + var(--st)); right: calc(278px + var(--sr)); z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 6px; user-select: none; -webkit-user-select: none; }
.ng-ball { display: block; width: 92px; height: 92px; border-radius: 50%; cursor: grab; touch-action: none; }
.ng-ball:active { cursor: grabbing; }
.ng-btns { display: flex; gap: 6px; }
.ng-btn { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, 0.78); box-shadow: 0 2px 6px rgba(42, 36, 64, 0.12); display: grid; place-items: center; color: #4d466a; cursor: grab; touch-action: none; transition: background 0.15s, color 0.15s; }
.ng-btn .ic { width: 16px; height: 16px; }
.ng-btn:hover { background: #fff; color: var(--ink); }
.ng-btn.on { background: var(--accent); color: #fff; }
.ws3d[data-bd='night'] .ng-btn:not(.on) { background: rgba(255, 255, 255, 0.16); color: #e9e4ff; }
.ws3d.panel-open .w3-navgiz { opacity: 0.35; }
@media (max-width: 760px) { .w3-navgiz { right: calc(10px + var(--sr)); } }
@media (pointer: coarse) and (max-width: 900px), (max-height: 500px) { .w3-navgiz { display: none; } }
.w3-modal-hud {
  position: fixed;
  left: 50%;
  top: calc(84px + var(--st));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px 7px;
  border-radius: 14px;
  background: rgba(28, 24, 44, 0.88);
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(28, 24, 44, 0.25);
}
.w3-modal-hud .hud-main { display: flex; align-items: baseline; gap: 10px; }
.w3-modal-hud .op { font-weight: 900; }
.w3-modal-hud b { font-weight: 900; }
.w3-modal-hud small { opacity: 0.62; font-size: 11.5px; }
.w3-modal-hud .num { color: #ffd84d; }
.w3-modal-hud .ax-x { color: #ff7d93; }
.w3-modal-hud .ax-y { color: #84e693; }
.w3-modal-hud .ax-z { color: #7cb1ff; }
.w3-prop-ring { position: fixed; display: none; border-radius: 50%; border: 1.5px dashed rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(42, 36, 64, 0.35); pointer-events: none; z-index: 19; }
.ws3d.modal-on .w3-tipline, .ws3d.modal-on .w3-opts { opacity: 0; pointer-events: none; }

/* ================================================================ 3D: pro menus, menu bar, command search, Edit Mode */
.pmx-layer { position: fixed; inset: 0; z-index: 70; }
.pmx {
  position: fixed; min-width: 230px; max-width: 360px; max-height: calc(100vh - 12px); overflow-y: auto; overscroll-behavior: contain;
  padding: 5px; border-radius: 13px; background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 40px rgba(28, 22, 56, 0.26), 0 1px 3px rgba(28, 22, 56, 0.12), inset 0 0 0 1px rgba(42, 36, 64, 0.06);
  opacity: 0; transform: translateY(-3px); transition: opacity 0.09s, transform 0.12s; scrollbar-width: thin;
  font-weight: 750;
}
.pmx.show { opacity: 1; transform: none; }
.pmx-title { padding: 6px 10px 4px; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); }
.pmx-head { padding: 7px 10px 3px; font-size: 10.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); }
.pmx-sep { height: 1px; margin: 4px 6px; background: #ece9f4; }
.pmx-it { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 9px 0 7px; border-radius: 8px; font-size: 13.5px; text-align: left; color: var(--ink); white-space: nowrap; }
.pmx-it.hi:not(:disabled), .pmx-it:focus-visible { background: var(--accent); color: #fff; outline: none; }
.pmx-it.hi .pmx-k, .pmx-it.hi .pmx-ic { color: rgba(255, 255, 255, 0.85); }
.pmx-it:disabled { opacity: 0.38; cursor: default; }
.pmx-it.danger { color: var(--red-d); }
.pmx-it.danger.hi { background: var(--red); color: #fff; }
.pmx-ic, .pmx-ck { width: 17px; height: 17px; flex: none; display: grid; place-items: center; color: #8a83a3; }
.pmx-ic .ic, .pmx-ck .ic { width: 16px; height: 16px; }
.pmx-ck { border-radius: 5px; box-shadow: inset 0 0 0 1.5px #cfc9e2; }
.pmx-ck.on { background: var(--accent); color: #fff; box-shadow: none; }
.pmx-ck.on .ic { width: 13px; height: 13px; stroke-width: 3; }
.pmx-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pmx-k { margin-left: 14px; font-size: 12px; color: #9a94b2; font-weight: 700; letter-spacing: 0.3px; }
.pmx-arrow { display: grid; place-items: center; color: #9a94b2; }
.pmx-arrow .ic { width: 14px; height: 14px; }
.pmx-it.hi .pmx-arrow { color: #fff; }

.w3-bar { position: fixed; z-index: 11; left: calc(86px + var(--sl)); top: calc(14px + var(--st)); display: none; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.ws3d.pro .w3-bar { display: flex; }
.w3-bar > * { pointer-events: auto; }
.w3-menubar, .w3-head { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 13px; background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 4px 14px rgba(42, 36, 64, 0.12); }
.mb-t { height: 32px; padding: 0 11px; border-radius: 9px; font-size: 13.5px; color: #4d466a; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.mb-t .ic { width: 16px; height: 16px; }
.mb-t:hover { background: #f1eef9; color: var(--ink); }
.mb-t.on { background: var(--accent); color: #fff; }
.mb-t:first-child { background: #f3f0fb; color: var(--accent-d); }
.mb-t:first-child.on { background: var(--accent); color: #fff; }
.ws3d.editing .mb-t:first-child { background: #fff0dc; color: #b35a00; }
.ws3d.editing .mb-t:first-child.on { background: #ff8a1f; color: #fff; }
.w3-head .hb { width: 32px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #6a6386; }
.w3-head .hb .ic { width: 19px; height: 19px; }
.w3-head .hb:hover { background: #f1eef9; color: var(--ink); }
.w3-head .hb.on { background: var(--accent); color: #fff; }
.ws3d.editing .w3-head .hb.on.sm { background: #ff8a1f; }
.w3-head .hsep { width: 1px; height: 20px; margin: 0 4px; background: #e4e0f0; }
.w3-head .hlbl { font-size: 11px; color: var(--muted); padding: 0 4px 0 6px; letter-spacing: 0.4px; }
.w3-stats { font-size: 11.5px; color: rgba(42, 36, 64, 0.72); padding: 2px 6px; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); pointer-events: none !important; white-space: pre; line-height: 1.45; }
.ws3d[data-bd='night'] .w3-stats { color: rgba(240, 236, 255, 0.8); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.w3-stats b { color: #ff8a1f; font-weight: 900; }

.cmd-layer { position: fixed; inset: 0; z-index: 80; background: rgba(28, 24, 44, 0.18); opacity: 0; transition: opacity 0.12s; }
.cmd-layer.show { opacity: 1; }
.cmd-box { position: absolute; left: 50%; top: calc(80px + var(--st)); transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); border-radius: 16px; background: #fff; box-shadow: 0 24px 60px rgba(28, 22, 56, 0.3); overflow: hidden; }
.cmd-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid #efecf6; }
.cmd-in .ic { width: 20px; height: 20px; color: var(--accent); }
.cmd-in input { flex: 1; height: 52px; border: 0; outline: none; font: inherit; font-size: 17px; font-weight: 800; color: var(--ink); background: none; user-select: text; -webkit-user-select: text; }
.cmd-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 5px; }
.cmd-it { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.cmd-it.hi { background: var(--accent); color: #fff; }
.cmd-it.hi .cmd-p, .cmd-it.hi .pmx-k { color: rgba(255, 255, 255, 0.8); }
.cmd-it:disabled { opacity: 0.4; }
.cmd-l { white-space: nowrap; }
.cmd-p { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); font-weight: 700; }
.cmd-none { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }

.w3-box { position: fixed; z-index: 15; border: 1.5px dashed rgba(42, 36, 64, 0.75); background: rgba(255, 255, 255, 0.12); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); pointer-events: none; }
.w3-box.sub { border-color: #ff4d5e; background: rgba(255, 77, 94, 0.08); }
.ws3d.editing .w3-canvas { cursor: default; }
.ws3d.loopcut .w3-canvas { cursor: crosshair; }
.ws3d .w3-opts .pill.mode { padding: 0 12px; }
.ws3d.editing .w3-opts .pill.mode.on { background: #ff8a1f; color: #fff; }
.ws3d.editing .w3-dock .tool-btn.ed-op .ic { color: #ff8a1f; }
.ws3d.editing .w3-dock .tool-btn.ed-op:active .ic { color: #fff; }
/* the edit dock has more buttons: narrower on small screens */
@media (max-width: 900px) { .ws3d.editing .w3-dock .tool-btn span { display: none; } }
.ws3d.pro .w3-hint { top: 60%; }
.w3-shade .w3-seg { flex: 1; height: 32px; padding: 3px; border-radius: 11px; }
.w3-shade .w3-seg button { height: 26px; font-size: 12.5px; border-radius: 8px; }
.w3-asrow b { font-size: 12px; color: var(--muted); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.w3-asrow > span { width: 74px; }
.w3-asrow.hidden { display: none; }
.ws3d.no-side .w3-panel { display: none; }
.ws3d.no-side .w3-navgiz { right: calc(14px + var(--sr)); }
.w3-nrow input:disabled { opacity: 0.45; }
.w3-shade > span { width: 56px !important; }
.w3-shade .w3-seg button { padding: 0 4px; }
.ws3d.pro .w3-viewchip { display: none; }
@media (max-width: 1180px) {
  .mb-t { padding: 0 8px; font-size: 13px; }
  .mb-t .ic { display: none; }
}
/* properties: sections (Advanced) */
.w3-sec { border-top: 2px solid #f1eff8; margin: 4px -2px 0; padding: 2px 2px 4px; }
.w3-sec > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 6px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #6a6386; cursor: pointer; }
.w3-sec > summary::-webkit-details-marker { display: none; }
.w3-sec > summary::before { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; margin: 0 3px 0 2px; }
.w3-sec[open] > summary::before { transform: rotate(45deg); }
.w3-sec > summary:hover { color: var(--accent); }
.w3-cnt { font-style: normal; font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: #ece6ff; color: var(--accent-d); letter-spacing: 0; }
.w3-mods { display: flex; flex-direction: column; gap: 6px; padding: 2px 0 4px; }
.w3-mod { border-radius: 12px; background: #f7f5fc; box-shadow: inset 0 0 0 1px #ece8f6; overflow: hidden; }
.w3-mod.off { opacity: 0.6; }
.w3-mh { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 2px; font-size: 13px; }
.w3-mh b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.w3-mic { width: 18px; height: 18px; display: grid; place-items: center; color: var(--accent); margin-right: 3px; }
.w3-mic .ic { width: 16px; height: 16px; }
.w3-mfold { width: 20px; height: 24px; display: grid; place-items: center; color: #8a83a3; }
.w3-mfold .ic { width: 13px; height: 13px; transform: rotate(90deg); transition: transform 0.15s; }
.w3-mod.fold .w3-mfold .ic { transform: none; }
.w3-mod.fold .w3-mbody { display: none; }
.w3-mb { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: #9a94b2; }
.w3-mb .ic { width: 14px; height: 14px; }
.w3-mb:hover:not(:disabled) { background: #ebe6f8; color: var(--ink); }
.w3-mb.on { color: var(--accent); }
.w3-mb.x:hover { color: var(--red-d); }
.w3-mb:disabled { opacity: 0.3; }
.w3-mb[data-ma=up] .ic { transform: rotate(90deg); }
.w3-mbody { padding: 0 8px 7px; display: flex; flex-direction: column; gap: 3px; }
.w3-mrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #4d466a; min-height: 26px; }
.w3-mrow > span { flex: 1; min-width: 0; }
.w3-nf { width: 84px; flex: none; font: inherit; font-size: 12.5px; font-weight: 800; text-align: center; color: var(--ink); border: 0; border-radius: 7px; padding: 4px 4px; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; cursor: ew-resize; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.w3-nf:focus { outline: none; cursor: text; box-shadow: inset 0 0 0 2px var(--accent); user-select: text; -webkit-user-select: text; }
.w3-nf.scrub { background: #ece6ff; }
.w3-mrow select { font: inherit; font-size: 12.5px; font-weight: 800; color: var(--ink); border: 0; border-radius: 7px; padding: 3px 6px; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; max-width: 120px; }
.w3-ax { display: flex; gap: 3px; }
.w3-ax button { width: 26px; height: 24px; border-radius: 7px; font-size: 11.5px; font-weight: 900; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; color: #8a83a3; }
.w3-ax button.on.ax-x { background: #ff4d5e; color: #fff; box-shadow: none; }
.w3-ax button.on.ax-y { background: #22c070; color: #fff; box-shadow: none; }
.w3-ax button.on.ax-z { background: #2f7dff; color: #fff; box-shadow: none; }
.switch.sm { transform: scale(0.72); transform-origin: right; }
.w3-merr { margin: 0 8px 6px; padding: 4px 8px; border-radius: 8px; background: #ffe8ea; color: var(--red-d); font-size: 11.5px; line-height: 1.3; }
.w3-addmod { align-self: flex-start; height: 32px; padding: 0 12px; font-size: 12.5px; gap: 6px; }
.w3-addmod .ic { width: 15px; height: 15px; }
.ws3d.pro .w3-panel { width: 272px; }
.ws3d.pro .w3-navgiz { right: calc(300px + var(--sr)); }
/* a computer's panel: compact sliders in the sections */
.ws3d.pro .w3-sec .w3-row { padding: 1px 4px; font-size: 13px; }
.ws3d.pro .w3-sec .hslider { height: 26px; }
.ws3d.pro .w3-sec .hslider .sl-track { inset: 6px 0; border-radius: 8px; }
.ws3d.pro .w3-sec .hslider .sl-thumb { width: 26px; height: 26px; left: calc(var(--f, 0) * (100% - 26px)); }
.ws3d.pro .w3-sec .hslider .sl-thumb span { transform: scale(0.62); }
.w3-head .hb.hw { width: auto; padding: 0 9px 0 7px; gap: 5px; display: inline-flex; font-size: 12.5px; font-weight: 800; }
.w3-head .hb.hw .ic { width: 16px; height: 16px; }
.w3-snapmark { position: fixed; display: none; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #ff8a1f, 0 0 10px rgba(255, 138, 31, 0.8); pointer-events: none; z-index: 19; }
/* Render Image */
.w3-render { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; background: rgba(28, 24, 44, 0.45); padding: 16px; }
.w3r-card { width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 22px; background: #fff; box-shadow: 0 30px 80px rgba(20, 10, 50, 0.4); }
.w3r-head { display: flex; align-items: center; gap: 10px; }
.w3r-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.w3r-head b .ic { width: 20px; height: 20px; color: var(--accent); }
.w3r-n { flex: 1; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.w3r-view { position: relative; min-height: 0; flex: 1; border-radius: 14px; overflow: hidden; background: #f1eff8; display: grid; place-items: center; }
.w3r-cv { display: block; max-width: 100%; max-height: calc(100vh - 170px); width: auto; height: auto; }
.w3r-wait { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 15px; background: rgba(255, 255, 255, 0.55); }
.w3r-wait .ic { width: 34px; height: 34px; color: var(--accent); animation: w3spin 2.4s linear infinite; }
@keyframes w3spin { to { transform: rotate(360deg); } }
.w3-render.busy .w3r-wait { display: flex; }
.w3r-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(123, 92, 255, 0.15); }
.w3r-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.w3r-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.w3r-foot .seg { margin-right: auto; }
.w3r-foot .seg button { padding: 0 14px; }
.ws3d.drop-on::after { content: 'Drop a .glb, .gltf, .obj or .stl to open it'; position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 28px; display: grid; place-items: center; font-size: 22px; color: var(--accent-d); background: rgba(255, 255, 255, 0.55); pointer-events: none; z-index: 40; }
/* Sculpt Mode */
.w3-sculpt-ring { position: fixed; display: none; transform: translate(-50%, -50%); border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(42, 36, 64, 0.45), inset 0 0 0 1px rgba(42, 36, 64, 0.2); pointer-events: none; z-index: 19; }
.w3-sculpt-ring.adjust { background: radial-gradient(circle, rgba(123, 92, 255, calc(var(--s, 0.5) * 0.5)) 0%, transparent 70%); }
.w3-sculpt-ring.adjust::after { content: attr(data-label); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 8px; background: rgba(28, 24, 44, 0.85); color: #fff; font-size: 13px; white-space: nowrap; }
.ws3d.sculpting .w3-canvas { cursor: crosshair; }
.ws3d.sculpting .mb-t:first-child { background: #e3f6ff; color: #0f6f9c; }
.sc-sl { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 22px; background: #fff; box-shadow: 0 2px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.08); font-size: 13px; flex: none; }
.sc-sl .w3-sl { width: 120px; }
.sc-sl .hslider { height: 30px; }
.sc-sl .hslider .sl-track { inset: 9px 0; }
.sc-sl .hslider .sl-thumb { width: 30px; height: 30px; left: calc(var(--f, 0) * (100% - 30px)); }
.sc-sl .hslider .sl-thumb span { transform: scale(0.65); }
.sc-sl b { width: 38px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.ws3d.sculpting .w3-dock .tool-btn.sc-br .ic { color: #0f8fc9; }
.ws3d.sculpting .w3-dock .tool-btn.sc-br.on { background: #19a3e0; box-shadow: 0 4px 0 #0f6f9c; }
.ws3d.sculpting .w3-dock .tool-btn.sc-br.on .ic { color: #fff; }
@media (max-width: 1000px) { .ws3d.sculpting .w3-dock .tool-btn span { display: none; } }
.w3-m3 { flex-wrap: wrap; }
.w3-n3 { display: flex; gap: 3px; }
.w3-n3 .w3-nf { width: 52px; font-size: 11.5px; padding: 4px 2px; }
.w3-n3 .w3-nf.ax-x { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #ff4d5e66; }
.w3-n3 .w3-nf.ax-y { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #22c07066; }
.w3-n3 .w3-nf.ax-z { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #2f7dff66; }
