:root {
  --bg: #0f1318;
  --ink: #e8edf3;
  --dim: #8a96a6;
  --panel: rgba(12, 16, 22, 0.72);
  --hp: #5ad17a;
  --ar: #f2c84b;
  --hot: #ff6b4a;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.3 system-ui, "Noto Sans TC", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.status {
  display: grid;
  gap: 5px;
  background: var(--panel);
  padding: 7px 10px;
  border-radius: 10px;
}
/* Corner map on big maps; a tap makes it bigger. */
#mini {
  position: static;
  width: 118px;
  height: auto;
  align-self: start;
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
}
#mini.wide {
  width: 200px;
}
@media (min-width: 900px) {
  #mini {
    width: 160px;
  }
  #mini.wide {
    width: 260px;
  }
}
#clock {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bar {
  position: relative;
  width: 118px;
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  transition: width 0.12s;
}
.hp i {
  background: var(--hp);
}
.ar i {
  background: var(--ar);
}
.bar b {
  position: relative;
  display: block;
  font-size: 11px;
  line-height: 14px;
  padding-left: 6px;
  color: #0b0e12;
  mix-blend-mode: normal;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}
#board {
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  background: var(--panel);
  border-radius: 10px;
  display: grid;
  gap: 3px;
  min-width: 78px;
}
#board li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
#board li.me {
  font-weight: 700;
}
#board .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
#board .n {
  margin-left: auto;
}
#edge {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 70px 18px rgba(255, 45, 35, 0.8);
  opacity: 0;
}
#verdict {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
#verdict:empty {
  display: none;
}
#toast {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 104px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#toast.on {
  opacity: 1;
}
/* What a rival just said: a face, a name, a few words. */
#bark {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 134px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 15px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#bark.on {
  opacity: 1;
}
#bark .face {
  width: 30px;
  height: 30px;
}
.face {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: -5px;
  margin-right: 3px;
}
#board .rk {
  width: 1.4em;
  font-size: 0.8em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
#board .face {
  margin: -2px -4px -2px -2px;
}
#stick {
  position: absolute;
  width: 116px;
  height: 116px;
  margin: -58px 0 0 -58px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  left: 92px;
  top: calc(100% - 96px - env(safe-area-inset-bottom));
  opacity: 0.35;
}
@media (pointer: coarse) {
  #stick {
    opacity: 0.6;
  }
}
#stick.on {
  opacity: 1;
}
#stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}
#fire {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 140, 110, 0.9);
  background: radial-gradient(circle, rgba(255, 107, 74, 0.55), rgba(255, 107, 74, 0.25));
  pointer-events: auto;
  touch-action: none;
}
#fire::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
}
#fire.on {
  background: rgba(255, 107, 74, 0.8);
}
.weapons {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(260px, 62vw);
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 108px);
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.weapons button {
  min-width: 48px;
  color: var(--c);
  padding: 5px 6px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--panel);
  display: grid;
  justify-items: center;
  font-size: 13px;
  line-height: 1.15;
}
.weapons button canvas {
  position: static;
  width: 36px;
  height: 18px;
}
.weapons button b {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.weapons button.cur {
  border-color: var(--c);
  background: rgba(40, 48, 60, 0.9);
}
.weapons button.cur b {
  color: var(--ink);
}
.weapons button:disabled {
  opacity: 0.3;
}
.sheet {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: safe center;
  justify-items: center;
  overflow-y: auto;
  background: rgba(10, 13, 17, 0.4);
  padding: 16px;
  touch-action: pan-y;
}
/* The match stays in view behind the menu; a result or a pause dims it more. */
.sheet[data-view="result"],
.sheet[data-view="pause"] {
  background: rgba(10, 13, 17, 0.7);
}
#card {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 100%;
  padding: 22px 24px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 16, 22, 0.92);
}
.sheet[hidden],
.sheet [hidden] {
  display: none !important;
}
/* Settings: a name on the left, its control on the right. */
#settings {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(380px, 100%);
}
.set {
  display: grid;
  gap: 8px;
  width: 100%;
}
.set > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}
.set button {
  min-width: 96px;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
}
.set button[aria-pressed="true"] {
  border-color: var(--ar);
  color: var(--ar);
}
.set input {
  width: 150px;
  accent-color: var(--hot);
  touch-action: pan-x;
}
.set .note {
  text-align: center;
}
.set input[type="text"] {
  width: 150px;
  touch-action: auto;
}
.set textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  word-break: break-all;
  resize: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: pan-y;
}
.set #saveMsg {
  color: var(--dim);
  font-size: 13px;
}
@media (orientation: landscape) and (max-height: 500px) {
  .set textarea {
    grid-column: 1 / -1;
  }
}
.pad button:focus,
.pad input:focus {
  outline: 2px solid var(--ar);
  outline-offset: 2px;
}
@media (orientation: landscape) and (max-height: 500px) {
  #settings {
    width: min(640px, 100%);
    gap: 8px;
  }
  .set {
    grid-template-columns: 1fr 1fr;
    column-gap: 28px;
    row-gap: 4px;
  }
  .set .note {
    grid-column: 1 / -1;
  }
}
/* The armory: a card for each weapon and item. */
#arsenal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(560px, 100%);
}
@media (min-width: 900px) {
  #arsenal {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: min(860px, 100%);
  }
  #arsenal .item {
    padding: 2px 6px 8px;
  }
  #arsenal .item canvas {
    width: 56px;
    height: 56px;
  }
}
/* The way back stays in view under a long list. */
.sheet[data-view="armory"] #home {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 0 0 8px rgba(12, 16, 22, 0.96);
  background: rgba(12, 16, 22, 0.96);
}
.item {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  padding: 6px 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: radial-gradient(circle at 50% 34%, color-mix(in srgb, var(--c) 16%, transparent), transparent 62%);
  text-align: center;
}
.item canvas {
  position: static;
  width: 72px;
  height: 72px;
}
.item b {
  color: var(--c);
  font-size: 15px;
}
.item p,
.item span {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--dim);
}
.item p {
  color: var(--ink);
  white-space: pre-line;
  text-wrap: balance;
}
.item span {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) {
  #arsenal {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  #arsenal {
    grid-template-columns: repeat(4, 1fr);
    width: min(720px, 100%);
  }
}
/* The name's own face: Noto Sans TC Black, only the six letters of the cover
   (assets/fonts, SIL Open Font License 1.1). */
