/* The interface's own sheet: what the game shows over the picture while you play, and where all of it sits on a phone.
   index.html keeps the pieces' first rules; this comes after it. The panels made by the game's own parts (a word with someone,
   the journal, the seals: src/ui/*.js) put their rules in the page as they start, so what a phone changes of theirs is said
   here under body.touch, which outweighs them.

   The numbers for the phone's layout are src/ui/thumbs.js (place() writes them here as --dx, --dy, --s and the --t-* set), so
   the page and the test that checks nothing overlaps read the same ones.

   Painted pieces from the art kit (tools/ui/, assets/ui/kit/manifest.json) go over the drawn ones: src/ui/skin.js sets
   html.art-<piece> and --art-<piece> for each one that has come back. Nothing here needs them. */

:root {
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --u: 1px;
  --iron: #14100b; --iron-hi: #3a3024; --rim: rgba(201, 163, 92, .78); --rim-dim: rgba(201, 163, 92, .3);
  --life: #b82a1d; --life-lo: #6d120b; --mana: #4a8df0; --mana-lo: #1f3da0; --breath: #d9c078; --xp: #a77bf2;
  /* The player's frame: the level's medal and the three bars beside it. */
  --medal: 50px; --bars: 236px;
}

/* ---- the player's frame: the level in its medal, ringed by how far to the next; life, the well and breath beside it ---- */
#levelBox { position: absolute; left: calc(20px + var(--sl)); bottom: calc(20px + var(--sb)); width: var(--medal); height: var(--medal); display: grid; place-items: center;
  border-radius: 50%; color: #f3e6c4; text-shadow: 0 1px 2px #000; pointer-events: none; letter-spacing: 0;
  background: radial-gradient(circle at 50% 38%, var(--iron-hi), var(--iron) 72%) padding-box, conic-gradient(from 180deg, var(--xp) calc(var(--xpf, 0) * 1%), rgba(0, 0, 0, .7) 0) border-box;
  border: calc(var(--medal) * .075) solid transparent; box-shadow: 0 0 0 1.5px var(--rim), 0 2px 8px rgba(0, 0, 0, .7); }
#levelNum { font: 700 calc(var(--medal) * .42)/1 Cinzel, Georgia, serif; }
#levelNum em { display: none; }
#levelNum.three { font-size: calc(var(--medal) * .31); letter-spacing: -.02em; }
#xpBar { display: none; }
#vitals { position: absolute; left: calc(20px + var(--sl) + var(--medal) + 8px); bottom: calc(24px + var(--sb)); width: var(--bars); display: grid; gap: 3px; }
.meter, #mana, #stam { position: relative; background: rgba(6, 5, 4, .72); overflow: hidden; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .8), 0 0 0 2px var(--rim-dim); border: 0; margin: 0; }
#hp { height: 15px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .8), 0 0 0 2px var(--rim); }
#mana { height: 9px; } #stam { height: 5px; }
.meter > i, #mana > i, #stam > i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; will-change: transform; }
#hp > i { background: linear-gradient(180deg, #e0503c, var(--life) 40%, var(--life-lo)); transition: transform .12s; }
#mana > i { background: linear-gradient(180deg, #7fb6ff, var(--mana) 45%, var(--mana-lo)); transition: transform .08s; }
#stam > i { background: linear-gradient(180deg, #f0dc9a, var(--breath)); transition: transform .08s; }
#hpNum { position: absolute; inset: 0; display: grid; place-items: center; font: 700 10.5px/1 Georgia, serif; letter-spacing: .06em; color: #fff3df; text-shadow: 0 0 2px #000, 0 1px 1px #000; }
/* (what's on you, by the bars) */
#buffs { z-index: 1; }

/* The charm pouch under what's worn: two rows of ten, the width of the doll. */
#inv #charmRow { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; width: calc(var(--cell) * 4.2 + 6px); margin-top: 8px; }
#inv #charmRow .ch { width: auto; height: auto; aspect-ratio: 1; }
#inv #charmRow .ch img { width: 86%; height: 86%; }
html.art-icons #charmRow .ch img[src$=".webp"] { image-rendering: auto; }

/* The foe's bars take the same make. */
#foe { border-radius: 3px; }
#foeHp { height: 9px; }
#foeHp > i { background: linear-gradient(180deg, #d0402c, #a0231a 45%, #5b0e08); }
#foeArmor { border-radius: 1px; }

/* The corner map's rim: a square, as the map is. */
#mapRing { position: absolute; right: calc(20px + var(--sr)); top: calc(18px + var(--st)); width: 168px; height: 168px; border-radius: 6px; pointer-events: none; display: none;
  box-shadow: inset 0 0 0 2px var(--rim), inset 0 0 0 5px rgba(8, 6, 4, .75), inset 0 0 0 6px var(--rim-dim), 0 2px 10px rgba(0, 0, 0, .7); }
#mapMini { box-shadow: none; }
/* (With the mouse free, Tab's or auto-play's, a click on the corner map opens the big one: src/main.js.) */
body:not(.touch) #mapMini { pointer-events: auto; cursor: pointer; }

/* ---- a button's picture (src/ui/icons.js) ---- */
.sch { display: none; position: relative; width: 1.3em; height: 1.3em; margin-right: -2px; align-self: center; --ic-size: contain; }
[data-ic] > svg { display: block; width: 54%; height: 54%; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .9)); }
[data-ic] > .lb { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); font: 700 calc(8.5 * var(--u))/1 Cinzel, Georgia, serif; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; text-shadow: 0 0 3px #000, 0 1px 1px #000; pointer-events: none; }
[data-ic][data-lb]:not([data-lb=""]) > svg { transform: translateY(-9%); }
[data-ic][data-lb]:not([data-lb=""])::before { transform: translateY(-7%); }

