@font-face {
  font-family: "DM Sans";
  src: url("../fonts/DMSans-Variable.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #121212;
  --ink: #f2f2f2;
  --g1: #aaa;
  --g2: #555;
  --g3: #2a2a2a;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --tray: 66px;
  --scrim: rgba(18, 18, 18, 0.86);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: none;
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

#c { position: fixed; inset: 0; display: block; touch-action: none; }
.layer { position: fixed; left: 0; top: 0; display: block; pointer-events: none; }
#ground, #fog { will-change: transform; }

#top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 40px;
  grid-template-rows: 20px 30px;
  align-items: center;
  column-gap: 10px;
  padding: calc(var(--st) + 4px) calc(var(--sr) + 4px) 4px calc(var(--sl) + 14px);
  background: var(--bg);
  border-bottom: 1px solid var(--g3);
  z-index: 2;
}

#contract { display: contents; }
#c-line { grid-column: 1 / 3; grid-row: 1; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; height: 20px; min-width: 0; }
#c-title { color: var(--g1); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
#c-prog { display: flex; gap: 8px; align-items: center; font-size: 13px; }
#c-prog span { display: inline-flex; align-items: center; gap: 1px; }
#c-prog i { font-style: normal; white-space: pre; }
#c-prog .rough, #bank-more .rough { color: var(--g1); }
#c-note { display: none; }
@media (min-width: 900px) { #c-note { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; margin-left: 4px; color: var(--g1); font-size: 13px; } }
#c-bar { grid-column: 1; grid-row: 2; height: 2px; background: var(--g3); max-width: 200px; overflow: hidden; }
#c-bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform 0.25s; }

#bank { grid-column: 2; grid-row: 2; display: flex; gap: 10px; color: var(--g1); font-size: 13px; min-width: 0; overflow: hidden; height: 30px; align-items: center; justify-content: flex-end; cursor: pointer; }
#bank-more {
  position: fixed;
  top: calc(var(--st) + 60px);
  right: calc(var(--sr) + 8px);
  display: none;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 8px 6px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--g3);
  border-radius: 8px;
  color: var(--g1);
  font-size: 13px;
  z-index: 4;
}
#bank-more.shown { display: grid; }
.chip { display: inline-flex; align-items: center; gap: 3px; }
.chip.named { display: contents; }
.chip.named span:nth-child(3) { color: var(--ink); text-align: right; padding-left: 12px; }
#bank .chip { color: var(--ink); gap: 4px; }
#bank .gain { color: var(--g1); padding-left: 4px; }
.glyph { display: inline-block; vertical-align: middle; flex: none; }

#bank-more .chip { cursor: pointer; }
#bank-more .none { grid-column: 1 / -1; }
#lens { grid-column: 1; grid-row: 2; align-self: end; position: relative; display: none; align-items: center; justify-self: start; max-width: 100%; min-width: 0; height: 38px; margin-bottom: -6px; padding: 0 12px 0 10px; border: 1px solid var(--g1); border-radius: 19px; background: var(--bg); color: var(--g1); font-size: 13px; white-space: nowrap; }
#lens::after { content: ""; position: absolute; inset: -4px -3px; }
#lens > span:nth-child(2) { flex: none; margin-left: 5px; color: var(--ink); }
#lens > span:nth-child(3) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#lens b { flex: none; color: var(--ink); font-weight: 600; margin-left: 10px; }
body.lensed #top { padding-bottom: 8px; }
@media (max-width: 411px) { body.lensed #bank .gain { display: none; } }
body.lensed #lens { display: flex; }
body.lensed #c-bar { visibility: hidden; }
#menu-btn { grid-column: 3; grid-row: 1 / 3; width: 40px; height: 40px; display: grid; place-items: center; color: var(--g1); }

#corner {
  position: fixed;
  top: calc(var(--st) + 68px);
  right: calc(var(--sr) + 6px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 2;
}
body.early #corner, body.early #bank { visibility: hidden; }
#corner button {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--g3);
  background: var(--bg);
  color: var(--g1);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
}
#corner button.on { color: var(--ink); border-color: var(--g2); }
#pause .play, #pause.on .bars { display: none; }
#pause.on .play { display: inline; }
#corner svg { width: 18px; height: 18px; }
#corner #leak { display: none; width: auto; min-width: 40px; padding: 0 10px 0 8px; border-radius: 20px; border-color: var(--g2); color: var(--ink); gap: 4px; align-items: center; font-size: 13px; }
#corner #leak.shown { display: flex; }