@font-face {
  font-family: "Arena Title";
  src: url(assets/fonts/title.woff) format("woff");
  font-weight: 900;
  font-display: block;
}
/* The cover: the game's own scene behind the name, one way in. */
#cover {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(8vh, env(safe-area-inset-top)) 16px max(9vh, calc(env(safe-area-inset-bottom) + 24px));
  background: linear-gradient(rgba(0, 0, 0, 0.7), transparent 30%, transparent 66%, rgba(0, 0, 0, 0.65));
}
#cover[hidden] {
  display: none;
}
#cover h1 {
  margin: 0;
  font-size: clamp(48px, 13vmin, 112px);
  line-height: 1;
  font-family: "Arena Title", system-ui, "Noto Sans TC", sans-serif;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: #fff;
  text-shadow:
    0 0.055em 0 #c8321e,
    0 0.09em 0.2em #000;
}
#enter {
  min-width: min(280px, 72vw);
  padding: 16px 40px;
  border-radius: 16px;
  border: 3px solid #fff;
  background: var(--hot);
  color: #fff;
  font-family: "Arena Title", system-ui, "Noto Sans TC", sans-serif;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow:
    0 6px 0 #a3301c,
    0 14px 30px rgba(0, 0, 0, 0.6);
}
/* In: the name grows in, the red flashes, the button sinks. */
#cover.go h1 {
  animation: enter-name 1s ease-out both;
}
#cover.go #enter {
  animation: enter-go 0.35s ease-in both;
}
@keyframes enter-name {
  0% {
    transform: scale(0.85);
  }
  30% {
    transform: scale(1.04);
    text-shadow:
      0 0.055em 0 #ff6b4a,
      0 0 0.5em #ff6b4a;
  }
  60%,
  100% {
    transform: scale(1);
  }
}
@keyframes enter-go {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}
#enter:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #a3301c,
    0 8px 20px rgba(0, 0, 0, 0.6);
}
@media (orientation: landscape) and (max-height: 500px) {
  #cover {
    padding-block: 6vh 8vh;
  }
  #enter {
    padding: 10px 40px;
    font-size: 22px;
  }
}
.sheet h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 0.2em;
}
#result {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  min-width: 220px;
}
#result:empty {
  display: none;
}
#result li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}
#result li.me {
  outline: 1px solid var(--ink);
}
#result .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
#result .n {
  margin-left: auto;
  font-weight: 700;
}
#result .d {
  color: var(--dim);
  font-size: 13px;
}
#start,
#again {
  padding: 12px 44px;
  border-radius: 999px;
  border: 0;
  background: var(--hot);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