/* ============================================================ a phone ============================================================ */
#touch { position: fixed; inset: 0; z-index: 6; display: none; }
/* The buttons, bars and map on a phone sit by the screen's own edges, not the safe area's (src/ui/thumbs.js): the thumbs
   are in the corners, where a notch or an island isn't. Panels and menus keep the safe area (--sl, --sr, --sb). */
body.touch { --hl: 0px; --hr: 0px; --hb: 0px; --u: clamp(.8px, calc(100vh / 390), 1.3px); --medal: calc(var(--t-medal, 44) * var(--u)); --bars: calc(var(--t-bars, 150) * var(--u)); }
@supports (height: 100dvh) { body.touch { --u: clamp(.8px, calc(100dvh / 390), 1.3px); } }

/* What a thumb presses: a dark boss with a gold rim. */
.tbtn { position: absolute; display: flex; align-items: center; justify-content: center; box-sizing: border-box; border-radius: 50%; color: #efe4c8; touch-action: none;
  background: radial-gradient(circle at 50% 34%, rgba(64, 52, 38, .8), rgba(16, 12, 9, .8) 68%);
  box-shadow: inset 0 0 0 1.5px var(--rim), inset 0 0 0 4px rgba(8, 6, 4, .6), inset 0 0 0 5px var(--rim-dim), 0 2px 7px rgba(0, 0, 0, .55);
  transition: transform .07s, filter .1s, box-shadow .1s; }
.tbtn.down, .tbtn.on { color: #fff6dc; filter: brightness(1.35);
  box-shadow: inset 0 0 0 2px #f1d68a, inset 0 0 0 4px rgba(8, 6, 4, .6), inset 0 0 calc(14 * var(--u)) rgba(241, 214, 138, .45), 0 0 calc(12 * var(--u)) rgba(241, 214, 138, .45); }
.tbtn.down { transform: scale(.93); }

/* The right thumb: each from the middle of the staff's button (--dx to its left, --dy above it, --s across). */
.arc, body.touch #spells .spell.arc { --dx: 0; --dy: 0; --s: 56; width: calc(var(--s) * var(--u)); height: calc(var(--s) * var(--u));
  right: calc(var(--hr) + (var(--t-home-r, 48) + var(--dx) - var(--s) / 2) * var(--u));
  bottom: calc(var(--hb) + (var(--t-home-b, 48) + var(--dy) - var(--s) / 2) * var(--u)); }
#bAttack, #bCast { box-shadow: inset 0 0 0 2px var(--rim), inset 0 0 0 6px rgba(8, 6, 4, .6), inset 0 0 0 7.500px var(--rim-dim), 0 3px 10px rgba(0, 0, 0, .6); }
#bAttack > svg, #bCast > svg { width: 50%; height: 50%; }
#bWide { display: none; }
#bTake { display: none; color: #1c1408; background: radial-gradient(circle at 50% 34%, #f3dc9c, #c49a48 70%); box-shadow: inset 0 0 0 1.5px #fff0c0, inset 0 0 0 4px rgba(120, 84, 30, .5), 0 2px 8px rgba(0, 0, 0, .6), 0 0 calc(14 * var(--u)) rgba(241, 214, 138, .4); }
#bTake > svg { filter: none; }
#bTake > .lb { text-shadow: none; }
/* The opening's own cast (src/ui/opening.js): the one button there is, where the staff's will be. */
#bCast { display: none; }
body.op-cast #bCast { display: flex; visibility: visible !important; animation: tb-call 1.1s ease-in-out infinite; }
@keyframes tb-call { 50% { box-shadow: inset 0 0 0 2px #f1d68a, inset 0 0 0 6px rgba(8, 6, 4, .6), 0 0 calc(22 * var(--u)) rgba(241, 214, 138, .8); } }

/* The six spells, in their ring: a tap casts, a hold keeps casting. */
/* (A slot's picture is drawn again as it's pressed. A thumb that landed on the picture would be left holding something no
   longer on the page, and its lift would never be heard: so the slot itself is all a thumb can land on. The same for
   every button.) */
#spells .spell > *, .tbtn > * { pointer-events: none; }
body.touch #spells { position: absolute; inset: 0; left: 0; bottom: 0; transform: none; display: block; pointer-events: none; }
body.touch #spells .spell { position: absolute; padding: 0; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle at 50% 34%, rgba(46, 38, 30, .84), rgba(10, 8, 6, .84) 70%);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 62%, #000), inset 0 0 0 3.500px rgba(8, 6, 4, .6), 0 2px 6px rgba(0, 0, 0, .55); }
/* (The Utility three, 0, - and +, in the outermost ring: edged in pale bone, so they read as their own.) */
body.touch #spells .spell.util { box-shadow: inset 0 0 0 1.5px rgba(233, 223, 201, .6), inset 0 0 0 3.500px rgba(8, 6, 4, .6), 0 2px 6px rgba(0, 0, 0, .55); }
body.touch #spells .spell svg { width: 56%; height: 56%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .9)); }
body.touch #spells .spell b { left: auto; right: 50%; top: auto; bottom: -1px; transform: translateX(50%); font: 700 calc(8 * var(--u))/1 Georgia, serif; color: #cdbf9f; opacity: .8; }
body.touch #spells .spell.now { box-shadow: inset 0 0 0 2px var(--c), inset 0 0 0 3.500px rgba(8, 6, 4, .6), inset 0 0 calc(12 * var(--u)) -2px var(--c), 0 0 calc(10 * var(--u)) -2px var(--c); }
body.touch #spells .spell.up, body.touch #spells .spell.down { transform: scale(.93); filter: brightness(1.3); box-shadow: inset 0 0 0 2px var(--c), inset 0 0 calc(16 * var(--u)) var(--c), 0 0 calc(16 * var(--u)) var(--c); }
body.touch #spells .spell.empty { background: rgba(10, 8, 6, .35); box-shadow: inset 0 0 0 1.5px rgba(201, 163, 92, .28); border: 0; }
body.touch #spells .spell.util.empty { box-shadow: inset 0 0 0 1.5px rgba(233, 223, 201, .3); }
body.touch #spells .spell .cd { font: 700 calc(17 * var(--u)) Georgia, serif; border-radius: 50%; }
body.touch #spellOpen, body.touch #viewBtn { display: none !important; }
body.touch #spellName { left: auto; right: calc(var(--hr) + 300 * var(--u)); bottom: calc(var(--hb) + 10 * var(--u)); transform: none; margin: 0; font-size: calc(11.5 * var(--u)); text-align: right; opacity: .85; }
body.touch #buffs { position: absolute; left: calc(var(--hl) + (var(--t-side, 5) + var(--t-medal, 44) + 8) * var(--u)); top: calc(var(--st) + 46 * var(--u)); bottom: auto; margin: 0; gap: calc(3 * var(--u)); }
body.touch #buffs span { width: calc(22 * var(--u)); height: calc(22 * var(--u)); padding: calc(3 * var(--u)); }
body.cinematic #touch #spells { visibility: hidden; }

/* The left thumb: the stick itself where the thumb lands. (The run is the right thumb's, over spell six.) Where the stick's ring waits isn't drawn: nothing
   of the stick is on the screen until a thumb is on it (its place is shown only while Move Buttons is up: src/ui/arrange.js). */
#stickHome { position: absolute; left: calc(var(--hl) + var(--t-stick-l, 86) * var(--u)); bottom: calc(var(--hb) + var(--t-stick-b, 42) * var(--u)); width: calc(var(--t-stick-s, 112) * var(--u)); height: calc(var(--t-stick-s, 112) * var(--u));
  border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: radial-gradient(circle, rgba(233, 223, 201, .16) 0 21%, transparent 22%), radial-gradient(circle, transparent 0 62%, rgba(10, 8, 6, .22) 63%);
  box-shadow: inset 0 0 0 1.5px rgba(233, 223, 201, .26); }
#touch.sticking #stickHome { opacity: 0; }
#stick { position: absolute; width: 130px; height: 130px; border-radius: 50%; display: none; pointer-events: none;
  background: radial-gradient(circle, transparent 0 60%, rgba(10, 8, 6, .3) 61%); box-shadow: inset 0 0 0 1.5px var(--rim), inset 0 0 0 4px rgba(8, 6, 4, .4); }