#paused-label {
  position: fixed;
  top: calc(var(--st) + 74px);
  left: 0; right: 0;
  text-align: center;
  color: var(--g2);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: none;
  pointer-events: none;
}
body.paused #paused-label { display: block; }

#toast {
  position: fixed;
  top: calc(var(--st) + 70px);
  left: calc(var(--sl) + 8px); right: calc(var(--sr) + 54px);
  margin: 0 auto;
  width: fit-content;
  max-width: 380px;
  transform: translateY(-6px);
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--g3);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 3;
}
#toast.show { opacity: 1; transform: none; }
#toast.show.thin { opacity: 0.25; }

#update {
  position: fixed;
  top: calc(var(--st) + 8px);
  left: 0; right: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: 380px;
  padding: 9px 14px;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  transform: translateY(calc(-100% - var(--st) - 12px));
  transition: transform 0.3s;
  z-index: 6;
}
#update[hidden] { display: none; }
#update.show { transform: none; }

#guide {
  position: fixed;
  bottom: calc(var(--tray) + 13px + max(var(--sb), 14px));
  left: calc(var(--sl) + 8px); right: calc(var(--sr) + 8px);
  margin: 0 auto;
  width: fit-content;
  max-width: 360px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--g3);
  border-radius: 6px;
  color: var(--g1);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 2;
}
#guide.show { opacity: 1; pointer-events: auto; cursor: pointer; }
#guide.show.thin { opacity: 0.25; pointer-events: none; }
#tip {
  position: fixed;
  bottom: calc(var(--tray) + 13px + max(var(--sb), 14px));
  left: calc(var(--sl) + 8px); right: calc(var(--sr) + 8px);
  margin: 0 auto;
  width: fit-content;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  display: none;
  pointer-events: none;
  z-index: 2;
}
#tip.show { display: block; }
body.guided #tip { bottom: calc(var(--tray) + 13px + max(var(--sb), 14px) + 50px); }

#level {
  position: fixed;
  top: 32%;
  left: 0; right: 0;
  text-align: center;
  font-size: 40px;
  font-weight: 200;
  letter-spacing: 0.12em;
  opacity: 0;
  pointer-events: none;
}
#level.show { animation: level 2.4s ease-out; }
@keyframes level {
  0% { opacity: 0; letter-spacing: 0.3em; }
  15% { opacity: 1; letter-spacing: 0.14em; }
  70% { opacity: 1; }
  100% { opacity: 0; letter-spacing: 0.12em; }
}

