@font-face {
  font-family: 'Cutive Mono';
  src: url('fonts/cutive-mono.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Silkscreen';
  src: url('fonts/silkscreen.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Silkscreen';
  src: url('fonts/silkscreen-bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('fonts/pixelify-sans.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono.woff2') format('woff2');
  font-display: swap;
}

/* the dark set; light mode swaps it for paradigma.inc's paper and ink but keeps it inside the game scenes */
:root,
:root[data-theme='light'] :is(.camp, .camp-stage, .stage, .dialogue, .arena, .roll, .fate, .loot-tray) {
  --bg: #0e0e0e;
  --ink: #f2f2f2;
  --muted: #9a9a9a;
  --dim: #5a5a5a;
  --rule: #3a3a3a;
  --rule-soft: #242424;
  --red: #c83b31;
  --red-dark: #7a231d;
  --red-see: rgba(200, 59, 49, 0.62);
  --red-faint: rgba(200, 59, 49, 0.4);
  --red-missed: rgba(200, 59, 49, 0.3);
  --green: #5a9e5f;
  --green-dim: #2f5a33;
  /* letters swallowed by the darkness curse */
  --shroud: #1e1e1e;
  --veil: rgba(14, 14, 14, 0.95);
  /* rgb of the soft light effects, so they can take any alpha */
  --glow: 242, 242, 242;
  --caret-block: rgba(242, 242, 242, 0.22);
  /* an item's words while it is being readied */
  --amber: #d98a3d;
  --amber-dim: rgba(217, 138, 61, 0.55);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f2f2f2;
  --ink: #111;
  --muted: #5a5a5a;
  --dim: #a0a0a0;
  --rule: #c9c9c9;
  --rule-soft: #dcdcdc;
  --red-see: rgba(200, 59, 49, 0.72);
  --red-faint: rgba(200, 59, 49, 0.48);
  --red-missed: rgba(200, 59, 49, 0.36);
  --green: #3e7c43;
  --green-dim: #a6c9a9;
  --shroud: #e2e2e2;
  --veil: rgba(242, 242, 242, 0.95);
  --glow: 17, 17, 17;
  --caret-block: rgba(17, 17, 17, 0.16);
  --amber: #b5611c;
  --amber-dim: rgba(181, 97, 28, 0.6);
  color-scheme: light;
}

:root[data-theme='light'] :is(.camp, .camp-stage, .stage, .arena, .loot-tray) {
  background-color: var(--bg);
  color: var(--ink);
}

:root {
  --mono: 'Cutive Mono', 'Courier New', monospace;
  --mono-alt: 'JetBrains Mono', ui-monospace, monospace;
  --pixel: 'Silkscreen', monospace;
  --talk: 'Pixelify Sans', 'Silkscreen', monospace;
  --type-font: var(--mono);
  --type-size: clamp(21px, 5.2vw, 30px);
  --caret-ms: 100ms;
  --wipe: cubic-bezier(0.4, 0, 0.2, 1);
  --settle: cubic-bezier(0.2, 0.6, 0.2, 1);
  /* the page grows with big screens instead of sitting in a narrow column */
  --page: clamp(1040px, 72vw, 1480px);
  --gutter: clamp(16px, 4vw, 32px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  /* Pixelify Sans draws its fi ligature like an A */
  font-variant-ligatures: none;
  overflow-x: hidden;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* a blade of daylight across the page, like the hero shots on paradigma.inc */
.light {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(112deg, transparent 38%, rgba(var(--glow), 0.028) 47%, rgba(var(--glow), 0.012) 52%, transparent 60%),
    radial-gradient(70% 50% at 50% -12%, rgba(var(--glow), 0.075), transparent 70%);
}

/* daylight on paper would read as a smudge */
:root[data-theme='light'] .light {
  display: none;
}

.label {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.4;
}

/* pixel type sits on multiples of 8px so its square edges stay sharp */
.display {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 40px;
  line-height: 1.15;
  color: var(--ink);
}

.display.small {
  font-size: 24px;
}

.is-defeat {
  color: var(--red);
}

mark {
  background: none;
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 16px;
  letter-spacing: 0.02em;
}

.pixel-name {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.6;
}

.redaction {
  display: inline-block;
  width: 7em;
  max-width: 100%;
  height: 1.05em;
  background: var(--rule);
  vertical-align: text-bottom;
}

kbd {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: 0 4px 1px;
  margin-left: 6px;
  opacity: 0.7;
  vertical-align: 1px;
}

/* the redaction wipe: a solid block grows under the text and the text flips colour just after */
.wipe,
.btn {
  background-image: linear-gradient(var(--ink), var(--ink));
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 0% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition:
    background-size 0.22s var(--wipe),
    color 0.12s 50ms;
}

.wipe {
  margin: 0 -0.18em;
  padding: 0 0.18em;
}

@media (hover: hover) and (pointer: fine) {
  .wipe:hover,
  .btn:hover {
    background-size: 100% 100%;
    color: var(--bg);
  }
}

.wipe:focus-visible,
.btn:focus-visible,
.wipe.is-current,
.btn.is-on {
  background-size: 100% 100%;
  color: var(--bg);
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 2px 0.18em;
  white-space: nowrap;
}

.btn-box {
  border: 1px solid var(--rule);
  padding: 10px 14px;
}

.btn-box:hover,
.btn-box:focus-visible {
  border-color: var(--ink);
}

.btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* header */
.top {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 22px var(--gutter) 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 22px;
}

.brand {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}

/* Silkscreen's own ampersand reads like a euro sign, so this one is drawn on the same 8-per-em pixel grid */
.amp {
  display: inline-block;
  width: 0.875em;
  height: 0.625em;
  margin: 0 0.125em;
  overflow: hidden;
  color: transparent;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 5' shape-rendering='crispEdges'><path fill='%23c83b31' d='M1 0h1v1h-1zM2 0h1v1h-1zM3 0h1v1h-1zM0 1h1v1h-1zM1 1h1v1h-1zM3 1h1v1h-1zM4 1h1v1h-1zM1 2h1v1h-1zM2 2h1v1h-1zM3 2h1v1h-1zM6 2h1v1h-1zM0 3h1v1h-1zM1 3h1v1h-1zM3 3h1v1h-1zM4 3h1v1h-1zM5 3h1v1h-1zM1 4h1v1h-1zM2 4h1v1h-1zM3 4h1v1h-1zM5 4h1v1h-1zM6 4h1v1h-1z'/></svg>") center / 100% 100% no-repeat;
  vertical-align: baseline;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav a.is-current {
  color: var(--bg);
}

.sep {
  margin: 0 0.6em;
  color: var(--dim);
}

.hero-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero-chip canvas {
  margin: -6px 0;
}

.storage-warning {
  position: relative;
  z-index: 2;
  max-width: var(--page);
  margin: 12px auto 0;
  padding: 0 var(--gutter);
  color: var(--red);
}

main {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.foot {
  position: relative;
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 24px var(--gutter) 22px;
}

.foot-keys kbd {
  margin: 0 4px 0 0;
}

/* key hints are buttons that press their key; buttons drop the label styling by default, so take it back */
.key-hint {
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
}

.key-hint:hover kbd {
  opacity: 1;
}

/* screens */
.screen {
  display: none;
}

.screen.is-active {
  display: block;
  /* backwards, not both: a held transform would trap the fixed overlays under the header */
  animation: settle 0.34s var(--settle) backwards;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.sheet {
  max-width: 760px;
  padding: clamp(40px, 8vh, 80px) 0 24px;
}

.sheet-wide {
  max-width: none;
}

.sheet > .label:first-child {
  margin-bottom: 14px;
}

.lede,
.flavour {
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 62ch;
  margin-top: 18px;
}

.flavour {
  color: var(--ink);
}

.section-label {
  margin: 48px 0 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  margin-top: 40px;
}

.hint {
  margin-top: 26px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
}

.hint kbd {
  margin: 0 4px 0 0;
}

/* title */
.title-stage {
  position: relative;
  min-height: calc(100svh - 150px);
  display: grid;
  align-content: center;
  gap: clamp(14px, 3vh, 30px);
  padding: clamp(18px, 4vh, 48px) 0;
}

.camp {
  position: relative;
  height: clamp(140px, 32vh, 330px);
}

/* firelight on the ground around the camp */
.camp::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -10%;
  width: min(90%, 760px);
  height: 70%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(200, 59, 49, 0.2), rgba(200, 59, 49, 0.06) 60%, transparent);
  animation: firelight 1.6s steps(3) infinite;
  pointer-events: none;
}

@keyframes firelight {
  50% {
    opacity: 0.75;
  }
}

.title-dragon {
  position: absolute;
  right: 0;
  bottom: 0;
  opacity: 0.13;
  pointer-events: none;
  animation: fade-in 1.2s steps(6) both;
}

.embers {
  position: absolute;
  inset: -40% 0 0;
  width: 100%;
  height: 140%;
  pointer-events: none;
}

.camp-row {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 2vw, 26px);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.title-copy {
  position: relative;
}

.wordmark {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 88px;
  line-height: 1;
  margin: 14px 0 0;
  color: var(--ink);
  text-shadow: 0.0625em 0.0625em 0 var(--red-dark);
  animation: fade-in 0.6s steps(4) both;
}

@media (max-width: 1100px) {
  .wordmark {
    font-size: 64px;
  }
}

.title-party {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-height: 80px;
  margin-bottom: 36px;
}

.title-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
}

.title-menu .who {
  flex-basis: 100%;
  font-size: 16px;
  color: var(--muted);
}

.title-menu .btn-box {
  background-color: var(--bg);
}

.admin-note {
  max-width: 62ch;
  margin: 0 0 26px;
  color: var(--muted);
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 10px 0 26px;
}

.title-menu .press {
  font-family: var(--pixel);
  font-size: 18px;
  color: var(--ink);
  animation: blink 1.05s steps(1) infinite;
}

/* bob a sprite by exactly one of its own pixels */
.bob {
  animation: bob 1.2s steps(1) infinite;
}

.bob.late {
  animation-delay: -0.6s;
}

@keyframes bob {
  50% {
    transform: translateY(calc(var(--px, 4px) * -1));
  }
}

canvas.sprite {
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* the art is drawn for a dark room, so on paper each sprite gets a one-pixel ink outline (four hard shadows, one sprite pixel each) */
:root[data-theme='light'] canvas.sprite:not(:is(.camp, .camp-stage, .stage, .dialogue, .arena, .roll, .fate, .loot-tray) *) {
  filter: drop-shadow(var(--px, 4px) 0 0 var(--ink)) drop-shadow(calc(var(--px, 4px) * -1) 0 0 var(--ink))
    drop-shadow(0 var(--px, 4px) 0 var(--ink)) drop-shadow(0 calc(var(--px, 4px) * -1) 0 var(--ink));
}

/* the little line glyphs are greyscale, so on paper they flip to ink instead; red hearts read fine as they are */
:root[data-theme='light']
  canvas.sprite:is([data-sprite='star'], [data-sprite='starEmpty'], [data-sprite='heartEmpty'], [data-sprite='lock'], [data-sprite='skull'], [data-sprite='sword']):not(
    :is(.camp, .camp-stage, .stage, .dialogue, .arena, .roll, .fate, .loot-tray) *
  ) {
  filter: invert(1);
}

:root[data-theme='light'] canvas.sprite[data-sprite='heart'] {
  filter: none;
}

/* a selected card is filled with ink, so its stars flip the other way */
.is-on canvas.sprite:is([data-sprite='star'], [data-sprite='starEmpty']) {
  filter: invert(1);
}

:root[data-theme='light'] .is-on canvas.sprite:is([data-sprite='star'], [data-sprite='starEmpty']) {
  filter: none;
}

/* ledger */
.ledger-list {
  list-style: none;
  margin-top: 34px;
  border-top: 1px solid var(--rule-soft);
}

.ledger-list:empty {
  display: none;
}

.ledger-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.ledger-row.is-active .ledger-name::after {
  content: 'signed in';
  margin-left: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--green);
}

.ledger-name {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
}

.ledger-meta {
  color: var(--muted);
}

.ledger-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 16px;
}

.ledger-code {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.code-box {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 10px;
  resize: none;
}

.field {
  display: grid;
  gap: 6px;
  max-width: 420px;
}

.field input,
.import-code {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 6px 0 8px;
  font-family: var(--pixel);
  font-size: 24px;
  outline: none;
  border-radius: 0;
}

.import-code {
  font-family: var(--mono);
  font-size: 13px;
  resize: vertical;
  border: 1px solid var(--rule);
  padding: 10px;
}

.field input:focus,
.import-code:focus {
  border-color: var(--ink);
}

.field input::placeholder,
.import-code::placeholder {
  color: var(--dim);
}

.class-pick {
  border: 0;
  margin-top: 28px;
}

.class-pick legend {
  margin-bottom: 10px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.class-tile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 8px 14px;
  border: 1px solid var(--rule);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.class-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.class-tile:hover,
.class-tile:has(input:checked) {
  border-color: var(--ink);
}

.class-tile:has(input:focus-visible) {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.class-tile .pixel-name {
  margin-top: 4px;
}

.class-perk {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 24px;
}

.form-error {
  color: var(--red);
}

/* map */
.map-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: clamp(30px, 6vh, 56px) 0 34px;
}

.map-hero-name {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
}

.xpbar {
  position: relative;
  height: 6px;
  margin-top: 10px;
  max-width: 320px;
  background: var(--rule-soft);
  overflow: hidden;
}

.xpbar > i {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1.1s var(--settle);
}

.map-totals {
  text-align: right;
}

.map-totals .big-small {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
}

.act {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 28px;
  padding: 34px 0 30px;
  border-top: 1px solid var(--rule-soft);
}

.act-side {
  display: grid;
  align-content: start;
  gap: 12px;
}

.act-icon {
  opacity: 0.85;
}

.act[data-state='locked'] .act-icon {
  opacity: 0.25;
}

.act-title {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
  margin: 8px 0 10px;
}

.act[data-state='locked'] .act-title,
.act[data-state='locked'] .act-blurb {
  color: var(--dim);
}

.act-blurb {
  color: var(--muted);
  max-width: 60ch;
  font-size: 13.5px;
}

.nodes {
  position: relative;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 26px;
}

.nodes::before {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 44px;
  border-top: 1px dashed var(--rule);
}

.node {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 2px 6px;
  text-align: center;
  color: var(--ink);
}

.node-tile {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  background: var(--bg);
  border: 1px solid var(--rule);
  transition: border-color 0.2s;
}

.node-tile canvas {
  transition: transform 0.2s var(--settle);
}

.node[data-boss] .node-tile {
  border-style: double;
  border-width: 3px;
}

.node[data-state='locked'] {
  pointer-events: none;
}

.node[data-state='locked'] .node-tile canvas {
  filter: brightness(0) invert(0.18);
}

:root[data-theme='light'] .node[data-state='locked'] .node-tile canvas {
  filter: brightness(0) invert(0.8);
}

.node[data-state='next'] .node-tile canvas {
  filter: brightness(0) invert(0.5);
}

:root[data-theme='light'] .node[data-state='next'] .node-tile canvas {
  filter: brightness(0) invert(0.35);
}

.node[data-state='next'] .node-tile {
  border-color: var(--ink);
  animation: beckon 1.2s steps(1) infinite;
}

@keyframes beckon {
  50% {
    border-color: var(--rule);
  }
}

@media (hover: hover) and (pointer: fine) {
  .node:hover .node-tile {
    border-color: var(--ink);
  }
  .node:hover .node-tile canvas {
    transform: translateY(-3px);
  }
  .node:hover .node-title {
    background-size: 100% 100%;
    color: var(--bg);
  }
}

.node:focus-visible {
  outline: none;
}

.node:focus-visible .node-tile {
  border-color: var(--ink);
}

.node:focus-visible .node-title {
  background-size: 100% 100%;
  color: var(--bg);
}

.node-num {
  margin-top: 4px;
}

.node-title {
  font-size: 12.5px;
  line-height: 1.35;
}

.node-stars {
  display: flex;
  gap: 4px;
  min-height: 14px;
}

/* level intro */
.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 44px;
  margin-top: 44px;
}

.intro-stage {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 190px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
}

.intro-name {
  margin-top: 14px;
  font-size: 12px;
}

.intro-meta {
  margin-top: 4px;
}

.diff-list {
  margin-top: 10px;
  border-top: 1px solid var(--rule-soft);
}

.diff {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--rule-soft);
  text-align: left;
  font-size: 12.5px;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
}

.diff-key {
  font-family: var(--pixel);
  font-size: 8px;
  opacity: 0.7;
}

.diff-name {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.diff-note {
  grid-column: 2;
  color: var(--muted);
}

.diff-facts {
  grid-row: 1 / span 2;
  grid-column: 3;
  display: grid;
  justify-items: end;
  gap: 4px;
  font-family: var(--pixel);
  font-size: 8px;
}

.diff-lock,
.diff-warn {
  margin-top: 12px;
  color: var(--muted);
}

.diff-warn {
  color: var(--red);
}

.diff-lock .btn {
  margin-left: 4px;
}

.pause-diff {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.diff-tile {
  justify-items: start;
  text-align: left;
}

.diff.is-on .diff-note {
  color: var(--bg);
  opacity: 0.7;
}

.diff-best {
  display: flex;
  gap: 3px;
}

.roll,
.fate {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(14, 14, 14, 0.94);
  color: var(--ink);
  animation: settle 0.2s var(--settle) both;
}

.roll-tray,
.fate-tray {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.fate-title {
  position: absolute;
  top: 10%;
  left: var(--gutter);
  right: var(--gutter);
  text-align: center;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(16px, 2.6vw, 32px);
  color: var(--ink);
}

/* what a roll added up to and what it means; stays up until you press on */
.roll-info {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 8%;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.roll-sum {
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--muted);
  min-height: 1em;
}

.roll-sum b {
  font-weight: 700;
  color: var(--ink);
}

.roll-title {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(24px, 3.4vw, 40px);
  line-height: 1.1;
}

.roll-title.good {
  color: var(--green);
}

.roll-title.bad {
  color: var(--red);
}

.roll-text {
  max-width: 44ch;
  font-family: var(--talk);
  font-size: clamp(16px, 2.2vw, 24px);
  line-height: 1.35;
}

.roll-go kbd {
  margin: 0 4px 0 0;
}

.arena.is-boss .banner {
  top: 34%;
}

.star-sprites {
  display: flex;
  gap: 14px;
}

.roll-die {
  position: relative;
  display: grid;
  place-items: center;
}

.roll-die canvas {
  animation: tumble 0.12s steps(2) infinite;
}

.roll.is-done .roll-die canvas {
  animation: none;
}

@keyframes tumble {
  50% {
    transform: rotate(90deg) scale(0.92);
  }
}

.roll-num {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 48px;
  line-height: 1;
  min-width: 2ch;
  text-align: center;
}

.roll-num.is-nat20 {
  color: var(--green);
}

.roll-num.is-nat1 {
  color: var(--red);
}

/* play */
.play {
  max-width: var(--page);
  margin: 0 auto;
  padding-top: clamp(18px, 4vh, 40px);
}

.play-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 18px;
}

.play-title {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.15;
  order: -1;
}

.arena {
  position: relative;
  height: clamp(150px, 30vh, 420px);
  margin: 10px 0 0;
  overflow: hidden;
  border-bottom: 1px solid var(--rule-soft);
}

.arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 80% at 50% 100%, rgba(var(--glow), 0.05), transparent 70%);
  pointer-events: none;
}

.arena-back {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  opacity: 0.1;
}

.arena-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  background-repeat: repeat-x;
  background-position: 0 100%;
  image-rendering: pixelated;
}

.combatant {
  position: absolute;
  bottom: 14px;
  translate: 0 0;
}

.combatant.hero {
  left: 12%;
}

.combatant.enemy {
  right: 12%;
}

.combatant .sprite {
  transition: opacity 0.3s;
}

.lunge-right {
  animation: lunge-right 0.18s steps(2);
}

.lunge-left {
  animation: lunge-left 0.24s steps(3);
}

.knock {
  animation: knock 0.14s steps(2);
}

@keyframes lunge-right {
  50% {
    translate: calc(var(--px, 5px) * 4) 0;
  }
}

@keyframes lunge-left {
  45% {
    translate: calc(var(--px, 5px) * -8) 0;
  }
}

@keyframes knock {
  50% {
    translate: calc(var(--px, 5px) * 1) 0;
  }
}

.shake {
  animation: shake 0.28s steps(5);
}

@keyframes shake {
  20% {
    transform: translate(-4px, 1px);
  }
  40% {
    transform: translate(4px, -1px);
  }
  60% {
    transform: translate(-3px, 0);
  }
  80% {
    transform: translate(2px, 1px);
  }
}

.felled .sprite {
  animation: felled 0.9s steps(6) forwards;
}

@keyframes felled {
  20%,
  60% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

.fallen .sprite {
  animation: fallen 0.8s steps(4) forwards;
}

@keyframes fallen {
  to {
    transform: rotate(-90deg) translate(-30%, -10%);
    opacity: 0.4;
  }
}

.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fx .slash {
  position: absolute;
}

.dmg {
  position: absolute;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  white-space: nowrap;
  animation: rise 0.75s var(--settle) forwards;
}

.dmg.crit {
  color: var(--red);
  font-size: 24px;
}

.dmg.soft {
  color: var(--muted);
  font-weight: 400;
  font-size: 8px;
}

.dmg.heal {
  color: var(--green);
}

@keyframes rise {
  to {
    translate: 0 -34px;
    opacity: 0;
  }
}

.banner {
  position: absolute;
  left: 50%;
  top: 16%;
  display: grid;
  gap: 6px;
  translate: -50% 0;
  width: min(92%, 640px);
  text-align: center;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
}

.banner.is-on {
  animation: banner 2.2s var(--settle) forwards;
}

@keyframes banner {
  12%,
  80% {
    opacity: 1;
    translate: -50% -6px;
  }
  to {
    opacity: 0;
    translate: -50% -10px;
  }
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 18px;
  padding: 14px 0 22px;
}

.hud-side {
  display: grid;
  gap: 6px;
}

.hud-enemy {
  justify-items: end;
}

.hearts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 21px;
}

.hearts .sprite.pop {
  animation: pop 0.35s steps(3);
}

@keyframes pop {
  50% {
    transform: scale(1.5);
  }
}

.hud-mid {
  text-align: center;
}

.timer {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.timer.low {
  color: var(--red);
  animation: blink 1s steps(1) infinite;
}

.live {
  margin-top: 6px;
  min-height: 15px;
}

.live-streak {
  color: var(--ink);
}

.bar {
  position: relative;
  width: min(220px, 40vw);
  height: 10px;
  border: 1px solid var(--rule);
  padding: 2px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--ink);
  transform-origin: left;
}

.bar-hp > i {
  transition: transform 0.18s var(--settle);
}

.bar-charge > i {
  background: var(--muted);
  transform: scaleX(0);
}

.bar-charge.hot > i {
  background: var(--red);
}

.bar-charge.surge {
  border-color: var(--red);
}

.hud-enemy .bar-hp > i {
  transform-origin: right;
}

.hud-enemy .bar-charge > i {
  transform-origin: right;
}

.pause {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--veil);
}

.pause-box {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 0 var(--gutter);
}

.pause-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

/* typing */
.typing-mount {
  min-height: calc(var(--type-size) * var(--type-scale, 1) * 1.6 * var(--rows, 4));
}

.typing {
  position: relative;
  font-family: var(--type-font);
  font-size: calc(var(--type-size) * var(--type-scale, 1));
  --line-h: 1.6em;
  cursor: text;
}

.typing-lines {
  position: relative;
  height: calc(var(--line-h) * var(--rows, 4));
  overflow: hidden;
  contain: layout paint;
  transition:
    filter 0.25s,
    opacity 0.25s;
}

.typing-words {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.22s var(--wipe);
  will-change: transform;
}

.word {
  height: var(--line-h);
  line-height: var(--line-h);
  margin-right: 0.6em;
  white-space: nowrap;
}

.letter {
  color: var(--dim);
}

.letter.correct {
  color: var(--ink);
}

.letter.incorrect {
  color: var(--red-see);
}

.letter.extra {
  color: var(--red-faint);
}

.letter.missed {
  color: var(--red-missed);
}

.caret {
  position: absolute;
  left: 0;
  top: 0;
  width: max(2px, 0.07em);
  height: 1.15em;
  background: var(--ink);
  transition: transform var(--caret-ms) cubic-bezier(0.25, 0.8, 0.35, 1);
  will-change: transform;
  pointer-events: none;
}

:root[data-caret='block'] .caret {
  width: 0.6em;
  height: 1.25em;
  background: var(--caret-block);
}

:root[data-caret='under'] .caret {
  width: 0.6em;
  height: max(2px, 0.07em);
}

.caret.idle {
  animation: blink 1.05s steps(1) infinite;
}

/* the ghost of your best run: a dim second caret that glides between letters at its own pace */
.caret.ghost {
  background: var(--dim);
  transition: transform 160ms linear;
  animation: none;
}

:root[data-caret='block'] .caret.ghost {
  background: transparent;
  outline: 1px solid var(--dim);
  outline-offset: -1px;
}

.caret.ghost.is-off {
  display: none;
}

.ghost-note.is-ahead {
  color: var(--green);
}

.ghost-result {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
}

.ghost-result.is-beat {
  color: var(--green);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.no-anim .caret,
.no-anim .typing-words {
  transition: none !important;
}

.typing-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  font-size: 16px;
  border: 0;
  padding: 0;
  pointer-events: none;
  caret-color: transparent;
}

.typing-focus {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.typing.is-blurred .typing-lines {
  filter: blur(5px);
  opacity: 0.35;
}

.typing.is-blurred .typing-focus {
  opacity: 1;
}

.typing.is-finished .caret {
  opacity: 0;
}

/* training */
.train-top {
  display: flex;
  justify-content: center;
  padding: clamp(20px, 6vh, 56px) 0 0;
}

.train-modes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 14px;
  color: var(--muted);
}

.train-modes .group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.train-modes .btn {
  color: var(--muted);
}

.train-modes .btn.is-on {
  color: var(--bg);
}

.train-hud {
  display: flex;
  align-items: baseline;
  gap: 18px;
  min-height: 40px;
  margin: clamp(30px, 9vh, 90px) 0 10px;
}

.train-hud .live {
  margin: 0;
}

/* code: smaller text so real lines fit, more rows so you can see the shape of the function */
[data-screen='code'] {
  --type-scale: 0.7;
  --rows: 8;
}

.code-title {
  margin-left: auto;
}

.typing.is-code .typing-words {
  display: block;
  counter-reset: line;
}

/* spaces are exactly one character wide, so indentation lines up with the text above it */
.typing.is-code .word {
  margin-right: 1ch;
}

.code-line {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr);
  column-gap: 1.6ch;
  min-height: var(--line-h);
  counter-increment: line;
}

.code-line::before {
  content: counter(line);
  height: var(--line-h);
  line-height: var(--line-h);
  text-align: right;
  color: var(--rule);
}

.code-body {
  display: flex;
  flex-wrap: wrap;
  min-height: var(--line-h);
}

/* results */
.result-title {
  margin-top: 6px;
}

.result-stars {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  min-height: 1px;
}

.result-stars .sprite {
  opacity: 0;
}

.result-stars .sprite.in {
  animation: star-in 0.45s steps(4) forwards;
}

@keyframes star-in {
  0% {
    opacity: 0;
    transform: scale(2.2);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.result-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 64px;
  margin-top: 30px;
}

.big-num {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 80px;
  line-height: 1;
}

/* the pixel face has an odd percent sign, so units are set in the mono */
.unit {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.4em;
  margin-left: 0.15em;
  color: var(--muted);
}

.result-stats .unit {
  font-size: 13px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 18px 24px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
}

.result-stats dd {
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.4;
  margin-top: 4px;
}

.result-stats dd.small {
  font-family: var(--mono);
  font-size: 13px;
  padding-top: 6px;
}

.graph-wrap {
  margin-top: 28px;
}

.graph {
  display: block;
  width: 100%;
  height: 190px;
}

.graph-key {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.graph-key span {
  display: inline-block;
  width: 14px;
  height: 2px;
  margin-left: 10px;
}

.graph-key span:first-child {
  margin-left: 0;
}

.key-wpm {
  background: var(--ink);
}

.key-raw {
  background: var(--dim);
}

.key-err {
  height: 6px !important;
  width: 6px !important;
  background: var(--red);
}

.trouble {
  margin-top: 26px;
}

.trouble-words {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin-top: 10px;
  font-family: var(--type-font);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.7;
  color: var(--ink);
}

.tw .bad {
  color: var(--red-see);
}

.tw .ext {
  color: var(--red-faint);
}

.tw .typed {
  margin-left: 0.5em;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  text-decoration: line-through;
}

.xp {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
}

.xp .xpbar {
  max-width: none;
}

.xp-note {
  margin-top: 10px;
  color: var(--muted);
}

.xp-note strong {
  font-weight: 400;
  color: var(--ink);
}

/* settings */
.settings-list {
  margin-top: 40px;
  border-top: 1px solid var(--rule-soft);
}

.setting {
  display: grid;
  grid-template-columns: minmax(0, 220px) 1fr;
  align-items: center;
  gap: 10px 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.setting-help {
  color: var(--muted);
  margin-top: 2px;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.settings-preview {
  margin-top: 40px;
}

.settings-preview .typing-lines {
  height: auto;
}

/* small screens */
@media (max-width: 760px) {
  .act {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .act-side {
    grid-template-columns: auto 1fr;
    align-items: center;
  }
  .nodes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 22px;
  }
  .nodes::before {
    display: none;
  }
  .node-tile {
    width: 76px;
    height: 76px;
  }
  .intro-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .class-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ledger-row {
    grid-template-columns: 48px 1fr;
  }
  .ledger-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .map-head {
    grid-template-columns: auto 1fr;
  }
  .map-totals {
    grid-column: 1 / -1;
    text-align: left;
  }
  .setting {
    grid-template-columns: 1fr;
  }
  .hud {
    grid-template-columns: 1fr 1fr;
  }
  .hud-mid {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .combatant.hero {
    left: 6%;
  }
  .combatant.enemy {
    right: 6%;
  }
  .title-dragon {
    right: -30%;
    opacity: 0.1;
  }
  .wordmark {
    font-size: 40px;
  }
  .display {
    font-size: 32px;
  }
  .big-num {
    font-size: 56px;
  }
  .banner {
    font-size: 16px;
  }
  .map-hero-name {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
  .typing-words {
    transition: none;
  }
}

/* dialogue, in the spirit of Undertale: black box, thick white border, text that types itself */
.scene {
  max-width: var(--page);
  margin: 0 auto;
  padding-top: clamp(14px, 3vh, 36px);
}

.scene-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 18px;
}

.stage {
  position: relative;
  height: clamp(140px, 34vh, 460px);
  margin-top: 10px;
  overflow: hidden;
  border-bottom: 1px solid var(--rule-soft);
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 80% at 50% 100%, rgba(var(--glow), 0.05), transparent 70%);
  pointer-events: none;
}

.stage-back {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  opacity: 0.1;
}

.stage-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background-repeat: repeat-x;
  background-size: 64px 16px;
  image-rendering: pixelated;
}

.stage-left,
.stage-right {
  position: absolute;
  bottom: 12px;
}

.stage-left {
  left: 12%;
}

.stage-right {
  right: 12%;
}

.sprite.enter {
  animation: walk-in 0.45s steps(5) both;
}

@keyframes walk-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
}

.act-card {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  text-align: center;
  background: var(--bg);
  animation: fade-in 0.6s steps(4) both;
}

.act-card-blurb {
  max-width: 52ch;
  color: var(--muted);
  font-size: 14px;
}

.dialogue {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 18px;
  min-height: clamp(104px, 17vh, 168px);
  margin-top: 16px;
  padding: 16px 20px 22px;
  border: 3px solid var(--ink);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}

.dialogue:empty {
  border-color: var(--rule-soft);
}

.dialogue.is-narration {
  grid-template-columns: 1fr;
}

.dialogue.is-narration .dlg-portrait {
  display: none;
}

.dlg-portrait {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border: 1px solid var(--rule);
}

.dlg-name {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 12px;
  margin-bottom: 6px;
}

.dlg-text {
  font-family: var(--talk);
  font-size: clamp(17px, 2.3vw, 26px);
  line-height: 1.4;
  color: var(--ink);
  white-space: pre-wrap;
}

.dlg-next {
  position: absolute;
  right: 16px;
  bottom: 10px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--ink);
  opacity: 0;
}

.dialogue.is-waiting .dlg-next {
  opacity: 1;
  animation: nudge 0.8s steps(2) infinite;
}

@keyframes nudge {
  50% {
    transform: translateY(3px);
  }
}

/* the thrown die */
.die {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.die-face {
  display: block;
  transform-origin: 50% 100%;
}

.die.squash .die-face {
  animation: die-squash 0.12s steps(2);
}

@keyframes die-squash {
  50% {
    transform: scale(1.14, 0.8);
  }
}

.die.landed .die-face {
  animation: die-flash 0.45s steps(2);
}

@keyframes die-flash {
  50% {
    filter: brightness(2);
  }
}

.die-num {
  position: absolute;
  left: 50%;
  top: 57%;
  transform: translate(-50%, -50%) scale(0);
  padding: 0 0.12em;
  font-family: var(--pixel);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: var(--bg);
}

.die.landed .die-num {
  animation: num-pop 0.32s steps(3) forwards;
}

@keyframes num-pop {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.die.nat20 .die-num {
  color: var(--green);
}

.die.nat1 .die-num {
  color: var(--red);
}

.die-shadow {
  position: absolute;
  left: 0;
  top: 0;
  height: 8px;
  border-radius: 50%;
  background: #000;
}

/* loadout chips on the prep screen */
.loadout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.chip > span:last-child {
  display: grid;
}

.chip-name {
  font-size: 13px;
}

.chip-row {
  gap: 8px;
}

.chip-icon {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--rule);
}

.chip-icon kbd,
.slot kbd {
  position: absolute;
  left: -1px;
  top: -9px;
  margin: 0;
  background: var(--bg);
  opacity: 1;
}

.chip-icon.locked {
  opacity: 0.3;
}

/* the fight hotbar */
.hotbar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 18px;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--rule);
  background: var(--bg);
  cursor: pointer;
}

.slot.gap {
  margin-left: 14px;
}

.slot b {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-family: var(--pixel);
  font-size: 8px;
  font-weight: 400;
}

.slot.is-empty {
  opacity: 0.32;
}

.slot.is-readying {
  border-color: var(--amber);
}

.slot:hover {
  border-color: var(--ink);
}

.slot.used {
  animation: slot-used 0.3s steps(2);
}

@keyframes slot-used {
  50% {
    background: var(--ink);
  }
}

.slot.denied {
  animation: denied 0.3s steps(3);
}

@keyframes denied {
  33% {
    transform: translateX(-3px);
  }
  66% {
    transform: translateX(3px);
  }
}

/* power pips: words banked for the next shot, green when the stretch is clean enough to crit */
.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 8px;
}

