/* Evokar — in-game HUD, menus and touch controls (Inkwork style).
   Everything lives inside #hud-root (pointer-events: none); interactive parts opt back in. */

/* The `hidden` attribute must always win. The browser's built-in [hidden]{display:none} loses to
   any author rule that sets display (e.g. the two-column menu layout on short phones), which left
   the settings card permanently open in landscape on small screens. */
#hud-root [hidden] { display: none !important; }

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--font-ink);
  color: var(--sumi);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Visually hidden but read by screen readers (the HUD's role="status" announcement line). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Shared "parchment chip" and "card" surfaces. Semi-opaque paper instead of backdrop blur:
   blur is expensive on phones and doesn't fit a painted look anyway. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.38em 0.85em;
  border-radius: 999px;
  background: rgba(233, 223, 201, 0.86);
  box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.55), 0 2px 0 rgba(28, 27, 25, 0.12);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
}
.muted { color: var(--charcoal); opacity: 0.85; }

.card {
  position: absolute;
  pointer-events: auto;
  background: rgba(239, 230, 211, 0.97);
  /* hand-cut paper: slightly irregular corners + a doubled ink rule */
  border-radius: 14px 18px 13px 17px / 16px 12px 18px 14px;
  box-shadow: 0 0 0 1.5px var(--sumi), 0 0 0 5px rgba(233, 223, 201, 0.9), 0 0 0 6px rgba(28, 27, 25, 0.35),
    0 14px 40px rgba(28, 27, 25, 0.25);
  padding: 1.1rem 1.3rem 1.2rem;
}
.card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-transform: uppercase;
}
.card h2::after {
  content: "";
  display: block;
  width: 2.6em;
  height: 3px;
  margin-top: 0.45em;
  border-radius: 2px;
  background: var(--vermilion);
}

/* ---------------------------------------------------------------------------------------------
   Crosshair: an unfinished enso; turns vermilion and tightens on a target
   --------------------------------------------------------------------------------------------- */
