/* Cybertanx: dark chrome round a lit field map, a stencil name, condensed headings,
   plain text, and numbers in a typewriter face. Amber marks what you can do, and the
   Behemoth wears its side's color, red to begin with. Narrow, the map sits above the
   panel; wide, or a phone turned sideways, a column beside the map holds the sheet,
   the panel, the last roll and the log. The page itself never zooms, scrolls or
   selects text; only the map zooms. */

:root {
  --chrome: #1d2226;
  --bar: #161a1d;
  --panel: #272d32;
  --raise: #323a40;
  --line: #46505a;
  --ink: #eef1ec;
  --quiet: #b3bcc2;
  --amber: #f2b134;
  --on-amber: #1d1a10;
  /* The Behemoth's color, set from its side's choice. */
  --red: #b8432f;
  --cyan: #6ff0de;
  --foe: #ff9a85;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Avenir Next Condensed", "Helvetica Neue Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;
  background: var(--chrome);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.35;
  /* The page moves for nothing but the map's own drag and pinch. */
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

h2,
h3,
h4 {
  margin: 0;
  font-family: var(--head);
  font-stretch: condensed;
  font-weight: 700;
  line-height: 1.15;
}

/* ---------- The splash ---------- */

#splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--chrome);
  color: var(--ink);
  transition: opacity 300ms ease;
  /* If the script never runs, the splash still clears after a few seconds. */
  animation: splash-give-way 1ms linear 4s forwards;
}

#splash img {
  width: 128px;
  height: 128px;
  border-radius: 28px;
}

#splash .splash-name {
  width: min(78vw, 300px);
  height: auto;
}

#splash.leaving {
  opacity: 0;
}

@keyframes splash-give-way {
  to {
    visibility: hidden;
  }
}

/* Once the splash has gone, the first start after an update says so, low over the
   game. Taps pass through it, and its animation ends by removing it. */
#updated {
  position: fixed;
  inset-inline: 0;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  margin-inline: auto;
  padding: 12px 20px;
  border: 2px solid var(--amber);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 3px 16px rgb(0 0 0 / 45%);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  animation: updated-shows 3s ease-in-out forwards;
}

@keyframes updated-shows {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }

  12%,
  80% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes updated-fades {
  0%,
  100% {
    opacity: 0;
  }

  12%,
  80% {
    opacity: 1;
  }
}

/* ---------- The game ---------- */

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--chrome);
}

#bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  min-height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0 4px;
  background: var(--bar);
  border-bottom: 1px solid #0b0d0f;
}

#menu-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
}

#menu-button:active {
  background: var(--raise);
}

#menu-button .bars {
  display: grid;
  gap: 5px;
}

#menu-button .bar {
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: var(--ink);
}

#bar .logo {
  flex: none;
  width: auto;
  height: 14px;
  color: var(--ink);
}

#round {
  flex: none;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--quiet);
  white-space: nowrap;
}

#turn {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#turn.you {
  color: var(--amber);
}

#turn.foe {
  color: var(--foe);
}

#turn.monster {
  color: var(--cyan);
}

#main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

#map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #12161a;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* The isometric view's canvas lies over plan view's SVG. The one not on the screen is
   hidden but keeps its size, so the two hand over at the same scale and middle; while
   they switch, the canvas fades over the SVG and neither takes a tap. */
#iso-map {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#map-wrap[data-view="iso"] #map,
#map-wrap[data-view="plan"] #iso-map {
  visibility: hidden;
  pointer-events: none;
}

#map-wrap[data-view="switching"] #map,
#map-wrap[data-view="switching"] #iso-map {
  pointer-events: none;
}

#map-wrap[data-view="switching"] #iso-map {
  opacity: var(--fade, 1);
}

/* The map's buttons stand where game.js's layOutButtons puts them, by column from the
   right and row from the top, 50 pixels apart: the column five tall where it fits, as
   approved, and wrapped into another column on a shorter map. The column's own box
   holds its buttons, as many columns and rows as they take. */
#zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  width: calc(var(--cols, 1) * 50px - 6px);
  height: calc(var(--rows, 5) * 50px - 6px);
  pointer-events: none;
}