#tray {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: safe center;
  gap: 2px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  touch-action: pan-x;
  padding: 4px calc(var(--sr) + 6px) max(var(--sb), 14px) calc(var(--sl) + 6px);
  background: var(--bg);
  border-top: 1px solid var(--g3);
  transform: translateY(110%);
  transition: transform 0.45s cubic-bezier(.2, .9, .3, 1.1);
  z-index: 2;
}
#tray.shown { transform: none; }
.piece {
  position: relative;
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: 60px;
  height: var(--tray);
  border-radius: 8px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.piece[hidden] { display: none; }
/* Improve is pinned to the tray's right end in a box of its own (a tester at Hub 5 thought it had gone): the scroller ends
   at its edge, so no tile is ever drawn under it. 73px is the box: its edge, 6px, the tile and 6px. */
#tray.end { right: calc(var(--sr) + 73px); padding-right: 6px; }
#tray-end {
  position: fixed;
  right: 0; bottom: 0;
  display: flex;
  padding: 4px calc(var(--sr) + 6px) max(var(--sb), 14px) 6px;
  background: var(--bg);
  border-top: 1px solid var(--g3);
  border-left: 1px solid var(--g3);
  transform: translateY(110%);
  transition: transform 0.45s cubic-bezier(.2, .9, .3, 1.1);
  z-index: 2;
}
#tray-end.shown { transform: none; }
.piece .name { font-size: 10px; line-height: 12px; color: var(--g1); white-space: nowrap; letter-spacing: -0.01em; }
.piece .cost { display: flex; gap: 5px; font-size: 11px; color: var(--g1); height: 13px; align-items: center; }
.piece .cost span { display: inline-flex; align-items: center; gap: 1px; }
.piece.poor .cost, .piece.locked .cost, .piece.locked .name { color: var(--g2); }
.piece.armed { border-color: var(--ink); background: var(--g3); box-shadow: inset 0 0 0 1px var(--ink); }
.piece.armed .name { color: var(--ink); font-weight: 600; }
.piece.repeat { box-shadow: inset 0 0 0 2px var(--ink); }
.piece .put { display: none; position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 7px; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23121212' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6A3.5 3.5 0 1 1 8 3.1'/%3E%3Cpath d='M8.6 1.2 8.2 3.4 10.4 3.6'/%3E%3C/svg%3E") center / 10px no-repeat; pointer-events: none; }
.piece.repeat .put { display: block; }
.piece.fresh::after, .piece.improve.ready::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  animation: fresh 1.3s ease-in-out 4;
  pointer-events: none;
}
.piece.improve.ready::after { animation: none; }
@keyframes fresh {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

#name {
  position: fixed;
  left: 0;
  top: 0;
  padding: 3px 8px;
  background: var(--bg);
  border: 1px solid var(--g3);
  border-radius: 4px;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1;
}
#name.show { opacity: 1; transition-duration: 0.12s; }

#select {
  position: fixed;
  left: 0;
  top: 0;
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  gap: 3px;
  padding: 4px 4px 4px 14px;
  background: var(--bg);
  border: 1px solid var(--g2);
  border-radius: 27px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 2;
  white-space: nowrap;
}
#select.shown { opacity: 1; pointer-events: auto; }
#select.shown.thin { opacity: 0.78; }
#select.shown.through { pointer-events: none; }
#select.shown.through button { pointer-events: auto; }
#select.shown.through.early button { pointer-events: none; }
#select #rot-r, #select #alt, #select #mv { width: 44px; padding: 0; justify-content: center; }
#select #mv.on { border-color: var(--ink); }
#select #up { padding: 0 8px 0 5px; gap: 2px; }
#select #up.poor span { color: var(--g2); }
#select #rot-r[hidden], #select #alt[hidden], #select #up[hidden], #sel-name[hidden] { display: none; }
#select:has(#sel-name[hidden]) { padding-left: 4px; }
#sel-name { color: var(--g1); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; margin-right: 6px; }
#select button {
  height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 22px;
  border: 1px solid var(--g3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#select button span { display: inline-flex; align-items: center; gap: 1px; color: var(--g1); }
#select svg { width: 16px; height: 16px; }
#select #rem .back { font-size: 11px; color: var(--g1); margin-left: -2px; }

#menu {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(max(var(--sb), 14px) + 6px);
  z-index: 5;
}
#menu[hidden] { display: none; }
.sheet {
  width: min(360px, calc(100vw - 32px));
  background: var(--bg);
  border: 1px solid var(--g3);
  border-radius: 12px;
  padding: 6px 18px 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.sheet-title { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--g1); font-weight: 600; }