.hud-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  transition: transform 0.12s ease;
}
.hud-crosshair svg { width: 100%; height: 100%; overflow: visible; }
.ch-ring {
  fill: none;
  stroke: var(--sumi);
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.8;
  filter: drop-shadow(0 0 1.5px rgba(233, 223, 201, 0.95));
  transition: stroke 0.12s ease, opacity 0.12s ease;
}
.ch-dot { fill: var(--sumi); filter: drop-shadow(0 0 1px rgba(233, 223, 201, 0.95)); }
.ch-charge {
  fill: none;
  stroke: var(--vermilion);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.hud-crosshair.is-charging .ch-charge { opacity: 0.75; }
.hud-crosshair.is-hit { transform: translate(-50%, -50%) scale(0.86); }
.hud-crosshair.is-hit .ch-ring { stroke: var(--vermilion); opacity: 1; }
.hud-crosshair.is-hit .ch-dot { fill: var(--vermilion); }
.menu-open .hud-crosshair { opacity: 0.25; }

/* Item meters (fuel, heat, stamina…): a short brush-stroke bar under the crosshair, in the item's
   colour; it pulses vermilion when low, shakes when empty, and rests (fades) when full. */
.hud-meters {
  position: absolute;
  left: 50%;
  top: calc(50% + 30px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.hud-meter {
  --mt: var(--umber);
  display: grid;
  grid-template-columns: auto 92px;
  align-items: center;
  gap: 6px;
  font: 700 0.62rem/1 var(--font-ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sumi);
  text-shadow: 0 0 3px var(--parchment), 0 0 6px var(--parchment);
  transition: opacity 0.45s ease;
}
.mt-label { justify-self: end; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-track {
  position: relative;
  height: 6px;
  border-radius: 3px 1px 3px 1px;
  background: rgba(233, 223, 201, 0.72);
  box-shadow: 0 0 0 1.5px var(--sumi);
  overflow: hidden;
}
.mt-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--mt), color-mix(in srgb, var(--mt) 70%, var(--parchment)));
  transform-origin: 0 50%;
  will-change: transform;
}
.hud-meter.is-low .mt-fill { animation: mt-low 0.45s ease-in-out infinite alternate; }
.hud-meter.is-empty .mt-track { animation: mt-empty 0.32s ease-in-out 2; box-shadow: 0 0 0 1.5px var(--vermilion); }
.hud-meter.is-rest, .hud-meter.is-gone { opacity: 0; }
@keyframes mt-low { from { background: var(--mt); } to { background: var(--vermilion); } }
@keyframes mt-empty { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.menu-open .hud-meters { visibility: hidden; }

/* ---------------------------------------------------------------------------------------------
   Status chip (top-left) + menu button (top-right)
   --------------------------------------------------------------------------------------------- */
.hud-status {
  position: absolute;
  left: calc(12px + var(--safe-l));
  top: calc(10px + var(--safe-t));
}
.st-dot {
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  border: 1.5px solid var(--sumi);
  background: transparent;
}
.hud-status.is-online .st-dot { background: var(--vermilion); border-color: var(--vermilion); }
.st-fps { color: var(--charcoal); font-variant-numeric: tabular-nums; }
.st-fps:empty { display: none; }
/* Our name is our colour: written in sumi, underlined with the scarf's own colour. */
.st-name {
  font-weight: 800;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--scarf, var(--vermilion));
  line-height: 1.1;
}
.st-name:empty { display: none; }
/* Phones held upright: just the dot (filled = online) and the name; the rest crowded the menu button */
@media (max-width: 600px) {
  .is-touch .st-text, .is-touch .st-fps { display: none; }
}

/* Scarf row in the settings menu: ten small ink dots in a 5 × 2 grid (36 px targets). */
.scarf-mini { display: grid; grid-template-columns: repeat(5, 36px); gap: 6px 8px; }
.mini-swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 48% 52% 50% 50% / 53% 47% 52% 48%;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px rgba(28, 27, 25, 0.28);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.mini-swatch[aria-checked="true"] {
  transform: scale(1.06);
  box-shadow: inset 0 0 0 1.5px rgba(28, 27, 25, 0.28), 0 0 0 2.5px var(--parchment), 0 0 0 4.5px var(--sumi);
}
.mini-swatch:focus-visible { outline: 2px dashed var(--sumi); outline-offset: 3px; }
/* (Sun gaze fades #hud-root by opacity from HUD.setCinematic. Touch controls stay live while faded:
   touching the joystick is how a phone player breaks the gaze.) */

.hud-menu-btn {
  position: absolute;
  right: calc(12px + var(--safe-r));
  top: calc(8px + var(--safe-t));
  width: 46px;
  height: 46px;
  padding: 0;
  border: none;
  border-radius: 51% 49% 47% 53% / 48% 53% 47% 52%;
  background: rgba(233, 223, 201, 0.88);
  box-shadow: 0 0 0 2px var(--sumi);
  color: var(--sumi);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}
.hud-menu-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.hud-menu-btn:hover, .hud-menu-btn:focus-visible { background: var(--parchment); outline: none; box-shadow: 0 0 0 2px var(--vermilion); }
.hud-menu-btn:active { transform: scale(0.94); }
.hud-menu-btn[aria-expanded="true"] { background: var(--sumi); color: var(--parchment); }

/* ---------------------------------------------------------------------------------------------
   Pointer-lock hint, toasts
   --------------------------------------------------------------------------------------------- */
.hud-lock-hint {
  position: absolute;
  left: 50%;
  bottom: calc(14% + var(--safe-b));
  transform: translate(-50%, 6px);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.hud-lock-hint.is-on { opacity: 1; transform: translate(-50%, 0); }

.hud-toasts {
  position: absolute;
  left: 50%;
  top: calc(12px + var(--safe-t));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 140px);
}
.hud-toast {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: normal;
  text-align: center;
}
.hud-toast.is-in { opacity: 1; transform: none; }
.hud-toast.is-out { opacity: 0; transform: translateY(-4px); }

/* ---------------------------------------------------------------------------------------------
   Help card
   --------------------------------------------------------------------------------------------- */
/* Desktop: a card on the left so it never covers the crosshair. Touch: centred (the left side is
   the joystick), dismissed by the first tap anywhere. */
.hud-help {
  left: calc(18px + var(--safe-l));
  top: 50%;
  transform: translateY(-50%);
  width: min(380px, calc(100vw - 40px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100% - 40px - var(--safe-t) - var(--safe-b));
  overflow: auto;
}
.hud-help.is-touch {
  left: 50%;
  transform: translate(-50%, -50%);
}
/* Grouped rows (HUD.js HELP_ROWS): Move · Fight · Conjure · Other, the verb left, the key caps or
   the on-screen button itself right, one line each. */
.hud-help h2 { margin-bottom: 0.5rem; }
.hk { margin: 0 0 0.7rem; }
.hk-group h3 {
  margin: 0.55rem 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--vermilion);
}
.hk-group:first-child h3 { margin-top: 0; }
.hk dl { margin: 0; display: grid; gap: 0.12rem; }
.hk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  min-height: 1.75rem;
  font-size: 0.9rem;
  border-bottom: 1px dashed rgba(28, 27, 25, 0.12);
}
.hk-row:last-child { border-bottom: none; }
.hk-row dt { font-weight: 600; white-space: nowrap; }
.hk-row dt small { font-weight: 500; color: var(--charcoal); font-size: 0.78em; margin-left: 0.3em; }
.hk-row dd { margin: 0; display: flex; align-items: center; gap: 0.22em; white-space: nowrap; }
.hk kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.6em;
  height: 1.55em;
  padding: 0 0.38em;
  border-radius: 5px 6px 4px 5px;
  background: var(--sumi);
  color: var(--parchment);
  font: 700 0.78rem/1 var(--font-ink);
  letter-spacing: 0.02em;
}
.hk-w { font-size: 0.8rem; color: var(--charcoal); font-style: italic; }
.hk-or { font-size: 0.72rem; color: var(--charcoal); margin: 0 0.15em; }
/* the touch buttons' own icons, small */
.hk-btn {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: rgba(28, 27, 25, 0.86);
  color: var(--parchment);
}
.hk-btn svg { width: 64%; height: 64%; overflow: visible; }
.hk-btn .ic-stroke { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.hk-btn .ic-stroke.thin { stroke-width: 2.6; opacity: 0.7; }
.hk-btn .ic-fill { fill: currentColor; }
.hk-btn .ic-accent { fill: var(--vermilion); }
.hk-btn.is-ring { background: transparent; color: var(--sumi); box-shadow: inset 0 0 0 1.5px rgba(28, 27, 25, 0.6); }
.hk-btn.is-menu { background: rgba(233, 223, 201, 0.9); color: var(--sumi); box-shadow: 0 0 0 1.5px var(--sumi); }
.hk-btn.is-menu svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.hk-btn.is-menu .fs-out { display: none; }
.help-touch.no-fs [data-act="fs"] { display: none; }
.hud-help .help-touch { display: none; }
.hud-help.is-touch .help-touch { display: block; }
.hud-help.is-touch .help-desktop, .hud-help.is-touch .help-pad { display: none; }
.help-pad { margin: 0 0 0.8rem; }
.help-pad summary { cursor: pointer; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.26em; text-transform: uppercase; color: var(--charcoal); }
.help-pad[open] summary { margin-bottom: 0.4rem; }
.help-pad .hk { margin: 0; }

/* ---------------------------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------------------------- */
.ink-btn {
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  min-height: 44px;
  padding: 0.55em 1.3em;
  border: none;
  border-radius: 999px;
  color: var(--parchment);
  background: var(--sumi);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.ink-btn:hover, .ink-btn:focus-visible { background: #34322f; outline: none; }
.ink-btn:active { transform: scale(0.97); }
.ink-btn.ghost { background: transparent; color: var(--sumi); box-shadow: inset 0 0 0 1.5px var(--sumi); }
.ink-btn.ghost:hover, .ink-btn.ghost:focus-visible { background: rgba(28, 27, 25, 0.08); }
.ink-btn.vermilion { background: var(--vermilion); }
.ink-btn.vermilion:hover, .ink-btn.vermilion:focus-visible { background: #a9473a; }

/* ---------------------------------------------------------------------------------------------
   Settings menu
   --------------------------------------------------------------------------------------------- */
/* The menu itself is the settings book (ui/SettingsBook.js, css/settingsbook.css); these are its rows.
   If the book ever fails to build, HUD._plainMenu leaves them as this plain card (the old menu). */
.hud-menu.is-plain {
  right: calc(12px + var(--safe-r));
  top: calc(62px + var(--safe-t));
  width: min(340px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100% - 74px - var(--safe-t) - var(--safe-b));
  overflow: auto;
  z-index: 60;
}
.hud-menu.is-plain .menu-actions { margin-top: 0.6rem; }
.menu-row {
  display: flex;
  flex-direction: column;
  gap: 0.45em;
  margin-bottom: 0.9rem;
}
.menu-label { font-size: 0.85rem; letter-spacing: 0.08em; display: flex; justify-content: space-between; gap: 0.6em; }
.menu-label output { color: var(--vermilion); font-variant-numeric: tabular-nums; }
.menu-label small { font-size: 0.8em; letter-spacing: 0.04em; }
.seg { display: flex; gap: 6px; }
/* Every menu control keeps the 44 px touch target (ARCHITECTURE §7), in every layout. */
.seg-btn {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  text-transform: capitalize;
  min-height: 44px;
  border: none;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(28, 27, 25, 0.6);
  color: var(--sumi);
  cursor: pointer;
}
.seg-btn.is-on { background: var(--sumi); color: var(--parchment); box-shadow: none; }
/* first tap on another preset: waiting for the confirming second tap */
.seg-btn.is-armed { box-shadow: inset 0 0 0 2px var(--vermilion); color: var(--vermilion); }

.menu-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  touch-action: pan-x;
}
.menu-row input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--sumi); }
.menu-row input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--sumi); }
.menu-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--vermilion);
  box-shadow: 0 0 0 3px var(--parchment), 0 0 0 4.5px var(--sumi);
}
.menu-row input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--vermilion);
  box-shadow: 0 0 0 3px var(--parchment), 0 0 0 4.5px var(--sumi);
}
.menu-check { flex-direction: row; align-items: center; justify-content: space-between; cursor: pointer; min-height: 44px; }
.menu-check input { position: absolute; opacity: 0; pointer-events: none; }
.menu-check .check {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--sumi);
  position: relative;
  transition: background 0.15s ease;
}
.menu-check .check::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sumi);
  transition: transform 0.15s ease, background 0.15s ease;
}
.menu-check input:checked + .check { background: rgba(196, 84, 67, 0.15); }
.menu-check input:checked + .check::after { transform: translateX(20px); background: var(--vermilion); }
.menu-check input:focus-visible + .check { box-shadow: inset 0 0 0 1.5px var(--sumi), 0 0 0 2px var(--vermilion); }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.3rem; }
.menu-actions .ink-btn { flex: 1 1 auto; }
/* Reset wipes everyone's work: on its own row, away from Resume, and it asks for a second tap. */
.menu-actions .act-reset { flex-basis: 100%; margin-top: 8px; }
.menu-actions .act-reset.is-armed { background: var(--sumi); box-shadow: inset 0 0 0 2px var(--vermilion); }
/* Settings → Picture → Screen edges (ui/ScreenEdges.js): the reach past the foot like the rows above;
   the four margins a compact grid, a side to a line (name, slider, px); Reset small, at the end. */