#zoom-out {
  --row: 1;
}

#zoom-all {
  --row: 2;
}

#look {
  --row: 3;
}

#iso {
  --row: 4;
}

#zoom button {
  position: absolute;
  top: calc(var(--row, 0) * 50px);
  right: calc(var(--col, 0) * 50px);
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1d2226;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
}

#zoom button.word {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
}

#zoom button.look svg {
  width: 26px;
  height: 26px;
}

#zoom button.look[aria-pressed="true"] {
  border-color: var(--amber);
  background: var(--amber);
  color: var(--on-amber);
}

/* The turn button, beside the cube at the column's foot, 6 pixels from it: outside the
   column, so nothing moves when it shows or hides, and it takes no width from the map. */
#rotate {
  position: absolute;
  top: calc(8px + var(--row, 4) * 50px);
  right: calc(8px + var(--col, 1) * 50px);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1d2226;
  color: var(--ink);
}

#rotate svg {
  width: 26px;
  height: 26px;
}

/* Words for a screen reader alone. */
.offscreen {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#pointer {
  position: absolute;
  top: var(--y, 50%);
  left: var(--x, 50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px 12px 4px 8px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--red);
  border-radius: 22px;
  background: #1d2226;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

#pointer svg {
  flex: none;
  width: 18px;
  height: 18px;
  transform: rotate(var(--turn, 0deg));
  color: var(--foe);
}

/* On a phone the marker is the arrow alone, a fingertip's target tight to the edge. */
#pointer.arrow {
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
}

#pointer.arrow svg {
  width: 26px;
  height: 26px;
}

#pointer.arrow #pointer-text {
  display: none;
}

/* The toast and the caption keep to the room the map's buttons leave them, which
   layOutButtons measures, in both views. */
#toast {
  position: absolute;
  bottom: 10px;
  left: calc((100% - var(--room-foot, 0px)) / 2);
  z-index: 3;
  width: max-content;
  max-width: calc(100% - var(--room-foot, 0px) - 24px);
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #111417;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

#caption {
  position: absolute;
  top: 10px;
  left: calc((100% - var(--room-caption, 60px)) / 2);
  z-index: 3;
  width: max-content;
  max-width: min(calc(100% - var(--room-caption, 60px) - 36px), 560px);
  padding: 8px 14px;
  transform: translateX(-50%);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #0d1114;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

/* The caption keeps to the half of the frame away from the piece the view follows. */
#caption.low {
  top: auto;
  bottom: 10px;
}

#caption.g {
  border-color: #2f6e66;
  color: #8ff3e4;
}

/* ---------- The side: the sheet, the panel, the dice, the buttons and the log ---------- */

#side {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
  max-height: 48%;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* What the game scrolls into view stops above the bar of Undo and End turn. */
  scroll-padding-bottom: var(--acts, 64px);
  /* The column stays where the game scrolled it when the bar grows to ask again, rather
     than following what was in view, which carried a hovercraft's line under Advice. */
  overflow-anchor: none;
  padding: 8px 8px 0;
  border-top: 1px solid #0b0d0f;
  background: var(--chrome);
  touch-action: pan-y;
}

#side > * {
  flex: none;
}

#sheet {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px 8px;
  padding: 6px 9px;
  border-radius: 10px;
  background: var(--panel);
}

.part {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.part b {
  overflow: hidden;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part.tracks,
.part.gsheet {
  grid-column: 1 / -1;
}

.part.gsheet {
  margin-top: 2px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
}

.part.gsheet b {
  color: var(--cyan);
}

.part.gsheet small {
  color: var(--quiet);
  font-size: 14px;
  line-height: 1.35;
}

.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 9px;
}

.pips i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--red);
}

.pips i.gone {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #8a6f69;
}

.pips.g i {
  background: #3fbfae;
}

.pips.g i.gone {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #3c8a80;
}

.speed {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.track {
  display: block;
  width: 100%;
  height: 9px;
  color: var(--red);
}

.short {
  display: inline;
}

.long {
  display: none;
}

#panel {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 88px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--panel);
}

#panel h4 {
  font-size: 18px;
}

