@font-face {
  font-family: "Alegreya";
  src: url("./fonts/alegreya-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Alegreya";
  src: url("./fonts/alegreya-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  font-family: var(--game-font);
  color: #37281f;
  background: #2a1c16;
  --game-font: "Alegreya", Georgia, "Times New Roman", serif;
  --ink: #37281f;
  --muted: #654a36;
  --red-ink: #762f26;
  --paper: #efe1bf;
  --rule: #9d7751;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(ellipse at 50% 12%, #5b3e2f, transparent 64%), #2a1c16;
  -webkit-tap-highlight-color: transparent;
}

button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--red-ink); outline-offset: 3px; }
.cell:focus-visible { outline: 2px solid #ffe1a3; outline-offset: 1px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button:disabled { cursor: default; }

.game {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(100%, 438px);
  height: min(100%, 745px);
  min-height: 0;
  padding: max(19px, env(safe-area-inset-top)) max(25px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(25px, env(safe-area-inset-left));
  border: 1px solid #755337;
  background:
    radial-gradient(ellipse at 15% 12%, #fff8dd88, transparent 64%),
    radial-gradient(ellipse at 108% 72%, #a25d3036, transparent 55%),
    radial-gradient(ellipse at 18% 92%, #bd784421, transparent 52%),
    repeating-linear-gradient(13deg, transparent 0 2px, #834b2205 3px, transparent 5px 8px),
    var(--paper);
  box-shadow: inset 0 0 26px #8a472a28, 0 4px 0 #6d4331, 0 18px 34px #150c0973;
  touch-action: pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.game::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 5px;
  border: 1px solid #94664465;
  pointer-events: none;
}

.top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  justify-items: center;
  gap: 5px;
  margin-bottom: 12px;
}

.brand-title {
  position: relative;
  grid-area: 1 / 2;
  width: min(100%, var(--brand-width, clamp(148px, 42vw, 188px)));
  aspect-ratio: 5 / 2;
  overflow: clip;
  margin: 0;
}
.brand-title img {
  display: block;
  position: absolute;
  inset: 50% 0 auto;
  width: 100%;
  height: auto;
  transform: translateY(-53%);
}

#settings, #open-workshop-upgrades, #exit-boss { grid-area: 1 / 3; }
#mode-toggle { grid-area: 1 / 1; }
#open-workshop-upgrades { display: none; }
.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid #9d77518c;
  border-radius: 2px;
  background: #a479531a;
  color: #6a3e2e;
  box-shadow: inset 0 0 0 2px #fef0c75e;
  touch-action: manipulation;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
  padding: 7px 0 8px;
  border-block: 1px solid var(--rule);
}

.score-card { display: grid; justify-items: center; gap: 2px; }
.score-card + .score-card { border-inline-start: 1px solid #a17a4d70; }
.chapter-entry {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid #7a6f4d;
  border-radius: 3px;
  background: linear-gradient(120deg, #505b43, #383c30);
  color: #fff0cb;
  text-align: left;
  touch-action: manipulation;
}
.chapter-entry:disabled { background: #82634014; color: #604936; border-color: #957b5580; }
.chapter-entry .ui-icon { width: 20px; height: 20px; flex: none; }
.chapter-entry strong { font: 700 1.25rem / 1 var(--game-font); }
.chapter-call { margin-inline-start: auto; font: 700 .85rem / 1 var(--game-font); }
.chapter-progress {
  appearance: none;
  flex: 0 0 auto;
  width: clamp(56px, 30%, 116px);
  height: 5px;
  margin-inline-start: auto;
  overflow: hidden;
  border: 0;
  border-radius: 2px;
  background: #9d775155;
}
.chapter-progress::-webkit-progress-bar { background: transparent; }
.chapter-progress::-webkit-progress-value { background: #687250; }
.chapter-progress::-moz-progress-bar { background: #687250; }
.workshop-open .chapter-entry, .boss-active :is(#mode-toggle, #settings, .score-card) { display: none; }
.boss-active .scores {
  border: 1px solid #75523a;
  border-radius: 4px;
  padding: 0;
  background:
    repeating-linear-gradient(5deg, #d19b6514 0 1px, transparent 2px 6px),
    linear-gradient(140deg, #64432d, #37251e 78%);
  color: #faebc7;
  box-shadow: inset 0 0 0 2px #be8d5a48, 0 2px 0 #493021;
}
.boss-hud {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: clamp(42px, 14cqi, 66px) minmax(0, 1fr);
  grid-template-rows: auto var(--battle-quip-height);
  align-items: center;
  gap: 7px 10px;
  padding: 8px 9px;
}
.boss-medallion {
  grid-area: 1 / 1;
  aspect-ratio: 1;
  border: 1px solid #ad875c;
  border-radius: 50%;
  background: #201e19 url("./art/earth-portraits.webp") left top / 205% no-repeat;
}
.boss-hud:is([data-phase="hurt"], [data-phase="last"]) .boss-medallion { background-position: left bottom; }
.boss-hud:has(.boss-quip[data-speaking]) .boss-medallion { border-color: #f0c589; box-shadow: 0 0 0 2px #efba7840; }
.boss-gauges { grid-area: 1 / 2; min-width: 0; }
.boss-meta { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.boss-meta h2 { margin: 0; font: 700 clamp(1.25rem, 6cqi, 1.8rem) / .95 var(--game-font); }
#boss-health-label {
  border: 1px solid #ae8254a1;
  border-radius: 2px;
  padding: 3px 6px;
  background: #312018;
  color: #ffe0ac;
  white-space: nowrap;
  font: 700 .9rem / 1 var(--game-font);
  font-variant-numeric: tabular-nums;
}
.boss-health {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(1px, .7cqi, 3px);
  min-height: 26px;
  margin-top: 5px;
  padding: 3px;
  border: 1px solid #d5aa6c;
  border-radius: 3px;
  background: repeating-linear-gradient(130deg, #301f17 0 3px, #36241b 4px 6px);
  box-shadow: inset 0 0 0 1px #704322, inset 0 2px 5px #090503, 0 1px 3px #20130c;
}
.boss-health > span {
  position: relative;
  border-radius: 1px;
  background: linear-gradient(135deg, #edb16e, #bb6441 30%, #944532 72%, #572a24);
  box-shadow: inset 0 1px #ffdca7d1, inset 1px 0 #d69765, inset 0 -2px #6a3429;
  transition: opacity 260ms ease-out;
}
.boss-health > span:nth-child(4n):not(:last-child) { margin-inline-end: 2px; }
.boss-health > span[data-spent] { opacity: .18; }
.battle-quip {
  position: relative;
  display: grid;
  align-items: center;
  min-inline-size: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #463127;
  font-size: clamp(.94rem, 4.3cqi, 1.05rem);
  line-height: 1.13;
  pointer-events: none;
}
.battle-quip:not([data-speaking]) { visibility: hidden; }
.battle-quip[data-speaking] {
  border-color: #c59a62;
  background: linear-gradient(135deg, #f6e5bd, #ead1a6);
  box-shadow: inset 0 0 0 2px #a7795038;
}
.boss-quip {
  grid-area: 2 / 2;
  min-block-size: 1.75rem;
  padding: 3px 6px;
}
.boss-quip[data-speaking]::before {
  position: absolute;
  top: 0;
  right: 100%;
  width: 8px;
  height: 11px;
  background: #e7c394;
  clip-path: polygon(0 0, 100% 35%, 100% 100%);
  content: "";
}
.agafon-quip {
  grid-area: 2 / 1 / 3 / -1;
  justify-self: end;
  width: min(100%, 21rem);
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 7px;
  padding: 4px 7px;
}
.agafon-quip[data-speaking] {
  border-color: #a0a077;
  background: linear-gradient(135deg, #f3ead1, #dcd7b6);
}
.agafon-quip > div { grid-area: 1 / 1; }
.agafon-medallion {
  grid-area: 1 / 2;
  aspect-ratio: 1;
  border: 1px solid #ad875c;
  border-radius: 50%;
  background: #574432 url("./art/agafon-expressions.webp") top left / 300% 200% no-repeat;
}
.agafon-quip strong { color: #76392c; }
.agafon-quip strong::after { content: " ·"; }
.score-label {
  color: var(--muted);
  font-size: clamp(.72rem, 3.5cqi, .875rem);
  font-weight: 700;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.score-card strong {
  color: #402c20;
  font-family: var(--game-font);
  font-size: clamp(1.75rem, 7.9vw, 2rem);
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: .95;
}

.score-card.current strong { color: var(--red-ink); }
.gold-score { position: relative; }
.gold-score strong { color: #755015; }
.gold-score .score-label { color: #77501e; }
.gold-shop-trigger {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: end;
  align-items: start;
  width: 100%;
  padding: 1px 4px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #805423;
  touch-action: manipulation;
}
.gold-shop-trigger .ui-icon { width: 13px; height: 13px; }
.gold-shop-trigger:active { background: #b7864e1e; }
.gold-shop-trigger:focus-visible { outline-offset: 0; }

.resource-stock {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  touch-action: pan-x pinch-zoom;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid #a17a4d52;
}
.resource-balance {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  color: #503a2b;
  font-size: clamp(.68rem, 3.3cqi, .8rem);
}
.resource-balance:first-child { margin-inline-start: auto; }
.resource-balance:nth-last-child(1 of :not([hidden])) { margin-inline-end: auto; }
.compact-stock .resource-balance > span:not(.resource-token) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(100%);
  white-space: nowrap;
}
.element-threshold { color: var(--muted); font: .65rem/1.1 var(--game-font); }
.resource-balance strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.resource-token {
  flex: none;
  position: relative;
  width: 17px;
  height: 17px;
  border: 1px solid var(--tile-rim);
  border-radius: 3px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px #fff2ce35;
}
.element-unlock {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.element-unlock[open] { display: grid; place-items: center; }
.element-unlock::backdrop {
  background: radial-gradient(ellipse at 50% 36%, #75985e45, #354f37a6 66%, #192c25e5);
  animation: element-dimming 1400ms ease-out both;
}
.element-unlock-card {
  width: min(100%, 320px);
  padding: 17px 16px 19px;
  border: 1px solid #c4a775;
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 0%, #5b6848, #3b4433 77%);
  box-shadow: inset 0 0 0 2px #bc9e675b, 0 8px 24px #21181091;
  color: #fff0cf;
  text-align: center;
  animation: element-notice 300ms ease-out both;
}
.element-unlock h2 { margin: 0; color: inherit; font: 700 1.65rem/1.05 var(--game-font); }
.element-unlock-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 13px; margin-block: 11px; }
.element-unlock-list > span { display: inline-flex; align-items: center; gap: 7px; font-size: 1.18rem; font-weight: 700; }
.element-unlock .resource-token {
  width: 34px;
  height: 34px;
  animation: element-token-in 450ms ease-out 80ms both;
}
.element-unlock p { margin: 0; color: #e6dbbb; font-size: .95rem; line-height: 1.2; }
.element-unlock-dismiss {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  touch-action: manipulation;
}
.element-unlock-dismiss:focus-visible { outline: none; }
.element-unlock:has(.element-unlock-dismiss:focus-visible) .element-unlock-card { outline: 2px solid #d9c49c; outline-offset: 3px; }
@keyframes element-notice {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes element-dimming {
  0% { opacity: 0; }
  28% { opacity: 1; }
  100% { opacity: .78; }
}
@keyframes element-token-in {
  0% { opacity: .45; transform: scale(.65) rotate(-9deg); }
  65% { opacity: 1; transform: scale(1.16) rotate(3deg); }
  100% { opacity: 1; transform: scale(1); }
}

.play {
  --board-outset: 16px;
  --slot-height: 112px;
  --tray-gap: clamp(18px, 4dvh, 34px);
  --bottom-clearance: clamp(14px, 3dvh, 24px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  /* Keep the square board and tray together near the top on taller screens. */
  max-block-size: calc(100cqi + 2 * var(--board-outset) + var(--tray-gap) + var(--slot-height) + var(--bottom-clearance));
  padding-block-end: var(--bottom-clearance);
}
.boss-active {
  --battle-slot-height: clamp(66px, 11dvh, 84px);
  --battle-quip-height: 46px;
}
.boss-active :is(.play, .pieces) { --slot-height: var(--battle-slot-height); }
.boss-active .play {
  --bottom-clearance: 8px;
  --tray-gap: 10px;
}
.boss-active .slot { --slot-controls: 0px; }
.board-space {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin-inline: calc(-1 * var(--board-outset));
  container-type: size;
}
.board-frame {
  --frame-padding: 10px;
  position: relative;
  width: min(100%, 100cqh);
  padding: var(--frame-padding);
  border: 1px solid #3c2a20;
  border-radius: 4px;
  background:
    radial-gradient(circle at 5px 5px, #d3a973 0 1px, #513723 1.2px 2px, transparent 2.2px),
    radial-gradient(circle at calc(100% - 5px) 5px, #d3a973 0 1px, #513723 1.2px 2px, transparent 2.2px),
    radial-gradient(circle at 5px calc(100% - 5px), #d3a973 0 1px, #513723 1.2px 2px, transparent 2.2px),
    radial-gradient(circle at calc(100% - 5px) calc(100% - 5px), #d3a973 0 1px, #513723 1.2px 2px, transparent 2.2px),
    repeating-linear-gradient(2deg, #492e2033 0 2px, #93624344 3px, #643d28 5px, #673e2c 7px 8px),
    #60402b;
  box-shadow: inset 0 0 0 2px #b0784c80, inset 0 0 0 5px #3d251e50, 0 3px 0 #503324, 0 8px 15px #6841253c;
}

.board-frame::after {
  position: absolute;
  bottom: 1px;
  left: 50%;
  width: 8px;
  height: 8px;
  border: 1px solid #c09963;
  border-radius: 50%;
  background:
    radial-gradient(circle, #d6af79 0 1px, transparent 1.4px),
    repeating-conic-gradient(from 22.5deg, #855b37 0 35deg, #c09963 35deg 45deg);
  transform: translateX(-50%);
  content: "";
  pointer-events: none;
}

.boss-arriving .board-frame { animation: quarry-tremor var(--quarry-arrival, 1120ms) linear both; }
.boss-arriving .board-space {
  position: relative;
}
.boss-arriving .board-space::after {
  content: "";
  position: absolute;
  inset: -14px;
  z-index: 4;
  background:
    radial-gradient(ellipse at 38% 38%, #f6d69d9c, transparent 40%),
    radial-gradient(ellipse at 60% 59%, #a879489a, transparent 56%),
    radial-gradient(ellipse, transparent 25%, #492b1799);
  pointer-events: none;
  animation: quarry-dust var(--quarry-arrival, 1120ms) ease-out both;
}
.boss-arriving .board-frame::before {
  content: "";
  position: absolute;
  z-index: 4;
  inset: var(--frame-padding);
  background: linear-gradient(138deg, #b38252, #ffe6a5 46%, #a45735 88%);
  clip-path: polygon(47% 1%, 50% 23%, 45% 35%, 53% 45%, 50% 51%, 70% 44%, 96% 51%, 72% 46%,
    49% 57%, 46% 68%, 53% 100%, 43% 68%, 46% 57%, 29% 48%, 4% 62%, 27% 45%, 47% 53%, 49% 46%,
    42% 35%, 47% 22%);
  transform-origin: 49% 52%;
  animation: quarry-fracture var(--quarry-arrival, 1120ms) ease-out both;
  pointer-events: none;
}
@keyframes quarry-tremor {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0); }
  8% { transform: translate3d(-2px, 1px, 0) rotate(-.3deg); }
  15% { transform: translate3d(3px, -2px, 0) rotate(.35deg); }
  21% { transform: translate3d(-5px, 3px, 0) rotate(-.6deg); }
  27% { transform: translate3d(6px, -3px, 0) rotate(.7deg); }
  33% { transform: translate3d(-6px, 2px, 0) rotate(-.75deg); }
  39% { transform: translate3d(5px, -3px, 0) rotate(.6deg); }
  45% { transform: translate3d(-7px, 4px, 0) rotate(-.8deg); }
  51% { transform: translate3d(11px, -7px, 0) rotate(1.05deg); }
  57% { transform: translate3d(-10px, 6px, 0) rotate(-1deg); }
  63% { transform: translate3d(8px, -4px, 0) rotate(.75deg); }
  69% { transform: translate3d(-5px, 3px, 0) rotate(-.65deg); }
  75% { transform: translate3d(4px, -2px, 0) rotate(.45deg); }
  83% { transform: translate3d(-3px, 2px, 0) rotate(-.3deg); }
  91% { transform: translate3d(1px, -1px, 0) rotate(.15deg); }
}
@keyframes quarry-fracture {
  0%, 28% { opacity: 0; transform: scale(.22); }
  51% { opacity: 1; transform: scale(1); }
  71% { opacity: .62; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes quarry-dust {
  0%, 40% { opacity: 0; transform: scale(.75); }
  56% { opacity: .76; }
  100% { opacity: 0; transform: scale(1.14) translateY(-9px); }
}

.board {
  --cell-gap: 3px;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: var(--cell-gap);
  aspect-ratio: 1;
  outline: 1px solid #b17c54;
  background: #271a16;
  touch-action: manipulation;
  user-select: none;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--cell-gap);
  min-height: 0;
}

.cell,
.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid #50372a;
  border-radius: 2px;
}

.cell {
  display: block;
  padding: 0;
  background: var(--well, #483228);
  box-shadow: inset 0 1px 2px #271a1780, inset 0 -1px #a0775424;
}

.board-row:nth-of-type(even) .cell:nth-child(odd),
.board-row:nth-of-type(odd) .cell:nth-child(even) { --well: #50372a; }

[data-color="violet"] { --tile: #885a74; --tile-rim: #643e54; --inlay: #eac6ca; }
[data-color="peach"] { --tile: #a94b39; --tile-rim: #73362c; --inlay: #efba88; }
[data-color="mint"] { --tile: #737e53; --tile-rim: #434e36; --inlay: #e0d6a8; }
[data-color="rose"] { --tile: #ae6e75; --tile-rim: #6f404b; --inlay: #f3c4b9; }
[data-color="blue"] { --tile: #517285; --tile-rim: #344a58; --inlay: #c9d8cf; }
[data-color="resource-dust"] {
  --tile: #6b5847;
  --tile-rim: #3f3028;
  --inlay: #f1d9af;
}
[data-color="resource-shard"] {
  --tile: #297673;
  --tile-rim: #244c4c;
  --inlay: #b5eee1;
  --resource-glyph: linear-gradient(124deg, #e2fff4 0 43%, #a0e2d5 43% 65%, #59b1a8 65%);
  --resource-cut: polygon(43% 3%, 77% 18%, 92% 51%, 47% 96%, 9% 70%, 17% 30%);
}
[data-color="resource-rune"] {
  --tile: #6a4887;
  --tile-rim: #482d64;
  --inlay: #f2deff;
  --resource-glyph: var(--inlay);
  --resource-cut: polygon(12% 15%, 27% 6%, 50% 34%, 73% 6%, 88% 15%, 60% 50%, 60% 59%,
    80% 68%, 73% 84%, 60% 78%, 60% 94%, 40% 94%, 40% 78%, 27% 84%, 20% 68%, 40% 59%, 40% 50%);
}

/* One stamped mark shared by the board, the tray, and the drag preview. */
.board .cell.filled, .board .cell.preview, .tile {
  border-color: var(--tile-rim);
  background: radial-gradient(circle at 2px 2px, #301b181c 0 .55px, transparent 1px) 0 0 / 5px 7px, var(--tile);
  box-shadow: inset 0 1px #f7d99b39, inset 0 -2px #3822194d;
}

:is(.cell.filled, .cell.preview, .tile)::before {
  position: absolute;
  inset: 14%;
  border: 1px solid var(--inlay);
  border-radius: 1px;
  opacity: .55;
  content: "";
  pointer-events: none;
}

:is(.cell.filled, .cell.preview, .tile)::after {
  position: absolute;
  inset: 36%;
  border: 1px solid var(--inlay);
  background: radial-gradient(circle, var(--inlay) 0 17%, transparent 22%);
  opacity: .88;
  transform: rotate(45deg);
  content: "";
  pointer-events: none;
}

:is(.cell.filled, .cell.preview, .tile)[data-color^="resource-"]::before {
  inset: 10%;
  border-color: color-mix(in srgb, var(--inlay) 62%, var(--tile-rim));
  border-radius: 26%;
  background: #15132145;
  opacity: .88;
}
:is(.cell.filled, .cell.preview, .tile)[data-color^="resource-"]::after,
.resource-token::after {
  position: absolute;
  inset: 20%;
  border: 0;
  background: var(--resource-glyph);
  clip-path: var(--resource-cut, none);
  opacity: 1;
  transform: none;
  content: "";
  pointer-events: none;
}
.mirror-shape .tile:not([data-color^="resource-"]) {
  border-color: #c5cabb;
  box-shadow: inset 0 1px #ecebd63d, inset 0 -2px #28332d5c;
}
.mirror-shape .tile:not([data-color^="resource-"])::after {
  border-color: #dedfc9;
  background: linear-gradient(90deg, #dedfc9 46%, transparent 46%);
}
.cutter-shape .tile {
  --inlay: #bee9cc;
  border-color: #a6cbb8;
}
.cutting-shape .tile {
  background: #3c7663ad;
  box-shadow: inset 0 1px #dbf5e6a6, inset 0 0 0 1px #477b66;
}

.board .cell.preview {
  border-color: #5c4132;
  opacity: .75;
  box-shadow: none;
}
.board .cell.drop-preview {
  background: color-mix(in srgb, var(--tile) 36%, #372319);
  opacity: .88;
}
.cell.drop-preview::before, .cell.drop-preview::after { opacity: .24; }
.cell.drop-preview[data-color^="resource-"]::after { opacity: .58; }

/* Tile faces in the two-row elemental artwork. */
:is([data-element="earth"], [data-color="resource-dust"]) { --element-column: 2.23%; }
:is([data-element="ice"], [data-color="resource-ice"]) { --element-column: 2.23%; --element-row: 72.64%; }
:is([data-element="fire"], [data-color="resource-fire"]) { --element-column: 26.32%; }
:is([data-element="lightning"], [data-color="resource-lightning"]) { --element-column: 26.32%; --element-row: 72.64%; }
:is([data-element="water"], [data-color="resource-water"]) { --element-column: 50.16%; }
:is([data-element="sound"], [data-color="resource-sound"]) { --element-column: 50.16%; --element-row: 72.64%; }
:is([data-element="air"], [data-color="resource-air"]) { --element-column: 73.84%; }
:is([data-element="light"], [data-color="resource-light"]) { --element-column: 73.84%; --element-row: 72.64%; }
:is([data-element="nature"], [data-color="resource-nature"]) { --element-column: 97.77%; }
:is([data-element="shadow"], [data-color="resource-shadow"]) { --element-column: 97.77%; --element-row: 72.64%; }
.element-sample,
:is(.resource-token, .board .cell.filled, .board .cell.preview, .tile)[data-color^="resource-"]:not([data-color="resource-shard"], [data-color="resource-rune"]) {
  background: #624d3c url("./art/elements.jpg")
    var(--element-column) var(--element-row, 25.99%) / 544.68% 349.49% no-repeat;
}
.board .cell.drop-preview[data-color^="resource-"]:not([data-color="resource-shard"], [data-color="resource-rune"]) { opacity: .7; }
:is(.cell.filled, .cell.preview, .tile)[data-color^="resource-"]:not([data-color="resource-shard"], [data-color="resource-rune"])::before,
:is(.cell.filled, .cell.preview, .tile, .resource-token)[data-color^="resource-"]:not([data-color="resource-shard"], [data-color="resource-rune"])::after { display: none; }

[data-color="boss-boulder"] { --tile: #756859; --tile-rim: #3a312b; --inlay: #c3af88; }
.board .cell.filled[data-color="boss-boulder"] {
  border-color: #3c2a22;
  background: var(--well, #483228);
}
.cell.filled[data-color="boss-boulder"]::before {
  inset: 0;
  border: 0;
  background: url("./art/krementiy-boulder.webp") center / 108% 108% no-repeat;
  opacity: 1;
}
.cell.filled[data-color="boss-boulder"]::after { content: none; }

.board .cell.clear-preview:is(.filled, .preview) {
  box-shadow: inset 0 0 0 2px #f7dda6c7, inset 0 0 12px #f7dda656;
  opacity: 1;
}
.board .cell.cut-preview.filled {
  box-shadow: inset 0 0 0 2px #c2f0d5, inset 0 0 11px #28594aae;
}
.board .cell.cut-preview.filled::after {
  display: block;
  inset: 11%;
  border: 0;
  border-radius: 0;
  background: linear-gradient(135deg, transparent 43%, #18483e 45% 47%,
    #d0ffe2 48% 53%, #18483e 54% 56%, transparent 58%);
  clip-path: none;
  opacity: 1;
  transform: none;
}

.cell.invalid { outline: 2px solid #ffb395; outline-offset: -2px; }
.cell.placed { animation: land-tile 175ms ease-out; }

@keyframes land-tile {
  0% { transform: scale(1.08); }
  38% { transform: scale(.89); }
  72% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.board-effects {
  display: grid;
  grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr));
  gap: var(--cell-gap);
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.ending-tile {
  animation: ending-fill var(--ending-tile-duration) ease-out var(--ending-delay) both;
}

@keyframes ending-fill {
  from { opacity: 0; transform: scale(.76); }
  to { opacity: 1; transform: scale(1); }
}

.tile-burst {
  --spark: #f4ce82;
  position: relative;
  border-radius: 2px;
  background: var(--tile);
  animation: tile-burst 330ms ease-out var(--burst-delay) both;
}

.tile-burst.combo { --spark: #ffe8b0; }
.tile-burst[data-color^="resource-"] { --spark: var(--inlay); }
.tile-burst::before {
  position: absolute;
  top: calc(50% - 1.5px);
  left: calc(50% - 1.5px);
  width: 3px;
  height: 3px;
  background: var(--spark);
  box-shadow: 0 -2.7cqi var(--spark), 2.5cqi 0 var(--spark),
    0 2.1cqi var(--tile), -2.3cqi .8cqi var(--spark),
    1.7cqi -1.6cqi var(--tile), -1.75cqi -1.6cqi var(--tile);
  animation: tile-sparks 330ms ease-out var(--burst-delay) both;
  content: "";
}

@keyframes tile-burst {
  0% { opacity: 1; background: var(--tile); transform: scale(.95); }
  26% { opacity: 1; background: var(--spark); box-shadow: 0 0 12px var(--spark); transform: scale(1.04); }
  100% { opacity: 0; background: var(--tile); transform: scale(.44); }
}

@keyframes tile-sparks {
  0% { opacity: 0; scale: .15; }
  25% { opacity: 1; }
  100% { opacity: 0; scale: 2.65; }
}

.points {
  position: absolute;
  inset: 33% 0 auto;
  color: #ffedbd;
  font-family: var(--game-font);
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 2px 8px #2d150c, 0 0 6px #2d150c;
  opacity: 0;
  pointer-events: none;
}

.points.show { animation: points 650ms ease-out both; }

.resource-effects {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.resource-flight {
  position: absolute;
  inset: auto;
  width: clamp(16px, 5cqi, 23px);
  height: auto;
  aspect-ratio: 1;
  translate: -50% -50%;
  box-shadow: 0 2px 4px #2b1d17aa;
}

@keyframes points {
  0% { opacity: 0; transform: translateY(7px); }
  20%, 53% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-21px); }
}

.pieces {
  --mirror-height: 44px;
  margin-top: var(--tray-gap);
  container-type: inline-size;
}
.tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

.slot {
  --slot-controls: 20px;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--slot-controls);
  min-height: var(--slot-height);
  user-select: none;
}

.piece-button {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 4px;
  border: 0;
  border-radius: 2px;
  background: none;
  touch-action: none;
}
.piece-button:focus-visible, .mirror-toggle:focus-visible, .cut-toggle:focus-visible { outline-offset: -3px; }
.slot.selected .shape .tile { outline: 1px solid #84513a; }
.piece-button.dragging .shape { opacity: .32; }
.mirror-toggle, .cut-toggle {
  position: absolute;
  inset-block-start: calc(100% - var(--slot-controls));
  inset-inline: 0;
  inline-size: 44px;
  block-size: var(--mirror-height);
  margin-inline: auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  touch-action: manipulation;
}
:is(.mirror-toggle, .cut-toggle):active :is(.mirror-mark, .cut-mark) {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px #60351c73;
}
:is(.mirror-toggle, .cut-toggle):disabled :is(.mirror-mark, .cut-mark) { opacity: .45; }
.mirror-mark, .cut-mark {
  position: relative;
  border: 1px solid;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px #fff0c592, 0 1px 1px #6540294d;
  pointer-events: none;
}
.mirror-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 24px;
  border-color: #443c2a;
  border-radius: 4px;
  background: linear-gradient(150deg, #796b4f, #4f4533);
  color: #fff0c7;
  box-shadow: inset 0 0 0 1px #d4b67d93, 0 1px 2px #53351f60;
}
.mirror-mark .ui-icon { width: 22px; height: 20px; }
.slot[data-mirror-lesson] .mirror-mark {
  outline: 2px solid #a07137;
  outline-offset: 3px;
  box-shadow: 0 0 10px 3px #c9954770;
}
.mirror-lesson {
  position: absolute;
  z-index: 3;
  inset-block-end: calc(100% + 2px);
  inset-inline-start: 0;
  width: max-content;
  max-width: min(15rem, 70cqi);
  padding: 5px 8px;
  border: 1px solid #9d7751;
  border-radius: 4px;
  background: #fff2d1;
  box-shadow: 0 2px 5px #402c2050;
  color: var(--ink);
  font: 700 .93rem/1.15 var(--game-font);
  pointer-events: none;
}
.cut-mark {
  width: 28px;
  height: 18px;
  border-color: #547462;
  background: linear-gradient(145deg, #e6e6c3, #9bbba4 72%, #82a58e);
  color: #315b4e;
}
.cut-toggle[aria-pressed="true"] .cut-mark {
  border-color: #315b4e;
  background: linear-gradient(145deg, #57816d, #345f53);
  color: #e4f1cc;
}
.cut-mark::before {
  position: absolute;
  inset: 3px 5px;
  background: currentColor;
  clip-path: polygon(0 50%, 35% 5%, 44% 35%, 100% 35%, 100% 65%, 44% 65%, 35% 95%);
  transform: rotate(-34deg);
  content: "";
}

.shape {
  --available-width: calc((100cqi - 12px) / 3 - 8px);
  --available-height: calc(var(--slot-height) - var(--slot-controls) - 8px);
  --mini: min(clamp(15px, 5.6cqi, 22px), calc(var(--available-width) / var(--width) - 2px),
    calc(var(--available-height) / var(--height) - 2px));
  display: grid;
  grid-template: repeat(var(--height), var(--mini)) / repeat(var(--width), var(--mini));
  gap: 2px;
  pointer-events: none;
}
.piece-spawn { animation: piece-spawn 180ms ease-out var(--spawn-delay) backwards; }
@keyframes piece-spawn {
  from { opacity: 0; translate: 0 5px; scale: .94; }
  to { opacity: 1; translate: 0; scale: 1; }
}

.drag-ghost {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 5;
  display: grid;
  grid-template: repeat(var(--height), var(--square)) / repeat(var(--width), var(--square));
  gap: var(--gap);
  opacity: .96;
  will-change: transform;
  filter: drop-shadow(0 6px 8px #3524199c);
  pointer-events: none;
}

.save-error {
  position: absolute;
  z-index: 3;
  inset: 6px 62px auto;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
  color: var(--red-ink);
  font-size: .875rem;
  text-align: center;
  pointer-events: none;
}

#offline[data-ready="true"] { color: #4a5134; }

.results-screen {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% 36%, #4f392a, transparent 69%),
    repeating-linear-gradient(13deg, transparent 0 4px, #ffdd9805 5px, transparent 6px 9px),
    #271a14;
  color: #f4e4bd;
  animation: results-reveal 220ms ease-out both;
}
.results-screen::before {
  position: fixed;
  inset: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  content: "";
  border: 1px solid #c496585c;
  box-shadow: inset 0 0 0 3px #2c1e16, inset 0 0 0 4px #c4965836;
  pointer-events: none;
}
@keyframes results-reveal { from { opacity: 0; } to { opacity: 1; } }
.results-content {
  display: grid;
  justify-items: center;
  gap: clamp(15px, 4dvh, 36px);
  width: min(100%, 370px);
  text-align: center;
}
.results-rune { width: clamp(38px, 10dvh, 68px); height: auto; aspect-ratio: 1; color: #d3a267; stroke-width: 1; }
.results-content h2 { margin: 0; font: 700 clamp(1.65rem, 6vw, 2.5rem) / 1 var(--game-font); }
#results-note { margin: 0; color: #dcc299; font-size: .95rem; }
#results-boss, #results-leaders { color: #ffe9c5; border-color: #d1a773; }
.results-totals { display: grid; width: 100%; gap: clamp(10px, 3dvh, 22px); margin: 0; }
.results-totals div:first-child { padding: 10px 4px; border-block: 1px solid #b688525e; }
.results-totals dt { color: #dcc299; font-size: .875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.results-totals dd {
  margin: 1px 0 0;
  font: 700 clamp(2.2rem, 7dvh, 3.5rem) / 1 var(--game-font);
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
.results-totals div:first-child dd { font-size: clamp(3.25rem, 11dvh, 5.5rem); }
#play-again {
  width: 62px;
  height: 62px;
  padding: 0;
  border-color: #e0bb83;
  background: #783828;
  color: #fff0cd;
  box-shadow: inset 0 0 0 3px #b1845752;
}
#play-again svg { width: 27px; height: 27px; }
#play-again:has(#boss-loss-label:not([hidden])) {
  grid-auto-flow: column;
  gap: 8px;
  width: auto;
  height: auto;
  min-height: 47px;
  padding: 8px 13px;
}
#play-again:has(#boss-loss-label:not([hidden])) svg { width: 22px; height: 22px; }
#play-again:focus-visible { outline-color: #eac08c; }

dialog {
  padding: 19px;
  border: 1px solid #8f6040;
  border-radius: 3px;
  background: var(--paper);
  box-shadow: inset 0 0 0 4px #9d775137, 0 10px 23px #2014097d;
}

dialog h2 {
  margin: 0 0 7px;
  color: var(--red-ink);
  font-family: var(--game-font);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

dialog p, dialog ol { margin: 0 0 14px; color: var(--muted); line-height: 1.45; }
dialog {
  width: min(calc(100% - 32px), 388px);
  max-height: calc(100% - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  color: var(--ink);
}
dialog::backdrop { background: #281a14bd; }
dialog ol { padding-left: 24px; }
dialog ol li + li { margin-top: 6px; }
.element-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px 5px;
  margin: 12px 0 14px;
  padding: 0;
  list-style: none;
}
.element-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  justify-items: center;
  min-width: 0;
  text-align: center;
  font: 700 clamp(.725rem, 3.8vw, .92rem) / 1.05 var(--game-font);
  overflow-wrap: anywhere;
}
.element-sample {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  box-shadow: 0 2px 3px #422b1e48;
}
.settings-menu {
  display: grid;
  gap: 6px;
  margin: 12px 0 16px;
}
.settings-menu button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #9d775197;
  border-radius: 2px;
  background: #a4795319;
  text-align: start;
  touch-action: manipulation;
}
.settings-menu button:active { background: #ca985542; }
.settings-menu #restart { color: var(--red-ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.primary, .secondary { min-height: 44px; padding: 7px 12px; border-radius: 2px; font-weight: 700; }
.primary { border: 1px solid #5e291e; background: #783828; color: #fff0cd; }
.secondary { border: 1px solid var(--rule); background: transparent; color: var(--red-ink); }

.cloud-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.cloud-actions :is(input, output) {
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: #fff3d3;
  color: var(--ink);
  font: 1rem / 1.4 monospace;
  overflow-wrap: anywhere;
  user-select: text;
}
.cloud-actions label { margin-top: 6px; }
.cloud-actions button:disabled { opacity: .6; cursor: default; }
.cloud-actions p { margin: 0; color: var(--muted); }
#leaders-list {
  max-height: min(36dvh, 234px);
  padding-inline-start: 2.2rem;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
}
#leaders-list li { padding: 6px 6px 6px 2px; border-bottom: 1px solid #9d77515e; }
#leaders-list li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
#leaders-list span { overflow-wrap: anywhere; }
#leaders-list strong { float: inline-end; margin-inline-start: 10px; color: var(--red-ink); font-variant-numeric: tabular-nums; }

.story-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0 max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
  touch-action: manipulation;
}
.story-dialog[open] { display: flex; align-items: flex-end; justify-content: center; }
.story-scene { position: relative; width: min(100%, 438px); }
.story-dialog::backdrop {
  background: #2e20186c;
  animation: story-dim 220ms ease-out;
}
@keyframes story-dim {
  from { opacity: 0; }
  to { opacity: 1; }
}
.story-character {
  position: absolute;
  z-index: 0;
  inset-inline-start: 2%;
  bottom: calc(100% - 44px);
  width: min(81%, 48dvh, 284px);
  aspect-ratio: 1;
  overflow: hidden;
  pointer-events: none;
  filter: drop-shadow(0 6px 9px #2c1c1687);
  transform-origin: center bottom;
}
.story-character img {
  position: absolute;
  top: var(--sprite-row, 0%);
  left: var(--sprite-column, 0%);
  display: block;
  width: 300%;
  height: 200%;
  max-width: none;
}
.story-character:is([data-mood="pleased"], [data-mood="smug"]) { --sprite-column: -100%; }
.story-character:is([data-mood="startled"], [data-mood="puzzled"]) { --sprite-column: -200%; }
.story-character:is([data-mood="frown"], [data-mood="smug"], [data-mood="puzzled"]) { --sprite-row: -100%; }
#story-earth-art { width: 200%; height: 200%; left: 0; top: 0; }
.story-character[data-mood="throwing"] #story-earth-art { left: -100%; }
.story-character[data-mood="tired"] #story-earth-art { top: -100%; }
#story-evlampiy-art { top: 0; left: 0; }
.story-character:is([data-mood="pleased"], [data-mood="puzzled"]) #story-evlampiy-art { left: -100%; }
.story-character:is([data-mood="explaining"], [data-mood="polishing"]) #story-evlampiy-art { left: -200%; }
.story-character:is([data-mood="startled"], [data-mood="puzzled"], [data-mood="polishing"]) #story-evlampiy-art { top: -100%; }
.story-panel {
  position: relative;
  z-index: 1;
  padding: 22px 16px 19px;
  border: 1px solid #69442f;
  border-radius: 7px;
  background:
    radial-gradient(ellipse at 16% 10%, #fff9e2b5, transparent 75%),
    repeating-linear-gradient(18deg, transparent 0 3px, #7d4d2606 4px, transparent 5px 8px),
    #efe0bc;
  box-shadow: inset 0 0 0 2px #c8a06c, inset 0 0 0 4px #8d5b3a70,
    0 5px 0 #4c2e20, 0 10px 24px #2014096e;
}
.story-dialog h2 {
  position: absolute;
  top: -17px;
  left: 16px;
  margin: 0;
  padding: 3px 13px 5px;
  border: 1px solid #60321f;
  border-radius: 4px;
  background: linear-gradient(175deg, #a35b35, #743f2a);
  box-shadow: inset 0 0 0 1px #e6b87d81, 0 2px 4px #56321d5c;
  color: #fff0cf;
  font-size: 1.48rem;
}
.story-stage { margin-bottom: 5px; font-size: .8rem; font-style: italic; }
.story-line {
  min-height: 2.7em;
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(.98rem, 4vw, 1.12rem);
  line-height: 1.35;
}
#story-untyped { visibility: hidden; }
.story-cue {
  position: absolute;
  right: 13px;
  bottom: 10px;
  width: 7px;
  height: 7px;
  border: solid #85522f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.story-dialog[data-typing="true"] .story-cue { visibility: hidden; }
.story-hit-area {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: manipulation;
}
.story-hit-area:focus-visible { outline: 0; }
.story-dialog:has(.story-hit-area:focus-visible) .story-panel { outline: 2px solid #d8b27b; outline-offset: 2px; }
@media (orientation: landscape) and (max-height: 430px) {
  .story-scene { width: min(100%, 508px); }
  .story-character { width: min(42dvh, 176px); bottom: calc(100% - 32px); }
}

#upgrades-status {
  margin-block: 14px;
  padding-block: 14px;
  border-block: 1px solid #a17a4d70;
  color: var(--muted);
  text-align: center;
  font-size: 1.25rem;
  font-style: italic;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(100%);
  white-space: nowrap;
}

.workshop-open {
  --bench-ink: #3f4437;
  --bench-muted: #605746;
  --bench-rule: #967b584d;
  touch-action: manipulation;
}
.workshop-open #settings { display: none; }
.workshop-open #open-workshop-upgrades { display: grid; }
.workshop-open .scores { grid-template-columns: 1fr; }
.workshop-open .score-card:not(.gold-score) { display: none; }
.workshop-open .gold-score { display: flex; justify-content: center; align-items: center; gap: 6px; border: 0; }
.workshop-open .resource-stock { display: none; }
.workshop-open #open-upgrades { display: none; }

.workshop {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(100%, 398px);
  min-height: 0;
  min-width: 0;
  margin-inline: auto;
}
.workshop-content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: clip;
}
#open-chains { font-size: 1.05rem; }
.workshop h2, .workshop h3 {
  margin: 0;
  color: var(--bench-ink);
  font: 700 1.8rem / 1 var(--game-font);
}
.workshop .icon-button {
  border-color: #95785683;
  border-radius: 6px;
  background: #fbf2de;
  box-shadow: inset 0 -2px #a7825126, 0 1px 2px #523b2118;
  color: #645033;
}
.workshop-dock { position: relative; z-index: 2; margin-top: 3px; }
.factory-shop {
  position: absolute;
  z-index: 1;
  inset: auto 0 100%;
  padding: 12px;
  border: 1px solid #9c805e;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(150deg, #f5ebd7, #e2d2ae);
  box-shadow: inset 0 0 0 3px #a48a5f38, 0 -6px 24px #51332142;
  transform-origin: bottom;
  transform: translateY(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 220ms ease, opacity 180ms ease, visibility 0s linear 220ms;
}
.factory-shop[data-open="true"] {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
#factory-shop-title { margin: 0 0 5px 2px; font-size: 1.5rem; }
#factory-shop-status { margin: 8px 0 0; color: var(--red-ink); font-size: .875rem; }
.factories {
  display: grid;
  grid-template-rows: repeat(2, minmax(var(--factory-card-height, 72px), auto));
  grid-auto-flow: column;
  grid-auto-columns: clamp(132px, 46%, 175px);
  gap: 7px;
  padding: 3px 3px 7px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.factories:focus-visible {
  outline: 2px solid var(--red-ink);
  outline-offset: 1px;
}
.factory-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  gap: 4px 6px;
  padding: 7px 6px;
  border: 1px solid var(--bench-rule);
  border-radius: 6px;
  background: #fcf2dbbf;
  box-shadow: inset 0 -2px #9d7c4d20;
  color: var(--family-deep);
  text-align: start;
  touch-action: manipulation;
}
.factory-button strong { align-self: end; font-size: .84rem; line-height: 1.15; overflow-wrap: anywhere; }
.factory-button:disabled { opacity: .59; cursor: default; }
.factory-button[data-locked="true"] { filter: saturate(.66); }
.factory-button[data-locked="true"] .factory-portrait { opacity: .7; }
.factory-button[data-depleted="true"] { box-shadow: inset 0 0 0 2px var(--family-light); }
.factory-button:active { filter: brightness(.94); }
.factory-portrait {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--family-deep);
  border-radius: 6px;
  background: var(--family-deep);
  box-shadow: inset 0 0 0 1px #fbdd9a5c;
  color: var(--family-glint);
}
.factory-portrait .ui-icon { width: 20px; height: 20px; }
.factory-action, .price, .order-token { display: inline-flex; align-items: center; gap: 3px; }
.factory-action { align-self: start; flex-wrap: wrap; color: var(--bench-muted); font-size: .74rem; line-height: 1.1; }
.factory-action .price { padding: 2px 3px; border-radius: 3px; background: #886c3623; }
.factory-action .price[data-enough="false"] { color: var(--red-ink); }
.factory-action .resource-token { width: 14px; height: 14px; }

[data-family="earth"] {
  --family-light: #a7784f;
  --family-deep: #5c3829;
  --family-glint: #f9d9ac;
}
[data-family="fire"] {
  --family-light: #c16947;
  --family-deep: #702b25;
  --family-glint: #ffe0b8;
}
[data-color="resource-fire"] { --tile: #c16947; --tile-rim: #702b25; --inlay: #ffe0b8; }
[data-family="water"] {
  --family-light: #4e8bb4;
  --family-deep: #284578;
  --family-glint: #daedff;
}
[data-color="resource-water"] { --tile: #4e8bb4; --tile-rim: #284578; --inlay: #daedff; }
[data-family="air"] {
  --family-light: #56a49e;
  --family-deep: #275764;
  --family-glint: #dbfaf1;
}
[data-color="resource-air"] { --tile: #56a49e; --tile-rim: #275764; --inlay: #dbfaf1; }
[data-family="nature"] {
  --family-light: #739052;
  --family-deep: #3b5a35;
  --family-glint: #e6f2c2;
}
[data-color="resource-nature"] { --tile: #739052; --tile-rim: #3b5a35; --inlay: #e6f2c2; }
[data-family="ice"] {
  --family-light: #6c9fbd;
  --family-deep: #46658c;
  --family-glint: #e9fbff;
}
[data-color="resource-ice"] { --tile: #6c9fbd; --tile-rim: #46658c; --inlay: #e9fbff; }
[data-family="lightning"] {
  --family-light: #a983bf;
  --family-deep: #5b4388;
  --family-glint: #f2e5ff;
}
[data-color="resource-lightning"] { --tile: #a983bf; --tile-rim: #5b4388; --inlay: #f2e5ff; }
[data-family="sound"] {
  --family-light: #b97d95;
  --family-deep: #783d63;
  --family-glint: #ffe8f2;
}
[data-color="resource-sound"] { --tile: #b97d95; --tile-rim: #783d63; --inlay: #ffe8f2; }
[data-family="light"] {
  --family-light: #b69248;
  --family-deep: #705022;
  --family-glint: #fff0b9;
}
[data-color="resource-light"] { --tile: #b69248; --tile-rim: #705022; --inlay: #fff0b9; }
[data-family="shadow"] {
  --family-light: #817eaa;
  --family-deep: #484162;
  --family-glint: #f0eaff;
}
[data-color="resource-shadow"] { --tile: #817eaa; --tile-rim: #484162; --inlay: #f0eaff; }

.workshop-board-space {
  display: grid;
  place-items: center;
  container-type: size;
  min-width: 0;
  min-height: 0;
  padding: 6px 4px 8px;
  overflow: clip;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.workshop-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  width: min(100cqw, 100cqh);
  aspect-ratio: 1;
  gap: clamp(2px, min(1.15cqw, 1.15cqh), 4px);
  padding: clamp(4px, min(2.65cqw, 2.65cqh), 10px);
  border: 1px solid #786044;
  border-radius: 10px;
  background:
    repeating-linear-gradient(3deg, #745b401f 0 1px, transparent 2px 5px),
    linear-gradient(148deg, #a88961, #7b6046);
  box-shadow:
    inset 0 0 0 2px #c8ac7f,
    inset 0 0 0 4px #72573e,
    0 3px 0 #624b33,
    0 5px 9px #5d432e4d;
}
.work-cell {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  min-inline-size: 0;
  min-block-size: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #6d5c48a0;
  border-radius: 7px;
  background: radial-gradient(circle, #5c57444d 0 1px, transparent 1.7px),
    linear-gradient(150deg, #c1b69c, #a69d83);
  box-shadow: inset 0 2px 4px #51463168, inset 0 -1px #fff1cf7d;
  color: #fdf1cf;
  touch-action: none;
}
:is(.work-cell[data-item]:not([data-item=""]), .chain-chip) {
  --tile-ink: color-mix(in srgb, var(--family-deep) 63%, #231b15);
  border-color: color-mix(in srgb, var(--family-deep) 75%, #8e7153);
  background:
    linear-gradient(150deg, #fff0cc57, transparent 54%, #33231a2b),
    color-mix(in srgb, var(--family-light) var(--tile-tint, 59%), #d3b88b);
  box-shadow: inset 0 0 0 1px #ffedc297, inset 0 0 0 3px #4c372d50,
    inset 0 0 0 4px #ffe7b867, inset 0 -2px #513c2956,
    0 1px 2px #3f311e62;
  color: var(--tile-ink);
}
:is(.work-cell, .chain-chip)[data-tier="2"] { --tile-tint: 69%; }
:is(.work-cell, .chain-chip)[data-tier="3"] { --tile-tint: 78%; }
:is(.work-cell, .chain-chip)[data-tier="4"] { --tile-tint: 88%; }
.work-cell[data-item]:not([data-item=""]), .chain-chip { border-radius: 4px; }
.work-cell[data-item]:not([data-item=""]) .work-glyph, .chain-chip .work-glyph {
  filter: drop-shadow(0 1px #f7e1b180);
}
.work-cell:is([data-item]:not([data-item=""]), [data-factory]:not([data-factory=""])) {
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.work-cell[data-factory]:not([data-factory=""]) {
  border-color: #463727;
  background:
    radial-gradient(circle at 12% 13%, #f7d291 0 1px, transparent 1.5px),
    radial-gradient(circle at 88% 13%, #f7d291 0 1px, transparent 1.5px),
    var(--family-deep);
  box-shadow: inset 0 0 0 2px #f8db9a86, inset 0 -3px #25192866, 0 2px 3px #3f311e72;
}
.work-cell[data-factory]:not([data-factory=""])::after {
  position: absolute;
  inset: auto 10% 8% 10%;
  height: 2px;
  background: linear-gradient(to right, var(--family-glint) var(--charge-level, 0%), #201c2359 var(--charge-level, 0%));
  content: "";
  pointer-events: none;
}
.work-cell[data-factory]:not([data-factory=""]):active { filter: brightness(1.12); }
.work-cell[data-depleted="true"][data-factory]:not([data-factory=""]) { filter: saturate(.35) brightness(.78); }
.workshop-board[data-placing="true"] .work-cell[data-factory=""][data-item=""] {
  box-shadow: inset 0 0 0 1px #56734c;
  background: #c2c7a0;
}
.work-cell[aria-pressed="true"] { outline: 2px solid var(--tile-ink, #ffe0a6); outline-offset: -3px; }
.work-cell:focus-visible { outline-color: var(--tile-ink, #f5d49d); outline-offset: -3px; }
.item-mark {
  display: grid;
  place-items: center;
  color: var(--tile-ink, var(--family-glint));
  font-size: var(--ghost-mark-size, clamp(10px, min(8.6cqw, 8.6cqh), 34px));
}
.work-cell[data-factory]:not([data-factory=""]) .item-mark {
  color: var(--family-glint);
  font-size: var(--ghost-mark-size, clamp(10px, min(7cqw, 7cqh), 28px));
}
.work-level {
  position: absolute;
  right: 5%;
  bottom: 5%;
  min-width: 12px;
  padding: 1px 2px;
  border-radius: 3px;
  background: var(--tile-ink, #38281e);
  color: #fff8e7;
  font: 700 .7rem/1.13 var(--game-font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.factory-charge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--family-glint);
  font-size: var(--ghost-charge-size, clamp(.52rem, min(3.1cqw, 3.1cqh), .78rem));
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.merge-burst {
  position: absolute;
  z-index: 1;
  inset: 17%;
  border: 2px solid #fff0bb;
  border-radius: 50%;
  box-shadow: 0 0 8px #fff0bb70, inset 0 0 8px #fff0bb70;
  pointer-events: none;
}
.work-cell.work-dragging > :is(.item-mark, .factory-charge, .work-level) { opacity: .25; }
.work-cell[data-drop] { outline: 2px solid #71523a; outline-offset: -3px; }
.work-cell[data-drop="merge"] { outline-color: #4b6444; box-shadow: inset 0 0 14px #cbe0a288; }
.work-ghost {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 5px 12px #2a190c95;
  will-change: transform;
}

.workshop-controls {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 7px;
  min-height: 55px;
  padding: 5px 5px 4px;
  border: 1px solid #a2875b70;
  border-radius: 9px;
  background: #f5ead3;
  box-shadow: inset 0 -2px #a9886230;
}
.workshop-controls p {
  margin: 0;
  color: var(--bench-muted);
  font-size: .84rem;
  line-height: 1.2;
}
#open-factory-shop {
  border-color: #4c5540;
  background: #5a694f;
  color: #fff0cc;
}
#open-factory-shop[aria-expanded="true"] { background: #796144; color: #fae9c6; }
.workshop button:disabled { opacity: .53; cursor: default; }
.workshop-orders { min-width: 0; margin-block: 3px 0; }
.orders-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.workshop-orders h2 { margin-inline-end: auto; font-size: clamp(1.02rem, 5cqi, 1.4rem); }
.orders-tally {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--bench-muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
#orders {
  --order-card-height: 76px;
  display: grid;
  grid-template-rows: var(--order-card-height);
  grid-auto-flow: column;
  grid-auto-columns: min(81%, 264px);
  gap: 8px;
  block-size: calc(var(--order-card-height) + 8px);
  padding: 2px 1px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  touch-action: pan-x;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
#orders::-webkit-scrollbar { display: none; }
#orders:focus-visible { outline: 2px solid #88613e; outline-offset: 1px; border-radius: 4px; }
.order-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-block-size: 0;
  min-inline-size: 0;
  padding: 5px 8px;
  border: 1px solid #ad90654f;
  border-inline-start: 3px solid #a3875d;
  border-radius: 4px 8px 8px 4px;
  background: linear-gradient(153deg, #fff8e5, #f4e7cc);
  box-shadow: 0 2px 3px #5b412326;
  scroll-snap-align: start;
}
.order-card h4 {
  overflow: hidden;
  margin: 0 0 3px;
  font: 700 1.1rem/1 var(--game-font);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-order-card {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 7px;
  border-inline-start-color: #746147;
  background: linear-gradient(145deg, #fff1d1, #e4cea3);
}
.story-order-card[data-status="invited"] { position: relative; }
.order-meet::after { position: absolute; inset: 0; content: ""; }
.order-portrait {
  aspect-ratio: 1;
  border: 1px solid #9d7751;
  border-radius: 50%;
  background: #d6bd94 url("./art/evlampiy-expressions.webp") 9% 1% / 480% no-repeat;
}
.chain-entry[data-discovered="false"] { color: var(--muted); opacity: .75; }
.chain-entry small { display: block; margin-block-start: 3px; color: var(--muted); font: italic .8rem / 1.25 var(--game-font); }
.order-progress {
  grid-template-columns: 1fr;
  align-content: center;
  gap: 4px;
  margin: 0;
  border: 1px dashed #ad9065;
  background: #fff8e54a;
  box-shadow: none;
  color: var(--bench-muted);
  font-size: .88rem;
}
.order-progress strong { color: var(--bench-ink); }
.order-items { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; color: var(--bench-muted); font-size: .8rem; }
.order-token .ui-icon { width: 17px; height: 17px; }
.order-coins { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.order-token[data-required] .ui-icon { color: var(--family-deep); }
.order-token[data-required] b { min-inline-size: 3ch; font-variant-numeric: tabular-nums; }
.order-token[data-met="true"] { color: #395431; }
.order-reward { padding-inline-start: 5px; border-inline-start: 1px solid #9d77517c; color: #764919; }
.order-gift {
  display: grid;
  place-items: center;
  padding: 2px 3px;
  border: 1px solid #a481526e;
  border-radius: 3px;
  background: #f5e3b4;
  color: #6e4c28;
}
.order-extra {
  min-height: 22px;
  padding: 2px 4px;
  border: 1px solid #9b713f80;
  border-radius: 4px;
  background: #ebd9b693;
  font: inherit;
  touch-action: manipulation;
}
.order-extra > .ui-icon { color: #624627; }
.order-extra:active { background: #dbc096; }
.order-submit .ui-icon { width: 22px; height: 22px; }
.order-card[data-status="waiting"] .order-submit { opacity: .46; }
.order-card[data-status="ready"] { border-color: #7d845c; background: linear-gradient(153deg, #f1edcd, #e0e0bb); }
.order-card[data-status="ready"] .order-submit {
  border-color: #5f5730;
  background: #4c583c;
  color: #fff0c2;
  box-shadow: inset 0 0 0 2px #e3c28162;
}

#chains-dialog {
  border-color: #a4835e;
  background: #f2e6cb;
  color: var(--ink);
}
#chains-dialog select {
  width: 100%;
  min-height: 40px;
  margin-block: 7px 12px;
  padding: 4px 8px;
  border: 1px solid #a4835ea0;
  border-radius: 4px;
  background: #f9eac9;
  color: inherit;
  font: inherit;
}
.chain-stages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  padding: 0;
  list-style: none;
}
.chain-stages .chain-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink);
  font-size: .81rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.chain-chip {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid;
  font-size: 20px;
}
.chain-chip b {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 8px;
  padding: 0 1px;
  border-radius: 2px;
  background: var(--tile-ink);
  color: #fff8e7;
  font: 700 .6rem/1 var(--game-font);
  text-align: center;
}
.workshop-coin {
  position: fixed;
  z-index: 6;
  width: 18px;
  height: 18px;
  margin: -9px;
  border: 1px solid #f4d383;
  border-radius: 50%;
  background: #9b6325;
  color: #fff1a5;
  box-shadow: 0 2px 4px #24151c92;
  pointer-events: none;
}
.workshop-coin .ui-icon { width: 100%; height: 100%; }

@media (min-width: 480px) {
  .game { height: min(calc(100% - 24px), 745px); border-radius: 3px; }
  .play { --tray-gap: 12px; }
}
@media (min-width: 480px) and (min-height: 541px) {
  .game {
    height: min(calc(100% - 12px), 745px);
    padding-block-start: max(10px, env(safe-area-inset-top));
  }
  .top, .scores { margin-block-end: 5px; }
  .brand-title { --brand-width: 144px; }
  .game:not(.boss-active) .scores { padding-block: 4px; }
  .play { --slot-height: clamp(84px, 14dvh, 104px); --tray-gap: 9px; --bottom-clearance: 12px; }
}
@media (max-width: 479px) {
  body { background: var(--paper); }
  .game { height: 100%; }
}
@media (max-width: 380px) {
  .game {
    padding-inline: max(15px, env(safe-area-inset-left)) max(15px, env(safe-area-inset-right));
  }
  .play { --board-outset: 10px; }
  .board-frame { --frame-padding: 8px; }
}
@media (orientation: portrait) {
  .boss-active .brand-title { --brand-width: 126px; }
}
@media (max-height: 740px) and (max-width: 479px) {
  .game { padding-top: max(10px, env(safe-area-inset-top)); }
  .top { margin-bottom: 5px; }
  .brand-title { --brand-width: 150px; }
  .scores { margin-bottom: 5px; padding-block: 5px 6px; }
  .play { --slot-height: clamp(84px, 14dvh, 104px); --tray-gap: 9px; --bottom-clearance: clamp(10px, 2dvh, 16px); }
  .pieces { --mirror-height: 38px; }
}
@media (max-width: 350px) {
  .order-items { gap: 3px 4px; font-size: .8rem; }
  .order-token .ui-icon { width: 15px; height: 15px; }
}
@media (max-width: 319px), (orientation: landscape) and (max-height: 540px) {
  .agafon-quip {
    grid-template-columns: minmax(0, 1fr) 26px;
    gap: 5px;
    padding: 3px 5px;
    font-size: .875rem;
  }
}
@media (orientation: landscape) and (max-height: 540px) {
  .game {
    width: min(100%, 850px);
    height: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(180px, .85fr);
    column-gap: 14px;
    padding: max(8px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  }
  .play { display: contents; }
  .board-space { grid-area: 1 / 1 / -1 / 2; margin-inline: 0; }
  .top { grid-area: 1 / 2; margin-bottom: 5px; }
  .brand-title { --brand-width: 144px; }
  .scores { grid-area: 2 / 2; margin-bottom: 5px; padding-block: 4px; }
  .score-card strong { font-size: 1.65rem; }
  .pieces { --slot-height: 88px; --mirror-height: 33px; grid-area: 3 / 2; align-self: center; margin-top: 0; }
  .boss-active { --battle-slot-height: 62px; --battle-quip-height: 62px; }
  .boss-active .pieces { align-self: end; margin-block-end: 4px; }
  .workshop-open { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .workshop-open :is(.workshop, .workshop-content) { display: contents; }
  .workshop-orders { grid-area: 3 / 2; overflow: clip; }
  .workshop-orders h2 { font-size: 1.08rem; }
  .workshop-dock { grid-area: 4 / 2; }
  .workshop-board-space { grid-area: 1 / 1 / -1 / 2; }
  #orders { --order-card-height: 72px; grid-auto-columns: min(96%, 264px); }
  .story-order-card { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 4px; }
  .order-card h4 { font-size: 1rem; }
  .order-items { gap: 2px 5px; }
  .order-token .ui-icon { width: 15px; height: 15px; }
  .results-content { gap: 9px; }
  .results-totals { display: flex; justify-content: center; align-items: center; gap: 20px; }
  .results-totals div:first-child { padding: 5px 0; border-block: 0; }
}
@media (orientation: landscape) and (max-height: 330px) {
  .top { margin-bottom: 3px; }
  .brand-title { --brand-width: 127px; }
  .scores { margin-bottom: 3px; padding-block: 3px; }
  .score-card strong { font-size: 1.45rem; }
  .pieces { --slot-height: 74px; --mirror-height: 28px; }
  .factory-shop { padding: 8px; }
  .factories { --factory-card-height: 60px; }
  .factory-button { padding-block: 5px; }
  .workshop-controls p { font-size: .77rem; line-height: 1.15; }
}
@media (prefers-reduced-motion: reduce) {
  .points.show, .cell.placed, .piece-spawn, .results-screen { animation: none; }
  .story-dialog::backdrop, .element-unlock::backdrop, .element-unlock-card, .element-unlock .resource-token { animation: none; }
  .board-effects { display: none; }
  .factory-shop { transition: none; }
  .boss-health > span { transition: none; }
  .boss-arriving .board-frame, .boss-arriving .board-frame::before, .boss-arriving .board-space::after { animation: none; }
}