.menu-row.edge-dz { gap: 0; }
.edge-m { display: grid; grid-template-columns: 4.6em 1fr 3.4em; align-items: center; gap: 0.6em; min-height: 44px; cursor: pointer; }
.edge-m-k { font-size: 0.85em; letter-spacing: 0.06em; }
.edge-m .edge-out { font-size: 0.85em; text-align: right; color: var(--vermilion); font-variant-numeric: tabular-nums; }
.menu-row.edge-dz .edge-m input[type="range"] { height: 44px; }
.edge-foot { display: flex; justify-content: flex-end; }
.edge-foot .ink-btn.edge-reset { font-size: 0.8rem; padding: 0.4em 1.3em; }
.edge-foot .ink-btn.edge-reset:disabled { opacity: 0.4; cursor: default; transform: none; background: transparent; }

/* ---------------------------------------------------------------------------------------------
   Debug overlay
   --------------------------------------------------------------------------------------------- */
.hud-debug {
  position: absolute;
  /* the admin's panel (` / F3) sits over everything in the HUD, the Lexicon scroll and its flying
     words (z 40) and the books (60) included: the user's call. It never takes a click (.hud passes
     pointer-events: none down); game/DevTicks.js puts its ticks just above it. */
  z-index: 1000;
  left: calc(12px + var(--safe-l));
  top: calc(52px + var(--safe-t));
  margin: 0;
  padding: 0.6em 0.8em;
  max-width: min(360px, calc(100vw - 24px));
  font: 11px/1.45 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--parchment);
  background: rgba(28, 27, 25, 0.78);
  border-radius: 8px;
  white-space: pre;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------------------------
   Touch controls
   --------------------------------------------------------------------------------------------- */