#panel .high {
  color: var(--quiet);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
}

#panel p {
  margin: 0;
  color: var(--quiet);
  font-size: 14px;
}

#panel .tip {
  display: none;
}

/* What firing does to Garakuta itself, said before it fires. */
#panel p.warn {
  color: var(--amber);
  font-weight: 700;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
}

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

.chip {
  min-height: 44px;
  padding: 4px 12px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: var(--raise);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.chip[aria-pressed="true"] {
  border-color: var(--amber);
  background: var(--amber);
  color: var(--on-amber);
}

/* Two cards to a row, so each phrase keeps to one line, on a phone as on a computer. */
.targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  container-type: inline-size;
}

/* A card shows its short words unless it is wide enough for its long ones, on any
   screen: the long words need cards about 180 pixels across. */
.target .long {
  display: none;
}

.target .short {
  display: inline;
}

@container (min-width: 370px) {
  .target .long {
    display: inline;
  }

  .target .short {
    display: none;
  }
}

.target {
  display: grid;
  align-content: start;
  gap: 1px;
  min-height: 52px;
  padding: 5px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--raise);
  color: var(--ink);
  text-align: left;
}

.target b {
  font-size: 13px;
}

/* The line under a part's name: its roll and hits. The name's own spans, inside b, keep
   the name's type. */
.target > span {
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 11px;
}

.target em {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

/* Garakuta, the one target when the task force fires at it, takes the row. */
.target.wide {
  grid-column: 1 / -1;
}

.target[aria-pressed="true"] {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1.5px var(--amber);
}

.steppers {
  display: grid;
  gap: 6px;
}

.step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 30px 44px;
  gap: 6px;
  align-items: center;
  font-size: 14px;
}

.step button {
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--raise);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
}

.step output {
  font-family: var(--mono);
  font-weight: 600;
  text-align: center;
}

.step small {
  display: block;
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 11px;
}

.odds {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 14px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.btn {
  min-height: 44px;
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--raise);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.btn.go {
  border-color: var(--amber);
  background: var(--amber);
  color: var(--on-amber);
}

.btn.warn {
  border-color: #b13d26;
  background: #7a2618;
  color: #ffffff;
}

.btn:disabled {
  border-color: var(--line);
  background: var(--panel);
  color: #8f989e;
  cursor: default;
}

#dice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 24px;
  padding: 0 2px;
}

#dice .say {
  margin-right: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.die {
  width: 22px;
  height: 22px;
}

#acts {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 8px;
  /* The bar keeps to the foot of the side column, so nothing shown above it, Advice's
     words included, moves it from under the finger. */
  margin-top: auto;
  padding-bottom: 8px;
  background: var(--chrome);
}

/* In the person's own turn Advice sits between Undo and End turn, each at least as
   wide as its words, with a tighter padding. Where the bar is too narrow for all three,
   Advice heads the panel instead, and the bar keeps its one row. */
#acts.advise {
  grid-template-columns: minmax(max-content, 1fr) minmax(max-content, 1fr) minmax(max-content, 1.4fr);
}

#acts.advise .btn {
  padding-right: 8px;
  padding-left: 8px;
}

/* End turn's reason, above the bar's buttons, while it asks again. */
#ask {
  grid-column: 1 / -1;
  margin: 0;
  padding: 6px 4px 0;
  color: var(--amber);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* Advice at the head of the side column, where the bar has no room for it: held in
   sight as the column scrolls, over what passes under it. */
#advise-row {
  position: sticky;
  /* Held at the very top of the column, over its padding too. */
  top: -8px;
  z-index: 1;
  order: -2;
  display: flex;
  justify-content: flex-end;
  background: var(--chrome);
}

#advise-row #advice {
  flex: none;
  min-width: 120px;
}

/* The panel's heading, copied for the eye on the row's left while the heading itself is
   under the row: one line in the heading's look, cut short with an ellipsis where it
   runs out of room, Advice keeping its place and size. */
#row-name {
  flex: 1 1 auto;
  align-self: center;
  min-width: 0;
  margin-right: 8px;
  overflow: hidden;
  font-family: var(--head);
  font-stretch: condensed;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#row-name .high {
  color: var(--quiet);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
}

