/* The browser client's look: the 8.60 client's dark stone and wood with
   gold-brown edges, its bar and chat colours, redrawn in CSS and SVG so it
   stays crisp at any size. Layouts (ui/layout.ts, by the room on screen):
   full (desktops and tablets: the side panel beside the view; a tablet
   upright gets the view on top of a tall chat), compact (phones: the side
   panel is a drawer) in portrait and landscape. */

:root {
  /* stone and wood */
  --stone-0: #0d0b09;
  --stone-1: #1a1713;
  --stone-2: #24201a;
  --stone-3: #302a22;
  --stone-4: #3d362c;
  --wood-1: #3a2a1a;
  --wood-2: #5b4127;
  --edge-hi: #6e5d46;
  --edge-lo: #070605;
  --gold: #c9a25a;
  --gold-hi: #ecd294;
  --gold-lo: #7a5a2c;
  --text: #e4dbc8;
  --muted: #9d917b;
  --faint: #6b6253;
  /* the classic bars and messages */
  --hp: #c81e1e;
  --hp-hi: #ff6a55;
  --mp: #2d5bd6;
  --mp-hi: #7aa2ff;
  --xp: #3aa14a;
  --cap: #b8a070;
  --msg-say: #ffff00;
  --msg-npc: #5fd7ff;
  --msg-pm: #9ccfff;
  --msg-look: #00f000;
  --msg-warn: #ff5a5a;
  --msg-advance: #ffffff;
  --msg-server: #f0f0f0;
  --danger: #c4493c;
  /* interface size (settings), the chat over the map, the walking pad */
  --ui: 1;
  --chat-alpha: .85;
  --pad: 1;
  --hud-h: 44px;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .42 0 0 0 0 .32 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  font: 12px/1.4 Verdana, "DejaVu Sans", Tahoma, Geneva, sans-serif;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--stone-0); color: var(--text); overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#app { height: 100%; }
body.in-game { overflow: hidden; position: fixed; inset: 0; }
body.dragging, body.dragging * { cursor: grabbing !important; }
body.crosshair canvas.map, body.crosshair .slot, body.crosshair .fighter { cursor: crosshair; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: var(--wood-2) var(--stone-0); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--stone-0); }
::-webkit-scrollbar-thumb { background: linear-gradient(90deg, var(--wood-2), var(--wood-1)); border: 1px solid var(--edge-lo); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-lo); }

