:root {
  font-family: ui-sans-serif, system-ui, 'PingFang SC', sans-serif;
  color: #f4ead6;
  background: #0e171b;
  font-size: 14px;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
button,
select {
  font: inherit;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
  background: #243335df;
  border: 1px solid #bc9b5c65;
  border-radius: 4px;
  padding: 10px 20px;
  transition:
    background 0.16s,
    transform 0.16s;
}
button:hover {
  background: #665b40;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid #e3c07d;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
[hidden] {
  display: none !important;
}
#game,
#stage {
  position: absolute;
  inset: 0;
}
#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}
.vignette {
  display: none;
}
#collab-badge {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #bfa46c55;
  background: #142226e6;
  color: #ddcdb0;
  font-size: 12px;
  pointer-events: none;
}
#collab-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b0745a;
}
#collab-badge.live i {
  background: #8fc07a;
}
#collab-badge b {
  font-weight: normal;
  color: #e6c794;
  letter-spacing: 1px;
}
#collab-badge small {
  color: #a99d84;
}
#studio-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#studio-legend {
  position: fixed;
  right: 12px;
  top: 64px;
  z-index: 40;
  padding: 6px 10px;
  border: 1px solid #bfa46c55;
  background: #142226e6;
  color: #ddcdb0;
  font-size: 12px;
  line-height: 1.8;
  pointer-events: none;
}
#studio-legend b {
  font-weight: normal;
  color: #e6c794;
}
#studio-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 3px 0 6px;
  vertical-align: -1px;
}
#studio-legend .block {
  background: #d0503c88;
}
#studio-legend .exit {
  border: 2px solid #8fc07a;
  border-radius: 50%;
}
#studio-legend .trigger {
  border: 2px solid #e0a050;
  border-radius: 50%;
}
#studio-legend .talk {
  border: 2px solid #7fc8d8;
  border-radius: 50%;
}
#studio-legend .patrol {
  border: 2px solid #d06a5a;
  border-radius: 50%;
}
#studio-legend .spawn {
  background: #e6c794;
}
#sandbox {
  position: fixed;
  left: 12px;
  top: 150px;
  z-index: 45;
  width: 270px;
  max-height: calc(100 * var(--vh) - 220px);
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid #bfa46c66;
  background: #142226ee;
  color: #ddcdb0;
  font-size: 12px;
}
#sandbox h3 {
  margin: 0 0 6px;
  color: #e6c794;
  font-size: 14px;
  font-weight: normal;
  letter-spacing: 2px;
}
#sandbox p {
  margin: 4px 0;
}
#sandbox label {
  margin-right: 8px;
  white-space: nowrap;
}
#sandbox select,
#sandbox input[type='number'] {
  background: #0e1a1c;
  color: #f4ecd8;
  border: 1px solid #bfa46c55;
}
#sandbox input[type='number'] {
  width: 48px;
}
#sandbox button {
  margin: 4px 6px 0 0;
  padding: 3px 8px;
}
#sandbox small {
  color: #a99d84;
}
#sandbox-log {
  margin: 8px 0 0;
  padding: 6px 0 0;
  list-style: none;
  overflow-y: auto;
  border-top: 1px solid #bfa46c33;
  line-height: 1.7;
}
#note-box {
  position: fixed;
  z-index: 50;
  width: 260px;
  transform: translate(-50%, 12px);
  padding: 6px 8px;
  border: 1px solid #c5a569;
  background: #142226;
  color: #f4ecd8;
  font-size: 13px;
}
#shop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 340px;
  max-width: calc(90 * var(--vw));
  padding: 30px;
  background: #14252af5;
  border: 1px solid #bb9a5e99;
  box-shadow: 0 20px 70px #0008;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