.tc { display: none; position: absolute; inset: 0; pointer-events: none; }
.tc.tc--on { display: block; }
.tc-zone {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.tc--disabled .tc-zone, .tc--disabled .tc-btn { pointer-events: none; }
/* TouchControls.setShown(name, false): hidden on top of the contextual rules (a tutorial) */
.tc .tc-off { display: none !important; }

/* The move stick is FIXED in the lower left (TouchControls reads this anchor's position, so these
   rules are the one place it is placed): a faint ring at rest, solid while held. */
.tc-stick {
  position: absolute;
  left: calc(96px + var(--safe-l));
  bottom: calc(96px + var(--safe-b));
  width: 0;
  height: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.tc-stick.is-resting { opacity: 0.38; }
.tc-stick.is-active { opacity: 1; transition: none; }
.tc-stick-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 128px;
  height: 128px;
  transform: translate(-50%, -50%);
  border-radius: 52% 48% 50% 50% / 47% 52% 48% 53%;
  border: 3px solid rgba(28, 27, 25, 0.75);
  background: radial-gradient(circle, rgba(233, 223, 201, 0.12) 0 55%, rgba(233, 223, 201, 0.35) 100%);
  transition: border-color 0.15s ease;
}
.tc-stick-knob {
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(28, 27, 25, 0.82);
  box-shadow: 0 0 0 3px rgba(233, 223, 201, 0.85);
}
.tc-stick.is-sprint .tc-stick-ring { border-color: var(--vermilion); }
.tc-stick.is-sprint .tc-stick-knob { background: var(--vermilion); }

.tc-btn {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(28, 27, 25, 0.8);
  box-shadow: 0 0 0 3px rgba(233, 223, 201, 0.75), 0 3px 10px rgba(28, 27, 25, 0.25);
  color: var(--parchment);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.12s ease;
}
.tc-btn svg { width: 56%; height: 56%; overflow: visible; }
.tc-btn .ic-stroke { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.tc-btn .ic-stroke.thin { stroke-width: 2.6; opacity: 0.6; }
.tc-btn .ic-fill { fill: currentColor; }
.tc-btn .ic-accent { fill: var(--vermilion); }
.tc-btn.is-down { transform: scale(0.92); background: var(--vermilion); }
.tc-btn.is-down .ic-accent { fill: var(--parchment); }
/* touch ADS is a toggle: lit while aimed, even with no thumb on it (input/InputManager.js) */
.tc-btn.is-latched { background: var(--vermilion); box-shadow: 0 0 0 3px rgba(243, 226, 176, 0.55); }
.tc-btn.is-latched .ic-accent { fill: var(--parchment); }

/* The right thumb's arc, from the corner: Brush (big), Jump to its left, the second action above it,
   the ability (only when it does something) between them; Dash and Ride (contextual) further left.
   Conjuring is on the hotbar (match.css). Portrait / tablet values here; short landscape below. */
.tc-btn-fire {
  width: 84px;
  height: 84px;
  right: calc(18px + var(--safe-r));
  bottom: calc(22px + var(--safe-b));
}
.tc-btn-jump {
  width: 62px;
  height: 62px;
  right: calc(112px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
}
/* the second action: the shove / ink burst (splash), or the held item's own (crosshair) */
.tc-btn-burst {
  width: 60px;
  height: 60px;
  right: calc(26px + var(--safe-r));
  bottom: calc(122px + var(--safe-b));
  --charge: 1;
}
.tc-ic { display: contents; }
.tc-btn-burst.is-secondary .tc-charge { opacity: 0; }
/* cooldown ring for the burst button */
.tc-btn-burst .tc-charge {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(var(--vermilion) calc(var(--charge) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%);
  mask: radial-gradient(circle, transparent 62%, #000 64%);
  opacity: 0.9;
  pointer-events: none;
}
.tc-btn-burst.is-ready .tc-charge { opacity: 0; }

/* (Short landscape phones: the settings book lays itself out as a low, wide spread whose pages
   scroll: css/settingsbook.css.) */

/* phones held upright: the stick a little further in (Dash and Ride: below, after their own rules) */
@media (max-width: 600px) {
  .tc-stick { left: calc(78px + var(--safe-l)); bottom: calc(100px + var(--safe-b)); }
}
/* the smallest phones (an SE held upright, 320 px): the right thumb's arc a size smaller and tucked to
   the corner, out of the stick's reach (the ability button: match.css) */
@media (max-width: 360px) {
  .tc-btn-fire { width: 76px; height: 76px; right: calc(14px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); }
  .tc-btn-jump { width: 56px; height: 56px; right: calc(96px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); }
  .tc-btn-burst { width: 54px; height: 54px; right: calc(22px + var(--safe-r)); bottom: calc(106px + var(--safe-b)); }
}
@media (max-height: 420px) {
  .tc-btn-fire { width: 76px; height: 76px; right: calc(20px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); }
  .tc-btn-jump { width: 58px; height: 58px; right: calc(110px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); }
  .tc-btn-burst { width: 56px; height: 56px; right: calc(26px + var(--safe-r)); bottom: calc(108px + var(--safe-b)); }
  .tc-stick { left: calc(84px + var(--safe-l)); bottom: calc(84px + var(--safe-b)); }
}
@media (max-height: 400px) {
  .hud-help { padding: 0.8rem 1rem 0.9rem; }
}

/* Touch UI: the mouse-lock hint never applies. */
.is-touch .hud-lock-hint { display: none; }

/* ---------------------------------------------------------------------------------------------
   Summoning: the parchment slip you type a name into, the "holding" chip, the touch ink-drop button
   --------------------------------------------------------------------------------------------- */
/* The slip sits at the TOP: a phone keyboard rises from the bottom and must never cover it. */
.summon-slip {
  left: 50%;
  top: calc(56px + var(--safe-t));
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  padding: 0.75rem 1rem 0.65rem;
  z-index: 3;
}
.summon-label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--charcoal);
}
.summon-field { display: flex; align-items: center; gap: 0.5rem; }
.summon-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0.35em 0.2em 0.3em;
  border: none;
  border-radius: 0;
  background: transparent;
  /* a brush-stroke underline instead of a box */
  background-image: linear-gradient(90deg, var(--sumi) 0 82%, rgba(28, 27, 25, 0.35) 92%, transparent);
  background-size: 100% 2.5px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  color: var(--sumi);
  font: inherit;
  font-size: max(16px, 1.15rem); /* ≥16 px: iOS zooms the whole page into smaller inputs */
  letter-spacing: 0.02em;
  outline: none;
  /* the HUD and body are user-select:none; iOS refuses to type into inputs that inherit that */
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  caret-color: var(--vermilion);
}
.summon-input::placeholder { color: var(--charcoal); opacity: 0.55; font-style: italic; }
.summon-input:focus { background-image: linear-gradient(90deg, var(--vermilion) 0 82%, rgba(196, 84, 67, 0.4) 92%, transparent); }
.summon-go {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--sumi);
  color: var(--parchment);
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
  touch-action: manipulation;
}
.summon-go:hover, .summon-go:focus-visible { background: var(--vermilion); outline: none; }
.summon-hint { margin: 0.4rem 0 0; font-size: 0.72rem; letter-spacing: 0.04em; color: var(--charcoal); opacity: 0.8; }
.summon-hint-touch { display: none; }
.is-touch .summon-hint-keys { display: none; }
.is-touch .summon-hint-touch { display: inline; }

/* What you're holding: right column, under the menu button (the menu card covers it when open). */
.summon-held {
  position: absolute;
  right: calc(12px + var(--safe-r));
  top: calc(62px + var(--safe-t));
  max-width: min(46vw, 280px);
  padding-right: 0.35em;
  pointer-events: auto;
}
.sh-mark {
  flex: 0 0 auto;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50% 40% 55% 45%;
  background: var(--vermilion);
}
.sh-name { overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.sh-away {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: -0.3em 0 -0.3em 0.1em;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sumi);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.sh-away:hover, .sh-away:focus-visible { background: rgba(28, 27, 25, 0.1); outline: none; }
.is-touch .sh-away { width: 40px; height: 40px; } /* thumb-sized */
/* "the ink gathers…": the mark breathes while Claude (or the library) works */
.summon-ui.is-busy .summon-held { font-style: italic; }
.summon-ui.is-busy .sh-mark { animation: summon-breathe 1.1s ease-in-out infinite alternate; }
@keyframes summon-breathe { from { transform: scale(0.7); opacity: 0.5; } to { transform: scale(1.25); opacity: 1; } }
.menu-open .summon-held { visibility: hidden; }
/* Touch: the hotbar's weapon tile already says what you hold (and holding it drops it), so the chip
   only appears while a free-play summon is gathering ("the ink gathers · …"). The conjure button
   itself is the hotbar's ink drop (match.css). */
.is-touch .summon-ui:not(.is-busy) .summon-held { display: none; }
@media (max-height: 400px) {
  .summon-slip { top: calc(8px + var(--safe-t)); padding: 0.55rem 0.9rem 0.5rem; }
  .summon-label, .summon-hint { display: none; }
}
/* typing a summon: the mouse is free on purpose, so the "click to enter" hint would only nag */
.summon-open .hud-lock-hint { display: none; }

/* ---------------------------------------------------------------------------------------------
   Items (docs/ITEMS.md): charge ring, cooldown bar, ammo, crosshair styles for aiming down
   sights, the scope, status-effect chips, control hints, and the contextual touch buttons
   --------------------------------------------------------------------------------------------- */
.ch-item {
  fill: none;
  stroke: var(--sumi);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  opacity: 0;
  filter: drop-shadow(0 0 1.5px rgba(233, 223, 201, 0.95));
  transition: opacity 0.15s ease, stroke 0.12s ease;
}
.hud-crosshair.is-item-charging .ch-item { opacity: 0.85; }
.hud-crosshair.is-item-full .ch-item { stroke: var(--vermilion); opacity: 1; }
.ch-circle, .ch-cross {
  display: none;
  fill: none;
  stroke: var(--sumi);
  stroke-width: 1.8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 1.5px rgba(233, 223, 201, 0.95));
}
/* aiming down sights: the enso gives way to the item's own reticle */
.hud-crosshair.ch--dot .ch-ring,
.hud-crosshair.ch--cross .ch-ring,
.hud-crosshair.ch--ring .ch-ring,
.hud-crosshair.ch--scope .ch-ring { opacity: 0; }
.hud-crosshair.ch--cross .ch-cross,
.hud-crosshair.ch--scope .ch-cross { display: inline; }
.hud-crosshair.ch--ring .ch-circle { display: inline; }
.hud-crosshair.ch--dot .ch-dot { transform: scale(1.25); transform-origin: 50% 50%; }
.hud-crosshair.is-hit .ch-cross, .hud-crosshair.is-hit .ch-circle { stroke: var(--vermilion); }

/* The lens, shown once the camera is at the eye (HUD info.sight; the avatar stops drawing itself
   there). A scope: a brush-ringed spyglass, everything outside the glass washed in ink, the rim one
   loaded stroke (canvas, brushed once) and a duplex reticle. Any other sight (.is-aperture): a soft
   ink vignette round the item's own reticle. Static layers: only the opacity changes, while it eases. */
.hud-scope {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  --r: min(36vh, 36vw);
  --lens-ink: rgba(28, 27, 25, 0.93);
  background: radial-gradient(circle at 50% 50%, transparent 0 var(--r), var(--lens-ink) calc(var(--r) + 2px), rgba(28, 27, 25, 0.96) 100%);
}
.hud-scope-rim {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--r) * 2.4); /* LENS_SPAN in HUD.js */
  height: calc(var(--r) * 2.4);
  transform: translate(-50%, -50%);
}
.hud-scope i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
/* duplex reticle: heavy posts from the rim, a fine hair through the centre */
.hud-scope i::before, .hud-scope i::after {
  content: "";
  position: absolute;
  background:
    linear-gradient(rgba(28, 27, 25, 0.78), rgba(28, 27, 25, 0.78)) center / 100% 1.2px no-repeat,
    linear-gradient(90deg, var(--sumi) 0 32%, transparent 32% 68%, var(--sumi) 68%) center / 100% 3.5px no-repeat;
}
.hud-scope i::before { left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; }
.hud-scope i::after {
  top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px;
  background:
    linear-gradient(rgba(28, 27, 25, 0.78), rgba(28, 27, 25, 0.78)) center / 1.2px 100% no-repeat,
    linear-gradient(180deg, var(--sumi) 0 32%, transparent 32% 68%, var(--sumi) 68%) center / 3.5px 100% no-repeat;
}
.hud-scope.is-aperture {
  --r: min(44vh, 44vw);
  background: radial-gradient(circle at 50% 50%, transparent 0 calc(var(--r) * 0.8), rgba(28, 27, 25, 0.3) var(--r), rgba(28, 27, 25, 0.62) 100%);
}
.hud-scope.is-aperture .hud-scope-rim,
.hud-scope.is-aperture i { display: none; }
.is-lens .hud-scope { display: block; }
.is-scoped .hud-crosshair .ch-cross { display: none; }