/* Where the room runs out, the place words go first, then the name steps down towards
   14 pixels before it is cut short. */
#row-name.bare .high {
  display: none;
}

#row-name[data-size="17"] {
  font-size: 17px;
}

#row-name[data-size="16"] {
  font-size: 16px;
}

#row-name[data-size="15"] {
  font-size: 15px;
}

#row-name[data-size="14"] {
  font-size: 14px;
}

/* What the game scrolls into view stops below Advice where it heads the column. */
#side.advised {
  scroll-padding-top: 52px;
}

/* Room under the dice, above the bar, so a line can always be scrolled wholly under the
   row, even with the log short; the bar stays the column's last box, at its foot. */
#side.advised #dice {
  margin-bottom: 32px;
}

#advice[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
}

/* At the setup the panel heads the side column, above the Behemoth's sheet. */
#side.setup #panel {
  order: -1;
}

/* The setup names the battle, with Choose a battle beside it where it fits. */
#panel .battle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 8px;
}

#panel .battle p {
  margin: 0;
  font-weight: 700;
}

/* Advice's words head the panel. */
.advice .tag {
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--amber);
  color: var(--on-amber);
  font-size: 14px;
  font-weight: 700;
}

/* In the demo the bar holds Stop the demo alone. */
#acts.one {
  grid-template-columns: minmax(0, 1fr);
}

#acts.one #undo {
  display: none;
}

#log {
  display: none;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px;
  list-style: none;
  border-radius: 10px;
  background: var(--panel);
  color: var(--quiet);
  font-size: 14px;
  touch-action: pan-y;
}

#log li + li {
  margin-top: 4px;
}

#log li.r {
  margin-top: 10px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#log li.r:first-child {
  margin-top: 0;
}

#log li.g {
  color: #8ff3e4;
}

/* The card at a game's end, over the map. */
#over {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(10 12 14 / 62%);
}

#over .card {
  display: grid;
  gap: 10px;
  justify-items: center;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}

#over h2 {
  font-size: 28px;
  letter-spacing: 0.02em;
}

#over p {
  margin: 0;
  color: var(--quiet);
  font-size: 14px;
}

#over-count {
  font-family: var(--mono);
}

#over #over-next {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

#over .buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

#over .buttons .btn {
  white-space: nowrap;
}

/* On the smallest phones the card keeps Play again and Choose a battle side by side,
   with Look at the map below them. */
@media (max-width: 360px) {
  #over {
    padding: 12px;
  }

  #over .card {
    padding: 18px 10px;
  }
}

/* ---------- Wide: a column beside the map ---------- */

@media (min-width: 640px) and (min-height: 500px) {
  #main {
    flex-direction: row;
  }

  /* On a big screen the end card covers the map alone, beside the panel. */
  #over {
    right: 340px;
  }

  #side {
    width: 340px;
    max-height: none;
    padding: 10px 10px 0;
    border-top: 0;
    border-left: 1px solid #0b0d0f;
  }

  #sheet {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px 10px;
    padding: 8px 10px;
  }

  .part b {
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .pips i {
    width: 11px;
    height: 11px;
  }

  .track {
    height: 12px;
  }

  .long {
    display: inline;
  }

  .short {
    display: none;
  }

  #panel {
    min-height: 140px;
  }

  #panel .tip {
    display: block;
  }

  .target {
    padding: 5px 7px;
  }

  .target b {
    font-size: 14px;
  }

  .target > span {
    font-size: 12px;
  }

  .die {
    width: 24px;
    height: 24px;
  }

  /* The log fills the room above the bar, which keeps to the column's foot. */
  #log {
    display: block;
    flex: 1 1 auto;
    order: 1;
    min-height: 90px;
  }

  #acts {
    order: 2;
  }

  #bar .logo {
    height: 22px;
  }
}

@media (min-width: 1000px) and (min-height: 500px) {
  #side {
    width: 380px;
  }

  #over {
    right: 380px;
  }
}