#shop h2 {
  font-family: serif;
  letter-spacing: 4px;
  font-weight: 400;
  margin: 0 0 15px;
}
select {
  color: #e2d8c1;
  padding: 8px;
  background: #223637;
  border: 1px solid #647363;
}
#shop-items {
  display: grid;
  gap: 12px;
}
#shop-items button {
  text-align: left;
}
#gold {
  color: #dbc68c;
}
#shop-items button small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #c8cebc;
}
/* The bag: members with level, numbers and gear, then what the party carries. */
.bag-gold {
  margin: 0;
  color: #dbc68c;
}
.bag-members {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.bag-member {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  background: #1b2f33;
  border-left: 2px solid #c3a76c;
  font-size: 12px;
}
.bag-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.bag-head .level {
  font-size: 11px;
  color: #dbc68c;
}
.bar.exp i {
  background: #d9b86a;
}
.bag-member small,
.bag-item small {
  font-size: 10px;
  color: #c8cebc;
}
.bag-stats {
  margin: 2px 0 4px;
  font-size: 11px;
  line-height: 1.6;
  color: #e2d8c1;
}
.bag-slot {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.bag-slot .slot {
  color: #9fae9b;
}
.bag-slot button,
.bag-item button {
  padding: 3px 9px;
  font-size: 11px;
}
.bag-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #1b2f33;
}
.bag-item .about {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bag-item .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
#battle {
  position: absolute;
  inset: 0;
  pointer-events: none;
  --gold: #e3c07d;
  --gold-hi: #f2c76b;
  --ink: #2a1810;
  --ally: #d8b46a;
  --foe: #c4574b;
  --panel: #14242bf0;
}
/* Turn order: this round from the actor on, then the next. */
#turn-order {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 26px 7px 22px;
  background: linear-gradient(90deg, transparent, #0f1e26e6 14%, #0f1e26e6 86%, transparent);
  border-block: 1px solid #c3a76c4d;
  white-space: nowrap;
}
#turn-order .round {
  font-family: 'Songti SC', 'STSong', serif;
  letter-spacing: 3px;
  color: #edd4a3;
  font-size: 13px;
  margin-right: 10px;
}
.chip {
  position: relative;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--ally);
  background: radial-gradient(circle at 50% 35%, #34484b, #142226);
  box-shadow: inset 0 0 0 1px #0008;
}
.chip.enemy {
  border-color: var(--foe);
  background: radial-gradient(circle at 50% 35%, #4a2e2c, #1d1515);
}
.chip-face {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
.chip.now {
  width: 46px;
  height: 46px;
  margin: 0 6px 12px;
  border-width: 2px;
  border-color: var(--gold-hi);
  box-shadow:
    0 0 14px #f2c76b80,
    inset 0 0 0 1px #0009;
}
.chip.now.enemy {
  border-color: #ff8a73;
  box-shadow:
    0 0 14px #ff6d5280,
    inset 0 0 0 1px #0009;
}
.chip-name {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #f8e6bd;
  text-shadow: 0 1px 3px #000;
}
.chip.later {
  width: 26px;
  height: 26px;
  opacity: 0.5;
}
/* A fighter's second turn in a round: quick enough to be due again. */
.chip.again::after {
  content: '+';
  position: absolute;
  top: -7px;
  right: -5px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-hi);
  text-shadow: 0 1px 2px #000;
}
.next-round {
  font-size: 10px;
  letter-spacing: 2px;
  color: #c8cebc;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid #c3a76c55;
}
/* Rosters */
#enemy-list {
  position: absolute;
  right: 26px;
  top: 142px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 214px;
}
#battle-party {
  position: absolute;
  right: 26px;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Wide enough for a hero's own gauge after 士气, and the health after the bar. */
  width: 262px;
}
.roster-title {
  font-size: 10px;
  letter-spacing: 5px;
  color: #ec9f8f;
  text-shadow: 0 1px 3px #000;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.card-head b {
  font-weight: 600;
  letter-spacing: 1px;
}
.row-tag {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 1px 5px;
  color: #c8cebc;
  border: 1px solid #c8cebc4d;
}
.row-tag.front {
  color: #f0d39a;
  border-color: #d8b46a80;
}
.hp-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hp {
  flex: 1;
  display: block;
  height: 4px;
  background: #0d171a;
  box-shadow: inset 0 0 0 1px #000a;
  overflow: hidden;
}
.hp i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6f9e6a, #b9da9c);
}
.hp.low i {
  background: linear-gradient(90deg, #a2442e, #e7a05e);
}
.foe-hp i {
  background: linear-gradient(90deg, #8a2b27, #e0705c);
}
.hp-num {
  min-width: 52px;
  text-align: right;
  font-size: 10px;
  line-height: 1;
  color: #c8cebc;
  font-variant-numeric: tabular-nums;
}
.foe {
  pointer-events: auto;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 6px 11px 6px 12px;
  background: linear-gradient(100deg, #2b1c1de8, #182327e0);
  border: 1px solid #b8473b4d;
  border-left: 3px solid var(--foe);
  border-radius: 2px;
  transition:
    transform 0.16s,
    background 0.16s;
}
.foe:hover:not(:disabled) {
  background: linear-gradient(100deg, #3e2627f0, #212b2fe8);
}
.foe.selected {
  border-color: #f2c76b99;
  border-left-color: var(--gold-hi);
  background: linear-gradient(100deg, #4d3923f2, #232a2ae8);
  transform: translateX(-10px);
}
.foe.down {
  opacity: 0.4;
}
.pointer {
  color: var(--gold-hi);
  font-size: 9px;
  display: none;
}
.foe.selected .pointer {
  display: inline;
}
.ally {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 9px;
  align-items: center;
  padding: 4px 11px 4px 6px;
  background: linear-gradient(100deg, #17272cee, #13222ad8);
  border-left: 3px solid #66756a;
  transition: transform 0.2s;
}
.ally.now {
  border-left-color: var(--gold-hi);
  background: linear-gradient(100deg, #3b3423f4, #17272ce4);
  transform: translateX(-14px);
  box-shadow:
    0 0 0 1px #f2c76b4d,
    0 4px 14px #0007;
}
.ally.down {
  opacity: 0.5;
  filter: grayscale(0.85);
}
/* Whom a skill on an ally is for, while one is being picked; a click on another names them. */
.ally.ward {
  box-shadow: inset 0 0 0 1px #9fd8c0aa;
}
.ally.ward .card-head b::after {
  content: ' ◀';
  color: #9fd8c0;
}
.ally-face {
  width: 30px;
  height: 30px;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 35%, #34484b, #142226);
  border: 1px solid #c3a76c66;
}
.ally-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.skill-pip {
  color: var(--gold-hi);
  font-size: 11px;
}
.skill-pip.spent {
  color: #66756a;
}
.state-tag {
  font-size: 9px;
  color: #a9c8ff;
  border: 1px solid #a9c8ff66;
  padding: 0 4px;
}
/* Commands */
#combat-actions {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  pointer-events: auto;
  padding: 11px 16px 14px;
  background: linear-gradient(180deg, #14242bf2, #0f1c22f2);
  border-top: 1px solid #c3a76c88;
  box-shadow: 0 10px 30px #0009;
}
#combat-actions:empty {
  display: none;
}
.command-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: #c8cebc;
  letter-spacing: 1px;
}
.command-head b {
  font-family: 'Songti SC', 'STSong', serif;
  font-size: 18px;
  color: #f8e6bd;
  letter-spacing: 3px;
}
.command-head .aim {
  margin-left: auto;
  padding-left: 24px;
  color: #f1b8a6;
}
.command-list {
  display: flex;
  gap: 8px;
}
.command {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 9px;
  text-align: left;
  min-width: 128px;
  padding: 8px 26px 8px 10px;
  background: #1d2e33ee;
  border: 1px solid #c3a76c4d;
  border-radius: 2px;
}
.command:hover:not(:disabled) {
  background: #57492ef0;
  border-color: var(--gold-hi);
  transform: translateY(-2px);
}
.command .numeral {
  grid-row: span 2;
  font-family: 'Songti SC', 'STSong', serif;
  font-size: 22px;
  line-height: 1;
  color: var(--gold);
}
.command .label {
  font-size: 15px;
  letter-spacing: 3px;
}
.command small {
  grid-column: 2;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold);
}
.command kbd {
  position: absolute;
  top: 5px;
  right: 4px;
  margin: 0;
  padding: 0 4px;
  font-size: 9px;
  opacity: 0.65;
}
.command.skill {
  border-color: #e3c07d80;
  background: linear-gradient(100deg, #2d2a1eee, #1d2e33ee);
}
#combat-actions.waiting,
#combat-actions.result {
  background: none;
  border: 0;
  box-shadow: none;
}
#combat-actions.waiting {
  font-size: 13px;
  letter-spacing: 4px;
  color: #e9dcc0;
  text-shadow: 0 2px 6px #000;
}
#combat-actions .primary {
  font-size: 15px;
  letter-spacing: 3px;
  padding: 12px 28px;
  background: #5b4a2cf2;
  border-color: var(--gold-hi);
}
/* Timing: one button, judged by when it is pressed. */
#combat-actions.timing {
  justify-items: center;
  gap: 6px;
  padding: 10px 18px 12px;
}
.judge-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  justify-content: center;
  font-size: 16px;
  letter-spacing: 4px;
  padding: 12px 26px;
  background: #1d2e33ee;
  border-color: #c3a76c66;
}
.judge-button kbd {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0;
  opacity: 0.75;
}
.judge-hint {
  font-size: 11px;
  letter-spacing: 2px;
  color: #c8cebc;
}
.reaction {
  background: #4c4a3c !important;
  border-color: #f0f0e8 !important;
  box-shadow: 0 0 16px #ffffff55;
}
.reaction.perfect {
  background: #7a5a26 !important;
  border-color: #ffd27a !important;
  box-shadow: 0 0 22px #ffcf6aaa;
}
/* Stance (架势): one pip per point; broken stances flash. */
.stance {
  display: flex;
  align-items: center;
  gap: 3px;
}
.stance small {
  font-size: 9px;
  letter-spacing: 1px;
  color: #c8cebc;
  margin-right: 4px;
}
.stance i {
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  border: 1px solid #e3c07d99;
  background: transparent;
}
.stance i.full {
  background: #e3c07d;
}
.stance.broken i {
  border-color: #ff8a5c;
}
.stance small.block-chance {
  margin: 0 0 0 auto;
  color: #a9c4dc;
}
/* Lasting effects: a small tag each, with the turns left. */
.stance small.status {
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 700;
  color: #16120f;
}
.stance small.status.poison {
  background: #a98ad6;
}
.stance small.status.burn {
  background: #f08a4b;
}
.stance small.status.stun {
  background: #e9d36a;
}
.stance small.status.break {
  background: #c9a28a;
}
.stance small.status.rally {
  background: #e8c07a;
}
.stance small.status.reflect {
  background: #8ec9d6;
}
.stance small.status.cover {
  background: #9fd8c0;
}
.stance small.status.fury {
  background: #e8795c;
}
.stance small.status.poised {
  background: #e8d9a6;
}
/* 士气: round pips after the stance; a gap marks what the cheapest skill costs. */
.stance .qi {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}
.stance .qi small {
  margin-right: 3px;
  color: #8fc4dc;
}
.stance .qi b {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid #7fc6e899;
}
.stance .qi b.full {
  background: #8fd6f5;
  box-shadow: 0 0 4px #8fd6f588;
}
.stance .qi b.cost {
  margin-right: 4px;
}
.stance .qi.ready small {
  color: #d9f3ff;
}
.ally .stance {
  margin-top: 3px;
}
.state-tag.broken {
  color: #ffb27a;
  border-color: #ff8a5c99;
}
.state-tag.leader {
  color: #f2c76b;
  border-color: #f2c76b99;
}
/* Banners: the armies' formations, a skill being called, the outcome. */
#battle-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  opacity: 0;
  --slide: 0;
}
#battle-banner.skill {
  top: 21%;
}
#battle-banner .side {
  display: grid;
  justify-items: center;
  min-width: 230px;
  padding: 9px 30px 11px;
  background: linear-gradient(90deg, transparent, #0f1e26e0 22%, #0f1e26e0 78%, transparent);
  border-block: 1px solid #d8b46a55;
}
#battle-banner .side.party {
  transform: translateX(calc(var(--slide) * -260px));
}
#battle-banner .side.enemy {
  transform: translateX(calc(var(--slide) * 260px));
  border-color: #c4574b55;
}
#battle-banner small {
  font-size: 11px;
  letter-spacing: 6px;
  color: #d9ccb2;
}
#battle-banner .side b {
  font-family: 'Songti SC', 'STSong', serif;
  font-size: 34px;
  letter-spacing: 10px;
  margin-right: -10px;
  color: #f6dfa8;
  text-shadow:
    0 2px 10px #000,
    0 0 18px #f2c76b55;
}
#battle-banner .side.enemy b {
  color: #f6b6a4;
  text-shadow:
    0 2px 10px #000,
    0 0 18px #d0574a66;
}
#battle-banner .versus {
  font-family: 'Songti SC', 'STSong', serif;
  font-size: 18px;
  letter-spacing: 4px;
  color: #e9dcc0;
  text-shadow: 0 2px 8px #000;
  opacity: calc(1 - var(--slide));
}
#battle-banner .stripe {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 100%;
  padding: 11px 0 13px;
  background: linear-gradient(90deg, transparent, #120f0ce8 18%, #2b2116f0 50%, #120f0ce8 82%, transparent);
  border-block: 1px solid #e3c07d59;
  transform: translateX(calc(var(--slide) * -55%)) skewY(-1.5deg);
}
#battle-banner .stripe small {
  color: var(--gold);
}
#battle-banner .stripe b {
  font-family: 'Songti SC', 'STSong', serif;
  font-size: 38px;
  letter-spacing: 16px;
  margin-right: -16px;
  color: #fff3d0;
  text-shadow:
    0 0 16px #ffcf7a99,
    0 3px 10px #000;
}
#battle-banner.result .stripe b {
  font-size: 46px;
}
/* Over the stage: damage, the chosen target, an incoming blow. */
.float-label {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: 12px;
  background: #14292bd9;
  border: 1px solid #b3a87e77;
  padding: 5px 10px;
  white-space: nowrap;
  pointer-events: none;
}
.float-label.damage,
.float-label.judge,
.float-label.target-marker,
.float-label.alert-marker {
  background: none;
  border: 0;
  padding: 0;
}
.damage {
  font-family: 'Songti SC', 'STSong', serif;
  font-weight: 900;
  font-size: 30px;
  letter-spacing: 1px;
  color: #fff4d6;
  -webkit-text-stroke: 1px var(--ink, #2a1810);
  text-shadow:
    0 3px 0 #2a1810,
    0 4px 12px #000a;
  transform: translate(-50%, calc(-100% - var(--rise, 0px))) scale(var(--pop, 1));
  transform-origin: 50% 100%;
}
.damage.skill-hit {
  font-size: 38px;
  color: #ffe08a;
  text-shadow:
    0 3px 0 #4a2a0e,
    0 0 18px #ffb54a99;
}
.damage.evade {
  font-size: 22px;
  letter-spacing: 4px;
  color: #c4ece3;
}
.damage.blocked {
  font-size: 22px;
  color: #b9cbe0;
}
/* Met only in time: what still landed, half out of the way. */
.damage.graze {
  font-size: 24px;
  color: #e8d9b8;
}
.damage.heal {
  font-size: 26px;
  color: #b8f2a8;
}
.damage.status {
  font-size: 24px;
  color: #c9a8f0;
}
.damage.status.burn {
  color: #ffa86b;
}
.damage.reflect {
  font-size: 26px;
  color: #9fe0f0;
}
.judge.status {
  font-size: 22px;
  color: #f2e2c0;
}
.judge.status.cover {
  color: #b8f0d8;
}
#combat-actions .spoils {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 2px;
  color: #e9dcc0;
  text-shadow: 0 2px 6px #000;
}
/* The grade of a timing press, and what it led to. */
.judge {
  font-family: 'Songti SC', 'STSong', serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 3px;
  -webkit-text-stroke: 1px #2a1810;
  text-shadow:
    0 2px 0 #2a1810,
    0 3px 10px #000a;
  transform: translate(-50%, calc(-100% - var(--rise, 0px) - var(--stack, 0) * 34px)) scale(var(--pop, 1));
  transform-origin: 50% 100%;
}
.judge.perfect {
  font-size: 28px;
  color: #ffd76b;
  text-shadow:
    0 2px 0 #4a2a0e,
    0 0 18px #ffbf4a99;
}
.judge.good {
  color: #f2f4f0;
}
.judge.miss {
  font-size: 18px;
  color: #ff7a6a;
}
.judge.counter {
  color: #ffb08a;
}
.judge.break {
  font-size: 30px;
  color: #ff9a4a;
  text-shadow:
    0 2px 0 #4a1e0e,
    0 0 20px #ff7a2a99;
}
.judge.recover {
  font-size: 16px;
  color: #c8cebc;
}
.judge.qi-gain {
  font-size: 15px;
  color: #a8e2ff;
  text-shadow:
    0 2px 0 #10283a,
    0 0 12px #6cc6f099;
}
.judge.block {
  font-size: 20px;
  color: #c6dcf2;
  text-shadow:
    0 2px 0 #1e2a3a,
    0 0 14px #8fb4e099;
}
.target-marker {
  font-size: 17px;
  color: #f2c76b;
  text-shadow:
    0 0 8px #f2c76baa,
    0 2px 3px #000;
  transform: translate(-50%, calc(-100% + var(--bob, 0px)));
}
/* Choosing whom an order strikes: the order to strike, how to change the target, back. */
.command.confirm {
  flex: 0 0 auto;
  /* Room for the key's name, a word rather than a digit. */
  padding-right: 62px;
}
.aim-hint {
  flex: 1;
  align-self: center;
  font-size: 12px;
  opacity: 0.8;
}
/* Choosing whom an order strikes. */
.target-marker.aiming {
  font-size: 26px;
  color: #ffe08a;
  text-shadow:
    0 0 14px #f2c76b,
    0 2px 3px #000;
}
.alert-marker {
  font-size: 28px;
  font-weight: 900;
  color: #ffa66b;
  text-shadow:
    0 0 10px #ff7a3daa,
    0 2px 3px #000;
  transform: translate(-50%, calc(-100% + var(--bob, 0px)));
}
#battle-controls {
  display: flex;
  gap: 20px;
}
#world-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#diagnostics {
  position: absolute;
  right: 18px;
  bottom: 65px;
  background: #14212be0;
  padding: 10px;
  font-size: 10px;
  pointer-events: none;
}
#touch {
  display: none;
}
/* The touch controls are there for a finger, whatever the screen's size; the keys' line is not. */
#game[data-device='touch'] #touch:not([hidden]) {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/*
 * Where the thumb's controls hang: a corner (bottom right, or bottom left for the left hand) and, in it, the
 * hub where the wheel stands while walking and the big button in a fight. --hub is the hub's distance in from
 * the corner, both ways; the buttons round it (#thumb) are placed from the corner too (--x in, --y up).
 */
#game {
  --hub: calc(64px * var(--touch-scale, 1));
  --corner-x: calc(26px + env(safe-area-inset-right, 0px));
  --corner-y: calc(24px + env(safe-area-inset-bottom, 0px));
}
/* Apart: the wheel's half of the screen (below the top bar) takes a thumb anywhere; at rest it waits low on the left. */
#stick-zone {
  position: absolute;
  left: 0;
  width: 46%;
  top: 22%;
  bottom: 0;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#stick {
  position: absolute;
  left: calc(14% + 60px * var(--touch-scale, 1));
  top: calc(100% - 28px - 70px * var(--touch-scale, 1) - env(safe-area-inset-bottom, 0px));
  width: calc(124px * var(--touch-scale, 1));
  height: calc(124px * var(--touch-scale, 1));
  translate: -50% -50%;
  border-radius: 50%;
  /* The interface's lacquer: dark in the middle, a gold rim with a tick for each of the eight ways. */
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--ui-ink) 62%, transparent) 0 58%,
    color-mix(in srgb, var(--ui-ink) 88%, transparent) 70%
  );
  border: 2px solid color-mix(in srgb, var(--ui-gold) 75%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ui-ink) 80%, transparent),
    0 4px 14px #0008;
  opacity: calc(0.5 + var(--touch-alpha, 0.7) * 0.5);
  transition: opacity 0.15s;
}
#stick::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from -3deg,
    color-mix(in srgb, var(--ui-gold) 80%, transparent) 0 6deg,
    transparent 6deg 45deg
  );
  /* Only a thin ring at the rim shows the ticks. */
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
  mask: radial-gradient(circle closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
}
#stick-zone.held #stick {
  opacity: 1;
}
/* All under one thumb: the wheel stands still at the hub, and its zone is the wheel and a little round it. */
#game:not([data-touch-layout='split']) #stick-zone {
  left: auto;
  top: auto;
  right: calc(var(--corner-x) + var(--hub) - 84px * var(--touch-scale, 1));
  bottom: calc(var(--corner-y) + var(--hub) - 84px * var(--touch-scale, 1));
  width: calc(168px * var(--touch-scale, 1));
  height: calc(168px * var(--touch-scale, 1));
  border-radius: 50%;
}
#game[data-touch-layout='left'] #stick-zone {
  right: auto;
  left: calc(26px + env(safe-area-inset-left, 0px) + var(--hub) - 84px * var(--touch-scale, 1));
}
#game:not([data-touch-layout='split']) #stick {
  left: 50%;
  top: 50%;
}
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  height: 44%;
  margin: -22% 0 0 -22%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--ui-text) 55%, var(--ui-ink)), color-mix(in srgb, var(--ui-text) 15%, var(--ui-ink)));
  border: 2px solid var(--ui-gold);
  box-shadow: 0 3px 10px #000a;
  transition: background 0.12s, box-shadow 0.12s;
}
#stick-zone.hurry #stick-knob {
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--ui-gold) 85%, #fff), var(--ui-gold));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-gold) 35%, transparent), 0 3px 10px #000a;
}
/* The first time the wheel is there: what it does, until it has been pushed once. */
#touch-hint {
  position: absolute;
  right: max(6px, calc(var(--corner-x) + var(--hub) - 100px));
  bottom: calc(var(--corner-y) + var(--hub) * 2 + 34px);
  width: 200px;
  padding: 6px 10px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ui-text);
  background: color-mix(in srgb, var(--ui-ink) 88%, transparent);
  border: 1px solid var(--ui-gold);
  pointer-events: none;
  animation: hint-bob 1.6s ease-in-out infinite;
}
#game[data-touch-layout='left'] #touch-hint {
  right: auto;
  left: max(6px, calc(26px + env(safe-area-inset-left, 0px) + var(--hub) - 100px));
}
#game[data-touch-layout='split'] #touch-hint {
  right: auto;
  left: calc(14% + 60px * var(--touch-scale, 1) - 90px);
  bottom: calc(28px + 150px * var(--touch-scale, 1));
}
@keyframes hint-bob {
  50% {
    translate: 0 -4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #touch-hint {
    animation: none;
  }
}
/* The buttons under the thumb (ui/thumb.ts): a big one at the hub, the small ones round it in an arc. */
#thumb {
  display: none;
}
#game[data-device='touch'] #thumb {
  display: block;
  position: absolute;
  right: var(--corner-x);
  bottom: var(--corner-y);
  width: 0;
  height: 0;
  z-index: 35;
  --side: -1;
}
#game[data-device='touch'][data-touch-layout='left'] #thumb {
  right: auto;
  left: calc(26px + env(safe-area-inset-left, 0px));
  --side: 1;
}
#game #thumb button {
  position: absolute;
  left: calc(var(--x) * var(--side) * var(--touch-scale, 1));
  top: calc(var(--y) * var(--touch-scale, 1));
  width: calc(var(--d) * var(--touch-scale, 1));
  height: calc(var(--d) * var(--touch-scale, 1));
  translate: -50% -50%;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ui-gold) 70%, transparent);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--ui-ink) 55%, var(--ui-accent)), var(--ui-ink));
  color: var(--ui-text);
  font-family: var(--ui-font-heading);
  font-size: calc(15px * var(--touch-scale, 1));
  letter-spacing: 2px;
  line-height: 1.15;
  text-align: center;
  /* Solid, so the ground does not show through the words; the strength setting only fades it a little. */
  opacity: calc(0.55 + var(--touch-alpha, 0.7) * 0.45);
  transition: scale 0.08s, filter 0.08s;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 3px 10px #0009;
}
#game #thumb button[hidden] {
  display: none;
}
/* The big one at the hub; the arc kept low and close (a fight's orders and blows, and walking when apart). */
#game #thumb .thumb-main {
  --x: 64px;
  --y: -64px;
  --d: 96px;
  font-size: calc(19px * var(--touch-scale, 1));
}
#game #thumb .thumb-a {
  --x: 170px;
  --y: -92px;
  --d: 64px;
}
#game #thumb .thumb-b {
  --x: 119px;
  --y: -159px;
  --d: 64px;
}
#game #thumb .thumb-c {
  --x: 164px;
  --y: -18px;
  --d: 64px;
}
#game #thumb .thumb-d {
  --x: 40px;
  --y: -178px;
  --d: 56px;
}
/* Walking with all under one thumb: the wheel at the hub, round it what is near (the most to hand), a talk, the map, the pack. */
#game:not([data-touch-layout='split'])[data-moment='world'] #thumb .thumb-a {
  --x: 149px;
  --y: -149px;
  --d: 74px;
}
#game:not([data-touch-layout='split'])[data-moment='world'] #thumb .thumb-b {
  --x: 70px;
  --y: -182px;
  --d: 58px;
}
#game:not([data-touch-layout='split'])[data-moment='world'] #thumb .thumb-c {
  --x: 174px;
  --y: -83px;
  --d: 52px;
}
#game:not([data-touch-layout='split'])[data-moment='world'] #thumb .thumb-d {
  --x: 180px;
  --y: -20px;
  --d: 52px;
}
#game #thumb button.long {
  font-size: calc(12px * var(--touch-scale, 1));
  letter-spacing: 0;
}
#game #thumb button.latin {
  font-size: calc(13px * var(--touch-scale, 1));
  letter-spacing: 0;
}
/* Not to be pressed now: still a solid button, its words greyed (a see-through one looks broken). */
#game #thumb button:disabled {
  color: color-mix(in srgb, var(--ui-text) 40%, transparent);
  background: color-mix(in srgb, var(--ui-ink) 92%, #000);
  border-color: color-mix(in srgb, var(--ui-line) 70%, transparent);
  box-shadow: none;
}
#game #thumb button.lit {
  border-color: var(--ui-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-gold) 45%, transparent), 0 3px 10px #0009;
}
#game #thumb button.pressed {
  scale: 0.9;
  opacity: 1;
  filter: brightness(1.3);
}
/* A tablet (or any taller screen) on touch, in a fight: the rosters a little smaller, the party's lifted off the corner the thumb's buttons take. */
@media (min-height: 501px) {
  #game[data-device='touch'] #enemy-list {
    scale: 0.85;
    transform-origin: top right;
  }
  /* The buttons on the right: the party's cards top left, over the party, leaving the bottom right to the thumb. */
  #game[data-device='touch']:not([data-touch-layout='left']) #battle-party {
    right: auto;
    bottom: auto;
    left: 26px;
    top: 142px;
    scale: 0.85;
    transform-origin: top left;
  }
  /* The panel (words only) moves over from the side the buttons are on. */
  #game[data-device='touch'] #combat-actions {
    left: calc(50% - 130px);
  }
  #game[data-device='touch'][data-touch-layout='left'] #combat-actions {
    left: calc(50% + 130px);
  }
}
/*
 * A phone held sideways, on touch, in a fight. The thumb's buttons on the right (all right-handed, or apart):
 * each side's cards over its own fighters, the party's on the left and the foes' on the right, the panel
 * (words only) between them, the bottom right the thumb's. All left-handed: the foes' cards stay on the left
 * and the party's on the right, as the page had them, and the bottom left is the thumb's.
 */