.hud-ammo {
  position: absolute;
  left: calc(100% + 8px);
  top: calc(100% - 6px);
  font-weight: 800;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--sumi);
  white-space: nowrap;
  text-shadow: 0 0 3px rgba(233, 223, 201, 0.95), 0 0 1px rgba(233, 223, 201, 1);
}
.hud-ammo.is-empty { color: var(--vermilion); }
.is-scoped .hud-ammo { color: var(--parchment); text-shadow: 0 0 3px rgba(28, 27, 25, 0.9); }
.hud-cd {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: 34px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: rgba(28, 27, 25, 0.22);
  overflow: hidden;
}
.hud-cd i {
  display: block;
  height: 100%;
  background: var(--sumi);
  transform-origin: 0 50%;
}
/* A press refused for the item's budget (items/ItemRuntime.js _dry): its power recharging, and a flinch. */
.hud-cd.is-recharging { width: 44px; height: 4px; }
.hud-cd.is-recharging i { background: var(--vermilion); }
.hud-dry {
  position: absolute;
  left: 50%;
  top: calc(100% + 15px);
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vermilion);
  white-space: nowrap;
  text-shadow: 0 0 3px rgba(233, 223, 201, 0.95), 0 0 1px rgba(233, 223, 201, 1);
  pointer-events: none;
}
.is-scoped .hud-dry { text-shadow: 0 0 3px rgba(28, 27, 25, 0.9); }
.hud-crosshair.is-dry svg { animation: ch-dry 0.28s ease-out; }
@keyframes ch-dry { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-3px) scale(0.92); } 50% { transform: translateX(3px); } 75% { transform: translateX(-1px); } }
@media (prefers-reduced-motion: reduce) { .hud-crosshair.is-dry svg { animation: none; } }