#start,
#again,
#resume {
  white-space: nowrap;
}
#resume {
  padding: 11px 32px;
  border-radius: 999px;
  border: 0;
  background: var(--hot);
  color: #fff;
  font-weight: 700;
}
#paused {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.note,
#mine {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#mine:empty {
  display: none;
}
.keys {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}
@media (pointer: coarse) {
  .keys {
    display: none;
  }
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.seg {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.seg button {
  white-space: nowrap;
  padding: 9px 20px;
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 15px;
}
.seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 700;
}
.opts {
  display: flex;
  gap: 8px;
}
.opts button {
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.opts button:disabled {
  color: var(--dim);
  border-color: rgba(255, 255, 255, 0.1);
}
@media (max-width: 480px) {
  .seg button {
    padding: 9px 12px;
  }
  /* Six maps: two rows of three, not one row of broken names. */
  #map {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-radius: 16px;
  }
  #card {
    padding: 18px 14px;
  }
}
#demo,
#learnGo,
#edit,
#stats,
#armory,
#set,
#back,
#quit,
#home {
  white-space: nowrap;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: none;
  font-size: 15px;
}
#mute {
  color: var(--dim);
}
.side {
  display: grid;
  gap: 6px;
  justify-items: end;
}
#feed {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
  justify-items: end;
  font-size: 13px;
}
#feed li {
  background: var(--panel);
  padding: 3px 8px;
  border-radius: 6px;
}
.ico {
  width: 20px;
  height: 20px;
  margin: -4px 2px -5px 0;
  vertical-align: baseline;
}
#feed .ico {
  margin-inline: 3px;
}
#feed span {
  color: var(--dim);
  margin: 0 3px;
}
#stop {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--panel);
  pointer-events: auto;
}
.demo #stop {
  display: block;
}
#pause {
  margin-right: auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: var(--panel);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
#pause::before,
#pause::after {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 1px;
  background: var(--ink);
}
.demo #pause,
.demo #tips {
  display: none;
}
/* A first match on a touch screen: one label over each thumb. */
#tips {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  top: 56%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}
#tips span {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
}
#tips [data-tip="fire"] {
  margin-left: auto;
}
#tips[hidden],
#tips [hidden] {
  display: none;
}
/* A mouse and keys need no stick or fire button, until a finger arrives. */
@media (hover: hover) and (pointer: fine) {
  body:not(.touch) #stick,
  body:not(.touch) #fire {
    display: none;
  }
}
button:focus-visible {
  outline: 2px solid var(--ar);
  outline-offset: 2px;
}
.seg button:focus-visible {
  outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
.demo #fire,
.demo #stick,
.demo .weapons {
  opacity: 0.25;
  pointer-events: none;
}

#powers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
#powers:empty {
  display: none;
}
#powers i {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: 6px;
  padding: 0 5px;
  font-variant-numeric: tabular-nums;
}