.pips i {
  width: 8px;
  height: 8px;
  border: 1px solid var(--rule);
}

.pips i.on {
  background: var(--ink);
  border-color: var(--ink);
}

.pips.clean i.on {
  background: var(--green);
  border-color: var(--green);
}

.pips.empowered i {
  border-color: var(--red);
}

/* health over each fighter's head */
.unit-bar {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  width: max(48px, 70%);
  height: 6px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}

.enemy-bar {
  border: 1px solid var(--rule);
  padding: 1px;
}

.enemy-bar > i {
  flex: 1;
  background: var(--ink);
  transform-origin: right;
  transition: transform 0.2s var(--settle);
}

.hero-bar i {
  flex: 1;
  background: var(--rule);
}

.hero-bar i.on {
  background: var(--green);
}

.arena.is-boss .enemy-bar {
  display: none;
}

.status {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 18px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.status-icon {
  position: relative;
}

.status-icon b {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-family: var(--pixel);
  font-size: 8px;
  font-weight: 400;
}

.missile {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 3;
}

.boss-bar {
  position: absolute;
  left: 50%;
  top: 8px;
  z-index: 2;
  width: min(560px, 86%);
  transform: translateX(-50%);
  text-align: center;
}

.boss-name {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.boss-track {
  position: relative;
  height: 12px;
  border: 2px solid var(--ink);
  padding: 2px;
}

.boss-fill {
  display: block;
  height: 100%;
  background: var(--red);
  transform-origin: left;
  transition: transform 0.25s var(--settle);
}

.boss-ticks i {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--ink);
}

.banner-title {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
}

.banner-note {
  font-family: var(--talk);
  font-size: clamp(14px, 1.8vw, 19px);
  color: var(--muted);
}

/* the diamond after a word where your shot fires; it stays in the flow because positioning the word
   moved the letters' offset parent and threw the caret back to the start of the line */
.word.marker::after {
  content: '';
  display: inline-block;
  width: 0.2em;
  height: 0.2em;
  margin-left: 0.3em;
  vertical-align: 0.22em;
  background: var(--muted);
  transform: rotate(45deg);
}

.word.marker.done::after {
  background: var(--dim);
}

.word.marker.fired::after {
  animation: fired 0.45s steps(3) forwards;
}

@keyframes fired {
  0% {
    background: var(--ink);
    transform: rotate(45deg) scale(2.4);
  }
  to {
    opacity: 0;
  }
}

.word.rewritten .letter {
  animation: rewritten 0.6s steps(3);
}

@keyframes rewritten {
  0% {
    color: var(--red);
  }
}

/* enemy curses on the text */
.word.burning:not(.done) .letter:not(.correct):not(.incorrect) {
  color: var(--red);
  animation: smoulder 0.7s steps(2) infinite;
}

@keyframes smoulder {
  50% {
    color: var(--red-dark);
  }
}

.word.item .letter:not(.correct):not(.incorrect):not(.extra):not(.missed) {
  color: var(--amber-dim);
}

.word.item .letter.correct {
  color: var(--amber);
}

.word.hexed:not(.done) .letter:not(.correct):not(.incorrect) {
  color: var(--green);
  animation: hexed 0.8s steps(2) infinite;
}

@keyframes hexed {
  50% {
    color: var(--green-dim);
  }
}

.typing.mood-dark .word:not(.done):not(.active) .letter {
  color: var(--shroud);
}

.typing.mood-webbed .word:not(.done):not(.active) {
  filter: blur(3px);
}

.typing.mood-quake .typing-lines {
  animation: quake 0.18s steps(2) infinite;
}

@keyframes quake {
  50% {
    transform: translate(2px, -1px);
  }
}

/* loot */
.loot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 28px;
}

