/* Cozy parchment and wood. Everything scales with the viewport so it works on a phone. */
:root {
  --paper: #f7e9cb; --paper2: #ead6ad; --ink: #3a2a1a; --ink2: #6b5440; --wood: #6b4a2e; --wood2: #8a5a34;
  --good: #4f8a3c; --good2: #66a64e; --bad: #b4382c; --gold: #f2c94c;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --slot: min(48px, calc((100vw - 60px) / 11));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1e1610; color: var(--ink); font-family: 'DotGothic16','Pixelify Sans', system-ui, sans-serif; font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'clig' 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; image-rendering: pixelated; cursor: pointer; }
/* (a double tap on a button inside a panel, where text can be selected, used to select its words: issue #34) */
button, summary { font-family: inherit; color: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button:disabled { cursor: default; }
input, textarea, select, button { font-variant-ligatures: none; }
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--ink); background: #fffaf0; border: 2px solid var(--wood2); border-radius: 6px; padding: 8px 10px; width: 100%; user-select: text; -webkit-user-select: text; }
textarea { resize: vertical; margin: 6px 0; }
.box { background: var(--paper); border: 3px solid var(--wood); border-radius: 10px; box-shadow: 0 3px 0 rgba(0, 0, 0, .35), inset 0 0 0 2px var(--paper2); }
.hud { position: fixed; z-index: 5; pointer-events: none; }
.hud > * { pointer-events: auto; }

/* top: party frames, clock, buttons */
#hud-top { top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
#hud-top .spacer { flex: 1; pointer-events: none; }
#party { display: flex; flex-direction: column; gap: 5px; }
.frame { display: grid; grid-template-columns: 34px auto; grid-template-rows: auto auto; column-gap: 7px; align-items: center; padding: 4px 10px 4px 5px; min-width: 120px; text-align: left; border-radius: 8px; }
.frame .portrait { grid-row: span 2; width: 34px; height: 29px; image-rendering: pixelated; background: #cfe6a8; border-radius: 5px; border: 2px solid var(--wood2); }
.frame .fname { font-weight: 700; font-size: 15px; line-height: 1; }
.frame .fsub { font-size: 11px; color: var(--ink2); line-height: 1.1; }
.frame.off { opacity: .72; filter: saturate(.6); }
.frame.off .portrait { background: #c8c0b0; }
.frame.mine { background: #fff3d6; }
#status { padding: 6px 12px; text-align: right; }
#clock { font-size: 15px; font-weight: 600; white-space: nowrap; }
#gold { font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.coin { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8 0 20%, var(--gold) 21% 70%, #c8962a 71%); vertical-align: middle; box-shadow: 0 1px 0 #8a6020; flex: none; }
.coin.big { width: 22px; height: 22px; }
/* (#55) a column, and when there's no more room above the spells, more to its left, below the
   clock (ui.ts fitButtons places each one): right to left, so the first column stays at the edge */
#buttons { display: grid; grid-auto-flow: column; gap: 5px; direction: rtl; align-content: start; pointer-events: none; }
#buttons > * { direction: ltr; pointer-events: auto; }
.hbtn { position: relative; width: 42px; height: 42px; font-size: 20px; border-radius: 10px; background: var(--paper); border: 3px solid var(--wood); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); padding: 0; }
.hbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; line-height: 18px; padding: 0 4px; border: 2px solid #fff3d6; }

/* bottom: hotbar and meters */
#bottom { left: 50%; transform: translateX(-50%); bottom: calc(8px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hotbar { display: flex; gap: 3px; padding: 4px; background: rgba(60, 40, 24, .85); border-radius: 10px; border: 3px solid var(--wood); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.slot { position: relative; width: var(--slot); height: var(--slot); padding: 0; border-radius: 7px; background: var(--paper2); border: 2px solid #b08a5a; display: flex; align-items: center; justify-content: center; }
.slot.sel { background: #fff6d8; border-color: #f2a83a; box-shadow: 0 0 0 2px #f2a83a; }
.slot .ico { width: 78%; height: 78%; image-rendering: pixelated; pointer-events: none; }
.slot .n { position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #3a2a1a, -1px -1px 0 #3a2a1a, 1px -1px 0 #3a2a1a, -1px 1px 0 #3a2a1a; }
.slot .k { position: absolute; left: 3px; top: 0; font-size: 9px; color: var(--ink2); }
.slot.bag { font-size: calc(var(--slot) * .5); background: #d8b880; }
.slot.small { --slot: 34px; }
.ico { image-rendering: pixelated; width: 32px; height: 32px; flex: none; }
.ico.tiny { width: 16px; height: 16px; vertical-align: middle; }
.ico.big { width: 44px; height: 44px; }
.meter { width: 160px; height: 9px; border-radius: 5px; background: rgba(40, 30, 20, .7); border: 2px solid var(--wood); overflow: hidden; }
#water-fill { height: 100%; background: linear-gradient(#8fd8f0, #3c8ac0); }

/* spells, right side */
#spells { right: calc(8px + var(--safe-r)); bottom: calc(80px + var(--safe-b)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#spells .mana { width: 46px; height: 8px; border-radius: 4px; background: rgba(40, 30, 50, .75); border: 2px solid #4a3a6a; overflow: hidden; }
#mana-fill { height: 100%; background: linear-gradient(90deg, #8a6ae0, #c8b4ff); }
.spell { position: relative; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; background: radial-gradient(circle at 40% 35%, #5a4a8a, #2a2050); border: 3px solid #b48cff; box-shadow: 0 3px 0 rgba(0, 0, 0, .4), 0 0 10px rgba(180, 140, 255, .4); padding: 0; }
.spell.sel { box-shadow: 0 0 0 3px #fff, 0 0 16px #b48cff; }
.spell .k { position: absolute; bottom: -3px; right: -2px; font-size: 10px; background: #2a2050; color: #e8dcff; border-radius: 4px; padding: 0 3px; }

/* chat */
#chat { left: calc(8px + var(--safe-l)); bottom: calc(76px + var(--safe-b)); width: min(360px, 60vw); display: flex; flex-direction: column; gap: 4px; }
#chat-log { max-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; pointer-events: none; scrollbar-width: none; }
#chat-log .line { font-size: 14px; color: #fff; text-shadow: 1px 1px 0 #2a1a0a, -1px 0 0 #2a1a0a, 0 -1px 0 #2a1a0a, 1px 0 #2a1a0a; transition: opacity 1s; }
#chat-log .line b { color: #9cf09c; }
#chat-log .line.sys { color: #ffe9a8; font-style: italic; }
#chat-log .line.old { opacity: 0; }
#chat.typing #chat-log .line.old { opacity: .85; }
#chat-form { display: none; }
#chat.typing #chat-form { display: block; }

/* mobile controls */
#stick { position: fixed; z-index: 4; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: rgba(255, 245, 220, .18); border: 3px solid rgba(255, 245, 220, .45); display: none; pointer-events: none; left: 90px; top: calc(100% - 170px); }
#stick.on, body.touch #stick { display: block; }
#stick.on { z-index: 7; } /* (while steering, over the hotbar: a thumb low down still sees its knob; it takes no touches) */
body.touch #stick:not(.on) { opacity: .5; left: calc(80px + var(--safe-l)) !important; top: calc(100% - 160px - var(--safe-b)) !important; }
#knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 245, 220, .75); border: 3px solid var(--wood); transform: translate(-50%, -50%); }
#act-btn { display: none; right: calc(14px + var(--safe-r)); bottom: calc(86px + var(--safe-b)); width: 74px; height: 74px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff6d8, var(--paper2)); border: 4px solid var(--wood); box-shadow: 0 4px 0 rgba(0, 0, 0, .4); font-size: 30px; padding: 0; align-items: center; justify-content: center; }
body.touch #act-btn { display: flex; }
body.touch #spells { bottom: calc(176px + var(--safe-b)); }
body.touch #chat { bottom: calc(220px + var(--safe-b)); }
/* On a phone, while the abilities fan out round the action button (platform.css's thumb arc), the
   chat steps clear of it: up past ability 6 and narrow enough to stop short of ability 7 (M12). */
@media (max-width: 600px) {
  body.touch:has(#abilities:not([style*="none"])) #chat { bottom: calc(230px + var(--safe-b)); width: min(360px, 60vw, calc(100vw - 165px - var(--safe-l) - var(--safe-r))); }
}
#planbar { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(64px + var(--safe-t)); display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-weight: 600; }

/* toasts */
#toasts { position: fixed; z-index: 30; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(58, 42, 26, .94); color: #fff6e0; padding: 8px 14px; border-radius: 8px; border: 2px solid var(--wood2); font-size: 15px; text-align: center; transition: opacity .5s, transform .5s; animation: pop .25s; }
.toast.good { background: rgba(60, 100, 50, .95); border-color: #9cd07c; }
.toast.out { opacity: 0; transform: translateY(-8px); }
/* a story: kept until it's tapped (issue #68) */
.toast.story { pointer-events: auto; cursor: pointer; line-height: 1.35; padding: 10px 16px 7px; }
.toast-x { display: block; margin-top: 5px; font-size: 12px; opacity: .7; }
.toast-x::after { content: 'click to close'; }
body.touch .toast-x::after { content: 'tap to close'; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

/* panels */
#panel-root { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; }
#panel-root.on { display: flex; }
.backdrop { position: absolute; inset: 0; background: rgba(20, 12, 6, .45); }
.panel { position: relative; width: min(440px, 94vw); max-height: min(88vh, 720px); display: flex; flex-direction: column; animation: pop .18s; }
.panel.wide { width: min(560px, 96vw); }
.ptitle { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 6px 14px; font-size: 20px; font-weight: 700; border-bottom: 2px solid var(--paper2); }
.x { width: 34px; height: 34px; border-radius: 8px; background: var(--paper2); border: 2px solid var(--wood2); font-size: 16px; }
/* "‹": back to the panel this one was opened from (#70) */
.ptitle .grow { flex: 1; min-width: 0; }
.ptitle .back { flex: none; margin: 0 10px 0 -6px; font-size: 26px; line-height: 1; padding-bottom: 4px; font-weight: 700; }
.pbody { padding: 10px 14px 14px; overflow-y: auto; user-select: text; -webkit-user-select: text; }
/* a value that just changed (a count, the purse): a little bigger and aglow, settling back over a second */
.bump { animation: bump 1s ease-out; }
.bump-i { display: inline-block; }
@keyframes bump { from { scale: 1.05; text-shadow: 0 0 6px rgba(255, 196, 58, .95); } }
@media (max-width: 600px) {
  #panel-root { align-items: flex-end; }
  .panel, .panel.wide { width: 100vw; max-height: 82vh; border-radius: 14px 14px 0 0; border-bottom: none; padding-bottom: var(--safe-b); }
}
.btn { background: var(--paper2); border: 2px solid var(--wood2); border-radius: 8px; padding: 7px 12px; font-size: 15px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.good { background: var(--good2); color: #fff; border-color: var(--good); text-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.btn.danger { background: #e8b0a0; border-color: var(--bad); margin-top: 8px; }
.btn.big { font-size: 18px; padding: 10px 18px; margin-top: 10px; }
.btn.tiny { padding: 2px 8px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.btns.col { flex-direction: column; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tab { flex: 1; padding: 7px; border-radius: 8px 8px 0 0; background: var(--paper2); border: 2px solid var(--wood2); border-bottom-width: 0; font-weight: 600; font-size: 15px; opacity: .7; }
.tab.sel { opacity: 1; background: #fff6d8; }
.grid.inv { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 6px 0; --slot: 100%; }
.grid.inv .slot { width: 100%; height: auto; aspect-ratio: 1; }
.grid.inv.small { grid-template-columns: repeat(10, 1fr); }
.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #fffaf0; border: 2px solid var(--paper2); border-radius: 8px; text-align: left; font-size: 15px; }
.row.dim { opacity: .55; }
.row .grow { flex: 1; min-width: 0; }
.row .big, .big { font-size: 26px; }
.row.unread { border-color: #f2a83a; background: #fff6d8; }
.row.gift { border-color: var(--good2); margin: 8px 0; }
.mailrow { width: 100%; }
.sub { font-size: 12.5px; color: var(--ink2); }
.need { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-top: 2px; }
.need span { display: inline-flex; align-items: center; gap: 2px; }
.need .no { color: var(--bad); }
.need.col { flex-direction: column; gap: 4px; }
.giverow { display: flex; align-items: center; gap: 6px; }
.giverow .bar { flex: 1; }
[data-tip] { cursor: help; }
/* a little tooltip bubble (ui.ts showTip, #22) */
#tip { position: fixed; z-index: 35; display: none; max-width: min(260px, 80vw); padding: 6px 9px; background: #fffaf0; color: var(--ink); border: 2px solid var(--wood2); border-radius: 8px; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); font-size: 13px; line-height: 1.3; pointer-events: none; }
#tip.on { display: block; }
#tip b { display: block; font-size: 14px; margin-bottom: 2px; }
/* the hotbar's bubble (#66) looks like a placed piece's card (#67): its icon by its name, a hint under a rule */
#tip .tip-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
#tip .tip-head b { margin: 0; }
#tip .tip-head .ico { width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
#tip .tip-hint { margin-top: 4px; padding-top: 3px; border-top: 1px dashed var(--paper2); color: var(--wood2); font-size: 11.5px; }
.price { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.hint { font-size: 13.5px; color: var(--ink2); margin: 6px 0; }
/* the bag's words about what you picked: always three lines' room (a longer one scrolls), so the bag keeps its size (#25) */
.bagfoot .hint { line-height: 1.3; height: 3.9em; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--wood2) transparent; }
/* the Shipping Bin's buttons, one width whatever the number on them (#21) */
.shiprow .btn { min-width: 6.6em; text-align: center; }
.npc { font-style: italic; margin: 0 0 8px; }
.bar { height: 9px; border-radius: 5px; background: var(--paper2); border: 1px solid var(--wood2); overflow: hidden; margin: 3px 0; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--good2), #9cd07c); }
.goal { padding: 8px 10px; background: #fffaf0; border: 2px solid var(--paper2); border-radius: 8px; }
.goal.done { background: #eef6e0; border-color: #b8d89c; }
.goal .gh { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hearts { color: #e2445c; font-size: 13px; letter-spacing: 1px; }
.letter { background: #fffaf0; border: 2px solid var(--paper2); border-radius: 8px; padding: 10px 14px; font-size: 15.5px; line-height: 1.4; white-space: pre-wrap; }
.letter p { margin: 0 0 8px; }
.journal .jl { font-size: 14px; padding: 3px 0; border-bottom: 1px dashed var(--paper2); }
.ready div { font-size: 15px; padding: 3px 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 52px; height: 40px; border-radius: 8px; border: 3px solid var(--wood2); font-size: 16px; }
.swatch.sel { box-shadow: 0 0 0 3px #f2a83a; }
.friend { text-align: center; }
.friend .portrait { width: 84px; height: 72px; image-rendering: pixelated; background: #cfe6a8; border-radius: 10px; border: 3px solid var(--wood2); }
h4 { margin: 12px 0 4px; }
label { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* the welcome screen */
#overlay { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, #4f8a46, #1e3a24); padding: 16px; }
#overlay.on { display: flex; }
.intro { width: min(420px, 100%); padding: 18px 20px; text-align: center; max-height: 96vh; overflow-y: auto; }
.intro h1 { margin: 0 0 4px; font-size: 40px; color: var(--wood); text-shadow: 0 3px 0 var(--paper2); letter-spacing: 1px; }
.intro p { margin: 6px 0 12px; font-size: 16px; line-height: 1.35; }
.look { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.look .preview { width: 216px; height: 99px; image-rendering: pixelated; align-self: center; background: #cfe6a8; border-radius: 10px; border: 3px solid var(--wood2); }
.opt { display: grid; grid-template-columns: 80px 34px 1fr 34px; align-items: center; gap: 6px; font-weight: 600; }
.opt .sw { height: 26px; border-radius: 6px; border: 2px solid var(--wood2); }
.opt .swn { text-align: center; text-transform: capitalize; }
#offline { position: fixed; z-index: 50; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 8px; display: none; font-weight: 600; }
body.offline #offline { display: block; }

@media (max-width: 600px) {
  .frame { min-width: 0; padding: 3px 7px 3px 3px; grid-template-columns: 28px auto; }
  .frame .portrait { width: 28px; height: 24px; }
  .frame .fname { font-size: 13px; }
  .frame .fsub { font-size: 10px; }
  #clock { font-size: 13px; }
  #gold { font-size: 15px; }
  .hbtn { width: 38px; height: 38px; font-size: 17px; }
  .slot .k { display: none; }
}
@media (max-height: 500px) {
  #party .frame:nth-child(n+4) { display: none; }
}

/* ------------------------------------------------------------------ the Wildwood HUD */
.frame .flvl { font-size: 12px; font-weight: 700; }
.frame .fbars { grid-column: 1 / span 2; display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.hpbar, .resbar { height: 6px; border-radius: 3px; background: rgba(40, 20, 10, .35); overflow: hidden; }
.resbar { height: 4px; }
.hpbar .hp { height: 100%; background: linear-gradient(#7ad35a, #3f9a2c); transition: width .2s; }
.resbar .res { height: 100%; transition: width .2s; }
.res.mana { background: linear-gradient(#7aaaf0, #3a64c0); }
.res.energy { background: linear-gradient(#ffe680, #e0b020); }
.frame.dead { filter: grayscale(.8); }
.frame.dead .fsub { color: var(--bad); font-weight: 700; }

#target { position: fixed; z-index: 6; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 5px 8px; min-width: 230px; }
#target.elite { border-color: #c8962a; box-shadow: 0 3px 0 rgba(0, 0, 0, .35), inset 0 0 0 2px #f2c94c; }
#target.rare { border-color: #8890a0; box-shadow: 0 3px 0 rgba(0, 0, 0, .35), inset 0 0 0 2px #d8e0f0; }
.tf-pic { width: 40px; height: 40px; image-rendering: pixelated; background: #2a3a2a; border-radius: 50%; border: 2px solid var(--wood2); }
.tf-main { flex: 1; min-width: 0; }
.tf-top { display: flex; gap: 6px; align-items: baseline; font-size: 15px; }
.tf-lvl { font-weight: 700; text-shadow: 1px 1px 0 #2a1a0a; }
.tag { font-size: 11px; background: #f2c94c; color: #5a3c06; padding: 0 4px; border-radius: 4px; }
.tf-bar { position: relative; height: 12px; border-radius: 4px; background: rgba(40, 20, 10, .4); overflow: hidden; margin: 2px 0; }
#tf-fill { height: 100%; background: linear-gradient(#e86a4a, #b4382c); transition: width .15s; }
#tf-hp { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 12px; color: #fff; text-shadow: 1px 1px 0 #000; }
.tf-sub { font-size: 12px; display: flex; gap: 8px; color: var(--ink2); }
#tf-cp { color: #d84030; letter-spacing: 1px; }
.cc { color: #3c6aa0; }
#target .x { width: 26px; height: 26px; font-size: 12px; }

#abilities { left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); display: flex; gap: 5px; }
.ab { position: relative; width: 50px; height: 50px; border-radius: 10px; padding: 0; background: radial-gradient(circle at 40% 30%, #5a4a6a, #2a2034); border: 3px solid #8a6aa0; box-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.ab .abi { font-size: 24px; line-height: 44px; }
.ab .k { position: absolute; left: 3px; top: 0; font-size: 10px; color: #e8dcff; }
.ab .cd { position: absolute; inset: 0; border-radius: 7px; pointer-events: none; }
.ab.poor { filter: saturate(.3) brightness(.6); }
.ab.far { border-color: #d84030; }
.ab.on { border-color: #fff; box-shadow: 0 0 12px #b48cff; }
.ab:active { transform: translateY(2px); }
#castbar { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(158px + var(--safe-b)); width: 220px; height: 16px; border-radius: 8px; background: rgba(30, 20, 40, .8); border: 2px solid #b48cff; overflow: hidden; }
#cast-fill { height: 100%; background: linear-gradient(90deg, #8a6ae0, #e8dcff); }
#cast-name { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 12px; color: #fff; text-shadow: 1px 1px 0 #000; }
#xpbar { position: relative; width: min(520px, 92vw); height: 10px; border-radius: 5px; background: rgba(30, 20, 40, .75); border: 2px solid #5a3a7a; overflow: hidden; }
.xp-fill, .xp-rest { position: absolute; left: 0; top: 0; bottom: 0; }
.xp-rest { background: rgba(80, 140, 255, .55); }
.xp-fill { background: linear-gradient(90deg, #8a3ab0, #c86ae0); }
#xpbar span { position: absolute; inset: 0; text-align: center; font-size: 9px; line-height: 7px; color: #fff; text-shadow: 1px 1px 0 #000; }
#tracker { right: calc(60px + var(--safe-r)); top: calc(90px + var(--safe-t)); width: 200px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.tq { font-size: 13px; color: #fff; text-shadow: 1px 1px 0 #1a0a00, -1px 0 0 #1a0a00, 0 -1px 0 #1a0a00, 1px 0 #1a0a00; text-align: right; }
.tq b { color: #ffe36e; }
.tq .done { color: #9cf09c; }
#fainted { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse, rgba(60, 50, 80, .2), rgba(20, 10, 30, .55)); }
.faint { padding: 16px 22px; text-align: center; max-width: 360px; }
.faint h2 { margin: 0 0 6px; }
body.fainted canvas#game { filter: grayscale(.7) brightness(.85); }

.callings { display: flex; gap: 10px; flex-wrap: wrap; }
.calling { flex: 1 1 200px; padding: 10px 12px; text-align: left; }
.calling .cname { font-size: 20px; font-weight: 700; text-shadow: 1px 1px 0 #3a2a1a; }
.calling p { margin: 6px 0; font-size: 14px; }
.cabs { font-size: 20px; display: flex; gap: 4px; }
.quest { padding: 8px 10px; margin: 8px 0; background: #fffaf0; border: 2px solid var(--paper2); border-radius: 8px; }
.quest.ready { border-color: #f2c94c; background: #fff6d8; }
.quest.dim { opacity: .6; }
.quest p { margin: 6px 0; font-size: 14px; font-style: italic; }
.quest .qh { display: flex; justify-content: space-between; gap: 8px; }
.quest .done { color: var(--good); }
.reward { font-size: 13px; margin: 4px 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.ri { display: inline-flex; align-items: center; gap: 2px; }
.fampick { padding: 8px; background: #f0e8ff; border-radius: 8px; border: 2px solid #b48cff; }
.btn.fam { display: inline-flex; align-items: center; gap: 6px; }
.famimg { width: 32px; height: 28px; image-rendering: pixelated; }

body.touch #abilities { left: auto; transform: none; right: calc(96px + var(--safe-r)); bottom: calc(80px + var(--safe-b)); flex-wrap: wrap-reverse; justify-content: flex-end; width: 170px; }
body.touch .ab { width: 48px; height: 48px; }
@media (max-width: 600px) {
  #tracker { display: none !important; }
  #target { min-width: 0; width: min(300px, 72vw); top: auto; bottom: calc(236px + var(--safe-b)); }
  #castbar { bottom: calc(240px + var(--safe-b)); }
}
