:root {
  color-scheme: light;
  --paper: #f2f0ea;
  --panel: #faf9f5;
  --ink: #20201e;
  --muted: #716f68;
  --line: #d6d2c8;
  --accent: #b9422c;
  --green: #277257;
  --shadow: 0 16px 36px rgb(38 35 29 / 12%);
  --palette-gap: 7px;
  --palette-stack-height:
    max(60px, calc(var(--palette-rows, 2) * 39px));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgb(242 240 234 / 96%);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) minmax(120px, 1fr);
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.topbar-link:hover {
  color: var(--accent);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  font-family: Georgia, serif;
  font-size: 19px;
}

.artwork-identity {
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.artwork-identity strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2vw, 23px);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artwork-identity span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.score {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.score span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.score strong {
  min-width: 44px;
  text-align: right;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
}

.section-kicker {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
}

.lobby-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: clamp(32px, 7vw, 76px) clamp(16px, 4vw, 40px);
}

.lobby-heading,
.browser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.lobby-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.lobby-heading h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
}

.lobby-status {
  color: var(--muted);
  font-size: 11px;
}

.player-form {
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--line);
}

.player-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.player-form-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
}

.player-form input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #aaa69c;
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
}

.player-form input:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(185 66 44 / 18%);
  outline-offset: 0;
}