#nub { position: absolute; left: 39px; top: 39px; width: 52px; height: 52px; border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, #f3e6c4, #b99a5c 70%); box-shadow: 0 2px 6px rgba(0, 0, 0, .6), inset 0 0 0 1.5px rgba(255, 244, 210, .7); }

/* Along the top: your frame on the left; on the right the corner map, and beside it the row of small buttons. */
body.touch #levelBox { left: calc(var(--hl) + var(--t-side, 5) * var(--u)); top: calc(var(--st) + var(--t-pad, 8) * var(--u)); bottom: auto; }
body.touch #vitals { left: calc(var(--hl) + (var(--t-side, 5) + var(--t-medal, 44) + 7) * var(--u)); top: calc(var(--st) + (var(--t-pad, 8) + 5) * var(--u)); bottom: auto; width: var(--bars); gap: calc(3 * var(--u)); }
body.touch #hp { height: calc(13 * var(--u)); } body.touch #mana { height: calc(8 * var(--u)); } body.touch #stam { height: calc(4.500 * var(--u)); }
body.touch #hpNum { font-size: calc(9.5 * var(--u)); }
body.touch #mapMini, body.touch #mapRing, #bMap { right: calc(var(--hr) + var(--t-side, 5) * var(--u)); top: calc(var(--st) + var(--t-pad, 8) * var(--u)); width: calc(var(--t-mini, 92) * var(--u)); height: calc(var(--t-mini, 92) * var(--u)); }
#bMap { background: none; box-shadow: none; border-radius: 6px; }
#bMap.down { transform: none; filter: none; box-shadow: inset 0 0 0 3px #f1d68a; }
body.touch #clock { left: auto; right: calc(var(--hr) + (var(--t-side, 5) + var(--t-mini, 92) - 20) * var(--u)); top: calc(var(--st) + (var(--t-pad, 8) + var(--t-mini, 92) - 30) * var(--u)); width: calc(34 * var(--u)); z-index: 2; }
body.touch #clock .phase { display: none; }
#dock { position: absolute; top: calc(var(--st) + var(--t-pad, 8) * var(--u)); display: flex; flex-direction: row-reverse; gap: calc(var(--t-gap, 3) * var(--u));
  right: calc(var(--hr) + (var(--t-side, 5) + var(--t-mini, 92) + var(--t-pad, 8)) * var(--u)); }
#dock .tbtn { position: relative; width: calc(var(--t-dock, 38) * var(--u)); height: calc(var(--t-dock, 38) * var(--u)); flex: none; }
#dock .tbtn > svg { width: 56%; height: 56%; }
#bView { display: none; }
/* (points waiting in the book) */
#bBook.pts { color: #1c1408; background: radial-gradient(circle at 50% 34%, #f3dc9c, #c49a48 70%); box-shadow: inset 0 0 0 1.5px #fff0c0, 0 0 calc(12 * var(--u)) rgba(241, 214, 138, .6); }
#bBook.pts > svg { filter: none; }
#bBook.pts::after { content: attr(data-n); position: absolute; right: -4px; bottom: -5px; padding: 1px 4px; font: 700 calc(9.5 * var(--u))/1.2 Georgia, serif; color: #14100a; background: #f0e5cd; border-radius: 7px; box-shadow: 0 1px 3px #000; }

/* Under the top, in the middle, one under the other: whoever means you harm, a great foe's own bar, the hall's word, what's
   just happened, and what the game has to tell you. */
