@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/sourceserif4/SourceSerif4%5Bopsz%2Cwght%5D.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/sourceserif4/SourceSerif4-Italic%5Bopsz%2Cwght%5D.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --room: #0d0a07;
  --room-2: #1a130d;
  --brass: #a8834a;
  --brass-dark: #4a3519;
  --brass-light: #e3c58a;
  --mahogany: #3a1e12;
  --mahogany-dark: #22110a;
  --paper: #d9c9a3;
  --paper-edge: #b9a57b;
  --ink: #2b1d12;
  --ink-faded: #5b4630;
  --label: #e8d6ae;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --type: "Courier Prime", "Courier New", monospace;
  --desk-w: clamp(320px, 31vw, 420px);
}

* { box-sizing: border-box; }
/* the page itself never scrolls or bounces: a swipe down at the top of the desk must not pull the browser into a reload */
html, body { margin: 0; height: 100%; background: var(--room); color: var(--label); overscroll-behavior: none; }
body {
  font: 16px/1.4 var(--serif);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 35% 45%, var(--room-2), var(--room) 70%);
}

/* header */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 12px;
  min-height: 52px;
  border-bottom: 1px solid #2c2014;
  background: linear-gradient(#150f0a, #0f0b07);
}
.bar-title {
  margin: 0;
  font-weight: 500;
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--brass-light);
  white-space: nowrap;
}
.bar-where { margin: 0; flex: 1; min-width: 0; font-size: 15px; color: #b49e74; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; gap: 6px; align-items: center; }
.bar-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #4b3720;
  border-radius: 3px;
  color: var(--label);
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.bar-btn[aria-pressed="true"]#btn-register, .bar-btn[aria-pressed="true"]#btn-help { background: #2a1d10; border-color: var(--brass); }
.bar-btn:focus-visible, .tool:focus-visible, .slot:focus-visible, .plate:focus-visible, .paper button:focus-visible { outline: 2px solid var(--brass-light); outline-offset: 2px; }
.jam { color: var(--brass-light); }

/* the booth */
.booth {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr var(--desk-w);
  grid-template-rows: 1fr;
}
.wall {
  position: relative;
  min-width: 0;
  min-height: 0;
  touch-action: none;
  cursor: grab;
}
.wall.dragging { cursor: grabbing; }
.wall-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.wall-say {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  margin: 0;
  text-align: center;
  font-style: italic;
  font-size: 16px;
  color: #c9b48a;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}

/* the desk: mahogany, brass carriage, crate */
.desk {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background-color: var(--mahogany);
  background-image:
    repeating-linear-gradient(92deg, rgba(0,0,0,0.0) 0 7px, rgba(0,0,0,0.12) 7px 9px, rgba(255,200,150,0.03) 9px 15px),
    linear-gradient(180deg, #43241a, #2a150c 60%, #1d0e07);
  background-size: cover;
  box-shadow: inset 8px 0 18px rgba(0,0,0,0.6);
}
.desk.textured { background-blend-mode: multiply, normal; }

/* the lantern: a riveted brass lamp-house whose mica window burns with the wall's flame (--flame, set each frame), and under
   it the carriage, a brass frame with four glass slots */
.lantern { display: flex; flex-direction: column; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.55)); }
.lamp-house {
  position: relative;
  height: 22px;
  margin: 0 14% -1px;
  border-radius: 5px 5px 0 0;
  background:
    radial-gradient(circle at 8px 50%, #f0d9a2 0 1.5px, #5a3f1c 2.5px, transparent 3px),
    radial-gradient(circle at calc(100% - 8px) 50%, #f0d9a2 0 1.5px, #5a3f1c 2.5px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(255,240,200,0.06) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #8c6a35, #5d4220 55%, #3c2a12);
  box-shadow: inset 0 1px 0 rgba(255,230,170,0.45);
}
.lamp-window {
  position: absolute; left: 50%; top: 5px; width: 34px; height: 12px; margin-left: -17px;
  border-radius: 6px 6px 2px 2px;
  background: radial-gradient(ellipse at 50% 85%, #fff2c8 0 12%, #f3b25a 38%, #7a3a12 80%, #2a1206);
  box-shadow: inset 0 0 0 1px #2a1a08, 0 0 calc(var(--flame, 1) * 14px) rgba(255,190,90,0.55);
  opacity: calc(0.55 + var(--flame, 1) * 0.4);
}
.lamp-lens {
  position: absolute; left: -12px; top: 3px; width: 14px; height: 16px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #b8955a, #6b4e24);
  box-shadow: inset -2px 0 0 #3c2a12;
}
.carriage {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 9px 9px 7px;
  border-radius: 4px;
  background:
    radial-gradient(circle at 5px 5px, #f3dfae 0 1.4px, #4a3519 2.4px, transparent 3px),
    radial-gradient(circle at calc(100% - 5px) 5px, #f3dfae 0 1.4px, #4a3519 2.4px, transparent 3px),
    radial-gradient(circle at 5px calc(100% - 5px), #f3dfae 0 1.4px, #4a3519 2.4px, transparent 3px),
    radial-gradient(circle at calc(100% - 5px) calc(100% - 5px), #f3dfae 0 1.4px, #4a3519 2.4px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(255,240,200,0.05) 0 1px, rgba(0,0,0,0.04) 1px 2px, transparent 2px 4px),
    linear-gradient(180deg, #d4b175, var(--brass) 24%, #7c5d2e 80%, var(--brass-dark));
  box-shadow: 0 2px 0 #120a05, inset 0 1px 0 var(--brass-light), inset 0 -2px 0 rgba(0,0,0,0.35);
}
.slot {
  position: relative;
  min-height: 72px;
  padding: 3px 3px 18px;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #0c0805, #1d150c);
  box-shadow: inset 0 3px 5px #000, inset 0 -1px 0 rgba(255,230,170,0.25), 0 1px 0 var(--brass-light);
  cursor: pointer;
  touch-action: none;
}
.slot { min-width: 0; }
.slot canvas { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; height: auto; }
/* a seated plate: a bevelled glass edge catching the flame along its top */
.slot:not(.empty) canvas { box-shadow: 0 0 0 1px rgba(210,225,230,0.28), 0 -1px 0 1px rgba(255,236,190,calc(var(--flame, 1) * 0.18)), 0 2px 3px rgba(0,0,0,0.8); }
.slot .slot-n {
  position: absolute; left: 0; right: 0; bottom: 1px;
  font-size: 14px; line-height: 16px; text-align: center; color: #d8c08a; font-style: italic;
}
.slot.empty canvas { opacity: 0.15; }
.slot.selected { box-shadow: inset 0 3px 5px #000, 0 0 0 2px var(--brass-light); }
.slot.drop { box-shadow: inset 0 0 0 2px #f1dfb1; }
.slot.lifting canvas { opacity: 0.35; }
/* the plate drops into its groove and settles */
.slot.settle canvas { animation: settle 0.3s cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes settle {
  0% { transform: translateY(-9px); box-shadow: 0 9px 8px rgba(0,0,0,0.6); }
  62% { transform: translateY(1px); }
  80% { transform: translateY(-1px); }
  100% { transform: none; }
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tools.idle .tool { opacity: 0.45; }
.pad { display: inline-flex; gap: 4px; }
.pieces { display: contents; }
/* the carriage's tools are brass tabs screwed to the frame: a cut brass face with two screw heads and an engraved label, the
   arrows round knurled knobs; pressed, the tab sinks into the rail and its face darkens */
.tool {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px 7px 3px 3px;
  background:
    radial-gradient(circle at 7px 50%, #f3dfae 0 1.3px, #4a3519 2.2px, transparent 2.8px),
    radial-gradient(circle at calc(100% - 7px) 50%, #f3dfae 0 1.3px, #4a3519 2.2px, transparent 2.8px),
    repeating-linear-gradient(90deg, rgba(255,240,200,0.06) 0 1px, rgba(0,0,0,0.05) 1px 2px, transparent 2px 4px),
    linear-gradient(180deg, #d8b679, #a8834a 30%, #7c5d2e 82%, #5a4120);
  box-shadow: inset 0 1px 0 #f0d9a4, inset 0 -2px 0 rgba(0,0,0,0.35), 0 2px 0 #120a05, 0 3px 4px rgba(0,0,0,0.5);
  color: #2a1a0a;
  text-shadow: 0 1px 0 rgba(255,236,190,0.45);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.tool:active, .tool.piece[aria-pressed="true"], .tool[data-act="inspect"][aria-pressed="true"] {
  background:
    radial-gradient(circle at 7px 50%, #e3c58a 0 1.3px, #3a2810 2.2px, transparent 2.8px),
    radial-gradient(circle at calc(100% - 7px) 50%, #e3c58a 0 1.3px, #3a2810 2.2px, transparent 2.8px),
    linear-gradient(180deg, #6e522a, #8e6e3c 40%, #a8834a);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 1px 0 #120a05;
  transform: translateY(1px);
}
.tool.arrow {
  padding: 0; width: 44px; font-size: 19px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #d8b679 0 13px, transparent 14px),
    repeating-conic-gradient(#8e6e3c 0 6deg, #5a4120 6deg 12deg);
  box-shadow: inset 0 0 0 2px #4a3519, 0 2px 0 #120a05, 0 3px 4px rgba(0,0,0,0.5);
}
.tool.arrow:active { background: radial-gradient(circle at 50% 50%, #a8834a 0 13px, transparent 14px), repeating-conic-gradient(#6e522a 0 6deg, #4a3519 6deg 12deg); }
.tool[aria-disabled="true"] { cursor: default; }
/* Hint and Empty are the old tarnished tabs at the desk's foot */
.tool.quiet { background: linear-gradient(180deg, #6b5a3a, #4f4027 60%, #3a2e1b); color: #e8d6ae; text-shadow: 0 -1px 0 rgba(0,0,0,0.5); font-weight: 400; }
.tool:disabled { opacity: 0.35; cursor: default; }

/* the catalogue card is a lot card: cream stock, a printed rule inset from its edge, foxing at the corners, pinned at its
   top left with a brass pin, and the card's number among the thirty stamped in red at the top right ("No.", since the
   plates in the crate carry their own lot numbers) */
.card {
  position: relative;
  margin: 2px 0 0;
  padding: 10px 70px 10px 22px;
  background:
    radial-gradient(circle at 96% 92%, rgba(120,80,30,0.16), transparent 30%),
    radial-gradient(circle at 4% 100%, rgba(120,80,30,0.12), transparent 25%),
    linear-gradient(176deg, #e4d6b2, var(--paper) 60%, #cdbb92);
  color: var(--ink);
  font-size: 16px;
  border-radius: 1px;
  outline: 1px solid rgba(70,45,20,0.35);
  outline-offset: -5px;
  box-shadow: inset 0 0 10px rgba(120,80,30,0.3), 0 2px 6px rgba(0,0,0,0.55);
  transform: rotate(-0.6deg);
}
.card::before {
  content: ""; position: absolute; top: 7px; left: 7px; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6e6bb, #a8834a 45%, #4a3519);
  box-shadow: 1px 2px 2px rgba(0,0,0,0.55);
}
.card[data-lot]::after {
  content: "No. " attr(data-lot); position: absolute; top: 8px; right: 9px;
  padding: 1px 5px; border: 2px solid rgba(150,40,30,0.7); border-radius: 2px;
  color: rgba(150,40,30,0.78); font: 13px/1.2 var(--type); letter-spacing: 0.06em;
  transform: rotate(5deg);
}
.card:empty::before, .card:empty::after { display: none; }
.card b { font-weight: 600; }

/* the crate: deal boards round a bed of sacking and straw (the straw is drawn once into a canvas behind the plates) */
/* the crate is last in the desk and gives up its height first: it scrolls inside its boards so the tabs above it stay whole */
.crate-box {
  position: relative;
  order: 2;
  flex: 1 1 0;
  min-height: 132px;
  display: flex;
  border: 7px solid #4a2e17;
  border-top-color: #5b3a1e;
  border-bottom-color: #2e1b0d;
  border-radius: 2px;
  background:
    repeating-linear-gradient(0deg, rgba(60,40,18,0.35) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(60,40,18,0.3) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #6b5532, #4c3b20);
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.85), 0 0 0 1px #160b05, inset 0 0 0 1px #1a0d05, 0 3px 6px rgba(0,0,0,0.6);
}
.straw { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crate {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px 8px;
  align-content: start;
  padding: 10px;
  overflow-y: auto;
}
/* plates past the right edge: the straw darkens toward the boards and an arrow points on */
.crate-box.more::after {
  content: "\2192";
  position: absolute; top: 0; right: 0; bottom: 0; width: 34px;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 3px;
  background: linear-gradient(90deg, rgba(20,12,5,0), rgba(20,12,5,0.92) 70%);
  color: var(--brass-light); font-size: 20px; text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.plate {
  position: relative;
  padding: 4px 4px 6px;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #2b2116, #1e170f);
  box-shadow: 0 3px 5px rgba(0,0,0,0.75), inset 0 0 0 3px #11100c, inset 0 1px 0 4px rgba(255,236,190,0.06);
  cursor: grab;
  touch-action: none;
  text-align: center;
  min-height: 44px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}
/* plates stand a little askew in the straw */
.plate:nth-child(3n+1) { transform: rotate(-0.9deg); }
.plate:nth-child(3n+2) { transform: rotate(0.7deg) translateY(1px); }
.plate:nth-child(4n+3) { transform: rotate(-0.4deg) translateY(-1px); }
.plate { min-width: 0; }
.plate canvas { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; height: auto; box-shadow: 0 0 0 1px rgba(210,225,230,0.18); }
.plate .plate-name { display: block; margin-top: 3px; font-size: 14px; line-height: 1.2; color: #e2cfa4; font-style: italic; text-shadow: 0 1px 2px #000; }
.plate.selected { box-shadow: 0 0 0 2px var(--brass-light), 0 3px 5px rgba(0,0,0,0.75); }
.plate.placed { filter: brightness(0.42) saturate(0.4); }
/* pushed out of its slot by another plate: it still holds its turn and position, marked by a brass clip on its frame */
.plate.kept::after { content: ""; position: absolute; top: -3px; right: 10px; width: 7px; height: 12px; border-radius: 1px; background: linear-gradient(90deg, #7c5d2e, var(--brass-light), #7c5d2e); box-shadow: 0 1px 2px #000; }
/* lifted out of the straw: it rises and its shadow drops away from it */
.plate.lifting { transform: translateY(-5px) scale(1.03); box-shadow: 0 14px 14px rgba(0,0,0,0.7), inset 0 0 0 3px #11100c; opacity: 0.55; }
.ghost {
  position: fixed;
  z-index: 50;
  width: 110px;
  pointer-events: none;
  transform: translate(-50%, -60%) rotate(-3deg);
  box-shadow: 0 0 0 1px rgba(210,225,230,0.3), 10px 22px 18px rgba(0,0,0,0.55), 3px 6px 5px rgba(0,0,0,0.45);
}
.ghost canvas { display: block; width: 100%; }

.desk-foot { order: 1; display: flex; gap: 8px; justify-content: space-between; }

/* paper panels: title, intros, register, help, credits; they cover the desk, never the wall */
.panel {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  z-index: 10;
  min-height: 0;
  padding: 10px;
  transform: translateX(105%);
  transition: transform 0.35s ease;
  pointer-events: none;
  display: flex;
}
.panel.open { transform: none; pointer-events: auto; background: rgba(18,9,4,0.94); }
.paper {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  padding: 22px 22px 18px;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,250,230,0.35), transparent 60%),
    radial-gradient(circle at 85% 80%, rgba(120,80,30,0.18), transparent 35%),
    var(--paper);
  color: var(--ink);
  border-radius: 2px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.7), inset 0 0 40px rgba(120,85,40,0.35);
}
.paper h2 { margin: 0 0 6px; font-weight: 500; font-size: 30px; line-height: 1.1; }
.paper h2.big { font-size: 34px; }
.paper h3 { margin: 18px 0 4px; font-weight: 600; font-size: 17px; }
.paper p { margin: 0 0 12px; }
.paper .goal { font-size: 18px; font-style: italic; }
.paper .small { font-size: 16px; font-style: italic; color: var(--ink-faded); }
.paper .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.paper button, .paper a.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.paper button.primary { background: var(--ink); color: var(--paper); }
.paper button.danger { border-color: #7a2a1a; color: #7a2a1a; }
.paper .hide-panel { float: right; margin: -8px -8px 0 8px; }
.paper canvas.heading { display: block; max-width: 100%; height: auto; }
.paper input[type="file"] { display: none; }

/* every paper carries the plaster's grain, softly; the register's pages are a ruled ledger with a red double margin and a blot */
.paper { background-color: var(--paper); }
.paper { background-image: radial-gradient(ellipse at 20% 10%, rgba(255,250,230,0.35), transparent 60%), radial-gradient(circle at 85% 80%, rgba(120,80,30,0.18), transparent 35%), var(--grain, none); background-size: auto, auto, 300px; background-blend-mode: normal, normal, soft-light; }
.register { position: relative; font-family: var(--type); font-size: 16px; }
.register::after {
  content: "";
  position: absolute; right: 6%; top: -14px; width: 26px; height: 20px;
  pointer-events: none;
  background:
    radial-gradient(ellipse 9px 7px at 45% 50%, rgba(28,20,30,0.78) 70%, transparent 100%),
    radial-gradient(circle 3px at 88% 30%, rgba(28,20,30,0.7) 60%, transparent 100%),
    radial-gradient(circle 2px at 12% 82%, rgba(28,20,30,0.6) 60%, transparent 100%),
    radial-gradient(ellipse 13px 9px at 50% 52%, rgba(40,30,40,0.18), transparent 100%);
  transform: rotate(-14deg);
}
.register ol { margin: 8px 0 0; padding: 0 0 0 0; list-style: none; counter-reset: reg; border-top: 2px solid rgba(60,80,120,0.4); }
.register li { padding: 5px 0; border-bottom: 1px solid rgba(60,80,120,0.32); display: flex; gap: 10px; min-width: 0; }
.register li::before { counter-increment: reg; content: counter(reg) "."; flex: 0 0 36px; margin: -5px 0; padding: 5px 0; color: var(--ink-faded); border-right: 3px double rgba(150,40,30,0.5); }
.register li > * { min-width: 0; }
.register li.new { background: rgba(255,240,200,0.4); }
.register li canvas { display: block; max-width: 100%; height: auto; min-width: 0; }
.register .caret { display: inline-block; width: 0.55em; border-bottom: 2px solid var(--ink); animation: blink 0.9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* portrait and narrow: wall on top, desk below */
@media (orientation: portrait), (max-width: 760px) and (min-height: 501px) {
  .bar { gap: 6px; padding: 4px 6px; }
  .bar-title { display: none; }
  .bar-where { font-size: 15px; }
  .bar-btn { padding: 0 9px; font-size: 15px; }
  .booth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .wall { aspect-ratio: 16 / 11.5; max-height: 50dvh; width: 100%; }
  .desk { grid-column: 1; grid-row: 2; min-width: 0; padding: 8px; gap: 8px; box-shadow: inset 0 8px 18px rgba(0,0,0,0.6); }
  .panel { grid-column: 1; grid-row: 2; padding: 6px; transform: translateY(105%); }
  .crate-box { flex: 0 0 auto; min-height: 0; border-width: 5px; }
  /* four plates to a row, so nothing lies past the edge; a seven-plate crate takes two rows */
  .crate { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 6px; overflow: visible; padding: 8px; }
  .slot { min-height: 64px; }
  .lamp-house { height: 16px; }
  .lamp-window { top: 3px; height: 10px; }
  .lamp-lens { top: 1px; height: 14px; }
  .tool { padding: 0 14px; }
  .paper { padding: 16px; }
  .paper h2 { font-size: 26px; }
}
@media (orientation: portrait) and (max-width: 560px) {
  .bar { flex-wrap: wrap; row-gap: 0; padding-top: 2px; }
  .bar-where { order: -1; flex: 1 0 100%; font-size: 15px; line-height: 22px; text-align: center; }
  .bar-tools { flex: 1; justify-content: space-between; }
}
/* under 360 px the four word tabs become marks (their names stay as aria-labels and tooltips), so the tools take two rows */
@media (max-width: 359px) {
  .tools { gap: 4px; }
  .tool[data-act="rotate"], .tool[data-act="flip"], .tool[data-act="remove"], .tool[data-act="inspect"] { padding: 0; width: 44px; font-size: 0; }
  .tool[data-act="rotate"]::before { content: "\21BB"; }
  .tool[data-act="flip"]::before { content: "\21C6"; }
  .tool[data-act="remove"]::before { content: "\21A5"; }
  .tool[data-act="inspect"]::before { content: "\25A3"; }
  .tool[data-act]::before { font-size: 20px; font-weight: 400; }
  .card { padding-right: 64px; }
}

/* a phone on its side: the carriage, two rows of tools and the first row of the crate fit beside the wall unscrolled; the
   catalogue card is pinned in the dark above the wall's frame, and Hint and Empty sit under the crate */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --desk-w: min(400px, 50vw); }
  .bar { min-height: 44px; padding: 0 10px; }
  .bar-title { display: none; }
  .desk { flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 5px 6px; }
  .tools, .desk-foot { display: contents; }
  .lantern { order: 1; flex: 1 0 100%; }
  .lamp-house { display: none; }
  .carriage { padding: 4px 5px 3px; gap: 5px; }
  .slot { min-height: 0; padding: 2px 2px 15px; }
  .slot canvas { aspect-ratio: 16 / 7; }
  .slot .slot-n { line-height: 14px; }
  .tool { order: 2; padding: 0 12px; }
  .pad, [data-act="inspect"] { order: 3; }
  .desk { overflow-x: hidden; }
  .crate-box { order: 5; flex: 1 0 100%; min-height: 0; min-width: 0; max-width: 100%; border-width: 4px; }
  .crate { display: flex; overflow-x: auto; overflow-y: hidden; padding: 5px; gap: 6px; scrollbar-width: thin; }
  .crate .plate { flex: 0 0 calc((100% - 18px) / 4); }
  .plate .plate-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card {
    position: fixed; z-index: 5;
    top: calc(env(safe-area-inset-top) + 48px);
    left: calc(env(safe-area-inset-left) + 10px);
    width: calc(100vw - var(--desk-w) - env(safe-area-inset-left) - env(safe-area-inset-right) - 20px);
    padding: 3px 9px; font-size: 16px; line-height: 1.3;
    transform: none; opacity: 0.92;
  }
  .card:empty, .app:not([data-screen="play"]) .card { display: none; }
  .card::before, .card::after { display: none; }
  #btn-hint, #btn-reset { order: 7; }
  .paper { padding: 12px 14px; }
  .paper h2.big canvas.heading { max-width: 74%; }
  .paper .actions { margin-top: 8px; }
}

/* a phone either way up: the line under the wall gets a band of its own below the frame, so a caption never lies over the
   answer or the frame's edge */
@media (orientation: portrait), (max-width: 760px) and (min-height: 501px), (orientation: landscape) and (max-height: 500px) {
  .wall { display: flex; flex-direction: column; }
  .wall-canvas { position: relative; inset: auto; flex: 1 1 0; min-height: 0; height: auto; }
  .wall-say {
    position: static; flex: 0 0 auto; min-height: 40px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 8px; font-size: 15px; line-height: 19px;
  }
}

.plate.hinted, .slot.hinted, .tool.hinted { animation: hinted 1.2s ease-in-out infinite; }
@keyframes hinted { 50% { box-shadow: 0 0 0 3px #f4e4b8, 0 0 14px rgba(244,228,184,0.7); } }

/* the desk's and the crate's scrollbars in brass on the dark wood, not the browser's white track */
.desk, .crate { scrollbar-color: #9a7a48 #1c120a; }

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
  .register .caret { animation: none; }
  .plate.hinted, .slot.hinted, .tool.hinted { animation: none; box-shadow: 0 0 0 3px #f4e4b8; }
}