/* The menu's views: home, tournament, your record, the result. */
.list {
  display: grid;
  gap: 10px;
  width: min(340px, 100%);
}
/* The map a card leads to. */
.pic {
  flex: none;
  width: 60px;
  height: 40px;
  border-radius: 6px;
  background: #08090a center / cover no-repeat;
}
.list button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
}
.list button span {
  margin-left: auto;
  color: var(--dim);
  font-size: 14px;
  font-weight: 400;
}
.list button {
  white-space: nowrap;
}
#stages button b {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
#stages .pic {
  width: 42px;
  height: 28px;
}
.list button.now {
  border-color: var(--hot);
}
.list button:disabled {
  opacity: 0.35;
}
#stages button {
  font-size: 15px;
  padding: 8px 14px 8px 10px;
}
.list button {
  padding: 10px 16px 10px 10px;
}
#stages button span {
  color: var(--hp);
}
#earned {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  color: var(--dim);
}
#earned:empty {
  display: none;
}
#earned b {
  color: var(--ar);
}
#profile {
  display: grid;
  gap: 14px;
  width: min(360px, 100%);
}
#profile .col {
  display: grid;
  gap: 12px;
  justify-items: center;
  align-content: start;
}
#profile p {
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#totals {
  font-weight: 700;
}
#medals,
#hint {
  color: var(--dim);
  font-size: 13px;
}
#medals:empty {
  display: none;
}
#hint {
  min-height: 1.3em;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.chips:empty {
  display: none;
}
.chips i,
.chips button {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: none;
  font-style: normal;
  font-size: 13px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.chips i {
  color: var(--c);
}
.chips button.got {
  color: var(--ar);
  border-color: var(--ar);
}
.seg .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}
.seg button.locked {
  opacity: 0.5;
}
.seg button.locked::after {
  content: " 🔒";
  font-size: 11px;
}

/* A phone held sideways: little height, so the board lies flat and the
   weapons sit beside the fire button. */
@media (orientation: landscape) and (max-height: 500px) {
  .sheet {
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  #card {
    gap: 10px;
    padding: 12px 20px;
  }
  .list:not(#stages) {
    grid-template-columns: repeat(4, auto);
    width: auto;
  }
  .list:not(#stages) button {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px;
  }
  .list:not(#stages) button span {
    margin-left: 0;
  }
  .list:not(#stages) .pic {
    width: 132px;
    height: 62px;
  }
  .sheet h1 {
    font-size: 28px;
  }
  #stages {
    grid-template-columns: 1fr 1fr;
    width: min(620px, 100%);
  }
  #profile {
    grid-template-columns: 1fr 1fr;
    width: min(740px, 100%);
  }
  #result {
    grid-template-columns: 1fr 1fr;
  }
  #result li {
    padding: 5px 12px;
  }
  .top {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }
  #board {
    display: flex;
    gap: 12px;
    min-width: 0;
    padding: 4px 10px;
  }
  #board li {
    gap: 5px;
  }
  #feed li:nth-child(n + 3) {
    display: none;
  }
  #toast {
    top: calc(max(10px, env(safe-area-inset-top)) + 60px);
  }
  .weapons {
    right: calc(max(22px, env(safe-area-inset-right)) + 108px);
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 420px);
    flex-wrap: wrap-reverse;
  }
  /* One row: the picture and the count, no name. */
  .weapons {
    gap: 4px;
  }
  .weapons button {
    min-width: 40px;
    padding: 4px 2px 2px;
  }
  /* One line each: the picture, the name, the count. */
  .weapons button {
    grid-template-columns: auto auto auto;
    align-items: center;
    column-gap: 3px;
    padding: 4px 6px;
    font-size: 12px;
  }
  .weapons button canvas {
    width: 28px;
    height: 14px;
  }
  .weapons button span {
    white-space: nowrap;
  }
  .weapons button b {
    font-size: 11px;
  }
}

/* Online rooms and the map editor. */
#net,
#room,
#editor {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(420px, 100%);
}
#editor {
  width: min(760px, 100%);
}
#net input,
#editor input,
#editor select {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
}
#net .set input {
  width: 170px;
  touch-action: auto;
}
#netCode {
  width: 110px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
#edCode {
  width: 190px;
}
#edName {
  width: 150px;
}
#roomCode {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.12em;
  user-select: text;
  -webkit-user-select: text;
}
#roomSeats {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  gap: 6px;
}
#roomSeats li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
#roomSeats li.me {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}
#roomSeats button {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--c);
  background: none;
  color: var(--c);
}
#roomSeats button:disabled {
  opacity: 0.75;
  cursor: default;
}
#edMirror[aria-pressed="true"],
#roomPub[aria-pressed="true"] {
  border-color: var(--ar);
  color: var(--ar);
}
#edWrap {
  width: 100%;
}
#edCanvas {
  position: static;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