#topStack { display: none; }
body.touch #topStack { position: absolute; left: 50%; top: calc(var(--st) + 52 * var(--u)); transform: translateX(-50%); width: min(430px, 52vw); display: flex; flex-direction: column; align-items: center; gap: calc(4 * var(--u)); pointer-events: none; }
body.touch #topStack > * { position: static; transform: none; margin: 0; flex: none; }
body.touch #topStack #foe { width: min(280px, 100%); padding: calc(4 * var(--u)) calc(10 * var(--u)) calc(5 * var(--u)); background: rgba(8, 6, 4, .62); box-shadow: 0 0 0 1px var(--rim-dim); }
body.touch #foe .name { font-size: calc(11.5 * var(--u)); letter-spacing: .18em; margin-bottom: calc(3 * var(--u)); }
body.touch #bleed { font-size: calc(10 * var(--u)); min-height: 0; margin-top: calc(3 * var(--u)); color: #ff6a4a; }
body.touch #bleed:empty { display: none; }
body.touch #topStack #bossFrame { width: min(380px, 100%); }
body.touch #topStack #bossFrame .bn { font-size: calc(14 * var(--u)); }
body.touch #topStack #hallStatus { max-width: 100%; font-size: calc(12 * var(--u)); }
body.touch #topStack #folkNotes { display: flex; }
body.touch #topStack .fn { font-size: calc(13 * var(--u)); padding: calc(3 * var(--u)) calc(12 * var(--u)); }
body.touch #topStack #tip { max-width: 100%; font-size: calc(13 * var(--u)); padding: calc(5 * var(--u)) calc(12 * var(--u)); border-radius: 3px; box-shadow: 0 0 0 1px var(--rim-dim); }
/* What's in reach, said beside the button that takes it. */
body.touch #take { left: auto; top: auto; transform: none; right: calc(var(--hr) + (var(--t-home-r, 48) + 196 - 29) * var(--u)); bottom: calc(var(--hb) + (var(--t-home-b, 48) + 28 + 33) * var(--u)); max-width: 40vw; text-align: right; font-size: calc(12.5 * var(--u)); padding: calc(3 * var(--u)) calc(9 * var(--u)); border-radius: 3px; }
body.touch #debug { top: calc(var(--st) + 60 * var(--u)); left: calc(var(--sl) + 12 * var(--u)); right: auto; text-align: left; font-size: 10px; }
body.touch #msg { font-size: clamp(26px, 6vw, 54px); }

/* The game's other pieces, on a phone (their own rules are in src/ui/*.js). */
/* (Over the stick's layer, #touch, z-index 6: the frames let a touch through, but their ▶ and the calls are the thumb's to
   press, not the stick's. Their sizes: PARTY in src/ui/thumbs.js.) */