/* ---- buttons and fields ---- */
button {
  font: inherit; color: var(--text); cursor: pointer; padding: 3px 10px; border-radius: 3px;
  background: linear-gradient(#4a4134, #2f2920);
  border: 1px solid; border-color: var(--edge-hi) var(--edge-lo) var(--edge-lo) var(--edge-hi);
  box-shadow: 0 1px 0 #0008; transition: filter .12s, background .12s;
}
button:hover:not(:disabled) { filter: brightness(1.18); }
button:active:not(:disabled) { border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); background: linear-gradient(#262119, #3a3227); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: linear-gradient(#b48a42, #7a5a28); color: #1d1406; font-weight: bold; border-color: var(--gold-hi) #3d2b10 #3d2b10 var(--gold-hi); text-shadow: 0 1px 0 #f0d79a66; }
button.danger { color: #ffb4a8; }
button.link { background: none; border: 0; box-shadow: none; color: var(--gold); text-decoration: underline; padding: 2px 0; }
button.small { padding: 0 5px; min-width: 20px; height: 20px; line-height: 1; }
button.on { background: linear-gradient(#b48a42, #7a5a28); color: #1d1406; }
.ib { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.ib .ico { flex: none; }
.ico { width: 16px; height: 16px; display: block; }
input, textarea, select {
  font: inherit; color: var(--text); background: #0b0a08; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo);
  border-radius: 2px; padding: 6px 8px;
}
input:focus, textarea:focus { outline: 1px solid var(--gold); }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); }
input[type=range] { accent-color: var(--gold); padding: 0; border: 0; background: none; }
a { color: var(--gold); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 11px; }
.error { color: #ff8a7a; margin: 0; min-height: 1em; white-space: pre-wrap; }
.hint { color: var(--muted); margin: 0 0 6px; font-size: 11px; }

/* ---- framed boxes (login, windows, dialogs) ---- */
.frame {
  background: var(--noise), linear-gradient(var(--stone-2), var(--stone-1));
  border: 1px solid; border-color: var(--edge-hi) var(--edge-lo) var(--edge-lo) var(--edge-hi);
  box-shadow: 0 0 0 1px #000, 0 0 0 2px var(--gold-lo), 0 0 0 3px #000, 0 14px 40px #000c;
}

/* ---- login and characters ---- */
.center {
  min-height: 100%; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 30%, #2a2219 0%, #0d0b09 70%), var(--stone-0);
}
.card { width: min(380px, 100%); padding: 22px 24px 18px; display: grid; gap: 10px; border-radius: 4px; }
.card .crest { display: grid; justify-items: center; gap: 2px; margin-bottom: 4px; }
.card .crest svg { width: 56px; height: 56px; filter: drop-shadow(0 2px 3px #000); }
.card h1 {
  margin: 0; font: bold 26px/1.1 Georgia, "Times New Roman", serif; letter-spacing: .08em; text-align: center;
  color: var(--gold-hi); text-shadow: 0 2px 0 #000, 0 0 12px #c9a25a55;
}
.card .sub { text-align: center; color: var(--muted); margin: 0 0 4px; font-style: italic; }
.card label { display: grid; gap: 3px; color: var(--muted); font-size: 11px; }
.card input { font-size: 14px; padding: 8px 10px; }
.card button.primary { padding: 8px; font-size: 13px; margin-top: 4px; }
.card .foot { text-align: center; }
.card fieldset { border: 1px solid var(--stone-4); border-radius: 2px; padding: 6px 10px 8px; margin: 0; display: grid; gap: 6px; }
.card legend { color: var(--gold); padding: 0 4px; font-size: 11px; }
.card fieldset.sexes { grid-template-columns: repeat(2, max-content); column-gap: 18px; }
.card label.choice { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-size: 12px; cursor: pointer; }
.card label.choice input { margin: 2px 0 0; accent-color: var(--gold); }
/* the start island dialog (ui/startdialog.ts): the two islands side by
   side, one above the other on a narrow screen */
dialog.start-dialog {
  width: min(620px, calc(100vw - 24px)); max-height: calc(var(--app-h, 100vh) - 24px); overflow-y: auto; padding: 18px 20px 14px;
  color: var(--text); border-radius: 4px; display: grid; gap: 10px;
}
dialog.start-dialog:not([open]) { display: none; }
dialog.start-dialog::backdrop { background: #0d0b09c0; backdrop-filter: blur(2px); }
dialog.start-dialog:focus { outline: none; }
.start-dialog h2 {
  margin: 0; text-align: center; font: bold 20px/1.2 Georgia, "Times New Roman", serif; letter-spacing: .04em;
  color: var(--gold-hi); text-shadow: 0 2px 0 #000, 0 0 12px #c9a25a55;
}
.start-dialog .start-intro { text-align: center; font-size: 12px; }
.start-islands { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.start-island {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; padding: 12px; border-radius: 3px;
  background: #0b0a08b3; border: 1px solid var(--stone-4); transition: border-color .15s, background .15s;
}
.start-island:hover, .start-island:focus-within { border-color: var(--gold-lo); background: #1d1812; }
.start-island h3 { margin: 0; text-align: center; color: var(--gold-hi); font: bold 16px/1.2 Georgia, "Times New Roman", serif; }
.start-island p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.start-island .start-here { padding: 7px; font-size: 13px; }
.start-picture { display: flex; justify-content: center; }
.start-items { display: flex; gap: 4px; padding: 4px; background: #0b0a08; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); border-radius: 2px; }
.start-items canvas { image-rendering: pixelated; }
.start-dialog .start-back { justify-self: center; }
.start-dialog .error:empty { display: none; }
@media (max-width: 520px) {
  .start-islands { grid-template-columns: 1fr; }
  dialog.start-dialog { padding: 14px 12px 10px; }
}
.card .made { color: var(--gold-hi); margin: 0; text-align: center; }
.card .row-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.loading .bar { height: 16px; }
.motd { white-space: pre-wrap; background: #0b0a08aa; border: 1px solid var(--stone-4); border-radius: 2px; padding: 8px 10px; margin: 0; color: var(--msg-pm); }
.characters { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; background: #0b0a08; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); padding: 3px; }
.character {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; text-align: left; font-size: 13px;
  background: transparent; border: 1px solid transparent; box-shadow: none; border-radius: 2px;
}
.character:hover:not(:disabled), .character:focus-visible { background: #3a2f1e; border-color: var(--gold-lo); filter: none; }
.character b { color: var(--text); }
.character span { color: var(--muted); font-size: 11px; }

/* ---- bars ---- */
.bar { position: relative; height: 14px; background: #0b0a08; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); overflow: hidden; border-radius: 1px; }
.bar .fill { position: absolute; inset: 0 auto 0 0; transition: width .25s ease-out; }
.bar.hp .fill { background: linear-gradient(var(--hp-hi), var(--hp) 45%, #7c0d0d); }
.bar.mp .fill { background: linear-gradient(var(--mp-hi), var(--mp) 45%, #142f7a); }
.bar.xp .fill { background: linear-gradient(#7fe08a, var(--xp) 45%, #1d5c27); }
.bar span { position: relative; display: block; text-align: center; font-size: 10px; line-height: 12px; color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000; white-space: nowrap; }
.bar.thin { height: 5px; }
.small-bar { width: 70px; height: 5px; }

/* ---- the game screen ---- */
.game {
  position: fixed; inset: 0; height: var(--app-h, 100dvh); display: grid; grid-template-columns: 1fr calc(272px * var(--ui));
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--stone-0); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.game input, .game textarea { user-select: text; -webkit-user-select: text; }
.view { display: grid; grid-template-rows: 1fr auto var(--chat-h, 188px); min-height: 0; min-width: 0; }
.stage { position: relative; min-height: 0; min-width: 0; overflow: hidden; display: grid; place-items: center; background: #000 radial-gradient(ellipse at center, #15120e, #000 75%); }
.map-wrap { position: relative; line-height: 0; box-shadow: 0 0 0 1px #000, 0 0 0 2px var(--stone-4), 0 0 24px #000; }
canvas.map { image-rendering: pixelated; image-rendering: crisp-edges; display: block; cursor: default; touch-action: none; }
canvas.icon { image-rendering: pixelated; pointer-events: none; }
.hud { display: none; }

/* conditions over the view */
.icons { position: absolute; left: 6px; top: 6px; display: flex; gap: 3px; flex-wrap: wrap; max-width: 60%; line-height: normal; pointer-events: none; }
.cond { display: grid; place-items: center; width: 22px; height: 22px; background: #000b; border: 1px solid var(--stone-4); border-radius: 3px; }
.cond .ico { width: 16px; height: 16px; }

/* notifications */
.notices { position: absolute; inset: 0; pointer-events: none; line-height: 1.3; }
.notice-center { position: absolute; left: 0; right: 0; top: 30%; display: grid; justify-items: center; gap: 4px; padding: 0 12px; }
#toast { position: absolute; left: 0; right: 0; bottom: 8px; display: grid; justify-items: center; gap: 3px; padding: 0 12px; }
.notice { font-weight: bold; text-align: center; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; animation: notice-in .18s ease-out, notice-out .5s ease-in forwards; animation-delay: 0s, var(--life, 3s); }
#toast .notice { font-size: 12px; background: #000a; padding: 2px 10px; border-radius: 3px; }
.notice-center .notice { font-size: 14px; }
.notice.advance { font: bold 20px/1.2 Georgia, serif; color: var(--gold-hi); letter-spacing: .04em; text-shadow: 0 0 10px #c9a25a99, 2px 2px 0 #000, -1px -1px 0 #000; }
.notice.loot { color: var(--msg-look); }
@keyframes notice-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes notice-out { to { opacity: 0; } }

/* the hotkey bar */
.hotbar { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; padding: 4px; background: var(--noise), var(--stone-1); border-top: 1px solid var(--edge-hi); zoom: var(--ui); }
.hotkey { position: relative; display: grid; grid-template-rows: auto 1fr; justify-items: center; align-items: center; height: 42px; padding: 1px 2px; font-size: 10px; overflow: hidden; }
.hotkey b { color: var(--gold); font-size: 9px; justify-self: start; line-height: 1; }
.hotkey span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.hotkey canvas { width: 22px !important; height: 22px !important; }
.hotkey.item span { position: absolute; right: 2px; bottom: 1px; font-size: 9px; color: var(--gold-hi); }
.hotkey.held, .slot.held { outline: 2px solid var(--gold); }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 4px; font-size: 11px; color: var(--muted); }
/* a spell's cooldown (0xA4/0xA5): a shade over the hotkey that drains */
.hotkey .cd { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); border-bottom: 3px solid #c84; transform-origin: left; pointer-events: none;
  animation: cd-run linear forwards; }
@keyframes cd-run { from { transform: scaleX(var(--from, 1)); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .hotkey .cd { animation-timing-function: steps(4); } }

/* chat */
.chat { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; background: var(--stone-1); border-top: 1px solid var(--edge-hi); zoom: var(--ui); }
.tabs { display: flex; gap: 1px; padding: 3px 4px 0; overflow-x: auto; background: var(--stone-2); border-bottom: 1px solid var(--edge-lo); scrollbar-width: none; touch-action: pan-x; }
.tab { border-radius: 3px 3px 0 0; padding: 2px 10px; font-size: 11px; white-space: nowrap; color: var(--muted); border-bottom: 0; box-shadow: none; background: linear-gradient(#2d271f, #201c16); display: inline-flex; align-items: center; gap: 4px; }
.tab.active { background: #0b0a08; color: var(--text); border-color: var(--gold-lo) var(--edge-lo) transparent var(--gold-lo); }
.tab.unread { color: #ff8a5a; }
.tab .close { color: var(--muted); padding: 0 2px; }
.tab .close:hover { color: var(--msg-warn); }
.logs { min-height: 0; position: relative; background: #0b0a08; }
.log { position: absolute; inset: 0; overflow-y: auto; padding: 3px 8px; font-size: 12px; line-height: 1.35; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.line { overflow-wrap: anywhere; }
.line time { color: var(--faint); margin-right: 5px; font-size: 10px; }
.chat-row { display: flex; border-top: 1px solid var(--edge-lo); }
.chat-input { flex: 1; min-width: 0; border-radius: 0; border: 0; background: #070605; padding: 6px 8px; font-size: 12px; }
.chat-row .send { border-radius: 0; display: none; }

/* the side panel and its windows */
.side { background: var(--noise), linear-gradient(90deg, var(--stone-1), var(--stone-2)); border-left: 1px solid var(--edge-hi); box-shadow: inset 1px 0 0 var(--edge-lo); overflow-y: auto; overflow-x: hidden; touch-action: pan-y; }
.side-inner { zoom: var(--ui); padding: 5px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; align-content: start; }
.menu { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
.menu .ib { flex-direction: column; gap: 1px; padding: 3px 0 2px; font-size: 9px; color: var(--gold-hi); min-width: 0; }
.menu .ib .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.menu .ib .lbl { color: var(--muted); }
.views { display: none; }
.win { border: 1px solid; border-color: var(--edge-hi) var(--edge-lo) var(--edge-lo) var(--edge-hi); background: var(--stone-1); box-shadow: 0 0 0 1px #000; }
.win > header { display: flex; align-items: center; gap: 5px; padding: 2px 3px 2px 6px; background: linear-gradient(#3a3227, #29231b); border-bottom: 1px solid var(--edge-lo); color: var(--gold-hi); font-size: 11px; min-height: 22px; }
.win > header .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 5px; align-items: center; }
.win > header .ico { color: var(--gold); }
.win > header button.small { height: 18px; min-width: 18px; padding: 0 2px; display: inline-grid; place-items: center; }
.win > header button .ico { width: 12px; height: 12px; }
.win .wbody { padding: 5px; display: grid; gap: 4px; }
.win.collapsed .wbody { display: none; }
.modes { display: flex; gap: 1px; }

.who { display: flex; justify-content: space-between; align-items: baseline; }
.who b { color: var(--text); }
.who span { color: var(--gold); font-size: 11px; }
.stats { display: flex; justify-content: space-between; gap: 4px; font-size: 10px; color: var(--muted); }
.stats b { color: var(--text); font-weight: normal; }

.paperdoll { display: grid; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(4, 38px); gap: 3px; justify-content: center; padding: 2px 0; }
.slot {
  position: relative; width: 38px; height: 38px; display: grid; place-items: center; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: radial-gradient(circle at 50% 45%, #2a251e, #0e0c0a); border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo);
}
.slot:hover { border-color: var(--gold-lo); }
.slot.empty { cursor: default; }
.slot .label { opacity: .32; color: var(--muted); }
.slot .label .ico { width: 22px; height: 22px; }
.slot small { position: absolute; right: 1px; bottom: -1px; font-size: 10px; color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000; }
.doll-stats { display: flex; justify-content: space-around; gap: 4px; }
.doll-stats span { flex: 1; text-align: center; background: #0b0a08; border: 1px solid var(--stone-4); padding: 1px 2px; font-size: 10px; color: var(--muted); }
.doll-stats b { color: var(--text); font-weight: normal; }
.containers { display: grid; gap: 5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, 38px); gap: 2px; justify-content: start; }
.minimap-box { display: flex; justify-content: center; }
.minimap { width: 100%; max-width: 200px; aspect-ratio: 1; height: auto; image-rendering: pixelated; background: #000; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); }

.skills { width: 100%; border-collapse: collapse; font-size: 11px; }
.skills td { padding: 1px 2px; }
.skills td:nth-child(2) { text-align: right; color: var(--text); }
.skills tr td:first-child { color: var(--muted); }
.skills tr.sep td { padding-top: 5px; }
.skills .bar.thin { width: 100%; margin-top: 1px; }

.fighter { display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: auto 5px; align-items: center; column-gap: 5px; padding: 2px 4px; border: 1px solid transparent; border-radius: 2px; cursor: pointer; }
.fighter:hover { background: #ffffff0a; }
.fighter canvas { grid-row: span 2; }
.fighter .ico { grid-row: span 2; width: 14px; height: 14px; }
.fighter.attacked { border-color: #ff2a2a; box-shadow: inset 0 0 0 1px #ff2a2a55; }
.fighter.followed { border-color: #2aff2a; }
.fighter > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fighter .hp { background: #000; height: 4px; border: 1px solid #000; grid-column: 2; }
.fighter .hp div { height: 100%; }
.empty-note { color: var(--faint); font-size: 11px; text-align: center; padding: 4px; }

.vip .buddy { padding: 2px 6px; cursor: pointer; border-radius: 2px; }
.vip .buddy.online { color: #5fe05f; }
.vip .buddy.offline { color: #e05f5f; }
.vip .buddy:hover { background: #ffffff0f; }

/* ---- dialogs, menus, tooltips ---- */
#dialogs, .dialogs { position: fixed; inset: 0; pointer-events: none; display: grid; place-items: center; z-index: 30; }
/* (the windows keep clear of a notch and the home bar) */
.dialog {
  pointer-events: auto; position: absolute; min-width: min(260px, calc(100vw - 16px));
  max-width: min(580px, calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: min(82vh, calc(var(--app-h, 100dvh) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  display: grid; grid-template-rows: auto 1fr; zoom: var(--ui); translate: var(--offset, 0) var(--offset, 0); animation: pop .14s ease-out;
  background: var(--noise), linear-gradient(var(--stone-2), var(--stone-1));
  border: 1px solid; border-color: var(--edge-hi) var(--edge-lo) var(--edge-lo) var(--edge-hi);
  box-shadow: 0 0 0 1px #000, 0 0 0 2px var(--gold-lo), 0 0 0 3px #000, 0 16px 44px #000d;
}
.dialog.moved { translate: none; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; background: linear-gradient(#3e352a, #28221a); border-bottom: 1px solid var(--edge-lo); color: var(--gold-hi); font-weight: bold; cursor: move; touch-action: none; }
.dialog > header .x { padding: 2px 4px; display: grid; place-items: center; }
.dialog > .body { padding: 10px 12px; overflow: auto; touch-action: pan-y; }
/* the server's modal windows (ui/modal.ts): the message as written, the
   choices to pick one from, the buttons */
.modal-window { display: grid; gap: 10px; max-width: 420px; }
.modal-window .modal-message { margin: 0; white-space: pre-wrap; line-height: 1.4; }
.modal-window .modal-choices { display: grid; gap: 2px; max-height: 40vh; overflow: auto; }
.modal-window .modal-choice { text-align: left; }
.modal-window .modal-choice[aria-selected="true"] { outline: 1px solid var(--gold-hi); }
.modal-window .modal-buttons { justify-content: flex-end; }
/* (a window as wide as the screen lets it: its content no wider) */
:where(.dialog > .body) > * { max-width: 100%; }
.list { display: grid; gap: 3px; }
.list > button { text-align: left; }
.list .done { color: var(--muted); }
.list h4 { margin: 8px 0 2px; color: var(--gold); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row input:not([type]) { flex: 1; min-width: 100px; }
.shop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.amount { width: 70px; }
.move-count { display: grid; gap: 10px; min-width: min(300px, 80vw); }
.move-count input[type=range] { flex: 1; min-width: 120px; }
.move-count .amount { width: 90px; }
.move-count button { min-width: 56px; }
.move-count :is(.move-one, .move-all) { flex: 1; }
.move-count .move-ok { margin-left: auto; }
.wares { display: grid; gap: 2px; background: #0b0a08; border: 1px solid var(--stone-4); padding: 3px; }
.ware { display: grid; grid-template-columns: 34px 1fr auto auto auto; gap: 6px; align-items: center; padding: 1px 3px; }
.ware:nth-child(odd) { background: #ffffff06; }
.ware small { color: var(--muted); }
.ware .look { cursor: help; }
.outfit { display: grid; gap: 8px; justify-items: center; }
.pick { display: flex; align-items: center; gap: 8px; }
.preview { background: radial-gradient(circle, #3a3227, #0b0a08); border: 1px solid var(--stone-4); }
.palette { display: grid; grid-template-columns: repeat(19, 14px); gap: 2px; }
.swatch { width: 14px; height: 14px; padding: 0; border-radius: 1px; border: 1px solid #000; box-shadow: none; }
.parts { display: flex; gap: 10px; flex-wrap: wrap; }
.book { display: grid; gap: 8px; justify-items: start; }
.book pre, .popup { white-space: pre-wrap; font-family: Georgia, serif; font-size: 13px; margin: 0; background: #e8dcbf; color: #2b1d0c; padding: 10px 12px; border: 1px solid #8a7347; box-shadow: inset 0 0 18px #a88a5a88; }
.missions h4 { margin: 8px 0 2px; color: var(--gold); }
.missions p { margin: 0; white-space: pre-wrap; }
.achievements-open { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 6px; font-size: 11px; }
.achievements-open b { margin-left: auto; color: var(--gold-hi); }
.achievements { display: grid; gap: 6px; width: min(460px, calc(100vw - 48px)); }
.achievements .summary { margin: 0; color: var(--muted); }
.achievements .summary b { color: var(--gold-hi); }
.achievement-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: min(60vh, 520px); overflow-y: auto; }
.achievement-list li { padding: 4px 6px; background: #ffffff06; border-left: 2px solid var(--gold-lo); }
.achievement-list li.secret { border-left-color: var(--gold-hi); }
.achievement-list li.none { border: 0; color: var(--muted); }
.achievement-list .head { display: flex; align-items: baseline; gap: 6px; }
.achievement-list .grade { color: var(--gold); font-size: 10px; min-width: 30px; }
.achievement-list .tag { color: var(--gold-hi); font-size: 10px; text-transform: uppercase; }
.achievement-list .pts { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.achievement-list p { margin: 2px 0 0 36px; color: var(--text); font-size: 11px; }
.help p { margin: 0 0 8px; }
.help h4 { margin: 10px 0 4px; color: var(--gold); }
.ctxmenu { position: fixed; z-index: 40; display: grid; min-width: 140px; padding: 2px; zoom: var(--ui); background: var(--stone-2); border: 1px solid; border-color: var(--edge-hi) var(--edge-lo) var(--edge-lo) var(--edge-hi); box-shadow: 0 0 0 1px #000, 0 8px 24px #000c; animation: pop .1s ease-out; }
.ctxmenu button { border: 0; text-align: left; background: none; box-shadow: none; padding: 4px 14px 4px 10px; border-radius: 0; }
.ctxmenu button:hover, .ctxmenu button:focus-visible { background: #4a3c26; color: #fff; filter: none; outline: 0; }
.tip { position: fixed; z-index: 50; max-width: 280px; padding: 3px 7px; background: #0b0a08f0; border: 1px solid var(--gold-lo); color: var(--text); font-size: 11px; pointer-events: none; animation: pop .1s ease-out; }
.bot { display: grid; gap: 6px; min-width: min(380px, 80vw); }
.bot h4 { margin: 4px 0; color: var(--gold); }
.bot .rules, .bot .fight-rules { display: grid; gap: 4px; }
.bot .pct { width: 60px; }
.bot .check { display: flex; gap: 6px; align-items: center; }
/* the route editor: the waypoints' list beside a map of them */
.route-editor { display: grid; gap: 4px; }
.route-panes { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.route-list { flex: 1 1 260px; min-width: 0; margin: 0; padding: 0; list-style: none; max-height: 220px; overflow-y: auto; border: 1px solid var(--edge-lo); background: var(--stone-0); }
.route-list li { padding: 2px 4px; font-size: 11px; }
.route-list .wp { display: flex; flex-wrap: wrap; gap: 3px 4px; align-items: center; border-bottom: 1px solid var(--stone-2); cursor: default; }
.route-list .wp.sel { background: #3a2f1e; }
.route-list .wp.insert { box-shadow: inset 0 2px 0 var(--gold); }
.route-list .wp.over { box-shadow: inset 0 -2px 0 var(--gold-hi); }
.route-list .wp.dragging { opacity: .5; }
.route-list .grip { cursor: grab; color: var(--faint); touch-action: none; }
.route-list .n { min-width: 2.2em; color: var(--gold); text-align: right; }
.route-list select { max-width: 7.5em; }
.route-list .label { width: 7em; }
.route-list .pos { font-variant-numeric: tabular-nums; }
.route-list textarea { flex: 1 1 100%; min-height: 2.6em; font: inherit; }
.route-list .acts { margin-left: auto; display: inline-flex; gap: 2px; }
.route-side { display: grid; gap: 2px; justify-items: center; }
.route-map { width: 192px; height: 192px; image-rendering: pixelated; border: 1px solid var(--edge-lo); cursor: crosshair; }
.record .rec { color: var(--muted); font-weight: bold; }
.record .rec.on { color: #ff5a4a; animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .record .rec.on { animation: none; } }
.bot .unsaved { color: var(--gold-hi); }
.bot [hidden] { display: none !important; }
.bot .row { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.bot .cnt { width: 70px; }
.item-pick { min-width: 0; flex: 1 1 140px; }
.item-pick.bad { outline: 1px solid var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 1px 2px 1px 4px; border: 1px solid var(--gold-lo); background: #1d1812; font-size: 11px; }
/* the bot's fighting part (botfight.ts) */
.spell-pick, .monster-pick { min-width: 0; flex: 1 1 150px; }
.spell-pick.bad, .monster-pick.bad { outline: 1px solid var(--danger); }
.bot .only-at { min-width: 0; flex: 1 1 100%; font-size: 11px; }
.bot-fight { display: grid; gap: 4px; padding-left: 8px; border-left: 2px solid var(--gold-lo); }
.chips.ordered .rank { color: var(--gold); font-weight: normal; }
/* the bot's resupply trip (resupply.ts) */
.bot-trip { display: grid; gap: 4px; padding-left: 8px; border-left: 2px solid var(--gold-lo); }
.bot-trip .npc-pick { min-width: 0; flex: 1 1 110px; }
.bot-trip .item-pick { min-width: 0; flex: 1 1 130px; }
.npc-pick.bad { outline: 1px solid var(--danger); }
.bot-trip .trip-now { color: var(--gold-hi); margin: 0; }
.bot-trip .trip-warnings p { margin: 0; }
.hunt-trips ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 11px; }
.hunt-trips li.error { color: var(--danger); }
/* the hunting analyser; drops coloured by value (12.00) */
.hunt { display: grid; gap: 4px; min-width: min(320px, 80vw); max-height: min(70vh, 640px); overflow-y: auto; }
.hunt h4 { margin: 6px 0 2px; color: var(--gold); }
.hunt-sum .row { display: grid; grid-template-columns: 1fr auto 6.5em; gap: 6px; align-items: baseline; }
.hunt-sum small { text-align: right; }
.hunt-sum .profit.pos b { color: #6fdc6f; }
.hunt-sum .profit.neg b { color: #ff8a7a; }
.hunt-items, .hunt-kills { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.hunt-items li { display: grid; grid-template-columns: 20px 1fr auto auto; gap: 6px; align-items: center; }
.hunt-items .v { font-variant-numeric: tabular-nums; }
.hunt-items .track { color: var(--faint); }
.hunt-items .track.on { color: var(--gold-hi); }
.tier-grey .n { color: #c9c2b2; }
.tier-green .n { color: #6fdc6f; }
.tier-blue .n { color: #7ab8ff; }
.tier-purple .n { color: #d08cff; }
.tier-gold .n { color: #ffd54a; }
.trade .offers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.trade h4 { margin: 0 0 6px; color: var(--gold); }
.house-list { width: 100%; min-width: min(280px, 70vw); }
.settings { display: grid; gap: 10px; min-width: min(320px, 80vw); }
.settings > fieldset > label, .settings > fieldset > .setting { display: grid; grid-template-columns: 9em 1fr auto; gap: 8px; align-items: center; }
.settings output { min-width: 3em; text-align: right; color: var(--gold-hi); }
.settings .seg { display: flex; gap: 0; }
.settings .seg button { border-radius: 0; flex: 1; }
.settings fieldset { border: 1px solid var(--stone-4); padding: 6px 10px 10px; margin: 0; display: grid; gap: 8px; }
.settings legend { color: var(--gold); padding: 0 4px; }
/* the sound controls (src/audio): mute, three volumes, credits */
.audio-controls { display: grid; gap: 8px; min-width: min(260px, 70vw); }
.audio-controls .audio-mute { display: flex; align-items: center; gap: 8px; }
.audio-controls .audio-slider { display: grid; grid-template-columns: 9em 1fr; align-items: center; gap: 8px; }
.audio-controls .audio-credits { justify-self: start; }
.audio-credit-list { max-width: 34em; max-height: 60vh; overflow: auto; padding-left: 1.2em; margin: 0 0 8px; display: grid; gap: 4px; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.audio-credit-list b { color: var(--gold-hi); font-weight: normal; }
.audio-slot:empty::before { content: "Sound: not available"; color: var(--faint); font-size: 11px; }
.pick-items { display: flex; flex-wrap: wrap; gap: 2px; max-height: 140px; overflow-y: auto; }
.pick-items .slot { cursor: pointer; }

/* the Market (src/ui/market.ts): the list and an item side by side; on
   narrow screens they take turns (data-pane) */
.dialog.market-dialog { width: min(880px, calc(100vw - 16px)); max-width: min(880px, calc(100vw - 16px)); }
.market { display: grid; gap: 8px; min-width: 0; }
.mk-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.mk-balance { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.mk-balance .ico { color: var(--gold); }
.mk-balance b { color: var(--gold-hi); }
.mk-tabs { display: flex; }
.mk-tabs button { border-radius: 0; }
.mk-tabs button:first-child { border-radius: 3px 0 0 3px; }
.mk-tabs button:last-child { border-radius: 0 3px 3px 0; }
.market:not([data-tab=browse]) .mk-browse, .market:not([data-tab=own]) .mk-own, .market:not([data-tab=history]) .mk-history { display: none; }
.mk-browse { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); gap: 8px; min-height: 0; }
.mk-list-pane { display: grid; grid-template-rows: auto 1fr; gap: 4px; min-height: 0; min-width: 0; }
.mk-filters { display: grid; gap: 4px; }
.mk-filters select, .mk-filters input { width: 100%; min-width: 0; }
.mk-items, .mk-item-pane { max-height: min(60vh, calc(var(--app-h, 100dvh) - 200px)); overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.mk-items { display: grid; align-content: start; gap: 1px; padding: 2px; background: #0b0a08; border: 1px solid; border-color: var(--edge-lo) var(--edge-hi) var(--edge-hi) var(--edge-lo); }
.mk-entry { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; align-items: center; gap: 6px; padding: 1px 4px; text-align: left; background: none; border: 1px solid transparent; box-shadow: none; border-radius: 2px; }
.mk-entry:hover:not(:disabled) { background: #ffffff0a; filter: none; }
.mk-entry.on { background: #3a2f1e; border-color: var(--gold-lo); color: var(--text); }
.mk-entry canvas, .mk-item-head canvas { background: radial-gradient(circle at 50% 45%, #2a251e, #0e0c0a); border: 1px solid var(--stone-4); }
.mk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-have { color: var(--gold); font-size: 10px; }
.mk-counts { display: flex; gap: 2px; }
.mk-counts span { min-width: 18px; padding: 0 3px; border-radius: 6px; font-size: 10px; text-align: center; background: #000; }
.market .s { color: #7fd17f; }
.market .b { color: #8fb8ff; }
.mk-item-pane { display: grid; gap: 8px; align-content: start; min-width: 0; }
.mk-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mk-item-head b { color: var(--gold-hi); font-size: 13px; }
.mk-back { display: none; }
.mk-back .ico { transform: rotate(-90deg); }
.mk-offers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mk-side h4, .mk-stats h4, .mk-form h4 { margin: 0 0 3px; color: var(--gold); font-size: 11px; }
.mk-side.sell h4 { color: #9be29b; }
.mk-side.buy h4 { color: #a8c8ff; }
.mk-rows { display: grid; gap: 1px; padding: 2px; background: #0b0a08; border: 1px solid var(--stone-4); font-size: 11px; }
.mk-row { display: grid; grid-template-columns: 1.1fr .8fr .9fr minmax(0, 1.3fr) auto; gap: 4px; align-items: center; padding: 1px 3px; min-height: 22px; }
.mk-row:nth-child(even):not(.head) { background: #ffffff06; }
.mk-row.head { color: var(--faint); font-size: 10px; min-height: 0; }
.mk-row.wide { grid-template-columns: 26px minmax(0, 2fr) .7fr 1fr .8fr 1fr auto; }
.mk-row.own { background: #c9a25a17; }
.mk-row .price { color: var(--gold-hi); }
.mk-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-accept { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px; background: #2a2219; border: 1px solid var(--gold-lo); }
.mk-accept .error { flex-basis: 100%; }
.mk-stats .mk-stat { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.mk-stat b { min-width: 4.5em; color: var(--text); font-weight: normal; }
.mk-form { display: grid; gap: 6px; padding: 8px; background: #0b0a0866; border: 1px solid var(--stone-4); }
.mk-form label { display: grid; grid-template-columns: 8em minmax(0, 1fr); align-items: center; gap: 6px; color: var(--muted); }
.mk-form label.check { display: flex; }
.mk-form input[type=number] { width: 100%; max-width: 12em; }
.mk-form .row { flex-wrap: nowrap; }
.mk-form .seg { display: flex; }
.mk-form .seg button { flex: 1; border-radius: 0; }
.mk-sums { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.mk-sums b { color: var(--gold-hi); font-weight: normal; }
.mk-create { justify-self: start; }
.mk-status { min-height: 1.2em; margin: 0; color: #7fd17f; }
.mk-status.bad { color: #ff8a7a; }
.mk-own .hint { margin-bottom: 4px; }
.win > header button.market-btn { display: inline-flex; gap: 3px; align-items: center; width: auto; padding: 0 6px; color: var(--gold-hi); font-size: 10px; }
@media (max-width: 700px) {
  .dialog.market-dialog { width: calc(100vw - 12px); }
  .mk-browse { grid-template-columns: minmax(0, 1fr); }
  .market[data-pane=list] .mk-item-pane, .market[data-pane=item] .mk-list-pane { display: none; }
  .mk-back { display: grid; place-items: center; }
  .mk-offers { grid-template-columns: minmax(0, 1fr); }
  .mk-items, .mk-item-pane { max-height: calc(var(--app-h, 100dvh) - 220px); }
  .mk-row.wide { grid-template-columns: 26px minmax(0, 2fr) .7fr 1fr .8fr auto; }
  .mk-row.wide > :nth-child(6) { display: none; }
  .mk-form label { grid-template-columns: 6.5em minmax(0, 1fr); }
}

/* ---- on-screen controls (touch) ---- */
.controls { display: none; }
.game.controls-on .controls { display: block; position: absolute; inset: 0; pointer-events: none; zoom: var(--ui); }
.controls > * { pointer-events: auto; }
.pad {
  position: absolute; bottom: 12px; left: 12px; width: calc(150px * var(--pad)); height: calc(150px * var(--pad)); border-radius: 50%; touch-action: none;
  background: radial-gradient(circle, #3d362c 0 18%, #1a1713cc 19% 62%, #2a241ccc 63%); border: 2px solid var(--gold-lo); box-shadow: 0 0 0 1px #000, inset 0 0 18px #000, 0 6px 16px #0009;
  opacity: .82; transition: opacity .15s;
}
.pad.active { opacity: 1; }
.pad .arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; border: 9px solid transparent; border-bottom: 13px solid var(--gold); margin: -16px 0 0 -9px; transform-origin: 9px 16px; transform: rotate(var(--a)) translateY(calc(-46px * var(--pad))); filter: drop-shadow(0 1px 0 #000); }
.pad .arrow.n { --a: 0deg; } .pad .arrow.ne { --a: 45deg; } .pad .arrow.e { --a: 90deg; } .pad .arrow.se { --a: 135deg; }
.pad .arrow.s { --a: 180deg; } .pad .arrow.sw { --a: 225deg; } .pad .arrow.w { --a: 270deg; } .pad .arrow.nw { --a: 315deg; }
.pad .arrow.nw, .pad .arrow.ne, .pad .arrow.sw, .pad .arrow.se { border-width: 7px; border-bottom-width: 10px; opacity: .8; }
.pad .arrow.on { border-bottom-color: var(--gold-hi); filter: drop-shadow(0 0 4px var(--gold-hi)); opacity: 1; }
.pad .knob { position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; margin: -17% 0 0 -17%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #6e5d46, #2a241c); border: 1px solid var(--gold-lo); box-shadow: 0 2px 6px #000a; transition: transform .06s; pointer-events: none; }
.actions { position: absolute; bottom: 12px; right: 12px; display: grid; grid-template-columns: repeat(3, 48px); gap: 6px; }
.actions .ib { flex-direction: column; width: 48px; height: 48px; padding: 0; gap: 1px; border-radius: 50%; font-size: 8px; color: var(--gold-hi); opacity: .88; touch-action: manipulation; }
.actions .ib .ico { width: 20px; height: 20px; }
.actions .ib .lbl { color: var(--muted); }
.actions .ib.on { opacity: 1; color: #1d1406; }
.actions .ib.on .lbl { color: #1d1406; }
.actions .ib .badge { position: absolute; top: 2px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #ff5a2a; box-shadow: 0 0 0 1px #000; display: none; }
.game.chat-unread .actions .ib.chat-btn .badge { display: block; }
.actions .ib { position: relative; }
.game[data-pad=right] .pad { left: auto; right: 12px; }
.game[data-pad=right] .actions { right: auto; left: 12px; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 60; width: 44px; height: 44px; margin: -40px 0 0 -22px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--gold); background: #000a; pointer-events: none; }
.drag-ghost canvas { width: 32px; height: 32px; image-rendering: pixelated; }

/* ---- compact: phones (and windows under 740 × 500) ---- */
.scrim { display: none; }
.game.compact { grid-template-columns: 1fr; grid-template-rows: auto 1fr; font-size: 13px; }
.game.compact .hud {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; height: var(--hud-h); zoom: var(--ui);
  background: var(--noise), linear-gradient(#2a241c, #1a1713); border-bottom: 1px solid var(--edge-lo); box-shadow: 0 1px 0 var(--edge-hi) inset;
}
.hud .bars { flex: 1; display: grid; gap: 2px; min-width: 0; }
.hud .bar { height: 15px; }
.hud .bar span { font-size: 10px; line-height: 13px; }
.hud .lvl { color: var(--gold-hi); font-size: 11px; white-space: nowrap; text-align: center; line-height: 1.1; }
.hud .lvl small { display: block; color: var(--muted); font-size: 9px; }
.hud .ib { width: 38px; height: 34px; padding: 0; flex: none; }
.hud .ib .lbl { display: none; }
.hud .ib .ico { width: 20px; height: 20px; }
.hud .hud-icons { display: flex; gap: 2px; }
.hud .hud-icons .cond { width: 18px; height: 18px; }
.game.compact .icons { display: none; }
.game.compact .view { grid-template-rows: 1fr auto var(--chat-h, 30%); }
.game.compact .stage { place-items: start center; }
.game.compact .hotbar { display: flex; overflow-x: auto; touch-action: pan-x; padding: 4px max(4px, env(safe-area-inset-left)); }
.game.compact .hotkey { flex: 0 0 46px; height: 46px; }
.game.compact .hotkey canvas { width: 26px !important; height: 26px !important; }
.game.compact .chat-row .send { display: grid; place-items: center; padding: 0 12px; }
.game.compact .chat-input { font-size: 16px; } /* 16px: no zoom on focus (iOS) */
.game.compact .log { font-size: 12px; }
.game.compact .tab { padding: 5px 12px; font-size: 12px; }
.game.compact.chat-hidden .view { grid-template-rows: 1fr auto 0; }
.game.compact.chat-hidden .chat { display: none; }
.game.compact.typing .controls { display: none; }
.game.compact .side {
  position: fixed; z-index: 20; top: 0; bottom: 0; right: 0; width: min(340px, 88vw); border-left: 2px solid var(--gold-lo);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
  transform: translateX(105%); transition: transform .22s ease-out; box-shadow: -10px 0 30px #000c; overscroll-behavior: contain;
}
.game.compact.drawer-open .side { transform: none; }
.game.compact.drawer-open.drag-peek .side { transform: translateX(105%); }
.game.compact.drawer-open.drag-peek .scrim { opacity: 0; pointer-events: none; }
.game.compact .scrim { display: block; position: fixed; inset: 0; z-index: 19; background: #0008; opacity: 0; pointer-events: none; transition: opacity .2s; }
.game.compact.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.game.compact .menu .ib { padding: 6px 0 4px; font-size: 10px; }
.game.compact .menu .ib .ico { width: 20px; height: 20px; }
.game.compact .views { display: flex; position: sticky; top: -5px; z-index: 1; margin: -5px -5px 0; padding: 5px 5px 0; background: var(--stone-1); border-bottom: 1px solid var(--edge-lo); }
.game.compact .views button { flex: 1; border-radius: 3px 3px 0 0; padding: 7px 2px; font-size: 11px; color: var(--muted); }
.game.compact .views button.on { color: #1d1406; }
.game.compact .views .drawer-close { flex: 0 0 44px; display: grid; place-items: center; }
.game.compact .side [data-view] { display: none; }
.game.compact .side[data-view=inv] [data-view=inv], .game.compact .side[data-view=battle] [data-view=battle],
.game.compact .side[data-view=skills] [data-view=skills], .game.compact .side[data-view=social] [data-view=social],
.game.compact .side[data-view=map] [data-view=map] { display: grid; }
.game.compact .side .win.collapsed .wbody { display: grid; }
.game.compact .slot { width: 44px; height: 44px; }
.game.compact .paperdoll { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(4, 44px); }
.game.compact .grid { grid-template-columns: repeat(auto-fill, 44px); }
.game.compact .fighter { padding: 5px 4px; }
.game.compact .minimap { max-width: 280px; }
.game.compact .vip .buddy { padding: 8px 6px; }
.game.compact .ctxmenu button, .ctxmenu.touch button { padding: 10px 18px 10px 12px; font-size: 14px; }
.game.compact ~ .dialogs .dialog { max-width: calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)); }

/* compact landscape: the view fills the height; the controls and the
   hotkeys sit beside it, the chat lies over the view's lower part */
.game.compact.landscape { grid-template-rows: 1fr; }
.game.compact.landscape .hud { position: absolute; z-index: 5; top: env(safe-area-inset-top); left: env(safe-area-inset-left); width: var(--margin-w, 180px); height: auto; flex-wrap: wrap; background: #1a1713e0; border: 1px solid var(--edge-lo); border-radius: 0 0 6px 0; }
.game.compact.landscape[data-pad=right] .hud { left: auto; right: env(safe-area-inset-right); border-radius: 0 0 0 6px; }
.game.compact.landscape .hud .bars { flex-basis: 100%; order: 3; }
.game.compact.landscape .hud .lvl { flex: 1; }
.game.compact.landscape .view { grid-template-rows: 1fr; }
.game.compact.landscape .stage { place-items: center; grid-row: 1; grid-column: 1; }
.game.compact.landscape .hotbar {
  grid-row: 1; grid-column: 1; align-self: start; justify-self: end; z-index: 4; display: grid; grid-template-columns: repeat(3, 44px); gap: 3px;
  width: auto; max-height: calc(100% - 140px); overflow-y: auto; overflow-x: hidden; touch-action: pan-y; background: #1a1713cc; border: 1px solid var(--edge-lo); margin: 6px;
}
.game.compact.landscape[data-pad=right] .hotbar { justify-self: start; }
.game.compact.landscape .hotkey { height: 44px; }
.game.compact.landscape .chat {
  grid-row: 1; grid-column: 1; align-self: end; justify-self: center; z-index: 3; width: var(--map-w, 60%); height: 42%;
  background: rgb(26 23 19 / var(--chat-alpha)); border: 1px solid var(--edge-lo); margin-bottom: 2px;
}
.game.compact.landscape .chat .logs { background: rgb(11 10 8 / var(--chat-alpha)); }
.game.compact.landscape.typing .chat { height: 70%; }
.game.compact.landscape.chat-hidden .chat { display: none; }
.game:not(.compact) .chat .logs { background: #0b0a08; }

/* coarse pointers on any layout: bigger targets */
@media (pointer: coarse) {
  .win > header button.small { height: 26px; min-width: 26px; }
  .ctxmenu button { padding: 10px 18px 10px 12px; font-size: 14px; }
  button { min-height: 32px; }
  .tab, button.small, .swatch, .character { min-height: 0; }
  .mk-entry { min-height: 40px; }
  .mk-row { min-height: 34px; }
  .mk-row.head { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* the quest log and its tracker on the map (features.ts) */
.quest-log { display: grid; gap: 4px; min-width: min(340px, 82vw); max-width: min(460px, 100%); max-height: min(70vh, 620px); overflow-y: auto; }
.quest-log .quests, .quest-log .missions { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.quest-log summary { cursor: pointer; color: var(--gold-hi); padding: 2px 0; }
.quest-log details.done > summary { color: var(--muted); }
.quest-log .missions { padding: 2px 0 6px 12px; }
.quest-log .mission .row { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.quest-log .mission p { margin: 1px 0 0; white-space: pre-wrap; color: var(--text); }
.quest-log .mission.done b { color: var(--muted); }
.quest-log button.pin { flex: none; padding: 0 7px; font-size: 10px; }
.quest-log button.pin.on { color: var(--gold-hi); border-color: var(--gold-lo); }
.quest-tracker { position: absolute; right: 6px; top: 6px; z-index: 2; width: min(230px, 40%); max-height: 70%; overflow-y: auto; line-height: 1.25;
  font-size: 11px; background: #0d0b09d9; border: 1px solid var(--stone-4); border-radius: 3px; padding: 3px 5px 4px; display: grid; gap: 4px; }
.quest-tracker[hidden], .win.boosted[hidden] { display: none; }
.quest-tracker header { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.quest-tracker header .title { background: none; border: 0; padding: 0; color: var(--gold); font-size: 11px; cursor: pointer; }
.quest-tracker .tracked .row { display: flex; gap: 4px; align-items: start; justify-content: space-between; }
.quest-tracker .tracked b { color: var(--gold-hi); font-weight: normal; }
.quest-tracker .tracked.done b { color: #7fd17f; }
.quest-tracker .tracked p { margin: 1px 0 0; color: var(--text); }
.quest-tracker .tracked small { display: block; }
.quest-tracker button.x { height: 16px; min-width: 16px; padding: 0 3px; flex: none; }

/* the depot search (features.ts) */
.win > header button.depot-search-btn { display: inline-flex; gap: 3px; align-items: center; width: auto; padding: 0 6px; color: var(--gold-hi); font-size: 10px; }
.depot-search { display: grid; gap: 6px; min-width: min(340px, 82vw); max-width: min(440px, 100%); }
.depot-search > .row { display: flex; gap: 6px; }
.depot-search input[type=search] { flex: 1; min-width: 0; }
.depot-status { min-height: 1.2em; margin: 0; }
.depot-status.ok { color: #7fd17f; }
.depot-results { max-height: min(60vh, 520px); overflow-y: auto; }
.depot-items, .depot-items .places { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.depot-items .head { display: flex; gap: 6px; align-items: center; }
.depot-items .head b { flex: 1; color: var(--gold-hi); font-weight: normal; }
.depot-items .places { padding-left: 30px; gap: 2px; }
.depot-items .places .row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; }
.depot-items .places .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.depot-items input.count { width: 5em; }

/* the boosted creature (features.ts) */
.win.boosted .row { display: flex; gap: 8px; align-items: center; }
.win.boosted canvas { flex: none; background: radial-gradient(circle at 50% 55%, #2a251e, #0e0c0a); border: 1px solid var(--stone-4); }
.win.boosted .boosted-name { display: block; color: var(--gold-hi); font-weight: normal; }
.win.boosted small { display: block; }
@media (max-width: 700px) {
  .quest-tracker { width: min(200px, 48%); font-size: 10px; }
  .depot-items .places { padding-left: 4px; }
}
.card.maintenance .maintenance-reason { text-align: center; font-size: 13px; }

/* ---- several characters at once (ui/sessions.ts) ----
   the bar of session tabs over the games' panes; each pane is the box its
   game lays out in (layout containment: the game's fixed layers, drawer
   and windows stay inside it); side by side, the game in front is framed */
.sessions { position: fixed; inset: 0; height: var(--app-h, 100dvh); display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--stone-0); }
.session-bar { display: flex; align-items: flex-end; gap: 4px; min-width: 0;
  padding: calc(env(safe-area-inset-top) + 3px) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  background: var(--stone-2) var(--noise); border-bottom: 1px solid var(--gold-lo); box-shadow: inset 0 -1px 0 var(--edge-lo); }
.session-tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
.session-tab { position: relative; display: inline-grid; grid-template-columns: auto auto auto; grid-template-rows: auto 4px; align-items: center; column-gap: 6px;
  padding: 3px 6px 3px 10px; border-radius: 4px 4px 0 0; border-bottom: 0; box-shadow: none; white-space: nowrap; font-size: 11px; color: var(--muted);
  background: linear-gradient(#2d271f, #201c16); transition: color .15s, background .15s; }
.session-tab.active { color: var(--gold-hi); background: linear-gradient(#3a3125, #15120e); border-color: var(--gold-lo) var(--edge-lo) transparent var(--gold-lo); }
.session-tab.unread .session-name { color: #ff9a6a; }
.session-name { grid-column: 1; grid-row: 1; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
.session-bars { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-rows: 2px 2px; background: #000; border-radius: 1px; overflow: hidden; }
.session-bars i { display: block; width: 0; height: 2px; transition: width .3s ease-out; }
.session-bars i.hp { background: var(--hp-hi); }
.session-bars i.mp { background: var(--mp-hi); }
.session-badge { grid-column: 2; grid-row: 1; min-width: 0; padding: 0 4px; border-radius: 7px; font-size: 9px; line-height: 13px; color: #1d1406; background: #ff9a6a; font-weight: bold; }
.session-badge:empty { display: none; }
.session-close { grid-column: 3; grid-row: 1; padding: 0 3px; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; }
.session-close:hover { color: var(--msg-warn); }
.session-add, .session-view { flex: none; display: grid; place-items: center; width: 26px; height: 22px; margin-bottom: 2px; padding: 0; }
.session-view { margin-left: auto; }
.session-view[hidden] { display: none; }
.session-panes { grid-row: 2; display: grid; gap: 2px; min-height: 0; min-width: 0; background: var(--edge-lo); }
.sessions[data-bar=off] .session-bar { display: none; }
.sessions[data-bar=off] .session-pane > .game { padding-top: env(safe-area-inset-top); }
/* the game menu's "Another character": while the bar (and its +) is hidden */
.sessions:not([data-bar=off]) .menu .ib.another { display: none; }
.session-pane { position: relative; min-width: 0; min-height: 0; overflow: hidden; contain: layout paint; }
.session-pane[hidden] { display: none; }
.session-pane > .game { height: 100%; padding-top: 0; }
.sessions[data-view=tiled] .session-pane::after { content: ""; position: absolute; inset: 0; z-index: 35; pointer-events: none; border: 2px solid transparent; transition: border-color .15s; }
.sessions[data-view=tiled] .session-pane.front::after { border-color: var(--gold); }
.sessions[data-view=tiled] .dialog { max-width: calc(100% - 16px); max-height: calc(100% - 16px); }
@media (pointer: coarse) { .session-tab { padding-block: 5px; font-size: 12px; } .session-add { width: 34px; height: 28px; } }

/* ---- the old login screens behind the character list (ui/slideshow.ts) ----
   two layers cross-fade; painted pictures fill the screen, the pixel-art
   one (10.20+) is shown whole with hard pixel edges; a dark veil keeps the
   card readable */
.backdrop { position: fixed; inset: 0; overflow: hidden; background: var(--stone-0); }
.backdrop img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  transition: opacity 1.2s ease-in-out;
}
.backdrop img.pixel { object-fit: contain; image-rendering: pixelated; }
.backdrop img.shown { opacity: 1; }
.backdrop::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, #0d0b0933 0%, #0d0b09b3 90%); }
.backdrop-caption {
  position: fixed; z-index: 2; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 3px;
  background: #0d0b09cc; border: 1px solid var(--gold-lo); color: var(--gold-hi); font-size: 11px; text-shadow: 0 1px 0 #000;
}
.backdrop-caption button.small { min-width: 28px; height: 26px; }
body.has-backdrop #app { position: relative; z-index: 1; }
body.has-backdrop .backdrop { z-index: 0; }
body.has-backdrop .center { background: transparent; padding-bottom: max(56px, env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .backdrop img { transition: none; } }

/* the Guide panel (guide.ts) */
.guide { display: grid; gap: 6px; width: min(520px, calc(100vw - 48px)); }
.guide-bar { display: flex; align-items: center; gap: 6px; }
.guide-bar .small { margin-left: auto; }
.guide-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--gold-lo); }
.guide-tabs button { font-size: 11px; padding: 3px 8px; border-radius: 3px 3px 0 0; color: var(--muted); }
.guide-tabs button.on { color: var(--gold-hi); background: #2a2219; border-color: var(--gold-lo) var(--gold-lo) transparent; }
.guide-body { max-height: min(62vh, 560px); overflow-y: auto; display: grid; gap: 4px; align-content: start; }
.guide-body h4 { margin: 6px 0 2px; color: var(--gold); font-size: 12px; }
.guide-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.guide-list > li { padding: 5px 7px; background: #ffffff06; border-left: 2px solid var(--gold-lo); }
.guide-list > li p { margin: 2px 0 0; font-size: 11px; }
.guide-list > li .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.guide-list > li .row .link { margin-left: auto; }
.guide-list h4 { margin: 0; color: var(--gold-hi); font-size: 12px; }
.guide-list .fit.low { color: #ffb070; }
.guide-list .fit.good { color: #8fe08f; }
.guide-list .fit.high { color: var(--muted); }
.guide-list .good { color: #8fe08f; }
.guide-list .warn { color: #ffb070; }
.guide-list .route { color: var(--text); }
.guide-list .show-on-map { display: inline-flex; align-items: center; gap: 3px; color: #ff9ae6; }
.guide-list li.better { border-left-color: #6ccf6c; }
.guide-list.gear .row > div { flex: 1; min-width: 0; }
.guide-list code { color: var(--msg-npc); font-size: 11px; }
.guide-list li.progress { border-left-color: var(--gold-hi); }
.map-target { margin: 3px 0 0; font-size: 10px; color: #ff9ae6; text-align: center; }

/* the Bestiary window (bestiary.ts) */
.bestiary { display: grid; gap: 6px; width: min(560px, calc(100vw - 48px)); max-height: min(70vh, 640px); overflow-y: auto; align-content: start; }
.bestiary .summary { margin: 0; color: var(--muted); }
.bestiary .crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 11px; }
.bestiary .bar { display: block; height: 3px; background: #000; border: 1px solid var(--edge-lo); }
.bestiary .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); }
.bestiary-classes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.bestiary-classes button { width: 100%; display: grid; gap: 2px; text-align: left; padding: 6px 8px; }
.bestiary-classes b { color: var(--gold-hi); }
.bestiary-classes small { color: var(--muted); font-size: 10px; }
.bestiary-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; }
.bestiary-grid button { width: 100%; display: grid; justify-items: center; gap: 2px; padding: 4px; min-height: 92px; }
.bestiary-grid .name { font-size: 10px; text-align: center; line-height: 1.15; }
.bestiary-grid .bar { width: 90%; }
.bestiary-grid .stars { color: var(--gold); font-size: 9px; letter-spacing: -1px; }
.bestiary-grid span.unknown { font: bold 20px/32px Georgia, serif; color: var(--faint); width: 32px; text-align: center; }
.bestiary-grid li.unknown button { min-height: 0; opacity: .7; }
.bestiary-grid li.stage-3 button { border-color: var(--gold-hi); }
.bestiary-detail > .row { display: flex; gap: 10px; align-items: center; }
.bestiary-detail h4 { margin: 4px 0 2px; color: var(--gold); }
.bestiary-detail p { margin: 0; font-size: 11px; }
.bestiary-detail .facts { border-collapse: collapse; font-size: 11px; }
.bestiary-detail .facts th { text-align: left; color: var(--muted); font-weight: normal; padding: 1px 10px 1px 0; }
.bestiary-detail .facts tr.weak td { color: #8fe08f; }
.bestiary-detail .facts tr.strong td { color: #ffb070; }
.bestiary-detail .locked { font-style: italic; }
.bestiary-loot { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px; font-size: 11px; }
.bestiary-loot li { display: flex; align-items: center; gap: 4px; }
.bestiary-loot small { margin-left: auto; }

/* ---- tablets: the full layout (side panel beside the view) with touch
   controls; layout.ts picks it by the room on screen ---- */
.game.tall .stage { place-items: start center; }
.game:not(.compact) .actions .chat-btn, .game:not(.compact) .actions .panel-btn { display: none; }
.game:not(.compact) .actions { grid-template-columns: repeat(2, 48px); }
/* sideways: the pad and its buttons flank the chat under the view */
.game:not(.compact):not(.tall).controls-on .view { position: relative; }
.game:not(.compact):not(.tall).controls-on .stage { position: static; }
.game:not(.compact):not(.tall).controls-on .chat { margin: 0 126px 0 calc(150px * var(--pad) + 24px); }
.game:not(.compact):not(.tall).controls-on[data-pad=right] .chat { margin: 0 calc(150px * var(--pad) + 24px) 0 126px; }
/* the side panel's targets as big as a finger's */
.game.touch:not(.compact) .slot { width: 44px; height: 44px; }
.game.touch:not(.compact) .paperdoll { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(4, 44px); }
.game.touch:not(.compact) .grid { grid-template-columns: repeat(auto-fill, 44px); }
.game.touch:not(.compact) .fighter { padding: 5px 4px; }
.game.touch:not(.compact) .vip .buddy { padding: 8px 6px; }
.game.touch:not(.compact) { grid-template-columns: 1fr calc(296px * var(--ui)); }
.game.touch:not(.compact) .menu .ib { padding: 6px 0 4px; }
.game.touch:not(.compact) .tab { padding: 5px 12px; font-size: 12px; }
.game.touch .chat-row .send { display: grid; place-items: center; padding: 0 14px; min-width: 48px; }

/* ---- touch screens on any layout: targets of 44 px (36 px in dense rows
   with room around them), text of 12 px at least in the windows, fields
   of 16 px (iOS zooms into smaller ones when they take the focus) ---- */
@media (pointer: coarse) {
  /* (the game and its windows: the login cards keep their own) */
  :where(.game, .dialogs, .ctxmenu) :is(input, select, textarea), .game .chat-input { font-size: 16px; }
  :where(.game, .dialogs) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select) { min-height: 44px; }
  :where(.game, .dialogs) :is(input[type=checkbox], input[type=radio]) { width: 22px; height: 22px; }
  :where(.game, .dialogs) input[type=range] { min-height: 36px; }
  .chat-input { min-height: 44px; }
  :where(.game, .dialogs, .ctxmenu, .session-bar) button { min-height: 44px; }
  :where(.game, .dialogs) :is(button.small, button.link) { min-height: 36px; min-width: 36px; }
  .hud .ib { width: 44px; height: 36px; min-height: 36px; }
  .dialog > header { min-height: 48px; }
  .dialog > header .x { width: 44px; height: 44px; }
  .ctxmenu button { min-height: 44px; }
  .win > header { min-height: 40px; }
  .win > header button.small { height: 36px; min-width: 36px; }
  .win > header button.market-btn, .win > header button.depot-search-btn { padding: 0 10px; font-size: 12px; }
  .tab { min-height: 44px; }
  .tab .close { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; margin: -6px -12px -6px -4px; font-size: 18px; }
  .session-close { min-width: 32px; min-height: 32px; display: grid; place-items: center; font-size: 16px; }
  .session-add, .session-view { width: 44px; height: 36px; min-height: 36px; }
  .session-tab { min-height: 36px; }
  .quest-tracker button.x, .quest-tracker header button.small { min-height: 36px; min-width: 36px; height: 36px; }
  .quest-tracker header .title { min-height: 36px; font-size: 12px; }
  .quest-log summary { padding: 10px 0; }
  .quest-log button.pin { padding: 0 12px; font-size: 12px; }
  .route-list .grip { display: none; } /* drag and drop is the mouse's: ↑ and ↓ move a waypoint */
  .route-list li { padding: 4px; }
  .route-list .acts { gap: 4px; }
  .backdrop-caption button.small { min-width: 44px; height: 40px; }
  /* the outfit's 133 colours: as wide as the window lets them */
  .outfit { width: min(440px, calc(100vw - 48px)); }
  .palette { width: 100%; grid-template-columns: repeat(19, minmax(0, 1fr)); gap: 3px; }
  .swatch { width: auto; height: auto; min-height: 0; aspect-ratio: 1; }
  .outfit .pick button, .outfit .mounts button { min-width: 44px; }
  button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .dialog { font-size: 13px; }
  .dialog :is(.hint, .small, small, p, li, td, th, .chip, .guide-tabs button, .mk-rows, .mk-stat, .bestiary-grid .name, .achievement-list .pts,
    .audio-credit-list, .hunt-trips ul, .route-list li, .quest-log .mission p, .depot-items, .bestiary-loot, .skills) { font-size: max(12px, 1em); }
}

/* ---- touch screens: the login, character and maintenance cards and the
   start island dialog follow the game's sizes (targets of 44 px, fields
   of 16 px, text of 13 px at least); a mouse keeps the smaller look ---- */
@media (pointer: coarse) {
  :where(.card, .start-dialog) :is(input:not([type=checkbox]):not([type=radio]), select) { font-size: 16px; min-height: 44px; }
  :where(.card, .start-dialog) button { min-height: 44px; }
  /* the links: a finger's height and some width, still drawn as links */
  :where(.card, .start-dialog) button.link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 0 12px; }
  .card > button.link, .start-dialog .start-back { justify-self: center; }
  .card .row-links button.link:first-child { padding-left: 0; }
  .card .row-links button.link:last-child { padding-right: 0; }
  .card legend { font-size: 13px; }
  .card fieldset.sexes { padding-block: 2px 4px; column-gap: 8px; }
  /* the whole label (box and word) is the radio's target */
  .card label.choice { align-items: center; min-height: 44px; padding: 0 14px 0 4px; font-size: 14px; }
  .card label.choice input { width: 22px; height: 22px; margin: 0; }
  .card .small, .card small, .card .hint, .character span { font-size: 13px; }
  .start-dialog .start-intro, .start-island p { font-size: 13px; }
  .start-island .start-here { font-size: 14px; }
  /* every checkbox and radio: the label around it is the target, 44 px high */
  :where(.game, .dialogs) label:has(> input:is([type=checkbox], [type=radio])) { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
  :where(.game, .dialogs) :is(label.check, .audio-mute):has(> input) { display: flex; }
}