@media (max-height: 500px) {
  #game[data-device='touch']:not([data-touch-layout='left']) #battle-party {
    right: auto;
    left: 10px;
    scale: 0.8;
    transform-origin: top left;
  }
  #game[data-device='touch']:not([data-touch-layout='left']) #enemy-list {
    left: auto;
    right: 10px;
  }
  #game[data-device='touch']:not([data-touch-layout='left']) #combat-actions {
    left: 150px;
    right: 290px;
  }
  #game[data-device='touch'][data-touch-layout='left'] #battle-party {
    scale: 0.8;
    transform-origin: top right;
  }
  #game[data-device='touch'][data-touch-layout='left'] #combat-actions {
    left: 290px;
    right: 180px;
  }
}
/* A line being read keeps clear of the corners: the thumb's big button (read on) stands in one of them. */
#game[data-device='touch'] #dialogue {
  width: min(680px, calc(100% - 340px));
}
/* What the thumb's buttons stand for is not shown twice: the fight panel keeps its words and lists, the footer its hint. */
#game[data-device='touch'] #combat-actions .judge-pair,
#game[data-device='touch'] #combat-actions #reaction,
#game[data-device='touch'] #combat-actions .command-list:not(.items),
#game[data-device='touch'] footer #interact {
  display: none;
}
/* On a touch screen the bottom corners are the thumbs': the party's cards go up under the objective, which keeps to two lines. */
#game[data-device='touch'] #party {
  top: 150px;
  bottom: auto;
}
/* All left-handed: the left side is the thumb's, so the party's cards go right, under the small map. */
#game[data-device='touch'][data-touch-layout='left'] #party {
  left: auto;
  right: 26px;
  top: 270px;
}
#game[data-device='touch'] #objective {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-height: 500px) {
  #game[data-device='touch'] #party {
    top: 116px;
  }
  #game[data-device='touch'][data-touch-layout='left'] #party {
    right: 14px;
    top: 140px;
  }
  #game[data-touch-layout='split'] #stick-zone {
    top: 45%;
  }
}
#game[data-device='touch'] #controls,
#game[data-device='touch'] #battle-controls {
  display: none;
}
/* A key's chip with no key to name (a touch screen's buttons say what they do). */
kbd:empty {
  display: none;
}
@media (max-width: 760px), (max-height: 500px) {
  #turn-order {
    top: 58px;
    padding: 5px 14px;
    gap: 4px;
    max-width: calc(100% - 16px);
  }
  #turn-order .round {
    font-size: 11px;
    margin-right: 4px;
  }
  .chip {
    width: 24px;
    height: 24px;
  }
  .chip.now {
    width: 34px;
    height: 34px;
    margin: 0 3px 12px;
  }
  .chip.later,
  .next-round {
    display: none;
  }
  #enemy-list {
    right: 10px;
    top: 118px;
    width: 150px;
    gap: 5px;
  }
  .foe {
    padding: 6px 8px;
  }
  .card-head {
    font-size: 11px;
  }
  .row-tag {
    display: none;
  }
  #battle-party {
    right: 10px;
    bottom: 158px;
    width: 168px;
    gap: 4px;
  }
  .ally {
    grid-template-columns: 26px 1fr;
    gap: 6px;
    padding: 4px 8px 4px 5px;
  }
  .ally-face {
    width: 26px;
    height: 26px;
  }
  .ally.now {
    transform: translateX(-8px);
  }
  #combat-actions {
    left: 10px;
    right: 10px;
    bottom: 40px;
    transform: none;
    padding: 8px 10px 10px;
  }
  .command-list {
    gap: 6px;
  }
  .command {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
  }
  .command .numeral {
    font-size: 17px;
  }
  .command .label {
    font-size: 13px;
    letter-spacing: 1px;
  }
  .command kbd {
    display: none;
  }
  #battle-banner .side {
    min-width: 0;
    padding: 6px 14px;
  }
  #battle-banner .side b,
  #battle-banner .stripe b {
    font-size: 24px;
    letter-spacing: 6px;
    margin-right: -6px;
  }
}
/* A phone held sideways: the fight between its two rosters, the orders under it. */
@media (max-height: 500px) {
  /* What spills past the screen would make a phone's page wider, and shrink it all to fit. */
  #game {
    overflow: hidden;
  }
  #turn-order {
    top: 44px;
    left: 170px;
    right: 180px;
    max-width: none;
    transform: none;
    overflow: hidden;
  }
  /* Six foes fit a phone's height; on the smallest the list scrolls. */
  #enemy-list {
    left: 10px;
    right: auto;
    top: 46px;
    width: 150px;
    max-height: calc(100% - 52px);
    gap: 2px;
    overflow-y: auto;
    pointer-events: auto;
    scrollbar-width: none;
  }
  .roster-title {
    display: none;
  }
  .foe {
    gap: 1px;
    padding: 2px 8px;
  }
  .foe.selected {
    transform: none;
  }
  .stance {
    flex-wrap: wrap;
  }
  #battle-party {
    right: 10px;
    top: 46px;
    bottom: auto;
    width: 160px;
    gap: 3px;
  }
  .ally {
    padding: 2px 8px 2px 5px;
  }
  .ally .stance {
    margin-top: 0;
  }
  .ally .stance .qi {
    margin-left: 0;
  }
  #combat-actions {
    left: 170px;
    right: 180px;
    bottom: 6px;
    padding: 5px 8px 6px;
    max-height: calc(62 * var(--vh));
    overflow: auto;
  }
  .command-head {
    margin-bottom: 3px;
  }
  .command {
    padding: 5px 6px;
    column-gap: 5px;
  }
  .command:not(.item) small {
    display: none;
  }
  /* A hero's skills or the bag can be many: as many to a row as fit, the rest under them. */
  .command-list.items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 4px;
  }
  .command-list.items .command {
    min-height: 32px;
    padding: 3px 6px;
  }

}
/* The narrowest phones: the orders two by two. */
@media (max-height: 500px) and (max-width: 660px) {
  .command-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
}
