:root {
  color-scheme: dark;
  --bg: #0e0e0c;
  --fg: #e7e2d4;
  --dim: #8f8a7c;
  --line: #2c2b26;
  --y: #e6c229;
  --mold: #c5d48a;
  --bad: #e07a6a;
  --tile: #767369;
  --tile-line: #8f8a7c;
}
:root[data-tile="dark"] {
  --tile: #1c1b18;
  --tile-line: #5c5a52;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
header {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
h1 { font-size: 16px; font-weight: 500; margin: 0; }
h1 b { color: var(--y); font-weight: 500; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
button, select, input {
  font: inherit;
  color: inherit;
  background: #161614;
  border: 1px solid var(--line);
  padding: 4px 8px;
}
input[type="range"] { padding: 0; }
nav button.on, button.on { border-color: var(--y); color: var(--y); }
button { cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
option:disabled, option.spent { color: var(--dim); }
main { padding: 16px 18px 48px; max-width: 920px; min-width: 0; overflow-wrap: anywhere; }
aside {
  border-left: 1px solid var(--line);
  padding: 14px;
  color: var(--mold);
  min-width: 0;
  overflow-wrap: anywhere;
}
aside .who { margin: 0 0 8px; color: var(--dim); }
#mold-line { min-height: 4.4em; margin: 0 0 12px; }
#mold-sug { display: flex; flex-wrap: wrap; gap: 6px; }
#status { color: var(--dim); margin-left: auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; min-width: 0; max-width: 100%; }
label.num { flex: 1 1 10rem; min-width: 0; display: flex; gap: 6px; align-items: center; }
label.num input, label.num select { flex: 1 1 auto; min-width: 0; width: 100%; }
.eq { font-size: 22px; margin: 12px 0; }
.dim { color: var(--dim); }
.mark { position: relative; display: inline-block; vertical-align: middle; }
.mark-hit {
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  margin: 0 0 0 2px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  cursor: help;
}
.tip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.mark.open .tip,
.mark:focus-within .tip {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  padding: 10px 12px;
  background: #161614;
  color: var(--fg);
  border: 1px solid var(--line);
  z-index: 20;
}
@media (hover: hover) {
  .mark:hover .tip {
    position: absolute;
    left: 0;
    right: auto;
    bottom: auto;
    top: calc(100% + 4px);
    width: max-content;
    height: auto;
    margin: 0;
    max-width: min(18rem, 70vw);
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    padding: 10px 12px;
    background: #161614;
    color: var(--fg);
    border: 1px solid var(--line);
    z-index: 20;
  }
}
.bad { color: var(--bad); }
.preview {
  border: 1px solid var(--line);
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 10px 0;
}
#cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 12px; min-width: 0; }
.card { border: 1px solid var(--line); padding: 8px; min-width: 0; }
.card img, .token { width: 100%; background: var(--tile); border: 1px solid var(--tile-line); image-rendering: pixelated; display: block; margin-top: 6px; }
.token { width: min(100%, 350px); height: auto; }
.traits { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0; }
.traits b { font-weight: 500; color: var(--dim); }
button.share { color: var(--dim); }
.card button.share { background: transparent; border-color: transparent; padding: 0 6px; min-width: 2em; min-height: 2em; }
.bits, .cells { display: grid; gap: 1px; width: 100%; max-width: 16rem; }
.bits { grid-template-columns: repeat(16, minmax(0, 1fr)); }
.bits i { width: 100%; aspect-ratio: 1; background: #1b1b18; display: block; }
.bits i.on { background: #f3f1e8; }
.cells { grid-template-columns: repeat(16, minmax(0, 1fr)); }
.cells button, .cells i { width: 100%; aspect-ratio: 1; height: auto; padding: 0; border: 0; display: block; min-width: 0; min-height: 0; }
#cells .cells { max-width: min(100%, 24rem); touch-action: none; user-select: none; }
.k { background: #141414; }
.b { background: #2f6bff; }
.g { background: #1ea84a; }
.c { background: #2ec8c8; }
.r { background: #e23b3b; }
.m { background: #d13bd1; }
.y { background: #e6c229; }
.w { background: #f4f4f4; }
.step { border-top: 1px solid var(--line); padding: 8px 0; }
.run { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--line); padding: 8px 0; min-width: 0; }
#batchNote { margin: 8px 0; max-width: 40rem; }
.piece { display: flex; gap: 6px; align-items: center; margin: 4px 0; min-width: 0; max-width: 100%; }
.piece input[type="text"] { width: min(18em, 100%); max-width: 100%; }
label { color: var(--dim); max-width: 100%; }
input, select { max-width: 100%; }
h2 { font-size: 14px; font-weight: 500; margin: 18px 0 8px; }
a { color: var(--y); }
.face { white-space: pre-wrap; color: var(--fg); }
.toon, .toon-wait { width: min(100%, 350px); margin: 8px 0; }
.toon { height: auto; display: block; background: var(--tile); border: 1px solid var(--tile-line); }
.toon-wait {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mine { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--line); padding: 8px 0; min-width: 0; }
.addr { color: var(--dim); text-align: left; max-width: 100%; }
.addr.open { color: var(--fg); word-break: break-all; }
.outs { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
a.out { color: var(--dim); }
footer {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
}
footer a { color: var(--dim); }
@media (max-width: 860px) {
  body { grid-template-columns: minmax(0, 1fr); }
  aside { border-left: 0; border-top: 1px solid var(--line); }
  #status { margin-left: 0; }
}
@media (max-width: 480px) {
  body { overflow-x: hidden; }
  main { padding: 12px 12px 32px; }
  button, select, input, .mark-hit { min-height: 40px; }
  button, select, .mark-hit { min-width: 40px; }
  input[type="checkbox"] { width: 40px; height: 40px; }
  .cells button, .bits i { min-width: 0; min-height: 0; }
  .piece { flex-wrap: wrap; }
  header, nav, footer { min-width: 0; max-width: 100%; }
  footer { padding: 8px 12px 16px; }
  footer a, a.out { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; }
  #run a, #run button, #pending a, #pending button { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; }
}
@media (hover: none) {
  footer a, a.out, #tile { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
  #run a, #run button, #pending a, #pending button { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; }
}