.loot-tray {
  position: relative;
  height: clamp(170px, 24vh, 230px);
  overflow: hidden;
  border: 1px solid var(--rule-soft);
}

.loot-card {
  display: grid;
  align-content: center;
  gap: 10px;
}

.rank-note {
  margin-top: 16px;
  color: var(--green);
  min-height: 1em;
}

/* gear cards */
.card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--rule);
}

.card + .card {
  margin-top: 10px;
}

.card.rarity-uncommon {
  border-color: var(--green);
}

.card.rarity-rare {
  border-color: var(--red);
}

.card.rarity-legendary {
  border: 3px double var(--ink);
}

.card.is-on {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.card.is-new {
  animation: card-in 0.4s steps(4) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.card.is-locked {
  opacity: 0.4;
}

.card-icon {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
}

.card-name {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}

.card-name kbd {
  margin: 0 4px 0 0;
}

.card-count {
  color: var(--muted);
}

.card-text {
  margin-top: 6px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 0 40px;
}

.belt {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.belt-slot kbd {
  margin: 0 8px 0 0;
}

.empty {
  color: var(--muted);
  margin-top: 8px;
}

.map-gear {
  margin-top: 10px;
  color: var(--muted);
}

/* leaderboard */
.board-tabs {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.board-groups,
.board-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.board-filter {
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
}

.board-filter .label {
  margin-right: 6px;
}

.board {
  margin-top: 22px;
}

.board-rows {
  list-style: none;
  border-top: 1px solid var(--rule-soft);
}

.board-row {
  display: grid;
  grid-template-columns: 3ch auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--rule-soft);
}

.board-row.is-me {
  background: rgba(90, 158, 95, 0.12);
}

.board-row.is-run {
  cursor: pointer;
}

.board-row.is-run:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

/* the run graph opens inside its row, across every column */
.board-run {
  grid-column: 1 / -1;
  padding: 4px 0 6px;
  cursor: default;
}

.board-mine {
  margin-top: 26px;
}

.board-rank,
.board-val {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 16px;
}

.board-name {
  font-family: var(--pixel);
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-empty {
  color: var(--muted);
  font-size: 15px;
}

.board-total {
  margin-top: 12px;
}

/* hero page */
.hero-head {
  grid-template-columns: auto 1fr;
  padding: 0 0 6px;
}

.hero-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px 28px;
  margin-top: 18px;
}

.hero-facts dd {
  margin-top: 4px;
  font-size: 13px;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 18px;
}

.hero-totals {
  margin-top: 0;
}

.hero-totals .big-num {
  font-size: 48px;
}

.hero-bosses {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 18px 14px;
  margin-top: 28px;
}

.hero-boss {
  display: grid;
  align-content: start;
  gap: 4px;
}

.hero-boss-pic {
  display: flex;
  align-items: flex-end;
  height: 72px;
}

/* a boss not beaten yet is only a shadow of itself */
.hero-boss:not(.is-beaten) .hero-boss-pic {
  opacity: 0.2;
}

.hero-boss-name {
  font-size: 13px;
  line-height: 1.3;
}

.hero-boss:not(.is-beaten) .hero-boss-name {
  color: var(--dim);
}

.hero-stats {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.hero-time .board-filter {
  padding-top: 0;
  border-top: 0;
}

.hero-recent {
  margin-top: 28px;
}

.hero-recent .board-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

/* the keyboard: flat keys that go redder the more often they slip, in steps rather than a blend */
/* one key is a share of the keyboard's width, so it fits a phone and stops growing on a wide screen */
.kb {
  --gap: 4px;
  --u: calc((100cqw - 13 * var(--gap)) / 13.5);
  container-type: inline-size;
  display: grid;
  gap: var(--gap);
  max-width: 680px;
}

.kb-row {
  display: flex;
  gap: var(--gap);
}

.kb-key {
  flex: none;
  width: var(--u);
  height: var(--u);
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  font-size: 11px;
  line-height: 1;
  color: var(--ink);
  overflow: hidden;
}

.kb-row[data-row='1'] .kb-key:first-child {
  margin-left: calc(var(--u) * 0.5 + var(--gap) * 0.5);
}

.kb-row[data-row='2'] .kb-key:first-child {
  margin-left: calc(var(--u) * 0.75 + var(--gap) * 0.75);
}

.kb-row[data-row='3'] .kb-key:first-child {
  margin-left: calc(var(--u) * 1.25 + var(--gap) * 1.25);
}

.kb-key.kb-space {
  width: calc(var(--u) * 6 + var(--gap) * 5);
  margin-left: calc(var(--u) * 3.5 + var(--gap) * 3.5);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

[data-heat='1'] {
  background: rgba(200, 59, 49, 0.16);
}

[data-heat='2'] {
  background: rgba(200, 59, 49, 0.34);
}

[data-heat='3'] {
  background: rgba(200, 59, 49, 0.6);
}

[data-heat='4'] {
  background: var(--red);
  border-color: var(--red);
  color: #f2f2f2;
}

.kb-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 14px;
}

.kb-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 1px solid var(--rule);
}

.hero-worst {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 22px 36px;
  margin-top: 28px;
}

.hero-list {
  list-style: none;
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
}

.hero-list b {
  display: inline-block;
  min-width: 3.5ch;
  font-family: var(--pixel);
  font-size: 16px;
  font-weight: 700;
}

/* daily challenge */
.daily-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px 36px;
  margin-top: 18px;
}

.daily-pic {
  display: flex;
  justify-content: center;
  min-width: 120px;
}

.daily-name {
  margin-bottom: 8px;
}

.daily-traits {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 16px;
  font-family: var(--talk);
  font-size: 15px;
  line-height: 1.35;
}

.daily-traits b {
  margin-right: 6px;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.daily-me {
  margin-top: 26px;
}

.daily-mine {
  font-size: 15px;
}

.daily-streak {
  margin-top: 8px;
}

.daily-actions {
  margin-top: 22px;
}

/* downloads */
.downloads {
  margin-top: 30px;
}

.download {
  margin-top: 26px;
  padding: 18px 0 0;
  border-top: 1px solid var(--rule-soft);
}

.download.is-mine {
  padding: 18px 16px 16px;
  border: 1px solid var(--ink);
}

.download-os {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
}

.download-files {
  list-style: none;
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.download-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}

.download-file.is-mine .download-meta {
  color: var(--ink);
}

.download-meta {
  color: var(--muted);
  font-size: 13px;
}

.download-how {
  margin-top: 14px;
  max-width: 64ch;
}

/* short windows: squeeze the scenery so the text still fits */
@media (max-height: 700px) {
  .arena {
    height: clamp(110px, 24vh, 170px);
  }
  .stage {
    height: clamp(110px, 26vh, 200px);
  }
  .play-head {
    display: none;
  }
  .hud {
    padding: 8px 0 12px;
  }
  .hint {
    margin-top: 12px;
  }
  :root {
    --rows: 3;
  }
  [data-screen='code'] {
    --rows: 6;
  }
}

/* very short windows, like a phone on its side: the text matters most */
@media (max-height: 480px) {
  .top {
    padding-top: 8px;
  }
  .arena {
    height: 96px;
  }
  .stage {
    height: 104px;
  }
  .hud {
    padding: 2px 0 6px;
    gap: 8px;
  }
  .hud .pixel-name,
  .hint {
    display: none;
  }
  .timer {
    font-size: 16px;
  }
  .hotbar {
    gap: 8px;
    margin-bottom: 6px;
  }
  .slot {
    width: 32px;
    height: 32px;
  }
  .boss-name {
    font-size: 8px;
    margin-bottom: 2px;
  }
  .dialogue {
    min-height: 84px;
    margin-top: 8px;
  }
  :root {
    --rows: 2;
  }
  [data-screen='code'] {
    --rows: 3;
  }
}

@media (max-width: 760px) {
  .loot {
    grid-template-columns: 1fr;
  }
  .board-row {
    grid-template-columns: 3ch auto minmax(0, 1fr) auto;
  }
  .board-sub {
    display: none;
  }
  .hero-recent .board-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .hero-when {
    grid-column: 1 / -1;
  }
  .daily-card {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .stage-left {
    left: 4%;
  }
  .stage-right {
    right: 4%;
  }
  .dialogue {
    gap: 12px;
    padding: 12px 14px 20px;
  }
  .dlg-portrait {
    width: 60px;
    height: 60px;
  }
  .slot {
    width: 40px;
    height: 40px;
  }
}

/* camp before a fight: the place, you and a fire, then your pack */
.camp-stage {
  position: relative;
  height: clamp(130px, 24vh, 260px);
  margin-top: 26px;
  overflow: hidden;
  border-bottom: 1px solid var(--rule-soft);
}

.camp-back {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  opacity: 0.12;
}

.camp-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background-repeat: repeat-x;
  background-position: 0 100%;
  background-size: 64px 16px;
  image-rendering: pixelated;
}

.camp-party {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, 3vw, 34px);
}

.camp-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 40px;
  align-items: start;
  margin-top: 26px;
}

.camp-bar .actions {
  margin-top: 10px;
}

/* the campaign picked at sign-up */
.camp-glyph {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
}

.lang-pick {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.lang-opt {
  position: relative;
  cursor: pointer;
}

.lang-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lang-opt input:checked + .btn {
  background-size: 100% 100%;
  color: var(--bg);
}

.lang-opt input:focus-visible + .btn {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* the briefing before the initiative roll: who you are about to fight and what it does */
.brief-card {
  position: absolute;
  top: clamp(16px, 8vh, 90px);
  left: 50%;
  transform: translateX(-50%);
  width: min(860px, calc(100% - 2 * var(--gutter)));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px 36px;
  align-items: center;
}

.brief-pic {
  display: grid;
  place-items: end center;
  min-width: 112px;
}

.brief-name {
  margin: 6px 0 14px;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.1;
}

.brief-traits {
  list-style: none;
  display: grid;
  gap: 9px;
  font-family: var(--talk);
  font-size: clamp(14px, 1.7vw, 18px);
  line-height: 1.35;
}

.brief-traits b {
  margin-right: 6px;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brief-meta {
  margin-top: 16px;
}

.brief-title,
.brief.is-rolling .brief-card {
  display: none;
}

.brief.is-rolling .brief-title {
  display: block;
}

/* big words under the text: what the enemy says and does, and what you yell back */
.callout {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 92px;
  margin-top: 6px;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.25s,
    transform 0.25s var(--settle);
  pointer-events: none;
}

.callout.is-on {
  opacity: 1;
  transform: none;
}

.callout-who {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.callout-title {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(20px, 3.2vw, 36px);
  line-height: 1.15;
  color: var(--ink);
}

.callout-note {
  max-width: 60ch;
  font-family: var(--talk);
  font-size: clamp(14px, 1.8vw, 20px);
  line-height: 1.3;
  color: var(--muted);
}

.callout.is-speech .callout-title {
  font-family: var(--talk);
  font-weight: 400;
  font-size: clamp(18px, 2.6vw, 30px);
}

.callout.is-hurt .callout-title,
.callout.is-crit .callout-title {
  color: var(--red);
}

.callout.is-good .callout-title {
  color: var(--green);
}

.callout.is-item .callout-title {
  color: var(--amber);
}

.callout.is-on .callout-title {
  animation: callout-pop 0.3s steps(3);
}

@keyframes callout-pop {
  0% {
    transform: scale(1.25);
  }
}

/* a red edge when you are hit, a quick light on a crit */
.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
}

.screen-flash.is-hurt {
  background: radial-gradient(ellipse at center, transparent 42%, rgba(200, 59, 49, 0.42));
  animation: flash-out 0.5s ease-out forwards;
}

.screen-flash.is-crit {
  background: rgba(var(--glow), 0.12);
  animation: flash-out 0.2s ease-out forwards;
}

@keyframes flash-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.combatant.enemy.dodge {
  animation: dodge 0.32s steps(3);
}

@keyframes dodge {
  50% {
    translate: calc(var(--px, 5px) * 5) 0;
  }
}

/* code fights: smaller text so real lines fit, and more rows to see the shape of the code */
.play.is-code {
  --type-scale: 0.72;
  --rows: 6;
}

@media (max-height: 700px) {
  .play.is-code {
    --rows: 4;
  }
  .callout {
    min-height: 64px;
  }
}

@media (max-height: 480px) {
  .play.is-code {
    --rows: 3;
  }
  .callout {
    min-height: 40px;
  }
  .callout-note,
  .callout-who {
    display: none;
  }
}

@media (max-width: 760px) {
  .camp-bar {
    grid-template-columns: 1fr;
  }
  .brief-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .brief-traits {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-flash {
    display: none;
  }
  .title-menu .press {
    animation: none;
  }
  .callout.is-on .callout-title {
    animation: none;
  }
}