.sheet-head .close { width: 40px; height: 40px; display: grid; place-items: center; margin-right: -10px; color: var(--g1); }
.row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  border-top: 1px solid var(--g3);
  font-size: 15px;
  text-align: left;
}
.row .val { color: var(--g1); }
.row.nav::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--g1); border-top: 1.5px solid var(--g1); transform: rotate(45deg); margin-right: 4px; }
.row.nav .val { display: none; }
.row.back::after { transform: rotate(-135deg); }
.row.danger { color: var(--g1); }
.row.dim { color: var(--g2); }
.row.dim .val { color: var(--g2); }
.row.up { height: 58px; }
.row.up b { display: block; font-weight: 500; }
.row.up small { display: block; font-size: 12px; color: var(--g1); margin-top: 1px; }
.row .cost { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; white-space: nowrap; }
.works .muted, .lab .muted { margin: 12px 0 8px; }
.row.slot { height: 58px; gap: 12px; }
.slot .pick { flex: 1; height: 100%; text-align: left; min-width: 0; }
.slot .pick b { display: block; font-weight: 500; }
.slot .pick small { display: block; font-size: 12px; color: var(--g1); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .val { font-size: 12px; color: var(--g2); }
.slot .clear { height: 32px; padding: 0 12px; border: 1px solid var(--g3); border-radius: 16px; color: var(--g1); font-size: 13px; }
.slot.armed .clear { border-color: var(--g1); color: var(--ink); }
.feedback textarea {
  display: block; width: 100%; margin: 4px 0 10px; padding: 10px 12px; resize: none;
  background: none; color: var(--ink); border: 1px solid var(--g3); border-radius: 8px; outline: none;
  font: inherit; font-size: 16px; line-height: 1.35; user-select: text; -webkit-user-select: text; touch-action: auto;
}
.feedback textarea::placeholder { color: var(--g2); }
.feedback textarea:focus { border-color: var(--g2); }
.feedback .muted { color: var(--g2); font-size: 12px; margin: 10px 0; }
.row.rec .val { color: var(--ink); }
.carillon .bells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px 0 4px; }
.carillon .bell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 3 / 4; min-width: 0; border: 1px dashed var(--g3); border-radius: 6px; color: var(--g2); font-size: 11px; overflow: hidden; }
.carillon .bell.rung { border: 1px solid var(--g2); color: var(--g1); }
.carillon .bell.card { justify-content: flex-end; gap: 0; }
.carillon .bell.card img { flex: 1; min-height: 0; width: 100%; object-fit: cover; }
.carillon .bell.card span { padding: 3px 0 4px; }
.carillon .muted, .postcard .muted { color: var(--g2); font-size: 12px; margin: 10px 0; }
.postcard img { display: block; width: 100%; max-height: 52vh; object-fit: contain; margin: 4px 0 10px; border-radius: 6px; background: var(--bg); }
.postcard .bare { display: grid; place-items: center; height: 120px; }
.postcard .fact { font-size: 14px; line-height: 1.4; margin: 2px 0; }
.postcard .row.picture { margin-top: 10px; }
.slots > .muted, .transfer .muted { color: var(--g2); font-size: 12px; margin: 10px 0; }
.transfer .holds { font-size: 15px; margin: 8px 0 4px; line-height: 1.35; }
.transfer .code { font-size: 30px; font-weight: 500; letter-spacing: 0.18em; text-align: center; margin: 14px 0 6px; user-select: text; -webkit-user-select: text; }
.transfer input {
  display: block; width: 100%; margin: 4px 0 10px; padding: 10px 12px;
  background: none; color: var(--ink); border: 1px solid var(--g3); border-radius: 8px; outline: none;
  font: inherit; font-size: 20px; letter-spacing: 0.18em; text-transform: uppercase; user-select: text; -webkit-user-select: text; touch-action: auto;
}
.transfer input::placeholder { color: var(--g2); letter-spacing: normal; text-transform: none; }
.transfer input:focus { border-color: var(--g2); }

#fps {
  position: fixed;
  left: calc(var(--sl) + 6px);
  top: calc(var(--st) + 62px);
  color: var(--g2);
  font-size: 11px;
  pointer-events: none;
  z-index: 3;
}

#credits {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 1.2s ease;
}
#credits.shown { opacity: 1; }
#credits > div { max-width: 300px; padding: 32px 28px; border: 1px solid var(--g2); background: var(--bg); text-align: center; line-height: 1.5; }
#credits p { margin: 0 0 10px; font-size: 15px; text-wrap: balance; }
#credits .title { margin: 0 0 18px; font-size: 22px; font-weight: 500; }
#credits .name { margin: 22px 0 14px; letter-spacing: 0.3em; text-transform: uppercase; }
#credits .dim { color: var(--g1); }
#credits .hint { font-size: 12px; color: var(--g2); }

