:root {
  --bg: #140f1a;
  --card: #231b2e;
  --card-2: #2e2440;
  --ink: #f4ecdf;
  --ink-dim: #b9adc6;
  --gold: #ffd24a;
  --gold-dark: #c38f16;
  --accent: #ff9a3c;
  --danger: #e2574c;
  --good: #57d977;
  --warn: #ffc94a;
  --bad: #ff6159;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; }

button { font: inherit; color: inherit; touch-action: manipulation; }

/* ---------------------------------------------------------------- Lobby -- */
#lobby {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background:
    radial-gradient(ellipse at 50% 0%, #3a2a4f 0%, rgba(20,15,26,0) 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 24px),
    var(--bg);
}

.lobby-card {
  width: 100%;
  max-width: 460px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-head { text-align: center; }
#lobby-art {
  width: 344px; height: 52px;
  max-width: 92%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#game-title {
  margin: 2px 0 0;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-dark), 0 5px 0 #3b2410, 0 8px 14px rgba(0,0,0,0.6);
}
.tagline { margin: 8px 0 0; color: var(--ink-dim); font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; }

input[type=text] {
  font: inherit;
  font-size: 18px; /* >= 16px so iOS does not zoom on focus */
  color: var(--ink);
  background: var(--card);
  border: 2px solid #4a3b5e;
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
}
input[type=text]:focus { border-color: var(--gold); }