.hud-effects {
  position: absolute;
  left: calc(12px + var(--safe-l));
  top: calc(50px + var(--safe-t));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  max-width: min(60vw, 320px);
}
.fx-chip { font-size: 0.74rem; padding: 0.3em 0.75em 0.3em 0.45em; gap: 0.45em; max-width: 100%; }
.fx-name { overflow: hidden; text-overflow: ellipsis; }
.fx-time { font-variant-numeric: tabular-nums; color: var(--charcoal); }
.fx-time:empty { display: none; }
.fx-ring {
  flex: 0 0 auto;
  width: 0.95em;
  height: 0.95em;
  border-radius: 50%;
  background: conic-gradient(var(--vermilion) calc(var(--p, 1) * 360deg), rgba(28, 27, 25, 0.18) 0);
}
.fx-chip.is-held .fx-ring { background: var(--sumi); }
.fx-chip.is-ending .fx-ring { animation: fx-ending 0.5s ease-in-out infinite alternate; }
@keyframes fx-ending { from { opacity: 1; } to { opacity: 0.3; } }

.hud-hints {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  gap: 0.4em;
  max-width: calc(100vw - 24px);
  overflow: hidden;
  font-size: 0.76rem;
  transition: opacity 0.6s ease;
}
.hud-hints kbd {
  font: inherit;
  font-weight: 800;
  padding: 0.05em 0.45em;
  border-radius: 5px;
  background: var(--sumi);
  color: var(--parchment);
}
.hud-hints span { margin-right: 0.5em; }
.hud-hints span:last-child { margin-right: 0; }
.hud-hints.is-faded { opacity: 0.32; }
/* (Touch: the hints ride just above the hotbar, between the thumbs: match.css) */
.menu-open .hud-hints, .menu-open .hud-effects { visibility: hidden; }