body.reduced #tray, body.reduced #tray-end, body.reduced #toast, body.reduced #select { transition: opacity 0.2s; }
body.reduced #toast { transform: none; }
body.reduced #update { transition: none; }
body.reduced .piece.fresh::after { animation: none; transform: none; }
body.reduced #level.show { animation-name: level-fade; }
@keyframes level-fade { 0%, 100% { opacity: 0; } 15%, 70% { opacity: 1; } }
.stats { padding: 4px 0 10px; }
.stats p { margin: 8px 0; font-size: 13px; line-height: 1.4; }
.stats .muted { color: var(--g2); font-size: 12px; }
.stat { display: grid; grid-template-columns: 92px 1fr 54px 48px; align-items: center; gap: 8px; height: 30px; font-size: 13px; }
.stat > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.stat b { height: 2px; background: var(--g3); display: block; overflow: hidden; }
.stat b i { display: block; height: 100%; background: var(--ink); transform-origin: left; }
.stat .val { text-align: right; }
.stat .tot { text-align: right; color: var(--g2); }
.stat.cols { height: 16px; font-size: 11px; color: var(--g2); }
.stat.cols .val { color: var(--g2); }
.mat { display: flex; align-items: center; justify-content: space-between; height: 30px; font-size: 13px; }
.mat > span { display: inline-flex; align-items: center; gap: 4px; }
.mat .from { color: var(--g1); gap: 3px; }
.stats .rule { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; margin: 0; padding: 5px 0; font-size: 13px; line-height: 1.35; }
.rule .glyph { margin-top: -1px; }
.stats .licence { display: grid; gap: 2px; margin: 0; padding: 6px 0; }
.licence b { font-weight: 500; color: var(--ink); }
.licence span { color: var(--g1); }
.licence a { color: var(--ink); text-underline-offset: 3px; }
#c-prog [data-need] { cursor: pointer; }
.version { margin: 6px 0 0; padding-top: 10px; border-top: 1px solid var(--g3); color: var(--g2); font-size: 11px; text-align: center; letter-spacing: 0.04em; }
#corner #box { display: none; }
#corner #box.shown { display: grid; }
#corner #box.on { color: var(--ink); border-color: var(--ink); }
body.boxing #guide { visibility: hidden; }
#area {
  position: fixed;
  bottom: calc(var(--tray) + 13px + max(var(--sb), 14px));
  left: calc(var(--sl) + 8px); right: calc(var(--sr) + 8px);
  margin: 0 auto;
  width: fit-content;
  max-width: 396px;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  padding: 5px 5px 5px 14px;
  background: var(--bg);
  border: 1px solid var(--g2);
  border-radius: 24px;
  font-size: 13px;
  z-index: 2;
}
#area.shown { display: flex; }
#undo {
  position: fixed;
  bottom: calc(var(--tray) + 13px + max(var(--sb), 14px));
  left: calc(var(--sl) + 8px); right: calc(var(--sr) + 8px);
  margin: 0 auto;
  width: fit-content;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 24px;
  color: var(--ink);
  font-size: 13px;
  z-index: 2;
}
#undo.shown { display: flex; }
body.guided #undo { bottom: calc(var(--tray) + 13px + max(var(--sb), 14px) + 50px); }
#undo button { height: 38px; padding: 0 18px; border-radius: 19px; border: 1px solid var(--ink); color: var(--ink); font-weight: 600; }
#area-refund { display: inline-flex; gap: 8px; color: var(--g1); }
#area-refund span { display: inline-flex; align-items: center; gap: 2px; }
#area .area-acts { display: inline-flex; gap: 4px; }
#area button { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--g3); }
#area #area-go { border-color: var(--ink); color: var(--ink); }
#corner #help { display: none; color: var(--ink); font-size: 17px; font-weight: 500; }
#corner #help.shown { display: grid; }
#corner #help.fresh { border-color: var(--g2); animation: help 1.6s ease-in-out 4; }
@keyframes help { 0%, 100% { border-color: var(--g2); } 50% { border-color: var(--ink); background: var(--g3); } }
body.reduced #corner #help.fresh { animation: none; border-color: var(--ink); }