#edTools,
#edSlots {
  flex-wrap: wrap;
  justify-content: center;
  border-radius: 16px;
}
#edSlots:empty {
  display: none;
}
#editor button:disabled,
#map button:disabled {
  opacity: 0.35;
}
@media (min-width: 481px) {
  #map {
    display: grid;
    grid-template-columns: repeat(5, auto);
    border-radius: 16px;
  }
}
/* A short wide screen: thirteen maps in two rows. */
@media (orientation: landscape) and (max-height: 500px) {
  #map {
    grid-template-columns: repeat(7, auto);
  }
  #map button {
    padding: 7px 10px;
  }
}
#net button,
#room .row button,
#editor .row button {
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: none;
  color: #fff;
  white-space: nowrap;
}
#netNew,
#roomGo,
#edTest {
  border: 0 !important;
  background: var(--hot) !important;
  font-weight: 700;
}
#editor .seg button {
  padding: 8px 13px;
}

/* Left hand: the stick on the right, fire and guns on the left. */
.lefty #stick {
  left: calc(100% - 92px);
}
.lefty #fire {
  right: auto;
  left: max(22px, env(safe-area-inset-left));
}
.lefty .weapons {
  right: auto;
  left: max(14px, env(safe-area-inset-left));
  justify-content: flex-start;
}
@media (orientation: landscape) and (max-height: 500px) {
  .lefty .weapons {
    right: auto;
    left: calc(max(22px, env(safe-area-inset-left)) + 108px);
  }
}
/* Bigger touch buttons. */
.big #stick {
  width: 148px;
  height: 148px;
  margin: -74px 0 0 -74px;
  left: 108px;
}
.big.lefty #stick {
  left: calc(100% - 108px);
}
.big #stick i {
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
}
.big #fire {
  width: 124px;
  height: 124px;
}
.big #fire::after {
  inset: 44px;
}
.big .weapons {
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 136px);
}
.big .weapons button {
  min-width: 58px;
  padding: 8px 8px;
  font-size: 15px;
}
@media (orientation: landscape) and (max-height: 500px) {
  .big .weapons {
    right: calc(max(22px, env(safe-area-inset-right)) + 136px);
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .big.lefty .weapons {
    right: auto;
    left: calc(max(22px, env(safe-area-inset-left)) + 136px);
  }
}
.lefty #tips {
  flex-direction: row-reverse;
}
.lefty #tips [data-tip="fire"] {
  margin-left: 0;
  margin-right: auto;
}

/* The tutorial: the step, what to do, and a way out. */
#learn {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 62px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 28px);
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: var(--panel);
  font-size: 17px;
  white-space: nowrap;
  pointer-events: auto;
}
#learn span {
  color: var(--dim);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
#learn button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 14px;
}
#learn[hidden],
#learn [hidden] {
  display: none;
}

/* First person on a narrow upright phone: the map is always on, so the top
   has less room. Captions go under it, rivals' lines are left out. */
@media (max-width: 600px) and (orientation: portrait) {
  #mini {
    width: 92px;
  }
  #toast {
    top: calc(max(10px, env(safe-area-inset-top)) + 196px);
  }
  #bark {
    display: none;
  }
  #feed li:nth-child(n + 3) {
    display: none;
  }
}
@media (pointer: coarse) {
  #stick:not(.on) {
    opacity: 0.3;
  }
}

/* Full screen, beside pause: four corners. */
#full {
  width: 40px;
  height: 40px;
  margin-left: 6px;
  margin-right: auto;
  border-radius: 10px;
  border: 0;
  background: var(--panel);
  pointer-events: auto;
  position: relative;
}
#full::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  clip-path: polygon(0 0, 35% 0, 35% 100%, 65% 100%, 65% 0, 100% 0, 100% 35%, 0 35%, 0 65%, 100% 65%, 100% 100%, 0 100%);
}
#full:not([hidden]) ~ .side,
#pause:has(+ #full:not([hidden])) {
  margin-right: 0;
}
#full[hidden] {
  display: none;
}
.demo #full {
  display: none;
}
/* Upright phone: smaller stick and fire button, more of the view. */
@media (max-width: 600px) and (orientation: portrait) {
  #fire {
    width: 80px;
    height: 80px;
  }
  #fire::after {
    inset: 28px;
  }
  #stick {
    width: 96px;
    height: 96px;
    margin: -48px 0 0 -48px;
  }
}