/* Touch: Dash (only with a dash modifier), left of Jump */
.tc-btn-dash {
  width: 52px;
  height: 52px;
  right: calc(182px + var(--safe-r));
  bottom: calc(18px + var(--safe-b));
  --charge: 1;
}
.tc-btn-dash .tc-charge {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(var(--vermilion) calc(var(--charge) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%);
  mask: radial-gradient(circle, transparent 62%, #000 64%);
  opacity: 0.9;
  pointer-events: none;
}
.tc-btn-dash.is-ready .tc-charge { opacity: 0; }
/* Ride (docs/ITEMS.md §3.9): next to a mount you can climb on, and while riding (then it gets you off) */
.tc-btn-ride {
  width: 54px;
  height: 54px;
  right: calc(178px + var(--safe-r));
  bottom: calc(90px + var(--safe-b));
  background: rgba(196, 84, 67, 0.88);
}
.tc-btn-ride.is-riding { background: rgba(28, 27, 25, 0.8); }
.tc-btn-ride.is-riding .ic-accent { fill: var(--vermilion); }
@media (max-height: 420px) {
  .tc-btn-dash { width: 50px; height: 50px; right: calc(186px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); }
  .tc-btn-ride { width: 52px; height: 52px; right: calc(180px + var(--safe-r)); bottom: calc(82px + var(--safe-b)); }
}
/* Phones held upright: the bottom row holds the stick's reach (its ring and the knob's travel), Jump and
   the Brush, and no more, so Dash and Ride stand in a row of their own above the arc while they show,
   and the hotbar rises over them (match.css, --hb-lift) */
@media (max-width: 600px) and (orientation: portrait) {
  .tc-btn-dash, .tc-btn-ride { bottom: calc(194px + var(--safe-b)); }
  .tc-btn-dash { right: calc(30px + var(--safe-r)); }
  .tc-btn-ride { right: calc(94px + var(--safe-r)); }
}
/* …but an SE's screen is too short to lift the hotbar a whole row (it would sit on the crosshair): the
   two, a size smaller, tuck into the arc's gaps (Ride over the ability button, Dash over the burst's
   ring) and the hotbar rises only a little */
@media (max-width: 360px) and (orientation: portrait) {
  .tc-btn-dash, .tc-btn-ride { width: 44px; height: 44px; }
  .tc-btn-dash { right: calc(14px + var(--safe-r)); bottom: calc(168px + var(--safe-b)); }
  .tc-btn-ride { right: calc(104px + var(--safe-r)); bottom: calc(136px + var(--safe-b)); }
}
/* The ride prompt: walk up to a mount and it names the key (ui/RidePrompt.js) */
.ride-prompt {
  position: absolute;
  left: 50%;
  top: 63%;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.ride-prompt[hidden] { display: none; }
.ride-prompt.is-quiet { opacity: 0.45; }
.ride-prompt kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 0.35em;
  border-radius: 6px;
  background: var(--sumi, #1c1b19);
  color: var(--parchment, #e9dfc9);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0;
}
.is-touch .ride-prompt { top: auto; bottom: calc(170px + var(--safe-b, 0px)); left: auto; right: calc(200px + var(--safe-r, 0px)); transform: none; }

/* ---------------------------------------------------------------------------------------------
   Full screen: a tiny toggle beside ☰ (touch only; HUD.js hides it where the Fullscreen API is
   missing, i.e. iPhone Safari, and when the game already runs from the Home Screen). iPhone gets a
   one-time tip in the toast column instead.
   --------------------------------------------------------------------------------------------- */
.hud-fs-btn {
  display: none;
  position: absolute;
  right: calc(12px + 46px + 10px + var(--safe-r)); /* left of the 46 px menu button */
  top: calc(16px + var(--safe-t));
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(233, 223, 201, 0.78);
  box-shadow: 0 0 0 1.5px rgba(28, 27, 25, 0.7);
  color: var(--sumi);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* small to look at, not to hit: the touch target reaches 44 px */
.hud-fs-btn::before { content: ""; position: absolute; inset: -7px; }
.hud-fs-btn svg { display: block; width: 15px; height: 15px; margin: auto; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hud-fs-btn .fs-out, .hud-fs-btn.is-fs .fs-in { display: none; }
.hud-fs-btn.is-fs .fs-out { display: inline; }
.hud-fs-btn:active { transform: scale(0.9); }
.is-touch .hud-fs-btn { display: grid; place-items: center; }

.hud-tip {
  order: -1;
  max-width: 100%;
  padding: 0.25em 0.2em 0.25em 0.85em;
  font-size: 0.72rem;
  white-space: normal;
  line-height: 1.3;
  pointer-events: auto;
}
.hud-tip b { font-weight: 800; }
/* the iPhone full-screen steps (HUD._showHomeHelp): a solid card over the chips, not a see-through chip */
.hud-tip.is-help {
  position: relative;
  z-index: 30;
  padding: 0.55em 0.3em 0.6em 0.95em;
  border-radius: 14px;
  background: rgba(233, 223, 201, 0.97);
  box-shadow: 0 0 0 1.5px rgba(28, 27, 25, 0.75), 0 6px 18px rgba(28, 27, 25, 0.22);
  font-size: 0.8rem;
  line-height: 1.45;
}
.hud-tip-share { width: 0.85em; height: 1.1em; vertical-align: -0.18em; fill: none; stroke: #2a6fdb; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hud-tip-x {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sumi);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------------------------------------
   Phones and tablets (touch): a clean top row. No status chip (name / painter count / fps belong
   to desktop), so health takes the top left, ☰ and the full-screen dot the top right, and toasts
   the row under them. Desktop is untouched by everything below (.is-touch only).
   --------------------------------------------------------------------------------------------- */
.is-touch .hud-status { display: none; }
/* health on the top row: game/Combat.js lays it out so for narrow screens and coarse pointers; a touch
   screen that reports neither (a touch laptop, an emulator) gets the same, never the desktop's
   bottom-left bar, which is where the stick is */
.is-touch .cb-hud { top: calc(16px + var(--safe-t)); bottom: auto; left: calc(12px + var(--safe-l)); flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
/* the death book open: the touch controls and the hotbar wait out of sight under it (the book takes
   every touch; seen through its shade they looked live, and its Return sat on top of them) */
.is-touch.is-reading:not(.is-watching) .tc, .is-touch.is-reading:not(.is-watching) .hotbar { visibility: hidden; }
.is-touch .hud-effects { top: calc(14px + var(--safe-t)); max-width: min(52vw, 260px); }
.is-touch .cb-hp-on .hud-effects { top: calc(42px + var(--safe-t)); }
.is-touch .hud-toasts,
.is-touch.in-match .hud-toasts {
  top: calc(62px + var(--safe-t));
  /* max-content: a box at left 50% would otherwise shrink to half the screen and wrap early */
  width: max-content;
  max-width: min(440px, calc(100vw - 32px - var(--safe-l) - var(--safe-r)));
}
.is-touch .hud-toast { font-size: 0.76rem; padding: 0.32em 0.85em; line-height: 1.25; }
/* item hints (first match only): just above the hotbar, where the eye goes for the tiles */
.is-touch .hud-hints { font-size: 0.72rem; max-width: calc(100vw - 32px); }
.is-ghost .hud-hints { display: none; }

/* The controls card on a phone: narrower type, and the four groups side by side when sideways. */
.hud-help.is-touch {
  z-index: 5; /* over the hotbar (match.css z-index 3), not threaded through it */
  width: min(400px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  padding: 0.85rem 1rem 0.9rem;
}
.hud-help.is-touch .cb-chart { display: inline-block; margin: 0 1rem 0 0; vertical-align: middle; }
.hud-help.is-touch .help-close { vertical-align: middle; }
@media (max-height: 500px) and (min-width: 560px) {
  .hud-help.is-touch {
    width: min(720px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
    max-height: calc(100% - 16px - var(--safe-t) - var(--safe-b));
    padding: 0.65rem 1rem 0.7rem;
  }
  .hud-help.is-touch h2 { font-size: 0.88rem; margin-bottom: 0.35rem; }
  .hud-help.is-touch .help-touch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 1.3rem; margin-bottom: 0.4rem; }
  .hud-help.is-touch .hk-group:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; }
  .hud-help.is-touch .hk-group:nth-child(2) { grid-column: 2; grid-row: 1 / span 2; }
  .hud-help.is-touch .hk-group:nth-child(3) { grid-column: 3; grid-row: 1; }
  .hud-help.is-touch .hk-group:nth-child(4) { grid-column: 3; grid-row: 2; }
  .hud-help.is-touch .hk-group h3 { margin-top: 0; }
  .hud-help.is-touch .hk-group:nth-child(4) h3 { margin-top: 0.4rem; }
  .hud-help.is-touch .hk-row { min-height: 1.55rem; font-size: 0.82rem; }
  .hud-help.is-touch .help-close { min-height: 40px; padding: 0.3em 1.5em; }
}

/* ---------------------------------------------------------------------------------------------
   Conjure feed (ui/ConjureFeed.js): one small ink book per other player conjuring, stacked on the
   right edge (oldest on top). It slides in shut, its cover swings open leftwards about the spine
   (the inside of the cover is the left page), their words are brushed onto the two pages (canvases,
   drawn by the JS), then it swings shut and fades. Anonymous: no names, no colours.
   Right edge, a third of the way down: clear of the menu button / "holding" chip above, the
   conjure slip (top centre), the effects (left) and, on touch, the thumb buttons below.
   --------------------------------------------------------------------------------------------- */
.hud-conjurers {
  --pw: 100px;          /* a page (the JS sizes its lettering from it: two lines a page) */
  --ph: 48px;
  --bd: 2.5px;          /* the board showing round the pages */
  --cover: #5b2a22;     /* the 3D book's cover (player/anim/InkBook.js) */
  --paper: #ece2c9;
  position: absolute;
  right: calc(12px + var(--safe-r));
  top: max(calc(118px + var(--safe-t)), 30%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  z-index: 1; /* over the floating name labels (net/RemotePlayers.js); the slip and room card stay above */
}
.cf-row {
  height: calc(var(--ph) + 2 * var(--bd));
  max-height: calc(var(--ph) + 2 * var(--bd));
  margin-bottom: 8px;
  animation: cf-in 0.24s ease-out backwards;
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.26s ease 0.24s, margin 0.26s ease 0.24s;
}
.cf-row.is-out { opacity: 0; transform: translateX(6px); max-height: 0; margin-bottom: 0; }
@keyframes cf-in { from { opacity: 0; transform: translateX(12px); } }
/* the open spread; shut, only its right half (the cover) shows, against the screen edge */
.cf-book {
  position: relative;
  width: calc(2 * (var(--pw) + var(--bd)));
  height: 100%;
  perspective: calc(var(--pw) * 4.5);
}
.cf-leaf, .cf-lid, .cf-cover {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(var(--pw) + var(--bd));
  box-sizing: border-box;
}
.cf-leaf { background: var(--cover); box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.82), 0 2px 0 rgba(28, 27, 25, 0.1); }
.cf-page { display: block; width: var(--pw); height: var(--ph); box-shadow: 1px 1px 0 #c8b994; } /* + the pages' edges */
.cf-l .cf-page { box-shadow: -1px 1px 0 #c8b994; }
/* the right page, fixed; a vermilion seal on its corner (as on the 3D book; out on the board, clear
   of the last letter and the caret) */
.cf-r { left: 50%; padding: var(--bd) var(--bd) var(--bd) 0; border-radius: 0 3px 3px 0; }
.cf-r .cf-page {
  background: linear-gradient(to right, rgba(90, 70, 40, 0.34), rgba(120, 96, 60, 0) 14%, rgba(120, 96, 60, 0) 90%, rgba(120, 96, 60, 0.16)) var(--paper);
}
.cf-r::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 4.5px;
  height: 5px;
  background: var(--vermilion);
  box-shadow: 0 0 0 0.5px rgba(236, 226, 201, 0.5);
}
/* the cover: hinged at the spine (its left edge); front = the cover, back = the left page */
.cf-lid {
  left: 50%;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  transform: rotateY(-180deg);
  animation: cf-open 0.44s cubic-bezier(0.3, 0.1, 0.25, 1) 0.16s backwards;
}
@keyframes cf-open { from { transform: rotateY(0deg); } }
.cf-row.is-shut .cf-lid { animation: cf-shut 0.32s cubic-bezier(0.55, 0, 0.8, 0.5) both; }
@keyframes cf-shut { from { transform: rotateY(-180deg); } to { transform: rotateY(0deg); } }
.cf-cover, .cf-l {
  left: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.cf-cover {
  transform: rotateY(0deg); /* Safari honours backface-visibility only on a transformed face */
  border-radius: 1px 3px 3px 1px;
  background:
    linear-gradient(to right, rgba(14, 6, 4, 0.45) 0 3px, rgba(255, 236, 214, 0.1) 3px 5px, rgba(255, 236, 214, 0) 45%),
    var(--cover);
  box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.85), 0 2px 0 rgba(28, 27, 25, 0.12);
}
.cf-cover::before { /* a paper title slip with a brushed stroke on it */
  content: "";
  position: absolute;
  left: 32%;
  right: 24%;
  top: 20%;
  height: 26%;
  border-radius: 1px;
  background: linear-gradient(transparent 44%, rgba(28, 27, 25, 0.7) 44% 58%, transparent 58%) 50% 0 / 62% 100% no-repeat, var(--paper);
  box-shadow: 0 0 0 1px rgba(28, 27, 25, 0.55);
}
.cf-cover::after { /* the vermilion seal */
  content: "";
  position: absolute;
  right: 11%;
  bottom: 15%;
  width: 7px;
  height: 7.5px;
  background: var(--vermilion);
  opacity: 0.9;
}
.cf-l { transform: rotateY(180deg); padding: var(--bd) 0 var(--bd) var(--bd); border-radius: 3px 0 0 3px; }
.cf-l .cf-page {
  background: linear-gradient(to left, rgba(90, 70, 40, 0.34), rgba(120, 96, 60, 0) 14%, rgba(120, 96, 60, 0) 90%, rgba(120, 96, 60, 0.16)) var(--paper);
}
/* the brush's place: a vermilion caret after the newest letter while they type (shown once open) */
.cf-caret {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  width: 1.5px;
  height: var(--ch, 14px);
  border-radius: 1px;
  background: var(--vermilion);
  transform: translate(calc(var(--bd) + var(--cx, 0px)), calc(var(--bd) + var(--cy, 0px)));
}
.cf-row.is-live .cf-caret { display: block; animation: cf-wait 0.6s steps(1), cf-caret 1.1s steps(1) 0.6s infinite; }
@keyframes cf-wait { from, to { opacity: 0; } }
@keyframes cf-caret { 50% { opacity: 0; } }
.menu-open .hud-conjurers, .hud-help:not([hidden]) ~ .hud-conjurers { visibility: hidden; }
.ui-guided .hud-conjurers { display: none; } /* the tutorial: nobody else is there */
/* our own slip open (desktop): the column steps down below it */
.summon-open:not(.is-touch) .hud-conjurers { top: max(calc(180px + var(--safe-t)), 30%); }
/* phones upright: narrower, so even a fourth book (y ≈ the screen's middle) keeps right of the
   crosshair at the centre: 375 px wide → 74 px pages, the spread's left edge ≈ 22 px past the centre */
@media (max-width: 600px) {
  .hud-conjurers { --pw: min(84px, calc(25vw - 20px)); --ph: calc(var(--pw) * 0.54); }
}
/* phones sideways: just under the menu button and the compact slip (it ends ≈ 70 px), above the
   thumb buttons; a step lower where the "holding" chip shows (desktop, or a touch summon gathering) */
@media (max-height: 400px) {
  .hud-conjurers, .summon-open:not(.is-touch) .hud-conjurers { --pw: 84px; --ph: 38px; --bd: 2px; top: calc(98px + var(--safe-t)); }
  .is-touch:not(:has(.summon-ui.is-busy)) .hud-conjurers { top: calc(78px + var(--safe-t)); }
  .cf-row { margin-bottom: 5px; }
}
/* …and there the right edge is short (the thumb cluster's top is ≈ 170 px off the bottom), so the
   books go two abreast: the oldest top right, the next to its left, then a second row (rtl grid) */
@media (max-height: 400px) and (min-width: 560px) {
  .hud-conjurers { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: start; direction: rtl; }
  .cf-row { direction: ltr; }
}
/* very short: three books, or one row of two abreast (the rest wait for a free slot, like a fifth) */
@media (max-height: 340px) {
  .cf-row:nth-child(n+4) { display: none; }
}
@media (max-height: 340px) and (min-width: 560px) {
  .cf-row:nth-child(n+3) { display: none; }
}
/* reduced motion: no swing, the book is simply open; it fades in and out */
@media (prefers-reduced-motion: reduce) {
  .cf-row { animation-name: cf-fade; }
  @keyframes cf-fade { from { opacity: 0; } }
  .cf-row.is-out { transform: none; }
  .cf-lid, .cf-row.is-shut .cf-lid { animation: none; }
  .cf-row.is-live .cf-caret { animation: none; }
}