.command-button {
  min-height: 38px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: white;
  cursor: pointer;
  display: inline-grid;
  grid-template-columns: 18px auto;
  place-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.command-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.command-button:hover:not(:disabled) {
  background: #3a3935;
}

.command-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.game-browser {
  padding-top: 22px;
}

.browser-heading {
  min-height: 42px;
}

.browser-heading h2 {
  margin: 0;
  font-size: 13px;
}

.game-list {
  border-top: 1px solid var(--line);
}

.game-list-row {
  min-height: 66px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
}

.game-list-primary,
.game-list-artwork {
  min-width: 0;
}

.game-list-primary strong,
.game-list-artwork strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-list-primary span,
.game-list-artwork span,
.game-player-count {
  color: var(--muted);
  font-size: 10px;
}

.game-status {
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
}

.game-status.running {
  color: var(--accent);
}

.join-button {
  min-width: 72px;
}

.empty-games {
  margin: 0;
  padding: 28px 0;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 15px;
  text-align: center;
}

.play-layout {
  width: min(1500px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 18px;
}

.countdown-band {
  width: 100%;
  height: 112px;
  display: grid;
  place-items: center;
  overflow: visible;
}

.countdown-band output {
  color: #000;
  font-family: Georgia, serif;
  font-size: 48px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.countdown-band.urgent output {
  color: #c1261d;
  font-size: 96px;
}

.game-shell {
  width: 100%;
  margin: 0 auto;
  padding: 10px clamp(16px, 3vw, 40px)
    calc(48px + var(--palette-stack-height));
}

.waiting-panel {
  min-height: 60px;
  margin: 4px 0 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
}

.duration-setting {
  display: grid;
  gap: 4px;
}

.duration-setting output {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.duration-control {
  display: flex;
  border: 1px solid var(--line);
}

.duration-control button {
  min-width: 58px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.duration-control button:last-child {
  border-right: 0;
}

.duration-control button.selected {
  background: var(--ink);
  color: white;
}

.duration-control button:disabled {
  cursor: default;
  opacity: 0.55;
}

.waiting-panel h2 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 500;
}

.waiting-player-list {
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
}

.waiting-player-list li {
  font-size: 11px;
  font-weight: 700;
}

.waiting-player-list small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.painting-picker {
  margin-bottom: 12px;
}

.painting-picker > header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.painting-picker h2 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.painting-picker-count {
  color: var(--muted);
  font-size: 11px;
}

.painting-grid {
  max-height:
    max(
      180px,
      calc(100svh - 314px - var(--palette-stack-height))
    );
  padding: 8px 6px 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  align-items: start;
  gap: 8px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.painting-option {
  min-width: 0;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.painting-option:hover:not(:disabled) {
  border-color: #a9a49a;
  background: var(--panel);
}

.painting-option.selected {
  border-color: var(--accent);
  background: var(--panel);
}

.painting-option:disabled {
  cursor: default;
}

.painting-option img {
  display: block;
  width: 100%;
  aspect-ratio: var(--painting-aspect, 1);
  border: 1px solid #c7c3b9;
  background: #ddd9d0;
  object-fit: contain;
}

.painting-option strong,
.painting-option span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.painting-option strong {
  margin-top: 5px;
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 500;
}

.painting-option span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.painting-picker[aria-busy="true"] .painting-option {
  pointer-events: none;
  opacity: 0.62;
}

.game-shell.choosing-painting .studio {
  display: none;
}

.leaderboard {
  min-width: 0;
  height: calc(100svh - 112px);
  margin-top: 38px;
  padding: 12px 0 130px 16px;
  border-left: 1px solid var(--line);
  position: sticky;
  top: 72px;
  overflow-y: auto;
}

.leaderboard > header {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.leaderboard h2 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.leaderboard-list {
  display: grid;
}

.leaderboard-player {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 9px;
}

.leaderboard-player.offline img {
  opacity: 0.48;
}

.leaderboard-player.offline .leaderboard-player-score {
  color: var(--muted);
}

.leaderboard-player img {
  width: 72px;
  aspect-ratio: var(--artwork-aspect, 1);
  border: 1px solid #c7c3b9;
  background: #ddd9d0;
  object-fit: cover;
}

.leaderboard-player-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.leaderboard-player-name {
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-player-name small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
}

.leaderboard-player-score {
  margin-top: 3px;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.connection-line {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b88932;
}

.connection-dot.connected {
  background: var(--green);
}

.connection-dot.offline {
  background: var(--accent);
}

.state-version {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.studio {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 36px);
}

.artboard {
  min-width: 0;
  width: min(
    100%,
    max(
      160px,
      calc(
        (100svh - 314px - var(--palette-stack-height))
        * var(--artwork-ratio, 1)
      )
    )
  );
  margin: 0;
  justify-self: center;
}

.board-label {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.image-stage {
  width: 100%;
  aspect-ratio: var(--artwork-aspect, 1);
  overflow: hidden;
  border: 1px solid #c7c3b9;
  background: #ddd9d0;
  box-shadow: var(--shadow);
}

.image-stage img,
.image-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.canvas-stage {
  position: relative;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#drawing-canvas {
  cursor: crosshair;
  touch-action: none;
}

.canvas-stage.precise-brush-cursor,
.canvas-stage.precise-brush-cursor #drawing-canvas {
  cursor: none;
}

.brush-cursor {
  position: absolute;
  left: var(--cursor-x);
  top: var(--cursor-y);
  z-index: 2;
  width: var(--cursor-width);
  height: var(--cursor-height);
  border: 1px solid white;
  border-radius: 50%;
  mix-blend-mode: difference;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.canvas-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 18px;
}

.canvas-loader[hidden] {
  display: none;
}

.tool-dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 25;
  width: min(1120px, calc(100% - 32px));
  min-height: calc(30px + var(--palette-stack-height));
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid #cbc7bc;
  background: rgb(250 249 245 / 97%);
  box-shadow: 0 14px 40px rgb(30 28 23 / 18%);
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
}

.tool-identity {
  min-width: 68px;
  height: 48px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
}

.tool-identity svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.dock-group {
  min-width: 0;
}

.dock-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.palette-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selected-colour {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border: 1px solid rgb(0 0 0 / 24%);
  background: var(--selected-colour);
}

.mix-button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.palette {
  min-width: 0;
  display: grid;
  gap: var(--palette-gap);
}

.palette-row {
  width: min(
    100%,
    calc(
      var(--row-colours, 1) * 32px
      + var(--row-group-gaps, 0) * var(--palette-gap)
    )
  );
  display: flex;
  gap: var(--palette-gap);
}

.palette-colour-group {
  display: grid;
  grid-template-columns: repeat(var(--group-colours, 1), minmax(0, 32px));
  gap: 0;
}

.colour-swatch {
  width: 100%;
  max-width: 32px;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgb(0 0 0 / 14%);
  border-radius: 0;
  background: var(--swatch);
  cursor: pointer;
  position: relative;
}

.colour-swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  background: var(--selection-pixel);
  pointer-events: none;
}

.colour-swatch:focus-visible,
.icon-button:focus-visible,
.size-button:focus-visible,
.new-button:focus-visible,
.command-button:focus-visible {
  outline: 3px solid rgb(185 66 44 / 30%);
  outline-offset: 2px;
}

.size-control {
  height: 36px;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(var(--size-count, 5), 38px);
}

.size-readout {
  display: block;
  min-height: 12px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 12px;
  text-align: center;
}

.size-button {
  width: 38px;
  height: 34px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.size-button:last-child {
  border-right: 0;
}

.size-button.active {
  background: var(--ink);
  color: white;
}

.size-button i {
  width: var(--dot-size);
  height: var(--dot-size);
  max-width: 22px;
  max-height: 22px;
  border-radius: 50%;
  background: currentColor;
}

.dock-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button,
.new-button {
  height: 38px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.icon-button svg,
.new-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button:hover:not(:disabled),
.size-button:hover,
.new-button:hover {
  border-color: #9f9a8f;
  background: #eeece6;
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.icon-button.quiet {
  border-color: transparent;
}

.new-button {
  padding: 0 14px 0 11px;
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  grid-template-columns: 18px auto;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.new-button:hover {
  background: #3a3935;
  border-color: #3a3935;
}

.debug-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 50;
  width: min(480px, 100%);
  padding: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 44px rgb(30 28 23 / 16%);
  transform: translateX(102%);
  transition: transform 180ms ease;
  overflow-y: auto;
}

.debug-drawer.open {
  transform: translateX(0);
}

.debug-drawer > header {
  min-height: 84px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-kicker {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
}

.debug-drawer h2 {
  margin: 3px 0 0;
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 500;
}

.debug-drawer header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.debug-content {
  padding: 20px;
}

.debug-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.debug-total strong {
  font-family: Georgia, serif;
  font-size: 44px;
  font-weight: 500;
  color: var(--accent);
}

.debug-total span {
  color: var(--muted);
  font-size: 12px;
}

.component-list {
  padding: 12px 0;
}

.component {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  padding: 10px 0;
}

.component-name {
  font-size: 12px;
  font-weight: 700;
}

.component-value {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.component-track {
  grid-column: 1 / -1;
  height: 5px;
  background: #dfdcd4;
}

.component-track i {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--green);
}

.component-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
}

.debug-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.debug-images figure {
  margin: 0;
}

.debug-images img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--line);
  background: white;
}

.debug-images figcaption {
  padding-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.constants {
  margin: 0;
  padding-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 11px;
}

.constants dt,
.constants dd {
  margin: 0;
}

.constants dd {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgb(20 19 17 / 36%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 116px;
  z-index: 60;
  max-width: min(420px, calc(100% - 32px));
  padding: 9px 12px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .leaderboard {
    height: auto;
    margin: 0;
    padding: 10px clamp(16px, 3vw, 40px) 0;
    border-bottom: 1px solid var(--line);
    border-left: 0;
    position: static;
    order: -1;
    overflow: hidden;
  }

  .leaderboard > header {
    display: none;
  }

  .leaderboard-list {
    grid-auto-columns: 180px;
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .leaderboard-player {
    padding: 6px 12px 8px 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .leaderboard-player img {
    width: 52px;
  }

  .tool-dock {
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px 14px;
  }

  .tool-identity {
    display: none;
  }

  .dock-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 680px) {
  :root {
    --palette-gap: 6px;
  }

  .topbar {
    min-height: 62px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 12px;
  }

  .lobby-shell {
    padding-top: 26px;
  }

  .player-form-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-list-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .game-list-artwork {
    grid-column: 1;
  }

  .game-player-count {
    grid-column: 2;
    grid-row: 1;
  }

  .join-button {
    grid-column: 2;
    grid-row: 2;
  }

  .waiting-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .waiting-player-list {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .duration-setting {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .duration-control button {
    flex: 1;
  }

  .countdown-band {
    height: 82px;
  }

  .countdown-band output {
    font-size: 34px;
  }

  .countdown-band.urgent output {
    font-size: 68px;
  }

  .painting-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .brand span:last-child {
    display: none;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .artwork-identity {
    text-align: left;
  }

  .artwork-identity strong {
    font-size: 16px;
  }

  .artwork-identity span {
    font-size: 10px;
  }

  .score {
    gap: 3px;
  }

  .score span {
    display: none;
  }

  .score strong {
    min-width: 40px;
    font-size: 22px;
  }

  .game-shell {
    padding: 6px 10px
      calc(162px + var(--palette-stack-height));
  }

  .painting-picker > header {
    min-height: 40px;
  }

  .painting-picker h2 {
    font-size: 17px;
  }

  .painting-grid {
    max-height:
      max(
        150px,
        calc(100svh - 570px - var(--palette-stack-height))
      );
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .painting-option {
    padding: 3px;
  }

  .studio {
    display: block;
  }

  .reference-board {
    display: grid;
    width: 100%;
    grid-template-columns: 84px 1fr;
    gap: 10px;
    margin-bottom: 8px;
  }

  .reference-board .board-label {
    grid-column: 2;
    grid-row: 1;
    height: 24px;
    justify-content: flex-start;
    gap: 4px;
  }

  .reference-board .image-stage {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: auto;
    height: 84px;
    justify-self: center;
  }

  .reference-board::after {
    content: attr(data-title);
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    color: var(--muted);
    font-family: Georgia, serif;
    font-size: 13px;
  }

  .canvas-board .board-label {
    height: 28px;
  }

  .canvas-board {
    width: min(
      100%,
      max(
        100px,
        calc(
          (100svh - 588px - var(--palette-stack-height))
          * var(--artwork-ratio, 1)
        )
      )
    );
  }

  .image-stage {
    box-shadow: 0 8px 20px rgb(38 35 29 / 12%);
  }

  .tool-dock {
    bottom: 0;
    width: 100%;
    min-height: calc(142px + var(--palette-stack-height));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    grid-template-columns: 1fr auto;
    padding: 9px 10px 10px;
  }

  .palette-group {
    grid-column: 1 / -1;
  }

  .palette-control {
    gap: 8px;
  }

  .selected-colour {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .palette-row {
    width: min(
      100%,
      calc(
        var(--row-colours, 1) * 27px
        + var(--row-group-gaps, 0) * var(--palette-gap)
      )
    );
    gap: var(--palette-gap);
  }

  .palette-colour-group {
    grid-template-columns: repeat(var(--group-colours, 1), minmax(0, 27px));
  }

  .colour-swatch {
    max-width: 27px;
  }

  .dock-actions {
    justify-content: space-between;
  }

  .new-button {
    margin-left: auto;
  }

  .toast {
    bottom: calc(152px + var(--palette-stack-height));
  }
}

@media (max-width: 390px) {
  :root {
    --palette-gap: 5px;
  }

  .colour-swatch {
    max-width: 25px;
  }

  .palette-row {
    width: min(
      100%,
      calc(
        var(--row-colours, 1) * 25px
        + var(--row-group-gaps, 0) * var(--palette-gap)
      )
    );
    gap: var(--palette-gap);
  }

  .palette-colour-group {
    grid-template-columns: repeat(var(--group-colours, 1), minmax(0, 25px));
  }

  .size-control {
    grid-template-columns: repeat(var(--size-count, 5), 34px);
  }

  .size-button {
    width: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