body.touch #partyFrames { left: calc(var(--hl) + var(--t-side, 5) * var(--u)); top: calc(var(--st) + var(--t-party-top, 78) * var(--u)); transform: scale(.82); transform-origin: 0 0; z-index: 7; }
body.touch #partyFrames .pf-play { width: calc(var(--t-party-play, 36) * var(--u)); height: calc(var(--t-party-play, 36) * var(--u)); right: calc((var(--t-party-play, 36) + 6) * var(--u) * -1); font-size: calc(14 * var(--u)); line-height: 1; touch-action: none; }
body.touch #partyFrames .pf-play::after { content: ''; position: absolute; inset: calc(var(--t-party-reach, 10) * var(--u) * -1); border-radius: 50%; }
body.touch.has-party #heroCalls { display: flex !important; z-index: 7; bottom: auto; gap: calc(5 * var(--u)); pointer-events: none; font-size: calc(12 * var(--u)); }
body.touch #heroCalls span { display: flex; align-items: center; justify-content: center; min-width: calc(var(--t-party-call, 40) * var(--u)); height: calc(var(--t-party-call, 40) * var(--u)); box-sizing: border-box; padding: 0 calc(6 * var(--u)); border-radius: calc(6 * var(--u)); pointer-events: auto; touch-action: none; }
body.touch #heroCalls span b { display: none; }
body.touch #heroCalls span.down { background: rgba(60,46,24,.9); border-color: #f1d68a; }
body.touch.hero-play #heroBar { z-index: 7; }
body.touch.has-party #heroChat:not(:empty) { display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
body.touch.menu-up :is(#heroCalls, #heroBar), body.touch.paused :is(#heroCalls, #heroBar), body.touch.map-open :is(#heroCalls, #heroBar) { visibility: hidden; }
body.touch #raidWarn { font-size: calc(16 * var(--u)); top: 34%; }
body.touch #heroChat { left: calc(var(--hl) + 32 * var(--u)); bottom: calc(var(--hb) + 12 * var(--u)); width: 40vw; font-size: calc(11.5 * var(--u)); }
body.touch #vskull { top: calc(var(--st) + (var(--t-pad, 8) + var(--t-mini, 92) - 12) * var(--u)); right: calc(var(--hr) + 2 * var(--u)); width: calc(30 * var(--u)); height: calc(30 * var(--u)); }
body.touch #vskullTag { top: calc(var(--st) + (var(--t-pad, 8) + var(--t-mini, 92) + 20) * var(--u)); right: calc(var(--hr) - 2 * var(--u)); width: calc(44 * var(--u)); font-size: calc(7.5 * var(--u)); }
body.touch #autoBtn { top: calc(var(--st) + (var(--t-pad, 8) + var(--t-mini, 92) - 12) * var(--u)); right: calc(var(--hr) + var(--t-auto-r, 40) * var(--u)); width: calc(var(--t-auto, 32) * var(--u)); height: calc(var(--t-auto, 32) * var(--u)); }
body.touch #autoBtn img { object-fit: contain; }
body.touch #autoStatus { top: calc(var(--st) + 121 * var(--u)); right: calc(var(--hr) + 73 * var(--u)); left: auto; bottom: auto; text-align: right; max-width: 34vw; }
body.touch #autoStatus b { font-size: calc(10.5 * var(--u)); }
body.touch #autoStatus small { font-size: calc(10 * var(--u)); }
body.touch #autoStatus u { margin: 0 6px 0 0; }

/* A menu, the pause or the big map is up: the thumbs and the frame are put away, and the menu has the screen. */
body.touch.menu-up #touch, body.touch.paused #touch, body.touch.map-open #touch,
body.touch.menu-up #hud, body.touch.paused #hud { visibility: hidden; }
body.touch.menu-up #vskull, body.touch.menu-up #vskullTag, body.touch.paused #vskull, body.touch.paused #vskullTag, body.touch.map-open #vskull, body.touch.map-open #vskullTag,
body.touch.menu-up #autoBtn:not(.on), body.touch.paused #autoBtn, body.touch.map-open #autoBtn:not(.on),
body.touch.menu-up #autoStatus, body.touch.paused #autoStatus { visibility: hidden; }
body.touch.map-open #hud > :not(#mapMini) { visibility: hidden; }

/* Auto-play with the interface put away (Settings, Interface in auto-play: src/ui/autoplay.js setBare): only the picture, and
   the map and the chat if they're kept. Anything touched brings it all back. */
body.auto-shot #cross { opacity: 0; }
body.ui-bare :is(#hud, #touch, #autoBtn, #autoStatus, #vskull, #vskullTag, #partyFrames, #bossFrame, #raidWarn, #folkNotes, #folkMarks, #heroLayer, #heroChat, #hallStatus, #softCursor) { visibility: hidden !important; }
body.ui-bare.bare-map :is(#mapMini, #mapRing, #bMap) { visibility: visible !important; }
body.ui-bare.bare-chat :is(#heroChat, #heroLayer) { visibility: visible !important; }

/* Upright: the game's on its side, so the phone is asked to be. */
#rotate { flex-direction: column; gap: 14px; font: 600 17px/1.4 Cinzel, Georgia, serif; letter-spacing: .08em; }
#rotate svg { width: 84px; height: 84px; color: var(--gold); animation: rot-nudge 2.4s ease-in-out infinite; }
@keyframes rot-nudge { 0%, 55%, 100% { transform: none; } 75% { transform: rotate(-12deg); } }

/* ============================================================ the menus, on a phone ============================================================ */
/* A thumb wants a row it can't miss, and no key names. */
body.touch .menu-x { width: 40px; height: 40px; }
body.touch .menu-x svg { width: 15px; height: 15px; }
body.touch .menu-x::after { inset: -4px; }
body.touch #folkTalk, body.touch #heroTalk, body.touch #hirePanel { bottom: calc(var(--sb) + 6px); width: min(820px, calc(100vw - var(--sl) - var(--sr) - 12px)); max-height: calc(100vh - 12px); padding: 9px 14px 8px; }
body.touch #folkTalk .tk-head, body.touch #heroTalk .tk-head, body.touch #hirePanel .tk-head { align-items: center; padding-bottom: 4px; margin-bottom: 6px; }
body.touch #folkTalk .tk-head .menu-x, body.touch #heroTalk .tk-head .menu-x, body.touch #hirePanel .tk-head .menu-x, body.touch #hallPanel .tk-head .menu-x { margin: -4px -8px -2px 6px; }
body.touch #folkTalk .tk-line, body.touch #heroTalk .tk-line { font-size: 15.5px; line-height: 1.4; min-height: 2.2em; }
body.touch #folkTalk ol, body.touch #heroTalk ol, body.touch #hirePanel ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 5px; margin-top: 7px; }
body.touch #folkTalk li, body.touch #heroTalk li, body.touch #hirePanel li { align-items: center; min-height: 40px; padding: 4px 12px; font-size: 14.5px; line-height: 1.25; background: rgba(255, 255, 255, .035); box-shadow: inset 0 0 0 1px rgba(140, 115, 68, .34); border-radius: 3px; }
body.touch #folkTalk li kbd, body.touch #heroTalk li kbd, body.touch #hirePanel li kbd { display: none; }
body.touch .tk-tabs button { min-height: 38px; padding: 4px 16px; }
body.touch .tk-wares { max-height: 46vh; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
body.touch .tk-ember button { width: 38px; height: 34px; }
body.touch .tk-paper { max-height: 34vh; font-size: 14px; padding: 9px 14px; }
/* (The quest log has its own rules for a phone: src/ui/folk.js.) */
body.touch .lands-panel { max-height: calc(100vh - 12px); padding: 12px 16px; }
body.touch .lands-panel button { min-height: 40px; }
body.touch #autoMenu, body.touch #autoLog { max-height: calc(100vh - 12px); padding: 12px 16px; }
body.touch #autoMenu .foot button, body.touch #autoLog .foot button { min-height: 40px; padding: 7px 18px; }
body.touch #hallPanel { width: 98vw; max-height: 94vh; padding: 9px 10px; }
body.touch #hallPanel .cols { grid-template-columns: 1fr; }
body.touch #hallPanel .book { max-height: 34vh; border-right: 0; }
body.touch #hallPanel button.hb { min-height: 34px; }

/* The pack: its × is the way out, and the cells are as big as the screen's height lets them be. What's in your hands is said
   in the bar underneath, and the charm pouch is in the pack's heading (src/ui/inventory.js moves the two). */
body.touch #inv { --cell: min(calc((100vh - 100px) / var(--rows, 8)), calc((100vw - var(--sl) - var(--sr) - 78px) / 16.2), 56px); justify-content: center; gap: 4px; padding: 4px; }
body.touch #invBody { margin-top: 0; gap: 8px; }
body.touch #invBody > .panel:first-child { width: auto; }
body.touch #inv .panel { padding: 5px 8px 8px; }
body.touch #inv .label { margin-bottom: 5px; font-size: 10.5px; }
body.touch #invBar { margin-bottom: 0; width: calc(16.2 * var(--cell) + 42px); max-width: calc(100vw - var(--sl) - var(--sr) - 8px); box-sizing: border-box; font-size: 11.5px; gap: 10px; padding: 3px 10px; }
body.touch #invBar #invStats { flex: 1 1 0; width: auto; min-width: 0; min-height: 0; margin: 0; font-size: 11.5px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #invBar #invStats br { display: none; }
body.touch #invBar #invStats b::after { content: '  \00b7  '; color: var(--gold-dim); }
body.touch #invHelp { display: none; }
body.touch #invNote { min-width: 0; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #inv #charmRow { grid-template-columns: repeat(10, 17px); gap: 2px; width: auto; margin: 0 auto 0 14px; }
body.touch #inv #charmRow .ch img { width: 16px; height: 16px; }
body.touch #invClose { display: none; }
body.touch .slot span { font-size: 8.5px; letter-spacing: .03em; }
body.touch #invSort { height: 40px; padding: 0 16px; margin-top: 0; font-size: 12px; }
body.touch #inv .inv-head { margin-bottom: 4px; }
body.touch #inv .inv-head .menu-x { margin: 0 -4px 0 0; }
body.touch #invTip, body.touch #invTip2 { max-width: min(300px, 44vw); font-size: 13px; padding: 7px 10px; }

/* The book. */
body.touch #spellClose { min-width: 44px; height: 40px; }
body.touch .tspend { min-height: 42px; }
body.touch .tslots { gap: 4px; }
body.touch .tslots button { max-width: 38px; height: 36px; }
body.touch .tbranch { padding: 8px 10px; }
body.touch #treeTabs button { min-height: 36px; }

/* The big map has the whole screen, and its own buttons to shut it. */
body.touch #mapBig { background: rgba(4, 3, 2, .82); gap: 0; pointer-events: auto; }
body.touch #mapBigCanvas { width: calc(100vw - var(--sl) - var(--sr) - 12px); height: calc(100vh - 12px); }
body.touch .mapTitle { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 1; padding: 2px 14px; background: rgba(8, 6, 4, .7); font-size: 15px; pointer-events: none; }
body.touch .mapKey { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 3px 10px; background: rgba(8, 6, 4, .7); font-size: 10.5px; white-space: nowrap; pointer-events: none; }
body.touch .mapKey .onTouch { display: none; }
body.touch .mapBtns { right: 10px; bottom: 10px; gap: 8px; }
body.touch .mapBtns button { width: 44px; height: 44px; border-radius: 50%; }

/* The pause, and the title's menu: two by three, each a thumb's size. */
body.touch #pause { background: rgba(4, 3, 2, .74); }
body.touch #pause .t-menu, #title.is-touch .t-main .t-menu { display: grid; grid-template-columns: repeat(2, minmax(180px, 250px)); gap: 7px 10px; }
body.touch #pause .t-btn, #title.is-touch .t-main .t-menu .t-btn { min-height: 44px; padding: 6px 12px; font-size: clamp(13px, 3.800vh, 17px); letter-spacing: .16em;
  background: linear-gradient(180deg, rgba(40, 31, 22, .82), rgba(14, 11, 8, .82)); box-shadow: inset 0 0 0 1px rgba(154, 118, 56, .55), 0 2px 8px rgba(0, 0, 0, .6); border-radius: 3px; }
body.touch #pause .t-btn::before, body.touch #pause .t-btn::after, #title.is-touch .t-main .t-menu .t-btn::before, #title.is-touch .t-main .t-menu .t-btn::after { display: none; }
#title.is-touch .t-btn.small { min-height: 38px; padding: 6px 16px; }
#title.is-touch .t-dbtns .t-btn { min-height: 42px; }
#title.is-touch .t-set label { min-height: 40px; }
#title.is-touch .t-set select { min-height: 36px; font-size: 14px; }
#title.is-touch .t-set input[type=range] { height: 34px; }
#title.is-touch .t-set input[type=range]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -9px; }
#title.is-touch .t-slot { min-height: 44px; }
@media (max-height: 480px) { body.touch #pause .p-title { font-size: 20px; margin-bottom: 8px; } }

/* ============================================================ painted pieces ============================================================ */
/* Each one from the art kit takes the place of what's drawn above, where it has come back (src/ui/skin.js). */
html.art-btn_round .tbtn:not(#bMap):not(#bAttack):not(#bCast):not(#bTake) { background: var(--art-btn_round) center / 100% 100% no-repeat; box-shadow: none; }
html.art-btn_round_on .tbtn.down:not(#bMap):not(#bAttack):not(#bCast):not(#bTake), html.art-btn_round_on .tbtn.on:not(#bMap):not(#bAttack):not(#bCast):not(#bTake) { background-image: var(--art-btn_round_on); filter: none; box-shadow: none; }
html.art-btn_main #bAttack, html.art-btn_main #bCast { background: var(--art-btn_main) center / 100% 100% no-repeat; box-shadow: none; }
html.art-btn_main_on #bAttack.down, html.art-btn_main_on #bCast.down { background-image: var(--art-btn_main_on); filter: none; }
html.art-btn_round #bTake { background: var(--art-btn_round_on, var(--art-btn_round)) center / 100% 100% no-repeat; box-shadow: 0 0 calc(14 * var(--u)) rgba(241, 214, 138, .5); color: #fff6dc; }
html.art-slot_spell #spells .spell { background: var(--art-slot_spell) center / 100% 100% no-repeat; border: 0; border-radius: 50%; box-shadow: none; }
html.art-slot_spell #spells .spell.empty { opacity: .6; }
html.art-slot_spell_on #spells .spell.now { background-image: var(--art-slot_spell_on); box-shadow: 0 0 12px -3px var(--c); }
/* (The Utility three over the painted frame: a thin ring of pale bone round it.) */
html.art-slot_spell #spells .spell.util:not(.now):not(.up):not(.down) { box-shadow: 0 0 0 1.5px rgba(233, 223, 201, .42); }
html.art-spells #spells .spell svg { width: 74%; height: 74%; }
/* (On a desk a painted spell fills its own square and the frame's well is about three quarters of the slot: the picture is
   drawn at two thirds, in the middle of it. The slot is a grid, so it's the middle whatever its size.) */
html.art-spells body:not(.touch) #spells .spell svg { width: 66%; height: 66%; filter: none; }
html.art-slot_spell body:not(.touch) #spells .spell .cd { inset: 12%; }
/* (the book, the quest log and the view beside the bar: the painted round button, lit while it's on) */
html.art-btn_round body:not(.touch) :is(#spellOpen, #questOpen, #partyOpen, #viewBtn) { background: var(--art-btn_round) center / 100% 100% no-repeat; box-shadow: 0 2px 8px rgba(0, 0, 0, .7); }
html.art-btn_round body:not(.touch) #spellOpen.pts { box-shadow: 0 0 0 2px #f1d68a, 0 0 16px 2px rgba(241, 214, 138, .7); }
html.art-btn_round_on body:not(.touch) #viewBtn.on { background-image: var(--art-btn_round_on); box-shadow: 0 0 10px rgba(241, 214, 138, .45); }
/* (the painted frame's band is a ninth of its width on each side: the frame is let out a little past the map's place and
   the map drawn in to sit inside it, so nothing beside the map is crowded) */
html.art-frame_map #mapRing { box-shadow: none; border-radius: 0; background: var(--art-frame_map) center / 100% 100% no-repeat; transform: scale(1.08); }
html.art-frame_map #mapMini { transform: scale(.85); border-radius: 2px; }
html.art-medallion #levelBox { background: var(--art-medallion) center / 100% 100% no-repeat; border: 0; box-shadow: none; }
html.art-medallion #levelBox::after { content: ''; position: absolute; inset: 12%; border-radius: 50%; z-index: -1; background: conic-gradient(from 180deg, var(--xp) calc(var(--xpf, 0) * 1%), transparent 0); -webkit-mask: radial-gradient(circle, transparent 0 62%, #000 63%); mask: radial-gradient(circle, transparent 0 62%, #000 63%); }
html.art-stick_base #stick, html.art-stick_base #stickHome { background: var(--art-stick_base) center / 100% 100% no-repeat; box-shadow: none; }
html.art-stick_nub #nub { background: var(--art-stick_nub) center / 100% 100% no-repeat; box-shadow: none; }
html.art-bar_frame #vitals { isolation: isolate; }
html.art-bar_frame #vitals::before { content: ''; position: absolute; inset: -9px -17px; z-index: -1; border-style: solid; border-width: 0 24px; border-image: var(--art-bar_frame) 0 56 fill / 0 24px stretch; }
html.art-bar_frame #vitals .meter, html.art-bar_frame #vitals #mana, html.art-bar_frame #vitals #stam { box-shadow: none; background: rgba(0, 0, 0, .55); }
html.art-bar_life #hp > i { background: var(--art-bar_life) 0 50% / auto 100% repeat-x; }
html.art-bar_mana #mana > i { background: var(--art-bar_mana) 0 50% / auto 100% repeat-x; }
html.art-bar_stamina #stam > i { background: var(--art-bar_stamina) 0 50% / auto 100% repeat-x; }
html.art-bar_foe #foeHp > i, html.art-bar_foe #bossFrame .bb i { background: var(--art-bar_foe) 0 50% / auto 100% repeat-x; }
/* (a cell of the paper doll, cut in nine, so the tall one for the staff keeps its corners) */
html.art-slot_item .slot, html.art-slot_item #charmRow .ch { border: 1px solid transparent; border-image: var(--art-slot_item) 40 fill / 8px stretch; background: none; }
html.art-slot_item #charmRow .ch { border-image-width: 4px; }
html.art-slot_item .slot.full { box-shadow: inset 0 0 0 1px var(--rc), inset 0 0 14px -6px var(--rc); }
/* (the windows: a frame cut in nine, its corners kept and its sides drawn out) */
/* (The painted frame's band is 28 of its 512 across and its corner pieces about 60, so it's cut 72 from each edge. --pw is
   how wide that cut is drawn: the band comes out two fifths of it. The frame stands a little outside the panel's own edge
   (--po), and the panel keeps its words clear of the band with a border of its own (--pb). The sides are laid end to end,
   not drawn out, so the beading keeps its shape.) */
html.art-panel { --pw: 34px; --po: 6px; --pb: 13px; }
html.art-panel body.touch { --pw: 26px; --po: 5px; --pb: 9px; }
html.art-panel :is(#inv .panel, #folkTalk, #folkBook, #heroTalk, #hirePanel, #hallPanel, .lands-panel, #title .t-frame, #treeInfo, #invTip, #invTip2, #autoMenu, #autoLog) {
  border: var(--pb) solid transparent; border-image: var(--art-panel) 72 fill / var(--pw) / var(--po) round; background: none; box-shadow: none; outline: 0; }
html.art-panel #treeInfo { --pw: 22px; --po: 3px; --pb: 8px; padding: 6px 8px; }
html.art-panel body.touch #inv { --cell: min(calc((100vh - 120px) / var(--rows, 8)), calc((100vw - var(--sl) - var(--sr) - 112px) / 16.2), 56px); gap: 9px; }
html.art-panel body.touch #invBody { gap: 14px; }
html.art-panel #title .t-frame::before { display: none; }
html.art-panel :is(#invTip, #invTip2) { --pw: 20px; --po: 4px; --pb: 6px; padding: 5px 8px; }
html.art-panel #inv .panel { padding: 0 2px 2px; }
html.art-paper .tk-paper { border: 12px solid transparent; border-image: var(--art-paper) 56 fill / 22px / 6px stretch; background: none; box-shadow: none; padding: 6px 10px; }
/* (A plate is 384 by 128, its garnet ends 44 in and its band 24 deep: cut there, and drawn at a plate's own height.) */
html.art-button :is(#invSort, #invClose, #spellClose, .tspend, .lands-panel button, #folkBook button:not(.menu-x), #autoMenu .foot button, #autoLog .foot button, #hallPanel button.hb, body.touch #pause .t-btn, #title.is-touch .t-main .t-menu .t-btn) {
  border: solid transparent; border-width: 7px 14px; border-image: var(--art-button) 24 44 fill / 8px 15px / 1px stretch; background: none; box-shadow: none; color: #f3e6c4; }
html.art-button :is(body.touch #pause .t-btn, #title.is-touch .t-main .t-menu .t-btn) { border-width: 8px 18px; border-image-width: 11px 20px; }
html.art-button .tspend { text-shadow: 0 1px 2px #000; }
html.art-button_on :is(#invSort, #invClose, #spellClose, .tspend, .lands-panel button, #folkBook button:not(.menu-x), #hallPanel button.hb, #autoMenu .foot button, body.touch #pause .t-btn, #title.is-touch .t-main .t-menu .t-btn):is(:hover, :active, .on) { border-image-source: var(--art-button_on); }
html.art-button_on .tspend { border-image-source: var(--art-button_on); }
html.art-btn_round .mapBtns button { border: 0; border-radius: 50%; background: var(--art-btn_round) center / 100% 100% no-repeat; color: #f3e6c4; }
html.art-tab :is(#treeTabs button, .tk-tabs button) { border: solid transparent; border-width: 5px 10px; border-image: var(--art-tab) 34 36 fill / 8px 10px / 1px stretch; background: none; }
html.art-tab #treeTabs button { padding-left: 4px; padding-right: 4px; }
html.art-tab_on :is(#treeTabs button, .tk-tabs button).on { border-image-source: var(--art-tab_on); color: #fff4d2; }
/* The icons, on their buttons: a little bigger than the drawn ones, and lifted so the darker ones read on a dark boss. */
html.art-icons .tbtn { --ic-size: 68%; }
html.art-icons #dock .tbtn { --ic-size: 72%; }
html.art-icons #bAttack, html.art-icons #bCast { --ic-size: 62%; }
html.art-icons .tbtn[data-ic]::before { filter: brightness(1.28) saturate(1.08) drop-shadow(0 1px 1px rgba(0, 0, 0, .85)); }
html.art-icons #bTake::before { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .9)); }
html.art-rule .t-rule { height: 14px; width: 80%; background: var(--art-rule) center / 100% 100% no-repeat; }
html.art-rule .t-rule::after { display: none; }

/* (the upright notice's own picture and words) */
#rotate > .lb { position: static; transform: none; font: inherit; letter-spacing: inherit; text-transform: none; white-space: normal; text-shadow: none; }

/* The living land (src/ui/wilds.js): a banner for what's begun or done, a tracker under it while something's on. */
#wildBanner { position: absolute; left: 50%; top: 21%; transform: translate(-50%, -8px); max-width: min(620px, 86vw); text-align: center; pointer-events: none; opacity: 0; transition: opacity .5s, transform .5s; z-index: 6; }
#wildBanner.on { opacity: 1; transform: translate(-50%, 0); }
#wildBanner b { display: block; font: 600 26px/1.15 Cinzel, 'Trajan Pro', Georgia, serif; letter-spacing: .2em; color: #f0dca6; text-shadow: 0 0 14px rgba(0, 0, 0, .95), 0 2px 3px #000; }
#wildBanner i { display: block; margin-top: 6px; font: italic 15px/1.3 Georgia, serif; color: #e6dcc6; text-shadow: 0 0 8px #000, 0 1px 2px #000; }
#wildTrack { position: absolute; left: 50%; top: 13.5%; transform: translateX(-50%); min-width: 230px; max-width: min(460px, 80vw); padding: 6px 14px 8px; text-align: center; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: rgba(8, 6, 4, .58); box-shadow: 0 0 0 1px rgba(200, 170, 110, .35); border-radius: 3px; z-index: 6; }
#wildTrack.on { opacity: 1; }
#wildTrack b { display: block; font: 600 12.5px/1.2 Cinzel, Georgia, serif; letter-spacing: .18em; color: #e9cf8f; }
#wildTrack i { display: block; margin-top: 3px; font: 13px/1.25 Georgia, serif; font-style: normal; color: #ddd3bd; }
#wildTrack u { display: block; height: 3px; margin-top: 6px; background: rgba(255, 255, 255, .12); text-decoration: none; }
#wildTrack u s { display: block; height: 100%; width: 0; background: #c9a24e; transition: width .25s linear; }
body.touch #wildBanner b { font-size: calc(15 * var(--u)); } body.touch #wildBanner i { font-size: calc(11.5 * var(--u)); margin-top: 2px; }
body.touch #wildTrack { min-width: 0; max-width: 100%; padding: calc(3 * var(--u)) calc(10 * var(--u)) calc(4 * var(--u)); } body.touch #wildTrack b { font-size: calc(10.5 * var(--u)); } body.touch #wildTrack i { font-size: calc(11 * var(--u)); margin-top: 1px; }
/* (In the stack they take room only while they're up.) */
body.touch #topStack #wildTrack:not(.on), body.touch #topStack #wildBanner:not(.on) { display: none; }
body.touch #topStack #wildBanner { max-width: 100%; }

/* The beacon stone's fifteen seconds (src/ui/beacon.js): a bar over the middle of the screen, filling in blue. */
#beaconCast { position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 6; width: min(300px, 70vw); display: none;
  pointer-events: none; text-align: center; font: 600 13px/1.2 Georgia, serif; color: #d8ecff; text-shadow: 0 1px 2px #000; }
#beaconCast.on { display: block; }
#beaconCast .bc-bar { height: 9px; margin: 4px 0 3px; border: 1px solid rgba(160,200,240,.55); background: rgba(6,10,18,.65); box-shadow: 0 0 10px rgba(80,160,255,.35); }
#beaconCast .bc-bar i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #2a6fd8, #7fc4ff); }
#beaconCast .bc-left { font-size: 11.5px; opacity: .8; }
body.paused #beaconCast { display: none; }