/* The top bar has room for the whole turn on any screen 640 pixels wide. */
@media (min-width: 640px) {
  #turn .long {
    display: inline;
  }

  #turn .short {
    display: none;
  }
}

/* A phone turned sideways: the panel moves beside the map, in a narrower column. */
@media (max-height: 499px) and (min-width: 480px) {
  #main {
    flex-direction: row;
  }

  #side {
    width: clamp(240px, 42vw, 320px);
    max-height: none;
    border-top: 0;
    border-left: 1px solid #0b0d0f;
  }

  #sheet {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* The narrow column on its side gives the target cards' lines the room they need. */
  #panel {
    padding: 9px 7px;
  }

  #bar {
    min-height: calc(44px + env(safe-area-inset-top));
  }

  /* The end card, on a phone on its side, keeps its buttons in one row. */
  #over {
    padding: 10px;
  }

  #over .card {
    gap: 8px;
    padding: 14px 16px;
  }

  #over h2 {
    font-size: 24px;
  }
}

/* The narrowest phones: the name gives the round and the turn the room, and the
   sheet's columns sit closer, so every label fits whole. */
@media (max-width: 374px) {
  #bar {
    gap: 6px;
  }

  #sheet {
    gap: 3px 3px;
    padding: 6px 7px;
  }

  #bar .logo {
    height: 11px;
  }

  #round {
    font-size: 12px;
  }

  #turn {
    font-size: 13px;
  }
}

/* ---------- The menu and its pages ---------- */

dialog {
  width: min(calc(100vw - 24px), 520px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 12px 40px rgb(0 0 0 / 50%);
}

dialog::backdrop {
  background: rgb(5 7 9 / 68%);
}

dialog .sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100dvh - 34px);
  padding: 14px;
  outline: none;
}

dialog .list,
dialog .page {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

dialog .page {
  gap: 10px;
  user-select: text;
  -webkit-user-select: text;
}

dialog h2 {
  font-size: 26px;
}

dialog h3 {
  margin-top: 6px;
  color: var(--amber);
  font-size: 17px;
}

dialog p,
dialog li {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

dialog ul,
dialog ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.3em;
}

dialog a {
  color: #8fc3ff;
  font-weight: 700;
}

/* How to play's link to the player's guide keeps its two words on one line, so the
   whole link is one place to tap. */
#how-to a[href="guide.html"] {
  white-space: nowrap;
}

dialog .glyph {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

dialog .note {
  color: var(--quiet);
  font-size: 14px;
}

dialog .ask {
  padding: 10px 12px;
  border: 1.5px solid var(--amber);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 700;
}

.item {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

.item.danger {
  color: var(--foe);
}

#version {
  margin: 2px 4px 0;
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 12px;
}

.close,
.danger-button {
  flex: none;
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.danger-button {
  border-color: #b13d26;
  background: #7a2618;
  color: #ffffff;
}

dialog .buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: none;
  gap: 8px;
}

dialog .buttons .btn {
  min-height: 48px;
  font-size: 16px;
}

.choices {
  display: grid;
  gap: 6px;
}

.choices.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choices.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  color: var(--ink);
  text-align: left;
}

.choice b {
  font-size: 15px;
}

.choice span {
  color: var(--quiet);
  font-size: 14px;
  line-height: 1.3;
}

.choice[aria-pressed="true"] {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1.5px var(--amber);
}

.toggles {
  display: grid;
  gap: 6px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
}

.toggle .state {
  min-width: 44px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.toggle[aria-pressed="true"] .state {
  background: var(--amber);
  color: var(--on-amber);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.swatch .dot {
  flex: none;
  width: 20px;
  height: 20px;
}

.swatch[aria-pressed="true"] {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1.5px var(--amber);
}

.swatch:disabled {
  border-style: dashed;
  background: var(--panel);
  color: #8f989e;
  cursor: default;
}

.swatch:disabled .dot {
  opacity: 0.4;
}

@media (max-width: 374px) {
  .choices.three {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Reduced motion: no fades or slides; the game's own moves jump straight to the end. */
@media (prefers-reduced-motion: reduce) {
  #splash {
    transition: none;
  }

  #updated {
    animation-name: updated-fades;
  }
}