.class-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (min-width: 560px), (orientation: landscape) and (min-width: 520px) {
  .lobby-card { max-width: 640px; }
}
.class-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  padding: 5px 2px 6px;
  border-radius: 12px;
  border: 2px solid #3c304d;
  background: var(--card);
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s, opacity 0.1s;
}
.class-card::before { /* the character's colour, also its colour in the party list */
  content: '';
  position: absolute;
  left: 8px; right: 8px; top: -2px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--cls);
}
.class-card canvas { width: 48px; height: 48px; image-rendering: pixelated; image-rendering: crisp-edges; }
.class-card .cc-text { display: flex; flex-direction: column; align-items: center; min-width: 0; width: 100%; }
.class-card b { font-size: 14px; line-height: 1.15; }
.class-card .cc-who {
  font-size: 11px; line-height: 1.2; min-height: 1.2em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-dim);
}
.class-card[aria-checked=true] {
  border-color: var(--cls, var(--gold));
  background: linear-gradient(180deg, color-mix(in srgb, var(--cls, #888) 30%, var(--card)) 0%, var(--card) 100%);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--cls, var(--gold)), 0 6px 18px rgba(0,0,0,0.35);
}
/* someone in this dungeon has it: greyed, not pickable, with their name */
.class-card.taken {
  cursor: not-allowed;
  background: #1a1422;
  border-color: #2a2235;
  border-style: dashed;
}
.class-card.taken::before { opacity: 0.35; }
.class-card.taken canvas { opacity: 0.55; }
.class-card.taken b { color: #6f6580; text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(111,101,128,0.6); }
.class-card.taken .cc-who {
  color: #f4ecdf; font-weight: 700;
  background: #3a2f48; border-radius: 6px; padding: 0 5px; margin-top: 1px;
}
.class-card.takeable .cc-who { color: var(--good); font-weight: 700; }
.class-detail {
  margin: 2px 0 0;
  min-height: 2.6em;
  font-size: 14px;
  line-height: 1.3;
  color: var(--ink-dim);
}
.class-detail b { color: color-mix(in srgb, var(--cls, #fff) 55%, #fff); }
.picker-note { margin: 0; font-size: 13px; color: var(--ink-dim); }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary {
  color: #2b1704;
  background: linear-gradient(180deg, #ffe07a, #ffb931);
  box-shadow: 0 4px 0 #a86a0c, 0 8px 18px rgba(0,0,0,0.35);
}
.btn-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #a86a0c; }
.btn-secondary { background: var(--card-2); color: var(--ink); box-shadow: 0 3px 0 #17111f; }
.btn-secondary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #17111f; }
.btn-danger { background: #4a1f25; color: #ffd8d4; box-shadow: 0 3px 0 #22090c; }
.btn-link { background: none; color: var(--ink-dim); font-weight: 600; font-size: 15px; padding: 8px; text-decoration: underline; }
.btn-toggle { background: var(--card-2); font-size: 15px; padding: 10px; }
.btn-toggle[aria-pressed=true] { background: #2c4a32; color: #d6ffdc; }

.join-row { display: flex; gap: 8px; }
.join-row input { width: 7.2em; flex: none; text-align: center; text-transform: uppercase; letter-spacing: 0.25em; font-weight: 800; }
.join-row .btn { flex: 1; }

.lobby-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #3a2230;
  color: #ffd8d4;
  font-size: 15px;
}

/* ----------------------------------------------------------------- Game -- */
#game {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#play {
  position: absolute;
  inset: 0;
  touch-action: none;
  overflow: hidden;
}
#view {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.stick {
  position: absolute;
  width: 128px; height: 128px;
  margin: -64px 0 0 -64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.10) 0 55%, rgba(255,255,255,0.18) 56% 60%, rgba(255,255,255,0.06) 61%);
  border: 2px solid rgba(255,255,255,0.28);
  pointer-events: none;
}
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 58px; height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6dc, #e6c27a 60%, #9a7637);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}

.fire-btn {
  position: absolute;
  right: calc(22px + var(--sar));
  bottom: calc(26px + var(--sab));
  width: 104px; height: 104px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, #ff9e7a, #e2574c 55%, #8f2a24);
  box-shadow: 0 5px 0 #5c1612, 0 10px 22px rgba(0,0,0,0.45), inset 0 -4px 0 rgba(0,0,0,0.18);
  border: 3px solid rgba(255,255,255,0.35);
  color: #fff4ec;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 rgba(60,10,6,0.8), 0 0 6px rgba(60,10,6,0.6);
  opacity: 0.88;
  pointer-events: none;
}
.fire-btn.down { transform: translateY(3px) scale(0.96); box-shadow: 0 2px 0 #5c1612, 0 6px 14px rgba(0,0,0,0.45); opacity: 1; }
.fire-btn.auto { background: radial-gradient(circle at 40% 35%, #ffc07a, #e2884c 55%, #8f4a24); }
body.no-touch .fire-btn { display: none; }

/* whether auto-fire is on: a small pill above the FIRE button (switched on the pause screen, #13) */
.auto-ind {
  position: absolute;
  right: calc(22px + 52px + var(--sar));
  bottom: calc(26px + 104px + 10px + var(--sab));
  transform: translateX(50%);
  display: flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: rgba(16,11,22,0.55);
  color: rgba(244,236,223,0.5);
  font-size: 10px; font-weight: 900; letter-spacing: 0.08em; line-height: 14px;
  white-space: nowrap;
  pointer-events: none;
}
.auto-ind i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.22); flex: none; }
.auto-ind.on { color: #ffd9a8; }
.auto-ind.on i { background: #ff9a3c; box-shadow: 0 0 5px #ff9a3c; }
body.no-touch .auto-ind { display: none; }

/* HUD */
#hud {
  position: absolute;
  left: 0; right: 0; top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: calc(8px + var(--sat)) calc(8px + var(--sar)) 0 calc(8px + var(--sal));
  pointer-events: none;
  font-size: 14px;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
.hud-row { display: flex; align-items: center; gap: 6px; }
.hud-me {
  display: flex; flex-direction: column; gap: 5px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(16,11,22,0.62);
  min-width: 0;
  max-width: 60vw;
}
.me-icon { width: 27px; height: 27px; image-rendering: pixelated; flex: none; }
.bar {
  position: relative;
  height: 14px;
  border-radius: 7px;
  background: #3b1720;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6);
}
.hp-bar { width: min(170px, 40vw); height: 18px; border-radius: 9px; }
.bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(180deg, #8af59a, #2fb350);
  transition: width 0.15s linear;
}
.bar-fill.mid { background: linear-gradient(180deg, #ffe17a, #e0a41e); }
.bar-fill.low { background: linear-gradient(180deg, #ff8f80, #d9342b); }
.bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  color: #fff;
}
.stats { gap: 4px 10px; font-weight: 800; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ico { width: 18px; height: 18px; image-rendering: pixelated; }
.pips { gap: 2px; }
.pip { width: 8px; height: 12px; border-radius: 2px; background: rgba(255,255,255,0.18); transform: skewX(-12deg); }
.pip.on { background: linear-gradient(180deg, #e2b8ff, #a259ff); box-shadow: 0 0 4px #a259ff; }
.lvl { color: var(--gold); }

.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-right > .hud-row {
  padding: 4px 4px 4px 9px;
  border-radius: 12px;
  background: rgba(16,11,22,0.62);
}
.net { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; min-width: 48px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #777; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,0.6); }
.dot.good { background: var(--good); }
.dot.ok { background: var(--warn); }
.dot.bad { background: var(--bad); }
.room-chip { font-weight: 900; letter-spacing: 0.14em; color: var(--gold); font-size: 15px; }
.icon-btn {
  pointer-events: auto;
  width: 40px; height: 34px;
  border: none; border-radius: 9px;
  background: rgba(255,255,255,0.12);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
}
.icon-btn i { display: block; width: 18px; height: 2.5px; border-radius: 2px; background: var(--ink); box-shadow: 0 1px 1px #000; }

.party {
  list-style: none;
  margin: 0; padding: 4px 6px;
  border-radius: 10px;
  background: rgba(16,11,22,0.5);
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px;
}
.party:empty { display: none; }
.party li { display: flex; align-items: center; gap: 5px; height: 16px; }
.party .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,0.7); }
.party .pname { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.party .mini { position: relative; width: 38px; height: 6px; border-radius: 3px; background: #3b1720; overflow: hidden; flex: none; }
.party .mini > i { position: absolute; left: 0; top: 0; bottom: 0; background: #4ad163; }
.party .tag { font-size: 10px; font-weight: 800; padding: 0 4px; border-radius: 4px; background: #555; color: #eee; text-shadow: none; }
.party .tag.dead { background: #6b2b33; }
.party .tag.away { background: #4b4b5a; }
.party .tag.ghost { background: #3d4a7a; color: #e4e8ff; }
.party .tag.ghost.pulse { display: inline-block; background: #6a7cff; color: #fff; animation: tag-pulse 0.9s ease-in-out infinite; }
.party li.needs-tag .pname { color: #e4e8ff; }
@keyframes tag-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 8px #9aa8ff; } }
.party li.me .pname { color: var(--gold); }
.party li.off { opacity: 0.6; }

/* Small phones: a tighter lobby so it fits with little or no scrolling. */
@media (max-width: 360px), (max-height: 600px) and (orientation: portrait) {
  .lobby-card { gap: 9px; }
  #lobby-art { width: 258px; height: 39px; }
  #game-title { font-size: 28px; }
  .tagline { display: none; }
  .class-picker { gap: 5px; }
  .class-card { padding: 4px 1px 5px; }
  .class-card canvas { width: 40px; height: 40px; }
  .class-card b { font-size: 13px; }
  .class-card .cc-who { font-size: 10.5px; }
  .class-detail { font-size: 13px; }
  input[type=text] { padding: 8px 12px; }
  .btn { padding: 11px 14px; font-size: 17px; }
}

/* Narrow phones: shrink the HUD so the two corners never collide. */
@media (max-width: 370px) {
  #hud { font-size: 13px; padding-left: calc(6px + var(--sal)); padding-right: calc(6px + var(--sar)); }
  .hud-me { padding: 5px 6px; max-width: 56vw; }
  .hp-bar { width: 30vw; }
  .stats { gap: 2px 8px; }
  .pip { width: 6px; height: 10px; }
  .net { min-width: 0; }
  .net #ping { display: none; }
  .room-chip { font-size: 13px; letter-spacing: 0.08em; }
  .icon-btn { width: 34px; }
  .party .pname { max-width: 64px; }
  .party .mini { width: 30px; }
}

/* Small screens in landscape: keep the HUD short. */
@media (max-height: 430px) {
  #hud { font-size: 13px; }
  .party li { height: 14px; }
  .fire-btn { width: 92px; height: 92px; }
  .auto-ind { right: calc(22px + 46px + var(--sar)); bottom: calc(26px + 92px + 8px + var(--sab)); }
}

.boss {
  position: absolute;
  left: calc(10px + var(--sal));
  top: calc(var(--sat) + 86px);
  width: min(200px, 46vw);
  text-align: center;
  pointer-events: none;
  font-size: 12px; font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase;
  color: #ffb3a6;
  text-shadow: 0 1px 2px #000;
}
@media (orientation: landscape) and (max-height: 600px) { .toasts { top: calc(var(--sat) + 46px); width: min(40vw, 380px); } }
@media (orientation: landscape) { .boss { left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 10px); width: min(260px, 34vw); } }
.boss .bar { height: 10px; margin-top: 2px; background: #2a0d10; border: 1px solid #7a2a24; }
.boss .bar-fill { background: linear-gradient(180deg, #ff8a5c, #c4271d); }

.toasts {
  position: absolute;
  left: 50%;
  top: max(calc(var(--sat) + 80px), 26%);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20,14,28,0.82);
  border: 1px solid rgba(255,210,74,0.35);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  animation: toast-in 0.25s ease-out, toast-out 0.5s ease-in 2.8s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

.respawn {
  position: absolute;
  left: 50%; top: 69%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: max-content;
  max-width: min(86vw, 380px);
  padding: 10px 20px;
  border-radius: 16px;
  background: rgba(20,14,28,0.78);
  border: 1px solid rgba(190,200,255,0.25);
  text-align: center;
  color: #e9e2ff;
  pointer-events: none;
  text-shadow: 0 2px 0 #000;
}
.respawn b { font-size: 22px; font-weight: 900; }
.respawn small { font-size: 15px; font-weight: 700; color: #cfd6ff; line-height: 1.25; }
/* Short landscape: sit at the bottom edge, between the thumbs, clear of the heroes. */
@media (max-height: 500px) and (orientation: landscape) {
  .respawn { top: auto; bottom: calc(8px + var(--sab)); transform: translateX(-50%); padding: 5px 16px; max-width: min(52vw, 420px); }
  .respawn b { font-size: 18px; }
  .respawn small { font-size: 13px; }
}
.hp-bar.ghost { background: #27305a; }

.wipe {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 50%, rgba(36,18,56,0.9) 0%, rgba(8,4,14,0.97) 70%);
  pointer-events: none;
  text-align: center;
  animation: wipe-in 0.7s ease-out;
}
.wipe-title {
  margin: 0;
  font-size: clamp(26px, 7.5vw, 44px);
  font-weight: 900;
  color: #d9c8ff;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 #2a1440, 0 0 24px rgba(160,110,255,0.55);
  animation: wipe-breathe 2.4s ease-in-out infinite;
}
.wipe-sub { margin: 0; font-size: 17px; font-weight: 700; color: #b9adc6; text-shadow: 0 2px 0 #000; }
@keyframes wipe-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes wipe-breathe { 50% { transform: scale(1.04); opacity: 0.85; } }

.fire-btn.off { filter: grayscale(1) brightness(0.7); opacity: 0.35; }

.banner {
  position: absolute;
  left: 50%;
  top: calc(var(--sat) + 30%);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-radius: 16px;
  background: rgba(28,20,38,0.94);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 6; /* above the pause screen: "Reconnecting…" and "Reload" must show there too */
}
.banner.fatal { pointer-events: auto; white-space: normal; flex-direction: column; text-align: center; width: min(86vw, 360px); }
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
.banner.fatal .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,5,12,0.66);
  padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal));
  overflow-y: auto;
  touch-action: pan-y;
}
.menu-code { margin: 0; font-size: 44px; line-height: 1; font-weight: 900; letter-spacing: 0.2em; color: var(--gold); padding-left: 0.2em; }
.share-msg { margin: 0; font-size: 14px; color: var(--good); word-break: break-all; text-align: center; }

/* --- The gathering at the exit (#3) ------------------------------------------------------ */
/* the counter, a third row of the HUD's left box, for everyone */
.gather-row { font-weight: 800; color: #fff1a8; gap: 5px; }
.gather-ico { width: 18px; height: 18px; image-rendering: pixelated; flex: none; }
.hp-bar.spirit { background: #5a4310; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), 0 0 8px rgba(255,214,110,0.55); }
.hp-bar.spirit .bar-fill { background: linear-gradient(180deg, #fff3b8, #ffc94a); }
.hp-bar.spirit .bar-text { color: #3a2604; text-shadow: none; }
#game.finished .auto-ind { display: none; }
/* "Follow me!" in place of FIRE for a roaming spirit; on a computer too (Space or a click) */
.fire-btn.call {
  background: radial-gradient(circle at 40% 35%, #fffbe0, #ffd24a 55%, #b9820f);
  box-shadow: 0 5px 0 #7a5208, 0 10px 22px rgba(0,0,0,0.45), 0 0 18px rgba(255,214,110,0.5);
  color: #3a2604;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  font-size: 16px; letter-spacing: 0.02em; line-height: 1.05; text-align: center;
  opacity: 0.95;
}
.fire-btn.call span { max-width: 76px; }
.fire-btn.calling { animation: call-pulse 0.8s ease-in-out infinite; }
@keyframes call-pulse { 50% { box-shadow: 0 5px 0 #7a5208, 0 0 0 7px rgba(255,241,168,0.45), 0 0 26px rgba(255,214,110,0.8); } }
body.no-touch .fire-btn.call { display: flex; }
/* waiting on the exit: "You made it!", "Go back for others?" and, once offered, the vote */
.gather {
  position: absolute;
  z-index: 2;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  pointer-events: auto;
  text-shadow: 0 2px 0 #000;
}
.gather.done { /* bottom left, clear of FIRE (off while waiting) and of the heroes in the middle */
  left: calc(12px + var(--sal)); bottom: calc(18px + var(--sab));
  width: min(calc(100vw - 24px - 104px - 36px - var(--sal) - var(--sar)), 340px);
  padding: 12px 14px 14px;
  border-radius: 18px;
  background: rgba(30,22,10,0.86);
  border: 2px solid rgba(255,214,110,0.55);
  box-shadow: 0 0 24px rgba(255,214,110,0.25), 0 10px 30px rgba(0,0,0,0.45);
  text-align: center;
}
.gather-text { display: flex; flex-direction: column; gap: 2px; }
.gather-text b { font-size: 22px; font-weight: 900; color: #fff1a8; }
.gather-text small { font-size: 15px; font-weight: 700; color: #f1e3c0; line-height: 1.25; }
.gather-text small:empty { display: none; }
.gather .btn { text-shadow: none; }
.gather.done .btn { font-size: 16px; padding: 10px 12px; }
.gather-skip { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 16px; padding: 10px 12px; }
.gather-skip small { font-size: 13px; font-weight: 700; opacity: 0.85; }
.gather-skip[aria-pressed=true] { background: #2c4a32; color: #d6ffdc; box-shadow: 0 3px 0 #13261a, 0 0 0 2px #57d977 inset; }
.gather.spirit { /* a roaming spirit: only the vote, just above "Follow me!", in the right thumb's half */
  right: calc(12px + var(--sar));
  bottom: calc(26px + 104px + 18px + var(--sab));
  width: min(210px, 46vw);
}
.gather.spirit .gather-text, .gather.spirit .gather-back { display: none; }
.gather.spirit .gather-skip { font-size: 15px; padding: 8px 10px; box-shadow: 0 3px 0 #17111f, 0 6px 16px rgba(0,0,0,0.4); }
.gather.spirit .gather-skip small { font-size: 12px; }
@media (max-height: 500px) and (orientation: landscape) {
  /* short landscape: one line of text, the buttons side by side, low between the thumbs */
  .gather.done { left: 50%; bottom: calc(8px + var(--sab)); transform: translateX(-50%); width: min(60vw, 520px); padding: 6px 10px 8px; gap: 6px; flex-direction: row; flex-wrap: wrap; }
  .gather.done .gather-text { flex-basis: 100%; flex-direction: row; justify-content: center; align-items: baseline; gap: 8px; }
  .gather-text b { font-size: 18px; }
  .gather-text small { font-size: 13px; }
  .gather.done .btn { flex: 1 1 0; padding: 8px 10px; font-size: 15px; }
  .gather.done .gather-skip small { font-size: 11px; }
  .gather.spirit { bottom: calc(26px + 92px + 14px + var(--sab)); }
}
.party .tag.made { background: linear-gradient(180deg, #fff1a8, #ffc94a); color: #3a2604; }
.party li.done .pname::before { content: '★ '; color: #ffd24a; }

/* --- The pause screen (#13)------------------------------------------------------------- */
/* The game stays visible, lightly dimmed, so a paused player can watch the family carry on.
   Portrait: a card at the bottom; landscape: a card on the left. main.js moves the camera so
   your meditating hero sits in the open part of the screen. */
.menu.pause {
  background: rgba(8,5,12,0.34);
  align-items: flex-end;
  justify-content: center;
  animation: pause-in 0.18s ease-out;
}
@keyframes pause-in { from { background: rgba(8,5,12,0); } }
.pause-card {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px 16px;
  border-radius: 20px;
  background: rgba(35,27,46,0.97);
  border: 1px solid rgba(217,200,255,0.16);
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
  animation: pause-card-in 0.2s ease-out;
}
@keyframes pause-card-in { from { transform: translateY(18px); opacity: 0; } }
.pause-head { display: flex; align-items: center; gap: 12px; }
.pause-icon { width: 40px; height: 40px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; }
.pause-head-text { min-width: 0; }
.pause-title { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 900; letter-spacing: 0.04em; color: #d9c8ff; text-shadow: 0 2px 0 #2a1440; }
.pause-sub { margin: 2px 0 0; font-size: 14px; line-height: 1.3; color: var(--ink-dim); }
.btn-resume { font-size: 22px; padding: 14px 16px; }
.pause-note { margin: -3px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--ink-dim); text-align: center; }
.pause-section { margin: 0; }
/* settings: a grid of rows that grows as settings are added */
.pause-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 44px; padding: 8px 10px 8px 12px;
  border: none; border-radius: 12px;
  background: var(--card-2); color: var(--ink);
  font-size: 15px; font-weight: 700; text-align: left;
  cursor: pointer;
}
.setting:active { transform: translateY(1px); }
.set-val {
  flex: none; min-width: 3.2em; padding: 3px 8px; border-radius: 999px; text-align: center;
  font-size: 13px; font-weight: 900; background: #43384f; color: var(--ink-dim);
}
.setting[aria-pressed=true] .set-val { background: #2c6a3a; color: #d6ffdc; }
.pause-room {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 8px 8px 12px; border-radius: 12px; background: #1b1524;
}
.room-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pause-label { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.pause-room .menu-code { font-size: 28px; padding-left: 0; letter-spacing: 0.16em; }
.btn-share { width: auto; flex: none; font-size: 16px; padding: 10px 16px; }
.pause-foot { display: flex; gap: 8px; }
.pause-foot .btn { flex: 1; margin: 0; font-size: 14px; padding: 9px 8px; }
#game.paused .toasts { z-index: 5; } /* "Ben revived Ana!", "Level 3!" show over the pause screen */

/* Small phones: a tighter card, so more of the game shows above it. */
@media (max-width: 360px), (max-height: 640px) and (orientation: portrait) {
  .pause-card { gap: 7px; padding: 10px 12px 12px; }
  .pause-icon { width: 36px; height: 36px; }
  .pause-title { font-size: 22px; }
  .pause-sub { font-size: 13px; }
  .btn-resume { font-size: 19px; padding: 11px 14px; }
  .setting { min-height: 40px; font-size: 14px; }
  .pause-settings { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 6px; }
  .pause-room { padding: 6px 6px 6px 10px; }
  .pause-room .menu-code { font-size: 22px; }
  .btn-share { font-size: 15px; padding: 9px 12px; }
  .pause-foot .btn { font-size: 13px; padding: 8px 6px; }
}
/* Landscape phones: the card on the left, the game and the party list on the right. */
@media (orientation: landscape) and (max-height: 600px) {
  .menu.pause { align-items: center; justify-content: flex-start; padding-top: calc(8px + var(--sat)); padding-bottom: calc(8px + var(--sab)); }
  .pause-card { width: min(360px, 46vw); max-height: 100%; overflow-y: auto; gap: 7px; padding: 10px 12px 12px; box-shadow: 4px 0 30px rgba(0,0,0,0.5); }
  .pause-icon { width: 34px; height: 34px; }
  .pause-title { font-size: 21px; }
  .pause-sub { font-size: 12.5px; }
  .pause-note { font-size: 12px; }
  .btn-resume { font-size: 19px; padding: 9px 14px; }
  .setting { min-height: 38px; padding: 6px 8px 6px 10px; font-size: 14px; }
  .pause-settings { gap: 6px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pause-room { padding: 5px 6px 5px 10px; }
  .pause-room .menu-code { font-size: 22px; }
  .btn-share { font-size: 15px; padding: 8px 12px; }
  .pause-foot .btn { font-size: 13px; padding: 7px 6px; }
  #game.paused .toasts { left: auto; right: calc(10px + var(--sar)); transform: none; width: min(44vw, 380px); }
}
/* party list: a paused teammate, calm and never mistaken for "away" */
.party .tag.paused { background: #2f5a5a; color: #d8fff7; }
.party .tag.paused.ghost { background: #3d4a7a; color: #e4e8ff; }

/* --- The play-test tuning page (#9): a testing tool, styled to look like one ---------- */
/* while the page is open, toasts ("Tuning: Mom set…") show over it, at the bottom, clear of the controls */
#game.tuning-open .toasts { z-index: 5; top: auto; bottom: calc(var(--sab) + 14px); }
.btn-test {
  background: repeating-linear-gradient(135deg, #2a2233 0 10px, #241d2c 10px 20px);
  color: #9fd6ff; font-size: 13px; font-weight: 800; letter-spacing: 0.06em;
  padding: 8px; border: 1px dashed #4b6c88; margin-top: 4px;
}
.tuning { align-items: flex-start; }
.tuning-card {
  width: min(720px, 100%);
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: var(--card);
  border: 2px dashed #4b6c88;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6);
}
.tuning-head { display: flex; align-items: center; gap: 10px; }
.tuning-head h2 { margin: 0; font-size: 20px; flex: 1; }
.test-tag {
  font-size: 11px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase;
  color: #10202c; background: #9fd6ff; border-radius: 6px; padding: 3px 7px; white-space: nowrap;
}
.tuning-x {
  width: 40px; height: 40px; flex: none; border: none; border-radius: 12px;
  background: var(--card-2); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer;
}
.tuning-note { margin: 0; font-size: 13px; color: var(--ink-dim); }
.tuning-tabs { display: flex; gap: 6px; }
.ttab {
  flex: 1; border: none; border-radius: 10px; padding: 9px 6px; cursor: pointer;
  background: var(--card-2); color: var(--ink-dim); font-weight: 800; font-size: 15px;
}
.ttab[aria-selected=true] { background: #9fd6ff; color: #10202c; }
.tuning-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip {
  border: 2px solid transparent; border-radius: 999px; padding: 6px 11px; cursor: pointer;
  background: var(--card-2); color: var(--ink); font-weight: 700; font-size: 14px;
  border-left: 6px solid var(--cls, #8a7fa0); position: relative;
}
.tchip[aria-pressed=true] { border-color: #9fd6ff; border-left-color: var(--cls, #9fd6ff); background: #3a3050; }
.tchip.changed::after {
  content: ''; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--card);
}
.tuning-fields { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .tuning-fields { grid-template-columns: 1fr 1fr; } }
.trow {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label ctl" "meta meta";
  align-items: center; gap: 4px 10px;
  padding: 8px 10px; border-radius: 12px; background: #1b1524; border: 1px solid transparent;
}
.trow.changed { border-color: var(--gold); background: #2a2118; }
.tlabel { grid-area: label; display: flex; flex-direction: column; min-width: 0; }
.tlabel b { font-size: 15px; }
.tlabel small { font-size: 12px; color: var(--ink-dim); line-height: 1.25; }
.tctl { grid-area: ctl; display: flex; align-items: center; gap: 4px; }
.tstep {
  width: 40px; height: 40px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--card-2); color: var(--ink); font-size: 22px; font-weight: 900; line-height: 1;
}
.tstep:disabled { opacity: 0.35; cursor: default; }
.tnum {
  width: 4.6em; height: 40px; text-align: center; font-size: 16px; font-weight: 800;
  border-radius: 10px; border: 1px solid #4a3d5e; background: #120d18; color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
.tnum::-webkit-outer-spin-button, .tnum::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ttoggle { width: 6.2em; padding: 9px 6px; }
.tmeta { grid-area: meta; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-dim); }
.trow.changed .tdef { color: var(--gold); font-weight: 700; }
.treset {
  border: none; background: none; color: #9fd6ff; font-size: 13px; font-weight: 700;
  text-decoration: underline; cursor: pointer; padding: 4px 2px;
}
.treset:disabled { visibility: hidden; }
.tuning-foot { display: flex; flex-direction: column; gap: 8px; }
.tuning-count { margin: 0; font-size: 14px; color: var(--ink-dim); text-align: center; }
.tuning-actions { display: flex; gap: 8px; }
.tuning-actions .btn { font-size: 15px; padding: 11px 8px; }
.tuning-copy-msg { margin: 0; font-size: 13px; color: var(--good); text-align: center; }
.tuning-text {
  width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; color: var(--ink);
  background: #120d18; border: 1px solid #4a3d5e; border-radius: 10px; padding: 8px; resize: vertical;
}
@media (max-width: 360px) {
  .tuning-card { padding: 10px; }
  .tuning-head h2 { font-size: 17px; }
  .trow { grid-template-columns: 1fr; grid-template-areas: "label" "ctl" "meta"; }
  .tuning-actions { flex-direction: column; }
}

/* Short landscape screens: a two-column lobby that fits without scrolling. */
@media (max-height: 500px) and (orientation: landscape) {
  #lobby { align-items: center; padding-top: calc(10px + var(--sat)); padding-bottom: calc(10px + var(--sab)); }
  .lobby-card {
    max-width: 780px;
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    grid-auto-flow: row dense;
    column-gap: 18px;
    row-gap: 8px;
    align-items: start;
  }
  .lobby-card > * { grid-column: 1; }
  .lobby-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 14px; }
  .picker-field { grid-column: 2; grid-row: 2 / span 6; }
  #lobby-art { width: 258px; height: 39px; max-width: none; }
  #game-title { font-size: 26px; margin: 0; }
  .tagline { display: none; }
  .class-card canvas { width: 44px; height: 44px; }
  .class-detail { min-height: 0; font-size: 13px; }
  .btn { padding: 10px 14px; font-size: 17px; }
  input[type=text] { padding: 8px 12px; }
}

/* --- The sandbox (#18): a testing tool, styled like the tuning page. Only in sandbox mode
   (public/js/sandbox.js builds it); remove with the sandbox. The game stays playable while the
   panel is open: a bottom sheet in portrait, a side panel in landscape. sandbox.js sets
   #game.sb-bottom / .sb-side / .sb-armed and --sb-top (below the HUD), --sb-cx (the middle of
   the open part of the screen) and --sb-edge (the bottom sheet's height). ---------------- */
body.sandbox-mode .pause-note { display: none; } /* "You wake up with the family..." is not true here */
.sb-btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px 0 10px;
  border-radius: 12px; border: 1px dashed #4b6c88;
  background: repeating-linear-gradient(135deg, #2a2233 0 10px, #241d2c 10px 20px);
  color: #9fd6ff; font-size: 14px; font-weight: 900; letter-spacing: 0.04em;
  text-shadow: none; cursor: pointer;
}
.sb-btn.on { background: #9fd6ff; color: #10202c; border-style: solid; border-color: #9fd6ff; }
.sb-btn-ico { /* a little test flask, drawn in CSS */
  width: 12px; height: 14px; flex: none; position: relative;
  border: 2px solid currentColor; border-top: none; border-radius: 0 0 6px 6px;
}
.sb-btn-ico::before { content: ''; position: absolute; left: 1px; right: 1px; bottom: 1px; height: 5px; border-radius: 0 0 4px 4px; background: currentColor; opacity: 0.7; }
.sb-btn-ico::after { content: ''; position: absolute; left: -3px; right: -3px; top: -2px; height: 2px; background: currentColor; }

.sb-panel {
  position: absolute; z-index: 3;
  display: flex; flex-direction: column;
  background: rgba(35,27,46,0.97);
  border: 2px dashed #4b6c88;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
}
@media (orientation: portrait) {
  .sb-panel {
    left: 50%; transform: translateX(-50%); bottom: 0;
    width: min(560px, 100%); max-height: 47%;
    border-radius: 18px 18px 0 0; border-bottom: none;
    padding-bottom: var(--sab);
  }
}
@media (orientation: landscape) {
  .sb-panel {
    left: calc(8px + var(--sal)); top: var(--sb-top, 80px); bottom: calc(8px + var(--sab));
    width: min(360px, 44vw);
    border-radius: 16px;
  }
}
#game.paused .sb-panel, #game.paused .sb-chip, #game.tuning-open .sb-panel, #game.tuning-open .sb-chip { display: none; }
.sb-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 6px 12px; }
.sb-head h2 { margin: 0; font-size: 19px; flex: 1; }
.sb-x {
  width: 44px; height: 40px; flex: none; border: none; border-radius: 12px;
  background: var(--card-2); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer;
}
.sb-tabs { display: flex; gap: 6px; padding: 0 10px 8px; }
.sb-tab {
  flex: 1; min-height: 40px; border: none; border-radius: 10px; padding: 6px; cursor: pointer;
  background: var(--card-2); color: var(--ink-dim); font-weight: 800; font-size: 15px;
}
.sb-tab[aria-selected=true] { background: #9fd6ff; color: #10202c; }
.sb-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  padding: 0 10px 12px;
}
.sb-sec { margin: 0 0 12px; }
.sb-sec h3 { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; color: #9fd6ff; }
.sb-note { margin: 0 0 6px; font-size: 12.5px; line-height: 1.3; color: var(--ink-dim); }
.sb-place-note { margin-bottom: 10px; color: var(--ink); }
.sb-chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sb-char {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 2px 5px; border-radius: 12px;
  border: 2px solid #3c304d; background: var(--card); cursor: pointer;
}
.sb-char::before { content: ''; position: absolute; left: 8px; right: 8px; top: -2px; height: 4px; border-radius: 0 0 4px 4px; background: var(--cls); }
.sb-char canvas { width: 36px; height: 36px; image-rendering: pixelated; image-rendering: crisp-edges; }
.sb-char b { font-size: 13px; line-height: 1.15; }
.sb-who { font-size: 11px; line-height: 1.2; min-height: 1.2em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-dim); }
.sb-char.mine { border-color: var(--cls); background: linear-gradient(180deg, color-mix(in srgb, var(--cls) 30%, var(--card)) 0%, var(--card) 100%); }
.sb-char.mine .sb-who { color: var(--gold); font-weight: 800; }
.sb-char.taken { cursor: not-allowed; background: #1a1422; border-color: #2a2235; border-style: dashed; }
.sb-char.taken::before { opacity: 0.35; }
.sb-char.taken canvas { opacity: 0.55; }
.sb-char.taken b { color: #6f6580; text-decoration: line-through; }
.sb-char.taken .sb-who { color: #f4ecdf; font-weight: 700; background: #3a2f48; border-radius: 6px; padding: 0 4px; }
.sb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.sb-item {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  min-height: 44px; padding: 4px 8px 4px 4px;
  border-radius: 10px; border: 2px solid transparent;
  background: var(--card-2); color: var(--ink);
  font-size: 13px; font-weight: 700; line-height: 1.15; text-align: left; cursor: pointer;
}
.sb-item canvas { width: 36px; height: 36px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; }
.sb-item span { min-width: 0; }
.sb-item[aria-pressed=true] { border-color: #9fd6ff; background: #33405a; }
.sb-row { display: flex; gap: 8px; }
.sb-act { flex: 1; margin: 0; font-size: 15px; padding: 11px 8px; min-height: 44px; }
.btn-danger.armed { background: #8a2a30; color: #fff; }
.sb-freeze { width: 100%; margin-bottom: 6px; }
.sb-nums { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.sb-nums dt { color: var(--ink-dim); }
.sb-nums dd { margin: 0; font-weight: 700; }

/* your numbers (#19): a slider per value, built from shared/tuning.js. The range input is
   drawn only (pointer-events: none, never focused); its track takes the pointer, letting the
   sheet scroll up and down (pan-y) and dragging sideways. THUMB in sandbox.js is the thumb's
   width (28px). --at: where the thumb or the default mark sits, 0..1. */
.sb-tgroup { padding: 8px 8px 2px; border-radius: 12px; background: rgba(20,14,28,0.55); border: 1px solid #3c304d; }
.sb-tgroup h3 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sb-tname { font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.sb-tgroup[data-sb-group=hero] .sb-tname { color: color-mix(in srgb, var(--cls) 55%, #fff); }
.sb-trow { padding: 7px 0 6px; border-top: 1px solid #33293f; }
.sb-trow:first-of-type { border-top: none; }
.sb-thead { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.sb-tlabel { font-size: 14px; font-weight: 800; }
.sb-tval { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 3.5em; text-align: right; }
.sb-trow.changed .sb-tval, .sb-trow.changed .sb-tlabel { color: var(--gold); }
.sb-trow.dragging .sb-tval { color: #9fd6ff; }
.sb-tline { display: flex; align-items: center; gap: 6px; }
.sb-tstep {
  flex: none; width: 44px; height: 44px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--card-2); color: var(--ink); font-size: 24px; font-weight: 900; line-height: 1;
}
.sb-tstep:disabled { opacity: 0.35; cursor: default; }
.sb-ttrack { position: relative; flex: 1 1 auto; min-width: 0; height: 44px; touch-action: pan-y; cursor: pointer; --at: 0; }
.sb-ttrack input[type=range] {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 44px; margin: 0; padding: 0; background: transparent; pointer-events: none;
}
.sb-ttrack input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #9fd6ff 0, #9fd6ff calc(14px + (100% - 28px) * var(--at)), #3c304d calc(14px + (100% - 28px) * var(--at)));
}
.sb-ttrack input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -10px;
  border-radius: 50%; background: #f4ecdf; border: 4px solid #9fd6ff; box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.sb-ttrack input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: #3c304d; }
.sb-ttrack input[type=range]::-moz-range-progress { height: 8px; border-radius: 4px; background: #9fd6ff; }
.sb-ttrack input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #f4ecdf; border: 4px solid #9fd6ff; }
.sb-trow.dragging .sb-ttrack input[type=range]::-webkit-slider-thumb { background: #9fd6ff; transform: scale(1.12); }
.sb-tmark { /* the default's place on the track */
  position: absolute; top: 12px; bottom: 12px; width: 2px; margin-left: -1px; border-radius: 1px;
  left: calc(14px + (100% - 28px) * var(--at)); background: #f4ecdf; opacity: 0.55; pointer-events: none;
}
.sb-trow:not(.changed) .sb-tmark { display: none; }
.sb-tmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 0; }
.sb-thint { font-size: 11.5px; line-height: 1.3; color: var(--ink-dim); min-width: 0; }
.sb-tright { display: flex; align-items: center; gap: 6px; flex: none; }
.sb-tdef { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.sb-treset {
  min-height: 36px; min-width: 64px; padding: 0 12px; border: 1px solid #5b4a6e; border-radius: 10px; cursor: pointer;
  background: #2a2233; color: var(--ink); font-size: 13px; font-weight: 800;
}
.sb-teff { display: block; margin: 2px 0 2px; font-size: 12.5px; font-weight: 800; color: #ffd27a; }
.sb-switch { /* an on/off switch, 44 px tall to touch */
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 44px; margin: -7px 0; padding: 0 0 0 6px;
  border: none; background: none; color: var(--ink-dim); font-size: 13px; font-weight: 800; cursor: pointer;
}
.sb-switch i { position: relative; order: 2; width: 52px; height: 30px; border-radius: 15px; background: #3c304d; transition: background 0.12s; }
.sb-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #b9adc6; transition: transform 0.12s; }
.sb-switch[aria-checked=true] { color: #9fd6ff; }
.sb-switch[aria-checked=true] i { background: #9fd6ff; }
.sb-switch[aria-checked=true] i::after { transform: translateX(22px); background: #10202c; }
.sb-switch span { order: 1; min-width: 2em; text-align: right; }
.sb-trow.changed .sb-switch span { color: var(--gold); }

/* what is armed for placing: always on screen while something is */
.sb-chip {
  position: absolute; z-index: 3;
  left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--sab));
  display: flex; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100% - 24px);
  padding: 6px 6px 6px 8px;
  border-radius: 16px; border: 2px dashed #9fd6ff;
  background: rgba(20,14,28,0.93);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}
.sb-chip-ico { width: 36px; height: 36px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; }
.sb-chip-text { display: flex; flex-direction: column; min-width: 0; }
.sb-chip-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-chip-text small { font-size: 12.5px; line-height: 1.25; color: var(--ink-dim); }
.sb-chip-text small.bad { color: #ffb3a6; font-weight: 700; }
.sb-chip-btn {
  flex: none; min-height: 44px; padding: 0 14px; border: none; border-radius: 12px;
  background: var(--card-2); color: var(--ink); font-size: 15px; font-weight: 800; cursor: pointer;
}
.sb-chip-done { background: #9fd6ff; color: #10202c; }

/* the rest of the screen makes room for the panel */
#game.sb-side .sb-chip, #game.sb-side .respawn { left: var(--sb-cx); }
#game.sb-side .toasts { left: var(--sb-cx); width: min(calc((100vw - var(--sb-cx)) * 2 - 24px), 420px); }
#game.sb-side .boss { left: var(--sb-cx); }
#game.sb-bottom .sb-chip { bottom: calc(var(--sb-edge) + 10px); }
#game.sb-bottom .toasts { top: auto; bottom: calc(var(--sb-edge) + 12px); } /* under your hero, not over it */
#game.sb-bottom.sb-armed .toasts { bottom: calc(var(--sb-edge) + 76px); }
#game.sb-bottom .respawn { top: 22%; }
#game.sb-bottom .fire-btn { bottom: calc(var(--sb-edge) + 14px); width: 80px; height: 80px; font-size: 14px; }
#game.sb-bottom .auto-ind { right: calc(22px + 40px + var(--sar)); bottom: calc(var(--sb-edge) + 14px + 80px + 8px); }
#game.sb-side .gather.done { left: var(--sb-cx); transform: translateX(-50%); } /* the gathering (#3), beside the panel */
#game.sb-bottom .gather.done { bottom: calc(var(--sb-edge) + 12px); }
#game.sb-bottom .gather.spirit { bottom: calc(var(--sb-edge) + 14px + 80px + 12px); }
#game.sb-armed .fire-btn { display: none; } /* while placing, a touch on the field places or walks, never fires */

/* --- The pixel editor (#22): the sandbox's art tool, desktop only (public/js/pixel-editor.js
   builds it; remove with it). A panel on the left, just right of the sandbox's side panel when
   that is open (--sb-right, set by sandbox.js), so the arena stays visible on the right. -- */
.px-btn-ico { /* four pixels, drawn in CSS */
  width: 12px; height: 12px; flex: none;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%) 0 0 / 12px 6px no-repeat,
    linear-gradient(90deg, transparent 50%, currentColor 50%) 0 6px / 12px 6px no-repeat;
  outline: 2px solid currentColor; outline-offset: 0;
}
.px-panel {
  position: absolute; z-index: 3;
  left: calc(var(--sb-right, 0px) + 8px + var(--sal)); top: var(--sb-top, 80px); bottom: calc(8px + var(--sab));
  width: min(580px, calc(100vw - var(--sb-right, 0px) - 360px));
  display: flex; flex-direction: column;
  background: rgba(35,27,46,0.97);
  border: 2px dashed #4b6c88; border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
#game.paused .px-panel, #game.tuning-open .px-panel { display: none; }
.px-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px 12px; }
.px-pics { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.px-gap { width: 8px; } /* between heroes, monsters, things and shots */
.px-pic {
  position: relative; width: 40px; height: 40px; padding: 2px; border-radius: 9px; cursor: pointer;
  border: 2px solid transparent; background: var(--card-2);
}
.px-pic canvas, .px-frame canvas { display: block; width: 32px; height: 32px; image-rendering: pixelated; image-rendering: crisp-edges; }
.px-pic[aria-pressed=true], .px-frame[aria-pressed=true] { border-color: #9fd6ff; background: #33405a; }
.px-pic.drawn::after, .px-frame.drawn::after { /* a gold dot: drawn in this browser */
  content: ''; position: absolute; right: 2px; top: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
}
.px-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 15px !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--ink) !important; }
.px-size { font-size: 12px; font-weight: 700; color: var(--ink-dim); }
.px-tag { font-size: 11px; font-weight: 900; padding: 1px 6px; border-radius: 6px; background: var(--gold); color: #2a1c00; }
.px-frames { display: flex; flex-wrap: wrap; gap: 6px; }
.px-frame {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 70px; padding: 4px 2px 3px; border-radius: 10px; cursor: pointer;
  border: 2px solid transparent; background: var(--card-2); color: var(--ink);
  font-size: 11px; font-weight: 700; line-height: 1.1; text-align: center;
}
.px-frame canvas { width: 40px; height: 40px; }
.px-work { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: start; margin: 0 0 6px; }
.px-canvas-wrap { min-width: 0; display: flex; justify-content: center; padding: 6px; border-radius: 12px; background: #17111f; border: 1px solid #3c304d; }
.px-canvas { display: block; cursor: crosshair; image-rendering: pixelated; touch-action: none; }
.px-side { display: flex; flex-direction: column; gap: 6px; }
.px-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.px-tool {
  min-height: 34px; padding: 2px 4px; border: none; border-radius: 9px; cursor: pointer;
  background: var(--card-2); color: var(--ink); font-size: 13px; font-weight: 800;
}
.px-tool[aria-pressed=true] { background: #9fd6ff; color: #10202c; }
.px-tool:disabled { opacity: 0.4; cursor: default; }
.px-current { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.px-cur-sw { width: 26px; height: 26px; flex: none; border-radius: 6px; border: 2px solid #f4ecdf; }
.px-cur-sw.none { background: repeating-conic-gradient(#2a2233 0 25%, #4a4252 0 50%) 0 0 / 10px 10px !important; }
.px-label { display: block; font-size: 11.5px; font-weight: 800; color: var(--ink-dim); margin: 2px 0 0; }
.px-prev { display: block; width: 150px; border-radius: 10px; image-rendering: pixelated; image-rendering: crisp-edges; }
.px-tip { margin: 0 0 10px; }
.px-left { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.px-pal { /* right under the canvas, and kept in view at the bottom while the panel scrolls */
  position: sticky; bottom: -12px; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding: 4px 0 12px; background: rgb(35,27,46);
}
.px-pal-all { flex: 1 1 100%; }
.px-pal .px-sw i { width: 22px; height: 22px; border-radius: 6px; border-width: 1px; }
.px-pal .px-sws { gap: 3px; margin-top: 2px; }
.px-pal .sb-note { margin: 3px 0 0; }
.px-wide { grid-column: 1 / -1; }
.px-size-box { display: flex; flex-direction: column; gap: 4px; }
.px-size-box[hidden] { display: none; }
.px-size-row { display: grid; grid-template-columns: 1fr 34px 26px 34px; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 800; }
.px-size-row b { text-align: center; font-variant-numeric: tabular-nums; }
.px-size-row .px-tool { min-height: 28px; font-size: 16px; }
.px-pal-group .sb-note { margin: 3px 0 0; }
.px-sws { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.px-sw { padding: 0; border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--ink-dim); }
.px-sw i {
  position: relative; display: block; width: 30px; height: 30px; border-radius: 7px;
  border: 2px solid #120d18; box-shadow: 0 0 0 1px #5b4a6e;
}
.px-sw b { position: absolute; right: 2px; bottom: 0; font-size: 10px; line-height: 1.1; font-weight: 900; font-style: normal; color: #fff; text-shadow: 0 0 2px #000; }
.px-sw b.dk { color: #120d18; text-shadow: 0 0 2px #fff; }
.px-sw small { font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.px-sws-l .px-sw { min-width: 46px; }
.px-sw[aria-pressed=true] i { box-shadow: 0 0 0 2px #f4ecdf, 0 0 0 4px #9fd6ff; }
.px-sw[aria-pressed=true] small { color: #9fd6ff; }
.px-row { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.px-row input[type=color] { width: 48px; height: 40px; flex: none; padding: 2px; border: 1px solid #5b4a6e; border-radius: 9px; background: var(--card-2); cursor: pointer; }
.px-change { font-size: 13px; font-weight: 700; cursor: pointer; }
.px-act { flex: 1; margin: 0; font-size: 14px; padding: 9px 8px; min-height: 40px; }
.px-act:disabled { opacity: 0.45; cursor: default; }
.px-msg { color: var(--gold); font-weight: 700; }
.px-text {
  display: block; width: 100%; height: 140px; resize: vertical; margin: 0 0 6px;
  font: 12px/1.3 ui-monospace, Consolas, monospace; color: var(--ink);
  background: #17111f; border: 1px solid #3c304d; border-radius: 10px; padding: 6px;
}
#px-forget { width: 100%; }
#px-forget.armed { background: #8a2a30; color: #fff; }
.sb-note.bad { color: #ffb3a6; font-weight: 700; }