#card {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--st) + 12px) 0 calc(max(var(--sb), 14px) + 6px);
  z-index: 5;
}
#card[hidden] { display: none; }
#card .sheet { display: flex; flex-direction: column; max-height: 100%; padding-bottom: 6px; }
#card .sheet-body { display: flex; flex-direction: column; min-height: 0; }
#card .goal { margin: 0 0 6px; font-size: 15px; line-height: 1.35; }
#card .chains { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; margin: 0 -4px; padding: 0 4px; }
#card .need { padding: 7px 0 4px; border-top: 1px solid var(--g3); }
#card .need-head { display: flex; justify-content: space-between; margin-bottom: 2px; color: var(--g1); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
#card .need-head span:last-child { color: var(--ink); letter-spacing: 0.02em; }
#card .need.done .need-head span:last-child { color: var(--g1); }
#card .howto { margin: 2px 0 2px; font-size: 13px; line-height: 1.4; }
#card .note { margin: 0; padding: 7px 0; border-top: 1px solid var(--g3); font-size: 15px; line-height: 1.35; }
#card .end { margin: 0; padding: 7px 0 10px; border-top: 1px solid var(--g3); color: var(--g1); font-size: 13px; }
.chain { display: flex; flex-wrap: wrap; align-items: flex-start; row-gap: 1px; margin: 1px 0; }
.chain .step { display: flex; align-items: flex-start; }
.chain .link { display: inline-flex; flex-direction: column; align-items: center; min-width: 28px; padding: 2px 2px 1px; border: 1px solid transparent; border-radius: 6px; color: var(--g1); font-size: 10px; line-height: 12px; white-space: nowrap; }
.chain .link.here { outline: 1px solid var(--ink); outline-offset: 1px; color: var(--ink); }
.chain .link.dim { color: var(--g2); }
.chain .to { flex: none; display: grid; place-items: center; width: 13px; height: 28px; color: var(--g1); }
.chain .to svg { width: 11px; height: 9px; stroke-width: 1.1; }
.chain .to.dim { color: var(--g2); }
.chain .join { flex: none; padding: 6px 3px 0; color: var(--g1); font-size: 13px; line-height: 16px; }
.chain .join.dim { color: var(--g2); }
#card .foot { display: flex; gap: 10px; border-top: 1px solid var(--g3); padding-top: 6px; }
#card .foot .row { flex: 1; height: 42px; border: 1px solid var(--g2); border-radius: 21px; justify-content: center; font-size: 14px; }
#card .foot .got { color: var(--g1); border-color: var(--g3); }
#card .chains + .foot, #card .goal + .foot { margin-top: 6px; }
#select:has(#sel-recipe:not([hidden])) { border-radius: 20px; padding-bottom: 8px; }
#sel-recipe { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 0 0; color: var(--ink); font-size: 12px; }
#sel-recipe[hidden] { display: none; }
#select:has(#sel-rate:not([hidden])) { border-radius: 20px; padding-bottom: 8px; }
#sel-rate { grid-column: 1 / -1; contain: inline-size; white-space: normal; padding: 2px 4px 0 0; color: var(--g1); font-size: 12px; line-height: 1.35; }
#sel-rate[hidden] { display: none; }
#select.over #sel-rate, #select.over #sel-recipe { order: -1; }
#select.over:has(#sel-rate:not([hidden])), #select.over:has(#sel-recipe:not([hidden])) { padding-top: 8px; padding-bottom: 4px; }
#select.over #sel-rate { padding: 0 4px 2px 0; }
#select.over #sel-recipe { padding: 0 4px 4px 0; }
#sel-rate .ticks { vertical-align: 0; margin-right: 7px; }
#sel-rate .ticks[hidden] { display: none; }
#sel-recipe .rec { display: flex; align-items: center; gap: 4px; }
#sel-recipe .rec span { display: inline-flex; align-items: center; gap: 3px; }
#sel-recipe .rec.dim { color: var(--g2); }
#sel-recipe i { font-style: normal; color: var(--g1); }
#sel-recipe .rec.dim i { color: var(--g2); }
#sel-recipe .to { display: inline-grid; place-items: center; width: 14px; color: var(--g1); }
#sel-recipe .to svg { width: 11px; height: 9px; stroke-width: 1.1; }
#sel-recipe .rec.dim .to { color: var(--g2); }
#top, #bank-more, #corner, #paused-label, #toast, #update, #guide, #tip, #area, #undo, #level, #tray, #tray-end, #name, #select, #menu, #card, #credits, #fps { zoom: var(--ui, 1); }
#menu { padding-top: calc(var(--st) + 12px); }
#menu .sheet { max-height: 100%; }
#menu .sheet.scroll { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none; }
