:root {
  --bg: #12151f; --panel: #1b2030; --panel2: #252c42; --line: #3a4466; --gold: #e8c860; --gold2: #b8923a; --text: #eef0f6; --dim: #9aa3bd; --good: #6ad08a; --bad: #e86a6a; --blue: #6aa8e8; --parch: #e8dcc0;
  --common: #c8ccd8; --uncommon: #6ad08a; --rare: #6aa8e8; --epic: #c08aff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000000; color: var(--text); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); user-select: text; }
.hidden { display: none !important; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; position: relative; background-color: var(--bg); }

/* buttons */
.btn { background: #323d62; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; font-weight: 800; font-size: 16px; text-align: center; box-shadow: 0 3px 0 #0c0f18; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0c0f18; }
.btn.gold { background: #d8b455; color: #1a1408; border-color: #8a6a20; }
.btn.good { background: #48a864; border-color: #2a6a3a; }
.btn.bad { background: #bc4a4a; border-color: #702a2a; }
.btn.small { padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.btn.dis, .btn:disabled { opacity: .4; pointer-events: none; }
.btn.on { outline: 3px solid var(--gold); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.dim { color: var(--dim); } .good-t { color: var(--good); } .bad-t { color: var(--bad); } .gold-t { color: var(--gold); }
.sm { font-size: 13px; } .xs { font-size: 12px; }
.pix { image-rendering: pixelated; }

/* join */
#join { padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; justify-content: center; flex: 1; }
#join h1 { text-align: center; font-size: 34px; letter-spacing: 3px; color: var(--gold); margin: 0; text-shadow: 0 3px 0 #000; }
#join label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 2px; display: block; margin-bottom: 4px; }
#join input { width: 100%; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: #0e1220; font-size: 22px; font-weight: 800; letter-spacing: 4px; text-transform: uppercase; text-align: center; }
#join input.txt { letter-spacing: 1px; text-transform: none; font-size: 20px; }
#join #j-form { display: flex; flex-direction: column; gap: 12px; }
#heroes { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#heroes h1 { margin: 0; font-size: 22px; color: var(--gold); }
#join .err { color: var(--bad); text-align: center; min-height: 20px; }
#join .err:not(:empty) { color: #ffd6d0; background: rgba(40, 8, 8, .88); border: 2px solid var(--bad); border-radius: 10px; padding: 6px 12px; margin: 6px auto; max-width: 92%; font-weight: 700; text-shadow: 0 1px 0 #000; box-shadow: 0 3px 8px rgba(0,0,0,.5); }          /* readable over the login picture */

/* top bar */
#top { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 2px solid var(--gold2); }
#top img { width: 34px; height: 34px; image-rendering: pixelated; background: #2a3354; border-radius: 8px; }
#top .who { flex: 1; min-width: 0; }
#top .nm { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 9px; background: #0c0f18; border-radius: 6px; overflow: hidden; border: 1px solid #000; position: relative; }
.bar > i { display: block; height: 100%; background: #5ac470; }
.bar.low > i { background: #e06a52; }
.bar.xp > i { background: #9d6ae4; }
#top .gold { color: var(--gold); font-weight: 800; white-space: nowrap; }

#stage { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
#nav { display: flex; gap: 6px; padding: 8px; background: var(--panel); border-top: 2px solid var(--line); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#nav .btn { flex: 1; padding: 8px 4px; font-size: 13px; }
#nav .btn .ic { display: block; font-size: 20px; }

/* hub controls */
#hub { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; }
#hub .hint { text-align: center; color: var(--dim); font-size: 14px; }
#pad-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 14px; }
#joy { width: 170px; height: 170px; border-radius: 50%; background: #222a45; border: 3px solid var(--line); position: relative; touch-action: none; flex: none; }
#joy .knob { position: absolute; width: 70px; height: 70px; border-radius: 50%; left: 50px; top: 50px; background: #6a7ac0; border: 3px solid #1a2036; pointer-events: none; }
#act { width: 130px; height: 130px; border-radius: 50%; font-size: 15px; line-height: 1.2; padding: 10px; }
#act b { display: block; font-size: 26px; }

/* overlay */
#overlay { position: absolute; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; }
#overlay .head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-bottom: 2px solid var(--gold2); }
#overlay .head h2 { margin: 0; font-size: 18px; flex: 1; color: var(--gold); }
#overlay .body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.card { background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.card.rare { border-color: var(--rare); } .card.uncommon { border-color: var(--uncommon); } .card.epic { border-color: var(--epic); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .t { font-size: 13px; color: var(--dim); }
.tabs { display: flex; gap: 6px; } .tabs .btn { flex: 1; padding: 8px; font-size: 14px; }
.item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.item .ic { font-size: 28px; text-align: center; }
.item .nm { font-weight: 800; font-size: 15px; }
.item.rare { border-color: var(--rare); } .item.uncommon { border-color: var(--uncommon); } .item.epic { border-color: var(--epic); }
.item.sel { outline: 3px solid var(--gold); }
.item .q { color: var(--gold); font-weight: 800; }
.tag { display: inline-block; font-size: 11px; background: #0e1220; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--dim); margin-left: 4px; }
.tag.eq { color: var(--good); border-color: var(--good); }

.dlg { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.dlg .who { display: flex; align-items: flex-end; gap: 12px; }
.dlg .who img { width: 96px; height: 96px; image-rendering: pixelated; background: #2a3354; border-radius: 12px; border: 2px solid var(--line); object-fit: contain; }
.dlg .who .n { font-size: 20px; font-weight: 800; color: var(--gold); } .dlg .who .t { color: var(--dim); font-size: 13px; }
.bubble { background: var(--parch); color: #2a2418; border-radius: 14px; padding: 14px 16px; font-size: 17px; line-height: 1.4; border: 3px solid #8a6a38; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.choices .btn { text-align: left; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stat { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; text-align: center; padding: 6px 2px; }
.stat.pr { border-color: var(--gold2); }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 11px; color: var(--dim); text-transform: uppercase; } .stat small { display: block; font-size: 11px; color: var(--dim); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.kv div { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; text-align: center; padding: 6px 2px; } .kv b { display: block; font-size: 20px; } .kv span { font-size: 11px; color: var(--dim); text-transform: uppercase; }
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 14px; }
.skills div { display: flex; justify-content: space-between; border-bottom: 1px dotted #2d3550; padding: 2px 0; } .skills .p { color: var(--gold); font-weight: 800; }
.sec { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 2px; margin: 6px 0 -2px; }

.compass { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto auto auto; gap: 8px; max-width: 360px; margin: 0 auto; width: 100%; }
.compass .btn { min-height: 80px; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 20px; }
.compass .btn small { font-size: 12px; font-weight: 600; opacity: .85; }
.compass .c { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; font-size: 34px; }

.big-btn { padding: 22px; font-size: 24px; }
.dice { font-size: 90px; text-align: center; line-height: 1; margin: 6px 0; }
.pbar { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; } .pbar img { width: 34px; height: 34px; image-rendering: pixelated; object-fit: contain; }

#toasts { position: fixed; top: 8px; left: 8px; right: 8px; z-index: 99; display: flex; flex-direction: column; gap: 6px; pointer-events: none; align-items: center; }
.toast { background: rgba(27,32,48,.97); border: 2px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 14px; animation: tin .2s ease-out; max-width: 520px; }
.toast.good { border-color: var(--good); } .toast.bad { border-color: var(--bad); }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner-msg { background: var(--panel2); border: 2px solid var(--gold2); border-radius: 12px; padding: 10px 14px; text-align: center; font-weight: 700; }

/* creator */
#creator { flex: 1; overflow-y: auto; padding: 10px 12px 90px; display: flex; flex-direction: column; gap: 12px; }
#creator h1 { margin: 4px 0 0; font-size: 22px; color: var(--gold); }
.prev { display: flex; gap: 12px; align-items: center; background: var(--panel2); border: 2px solid var(--gold2); border-radius: 14px; padding: 10px; }
.prev canvas { width: 112px; height: 224px; image-rendering: pixelated; background: #479240; border-radius: 10px; flex: none; }
.prev input { width: 100%; padding: 10px; border-radius: 10px; border: 2px solid var(--line); background: #0e1220; font-size: 18px; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 8px 12px; border-radius: 20px; background: var(--panel2); border: 2px solid var(--line); font-weight: 700; font-size: 14px; }
.chip.sel { background: var(--gold); color: #1a1408; border-color: #8a6a20; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); } .swatch.sel { border-color: #fff; outline: 3px solid var(--gold); }
.opt-style { width: 52px; height: 64px; border-radius: 10px; border: 3px solid var(--line); background: #4f9a45; padding: 0; overflow: hidden; } .opt-style.sel { border-color: #fff; outline: 3px solid var(--gold); } .opt-style img, .opt-style canvas { width: 100%; height: 100%; image-rendering: pixelated; object-fit: contain; display: block; }
.cls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cls .btn { padding: 8px 4px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; } .cls .btn .ic { font-size: 24px; }
.cls .btn.sel { background: #d8b455; color: #1a1408; border-color: #8a6a20; }
.info { background: #0e1220; border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.45; }
.info b { color: var(--gold); }
#creator .foot { position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 35%); }

/* combat */
#cbt { display: flex; flex-direction: column; gap: 8px; flex: 1; }
#cbt canvas { align-self: center; image-rendering: pixelated; background: #2f6a2a; border-radius: 8px; border: 3px solid #0c0f18; touch-action: manipulation; }
.cbt-info { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; background: var(--panel2); border-radius: 8px; padding: 6px 10px; border: 2px solid var(--line); }
.cbt-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cbt-actions .btn { padding: 10px 4px; font-size: 14px; }
.sheet { background: var(--panel); border: 2px solid var(--gold2); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.act-b { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; text-align: left; padding: 8px 10px; background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; width: 100%; }
.act-b .ic { font-size: 24px; text-align: center; } .act-b .n { font-weight: 800; font-size: 14px; } .act-b .d { font-size: 11px; color: var(--dim); } .act-b.dis { opacity: .4; } .act-b.sel { outline: 3px solid var(--gold); }
.turn-banner { text-align: center; font-weight: 900; padding: 8px; border-radius: 10px; font-size: 18px; }
.turn-banner.me { background: #d8b455; color: #1a1408; animation: pulse 1.2s infinite; } .turn-banner.other { background: var(--panel2); border: 2px solid var(--line); }
@keyframes pulse { 50% { filter: brightness(1.2); } }
#mini { width: 100%; image-rendering: pixelated; border-radius: 10px; border: 3px solid var(--gold2); align-self: center; max-width: 520px; background: #243050; }
.chip.dis { opacity: .35; }

/* ---- d-pad ---- */
#dpad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 6px; touch-action: none; flex: none; }
#dpad button { background: #3d4a80; border: 3px solid #1a2036; border-radius: 14px; font-size: 24px; color: #dfe6ff; box-shadow: 0 4px 0 #0c0f18; touch-action: none; user-select: none; }
#dpad button.on { background: #d8b455; color: #1a1408; transform: translateY(3px); box-shadow: 0 1px 0 #0c0f18; }
#dpad [data-d=up] { grid-column: 2; grid-row: 1; } #dpad [data-d=left] { grid-column: 1; grid-row: 2; } #dpad [data-d=right] { grid-column: 3; grid-row: 2; } #dpad [data-d=down] { grid-column: 2; grid-row: 3; }
#dpad .mid { grid-column: 2; grid-row: 2; border-radius: 50%; background: #1c2239; border: 3px solid #1a2036; }
/* ---- chat ---- */
.badge { background: #e84a4a; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 800; padding: 0 6px; margin-left: 4px; min-width: 16px; display: inline-block; text-align: center; }
.badge:empty { display: none; }
#chatfab { position: fixed; right: 12px; bottom: 14px; z-index: 15; width: 54px; height: 54px; border-radius: 50%; font-size: 24px; background: #323d62; border: 3px solid var(--gold2); box-shadow: 0 4px 0 #0c0f18; color: #fff; }
#chatfab .badge { position: absolute; top: -4px; right: -4px; margin: 0; }
#overlay .chatbar { display: flex; gap: 8px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 2px solid var(--gold2); }
#overlay .chatbar input { flex: 1; padding: 12px; border-radius: 10px; border: 2px solid var(--line); background: #0e1220; font-size: 16px; min-width: 0; }
.cl { font-size: 14px; line-height: 1.35; padding: 2px 0; word-break: break-word; }
.cl.detail { font-size: 12px; opacity: .78; padding: 1px 0 1px 10px; border-left: 2px solid rgba(160, 150, 120, .45); font-family: ui-monospace, Consolas, monospace; }          /* a detailed combat log line */
.cl b { color: var(--gold); } .cl.chat { color: #fff; } .cl.roll { color: #c8b0ff; } .cl.log, .cl.sys { color: var(--blue); } .cl.good { color: var(--good); } .cl.bad { color: var(--bad); } .cl.hit, .cl.crit { color: #ffcf7a; } .cl.miss { color: var(--dim); } .cl.act { color: #e8b0f0; }
.lootmini { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; } .lootmini .tag { color: var(--gold); border-color: var(--gold2); }

/* spell picker */
.sp-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.sp-row { display: flex; gap: 4px; align-items: stretch; }
.sp-pick { flex: 1; display: flex; align-items: center; gap: 6px; text-align: left; background: #151a2c; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; color: var(--ink, #e8e8f0); font: inherit; min-height: 40px; }
.sp-row.sel .sp-pick { border-color: var(--gold); background: #231f10; }
.sp-ck { width: 18px; height: 18px; border: 2px solid var(--line); border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: var(--gold); flex: none; }
.sp-row.sel .sp-ck { border-color: var(--gold); }
.sp-nm { flex: 1; }
.sp-i { width: 38px; background: #151a2c; border: 1px solid var(--line); border-radius: 8px; color: var(--dim); font-size: 16px; }
.sp-text { margin: 0 4px 4px 28px; padding: 6px 8px; background: #0e1220; border-radius: 6px; }
.slotpick { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.slotpick .btn { min-width: 64px; }

/* ---- phone-only layout ---- */
#app { max-width: 640px; height: 100dvh; padding-top: env(safe-area-inset-top); }
#app::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: #000; z-index: 2000; pointer-events: none; }          /* the notch / clock strip at the top of a phone stays black, not parchment */
#join .sub { text-align: center; color: var(--dim); font-size: 14px; }
#conn { position: fixed; top: var(--deadTop, 60px); left: 50%; transform: translateX(-50%); z-index: 120; background: #6b2a2a; border: 2px solid var(--bad); border-radius: 10px; padding: 6px 14px; font-weight: 800; font-size: 13px; pointer-events: none; }
#stage[data-mode=hub] { padding: 0; overflow: hidden; position: relative; gap: 0; }
#hub { position: absolute; inset: 0; display: block; }
#hub canvas#mini { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; max-width: none; touch-action: none; image-rendering: pixelated; background: #0e1220; }
#hub-top { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
#hub.pad-off #pad-row { display: none; }
#hub-top .btn { width: 44px; height: 44px; padding: 0; font-size: 20px; line-height: 1; opacity: .92; }
#party-chip { position: absolute; top: 8px; left: 8px; z-index: 3; }
#hub .hint { position: absolute; left: 0; right: 0; bottom: 150px; text-align: center; font-size: 12px; color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px #000; pointer-events: none; padding: 0 70px; }
#pad-row { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 0 12px max(12px, env(safe-area-inset-bottom)); pointer-events: none; }
#pad-row > * { pointer-events: auto; }
#dpad { opacity: .78; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); }
#act { width: 104px; height: 104px; opacity: .93; font-size: 13px; }
#act b { font-size: 22px; }
#xmap-wrap { display: flex; justify-content: center; flex: none; }
#xmap { border-radius: 10px; border: 3px solid var(--gold2); background: #0c0f18; image-rendering: pixelated; max-width: 100%; }
#xbody { display: flex; flex-direction: column; gap: 10px; }
@media (max-height: 640px) { #dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); } #act { width: 90px; height: 90px; } #hub .hint { bottom: 130px; } }

#lobbies { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#lobbies h1 { margin: 0; font-size: 22px; color: var(--gold); }
.lin { padding: 12px; border-radius: 10px; border: 2px solid var(--line); background: #0e1220; font-size: 16px; min-width: 0; width: 100%; box-sizing: border-box; }
#lobbies .card .lin { margin-top: 8px; }

/* ---- editable art ---- */
.ico { width: 1.25em; height: 1.25em; vertical-align: -0.28em; image-rendering: pixelated; }
.emo { width: 1.2em; height: 1.2em; vertical-align: -0.25em; image-rendering: pixelated; margin: 0 .05em; }
.ico-box { display: inline-block; width: 28px; height: 28px; flex: none; }
.ico-box .ico { width: 100%; height: 100%; vertical-align: top; }
.item .ic { display: flex; align-items: center; justify-content: center; } .item .ic .ico { width: 36px; height: 36px; }
.act-b .ic .ico { width: 30px; height: 30px; } .cls .btn .ic .ico { width: 34px; height: 34px; } .sp-ic .ico { width: 28px; height: 28px; vertical-align: middle; }
#nav .btn .ic .emo, #nav .btn .ic .ico { width: 26px; height: 26px; }
#top .emo { width: 1.1em; height: 1.1em; }
.dice .emo { width: 1em; height: 1em; } .compass .c .emo { width: 1.6em; height: 1.6em; }
.evart { width: 100%; max-width: 440px; margin-left: auto; margin-right: auto; display: block; image-rendering: pixelated; border-radius: 8px; margin-bottom: 6px; border: 2px solid var(--line); }
#logo { display: block; margin: 0 auto 4px; width: min(100%, 360px); image-rendering: pixelated; }
#join { background: var(--bg-login, none) center bottom / cover no-repeat; image-rendering: pixelated; }
#join > * { position: relative; }
#join input, #join .btn { box-shadow: 0 2px 8px rgba(0,0,0,.5); }
#lobbies { background: linear-gradient(rgba(18,21,31,.78), rgba(18,21,31,.9)), var(--bg-lobby, none) center / cover no-repeat; }
.btn .emo, .btn .ico { width: 1.15em; height: 1.15em; }
#hub-top .btn .ico, #hub-top .btn .emo { width: 28px; height: 28px; vertical-align: middle; }
#act b .emo, #act b .ico { width: 34px; height: 34px; }

/* ---- dyes ---- */
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; border: 1px solid rgba(255,255,255,.55); vertical-align: -1px; margin-right: 4px; }
.tag.dyed { background: rgba(255,255,255,.08); color: var(--dim, #aab); }

/* ---- top bar bars, chat popups ---- */
#top .who { display: flex; flex-direction: column; gap: 3px; }
.bar.big { height: 15px; border-radius: 8px; }
.bar.big > span { position: absolute; inset: 0; text-align: center; font-size: 10px; font-weight: 800; line-height: 13px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; letter-spacing: .3px; }
.bar.big.xp > i { background: #9d6ae4; }
#chatpop { position: fixed; left: 50%; transform: translateX(-50%); top: 74px; width: min(94vw, 480px); z-index: 1500; pointer-events: none; display: flex; flex-direction: column; gap: 4px; }
#chatpop .pop { background: rgba(14, 18, 30, .9); border: 1px solid var(--line); border-radius: 10px; padding: 5px 9px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.5); animation: popin .18s ease-out; }
#chatpop .pop .cl { margin: 0; }
@keyframes popin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
#overlay { top: var(--topH, 0px); }
#chatpop { top: calc(var(--topH, 0px) + 8px); }
/* the top of a phone screen is dead space (the notch, the clock, the camera): nothing pops up in the top 60px */
:root { --deadTop: max(60px, calc(env(safe-area-inset-top, 0px) + 12px)); }
#toasts { top: max(var(--deadTop), calc(var(--topH, 0px) + var(--sbH, 0px) + 8px)); z-index: 1500; }
#chatpop { position: static; transform: none; top: auto; z-index: auto; width: min(94vw, 480px); }
#chatpop:empty { display: none; }
.btn.bad { color: #fff; }
#dpad .mid { position: relative; touch-action: none; user-select: none; cursor: grab; display: flex; align-items: center; justify-content: center; }
#dpad .mid .knob { width: 22px; height: 22px; border-radius: 50%; background: #5c6ba8; border: 2px solid #1a2036; box-shadow: 0 2px 0 #0c0f18; pointer-events: none; transition: transform .06s linear; }
#dpad .mid.on { border-color: #c0983a; background: #232c4b; }
#dpad .mid.on .knob { background: #dbba60; }

/* combat: bigger icons, and the full-screen pickers (abilities / items / swap) */
.cbt-actions .btn { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 12px 4px; font-size: 15px; }
.cbt-actions .btn .emo, .cbt-actions .btn .ico { width: 1.75em; height: 1.75em; }
.act-b { grid-template-columns: 48px 1fr auto; }
.act-b .ic .ico, .act-b .ic .emo { width: 42px; height: 42px; }
.cbt-info .emo, .cbt-info .ico, .banner-msg .emo { width: 1.5em; height: 1.5em; }
.chips .emo, .chip .emo { width: 1.3em; height: 1.3em; }
#cbt.picking > canvas, #cbt.picking > #cbt-head, #cbt.picking > #cbt-info { display: none; }
.pick-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; position: sticky; top: 0; z-index: 2; padding: 4px 0; } .pick-head b { font-size: 18px; }
#cbt.picking .sheet { max-height: none; overflow: visible; }

/* trading */
.pmenu { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; background: #ecdbad; border: 3px solid #5b3d1f; box-shadow: inset 0 0 0 2px #c9a76b, 0 4px 14px rgba(0,0,0,.45); color: #2a1a0a; } .pmenu .pm-name { font-weight: 800; font-size: 14px; white-space: nowrap; }
.tradepop { position: fixed; left: 50%; top: max(40%, calc(var(--deadTop, 60px) + 170px));          /* below where chat and roll messages pop up */ transform: translateX(-50%); z-index: 70; width: min(86vw, 340px); padding: 12px; background: #ecdbad; border: 3px solid #5b3d1f; box-shadow: inset 0 0 0 2px #c9a76b, 0 6px 22px rgba(0,0,0,.55); color: #2a1a0a; text-align: center; }
.tradepop .tp-title { font-size: 15px; margin-bottom: 10px; } .tradepop .tp-btns { display: flex; gap: 8px; justify-content: center; } .tradepop .tp-btns .btn { flex: 1; }
.tr-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; } .tr-btns.gold-row { justify-content: flex-start; margin: 4px 0 8px; }
.tr-gold { font-size: 16px; display: flex; gap: 8px; align-items: center; }
.tr-status { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 2px; }
.item .tr-btns { margin-left: auto; }

/* stories */
#story-bar { position: absolute; left: 8px; top: 8px; right: 70px; z-index: 3; padding: 6px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; background: rgba(36, 22, 11, .82); border: 2px solid #c8963a; color: #f6e9c8; font-size: 12px; }
#story-bar .sb-t { flex: 1 1 100%; } #story-bar .sb-o { flex: 1 1 100%; color: #f2d27a; } #story-bar .btn { margin-left: auto; }

/* the dice icon in a conversation is big and sits on its own line of text */
.dlg .bubble { white-space: pre-line; }
.dlg .bubble .emo { width: 32px; height: 32px; vertical-align: middle; margin: 0 6px 0 0; }

/* the tutorial card sits under the top bar; while a menu is open it shrinks to a strip above the nav so the menu can be read */
.tutpop { top: 84px; z-index: 75; max-height: 70vh; overflow: auto; }
.tutpop.tut-low { top: auto; bottom: 86px; z-index: 95; padding: 8px; max-height: 38vh; }
.tutpop.tut-low .tp-title { font-size: 13px; margin-bottom: 6px; }
@keyframes tutpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 90, .9); } 50% { box-shadow: 0 0 0 7px rgba(255, 215, 90, 0); } }
#nav .btn.tut-pulse { animation: tutpulse 1.1s infinite; border-color: #ffd75a; }

/* the Close button: icon and word centred together */
#overlay .head .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1; }
#overlay .head .btn img { display: block; flex: none; }

/* PC and any wide window (a phone turned sideways too): use the width, keep reading columns narrow */
@media (min-width: 760px) {
  #app { max-width: min(100vw, 1200px); }
  #overlay .head, #overlay .body { padding-left: max(12px, calc((100% - 720px) / 2)); padding-right: max(12px, calc((100% - 720px) / 2)); }
  #overlay .head h2 { font-size: 20px; }
  #creator .foot { max-width: 720px; }
  #pad-row { padding-left: 28px; padding-right: 28px; }
}
/* a phone turned sideways: little height, so the bars shrink and the map gets the room */
@media (orientation: landscape) and (max-height: 520px) {
  #nav { padding-top: 2px; padding-bottom: 2px; }
  #nav .btn { flex-direction: row; gap: 6px; padding: 4px 8px; min-height: 0; font-size: 13px; }
  #nav .btn .ic { font-size: 18px; margin: 0; }
  #nav .btn .ic .emo, #nav .btn .ic .ico { width: 20px; height: 20px; }
  #dpad { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); gap: 4px; }
  #act { width: 78px; height: 78px; padding: 4px; font-size: 12px; }
  #hub-top { flex-direction: row; }
  #overlay .head { padding: 4px 12px; }
  #overlay .body { padding-top: 8px; padding-bottom: 8px; }
  .tutpop { top: 56px; max-height: 80vh; }
  .tutpop.tut-low { bottom: 52px; max-height: 50vh; }
}
@media (min-width: 760px) {
  #join, #lobbies, #heroes, #creator { padding-left: max(22px, calc((100% - 560px) / 2)); padding-right: max(22px, calc((100% - 560px) / 2)); }
  #creator .foot { left: 0; right: 0; }
}

/* login: the wide picture for computers and phones held sideways; the tall one stays for phones held upright */
#j-brand, #j-main { display: contents; }
@media (orientation: landscape), (min-width: 760px) { #join { background-image: var(--bg-login-wide, var(--bg-login, none)); background-position: center bottom; } }
/* a phone held sideways: its own long background, the title on the left, the form on the right, everything smaller */
@media (orientation: landscape) and (max-height: 520px) {
  #join { background-image: var(--bg-login-landscape, var(--bg-login-wide, var(--bg-login, none))); }
  #join { flex-direction: row; align-items: center; gap: 28px; padding: 8px max(24px, env(safe-area-inset-left)) 8px max(24px, env(safe-area-inset-right)); overflow-y: auto; }
  #j-brand, #j-main { display: flex; flex-direction: column; justify-content: center; gap: 6px; flex: 1; min-width: 0; }
  #logo { width: min(100%, 280px); }
  #join h1 { font-size: 24px; letter-spacing: 2px; }
  #join .sub { font-size: 12px; }
  #join label { font-size: 10px; margin-bottom: 2px; letter-spacing: 1px; }
  #join input, #join input.txt { padding: 6px 10px; font-size: 15px; border-width: 2px; border-radius: 8px; }
  #join #j-form { gap: 6px; }
  #join #j-step1 > div[style], #join #j-step2 > div[style], #join #j-step3 > div[style] { margin-top: 6px !important; }
  #join .row[style] { margin-top: 6px !important; }
  #join .btn { padding: 6px 10px; min-height: 0; font-size: 14px; }
  #join .err { min-height: 14px; font-size: 12px; }
  #j-resume .btn.big-btn { padding: 8px; }
}

/* the rolling dice (public/js/dice.js) */
#dice { position: fixed; inset: 0; z-index: 1700; display: none; justify-content: center; align-items: flex-start; padding-top: calc(var(--topH, 56px) + 84px); pointer-events: none; }
#dice.on { display: flex; }
#dice .dice-card { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: opacity .3s; cursor: pointer; }
#dice .dice-card.out { opacity: 0; }
#dice .dice-row { display: flex; gap: 2px; justify-content: center; }
#dice canvas { width: 150px; height: 150px; image-rendering: pixelated; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
#dice .dice-row.n3 canvas, #dice .dice-row.n4 canvas { width: 96px; height: 96px; }
#dice .dice-row.n2 canvas { width: 120px; height: 120px; }
/* a group of saving throws: each die with the creature's name under it, and every total below */
/* blackjack cards */
.bjrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.bjc { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 46px; background: #fbf6ea; color: #1a1a24; border: 2px solid #3a2a1a; border-radius: 5px; font-weight: 800; font-size: 14px; box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.bjc.red { color: #c02a2a; } .bjc.back { background: repeating-linear-gradient(45deg, #7a2a2a, #7a2a2a 4px, #a03a3a 4px, #a03a3a 8px); }
#dice .dg { display: flex; flex-direction: column; align-items: center; } #dice .dg canvas { width: 76px; height: 76px; } #dice .dice-row.n2 .dg canvas { width: 110px; height: 110px; }
#dice .dg-n { font-size: 11px; font-weight: 700; color: #f6e9c8; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dice .dg-r { display: inline-block; font-size: 15px; margin: 0 5px; } #dice .dg-r.ok { color: #9ad8a0; } #dice .dg-r.no { color: #f0a090; }
#dice .dice-row { flex-wrap: wrap; }
#dice canvas.off { opacity: .4; filter: grayscale(.7); }
#dice .dice-label { font-size: 13px; letter-spacing: 1px; color: var(--gold); text-transform: uppercase; text-shadow: 0 2px 0 #000, 0 0 6px #000; margin-top: -10px; }
#dice .dice-text { text-align: center; background: rgba(14,18,30,.9); border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px; box-shadow: 0 3px 10px rgba(0,0,0,.6); min-width: 150px; }
#dice .dice-text.hide { visibility: hidden; }
#dice .dice-text.pop { animation: dicepop .28s ease-out; }
#dice .dice-math { font-size: 28px; font-weight: 800; color: #fff; text-shadow: 0 3px 0 #000; }
#dice .dice-verdict { font-size: 16px; font-weight: 800; margin-top: 1px; }
#dice .dice-verdict.good { color: #8aff9a; } #dice .dice-verdict.bad { color: #ff9a9a; } #dice .dice-verdict.crit { color: #ffd060; }
@keyframes dicepop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }
@media (orientation: landscape) and (max-height: 520px) { #dice { padding-top: calc(var(--topH, 40px) + 70px); } #dice canvas { width: 110px; height: 110px; } #dice .dice-row.n2 canvas { width: 90px; height: 90px; } #dice .dice-row.n3 canvas, #dice .dice-row.n4 canvas { width: 70px; height: 70px; } #dice .dice-math { font-size: 22px; } #dice .dice-verdict { font-size: 14px; } }

/* a mission event (not a fight): the dice sit at the bottom, over the empty part of the screen */
#dice.low { align-items: flex-end; padding-top: 0; padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
@media (orientation: landscape) and (max-height: 520px) { #dice.low { padding-bottom: 56px; } }

#dice .dice-label { font-size: 12px; letter-spacing: 1px; color: var(--gold); text-transform: uppercase; text-shadow: none; margin: 0 0 2px; }
#dice .dice-math { text-shadow: none; }
#dice .dice-note { font-size: 11px; color: #cfd6ee; max-width: 260px; margin: 0 auto 2px; }

/* a monster's description window (public/js/play-combat.js) */
#cbt-insp { position: fixed; inset: 0; z-index: 1600; background: rgba(8,10,18,.45); display: flex; align-items: center; justify-content: center; padding: 14px; }
#cbt-insp .insp-win { position: relative; width: min(100%, 360px); max-height: 78vh; overflow-y: auto; background: var(--panel); border: 2px solid var(--gold2); border-radius: 12px; padding: 10px 14px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.6); line-height: 1.4; }
#cbt-insp h3 { margin: 0 28px 2px 0; font-size: 18px; color: var(--gold); }
#cbt-insp .insp-x { position: absolute; top: 6px; right: 6px; min-height: 0; padding: 2px 8px; }
#cbt-insp .insp-stats { font-size: 13px; }
#cbt-insp .insp-blurb { font-size: 12px; font-style: italic; color: var(--dim); margin: 2px 0 4px; }
#cbt-insp .insp-sec { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin: 7px 0 2px; border-bottom: 1px solid rgba(255,255,255,.12); }
@media (orientation: landscape) and (max-height: 520px) { #cbt-insp .insp-win { max-height: 92vh; width: min(100%, 520px); } }

/* a fight on a phone held sideways: the arena on the left, the buttons on the right, nothing to scroll */
@media (orientation: landscape) and (max-height: 520px) {
  #cbt { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto 1fr; column-gap: 10px; row-gap: 4px; align-content: start; }
  #cbt-head { grid-column: 1 / -1; }
  #cbt > canvas { grid-column: 1; grid-row: 2 / span 2; align-self: start; }
  #cbt-info { grid-column: 2; grid-row: 2; }
  #cbt-ctl { grid-column: 2; grid-row: 3; }
  #cbt-ctl .grid2 .btn, #cbt-ctl .btn { padding-top: 5px; padding-bottom: 5px; min-height: 0; font-size: 13px; }
}
#cbt { gap: 6px; }

/* popups slide to their places and fade out */
#chatpop .pop { transition: opacity .32s; animation: none; }
#chatpop .pop.leaving { opacity: 0; }
@keyframes popfresh { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
#chatpop .pop:not(.leaving) { animation: popfresh .22s ease-out; }
/* who rolls for what against whom */
#dice .dice-banner { font-size: 13px; font-weight: 800; letter-spacing: .5px; text-align: center; padding: 5px 12px; border: 3px solid #5a8ae8; border-radius: 10px; background: rgba(14,18,30,.94); color: #e6efff; box-shadow: 0 3px 10px rgba(0,0,0,.6); max-width: min(92vw, 380px); }
#dice .dice-banner.foe { border-color: #e05a4a; color: #ffe4de; }
#dice .dice-banner.party { border-color: #5ab87a; color: #e2ffe9; }

/* a computer: the move / action / bonus action line is bigger and easier to read */
@media (min-width: 760px) {
  #cbt-info { font-size: 20px; padding: 8px 14px; align-items: center; }
  #cbt-info .emo, #cbt-info .ico { width: 1.6em; height: 1.6em; }
  #cbt-info > span:first-child { display: flex; align-items: center; gap: 10px; }
  #cbt-info b { font-size: 1.1em; }
}
#cbt-insp .atk-t { font-size: 12px; color: var(--dim); margin: 1px 0 3px 10px; }
#cbt-insp .atk { margin-bottom: 2px; }

/* the initiative tracker: small, at the right of the arena (beside it on a phone too) */
#cbt { position: relative; }
#cbt-init.empty { display: none; }
#cbt-init { display: flex; flex-direction: column; gap: 3px; width: 56px; max-height: var(--arena, 320px); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
#cbt-init::-webkit-scrollbar { display: none; }
#cbt-init .ini-h { font-size: 9px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--gold); text-align: center; white-space: nowrap; }
#cbt-init .ini { display: flex; align-items: center; justify-content: center; gap: 3px; background: var(--panel2); border: 2px solid var(--line); border-radius: 7px; padding: 1px 3px; cursor: pointer; }
#cbt-init .ini img, #cbt-init .ini-ph { width: 20px; height: 20px; image-rendering: pixelated; object-fit: contain; font-size: 14px; line-height: 20px; text-align: center; flex: 0 0 auto; }
#cbt-init .ini-t { display: flex; flex-direction: column; font-size: 11px; line-height: 1.1; }
#cbt-init .ini-t b { display: none; }
#cbt-init .ini-t span { font-weight: 800; }
#cbt-init .ini.foe { border-color: #a04a40; } #cbt-init .ini.party { border-color: #3f6aa0; }
#cbt-init .ini.me { box-shadow: 0 0 0 1px #6aa8e8 inset; }
#cbt-init .ini.now { border-color: #ffd25a; background: rgba(255,210,90,.28); box-shadow: 0 0 6px rgba(255,210,90,.6); }
#cbt-init .ini.dead { opacity: .3; filter: grayscale(1); } #cbt-init .ini.down { opacity: .55; }
/* a phone held upright: the arena and the tracker side by side */
@media (max-width: 759px) and (orientation: portrait) {
  /* the arena always in the middle of the screen; the tracker just to its right, in the screen's margin (play-combat.js sizes the arena to leave room for it) */
  #stage[data-mode="combat"] { overflow-x: hidden; }
  #cbt > canvas { align-self: center; }
  #cbt-init, #cbt-init.empty { display: flex; position: absolute; top: var(--arenaTop, 44px); left: calc(50% + var(--arena, 240px) / 2 + 4px); width: 44px; z-index: 2; }
  #cbt-init .ini { padding: 1px 2px; } #cbt-init .ini-t { font-size: 10px; }
}
/* a computer: right beside the arena, with the names */
@media (min-width: 760px) {
  #cbt-init { position: absolute; top: 44px; left: calc(50% + var(--arena, 320px) / 2 + 14px); width: 124px; gap: 4px; }
  #cbt-init .ini { justify-content: flex-start; padding: 2px 6px 2px 4px; } #cbt-init .ini img, #cbt-init .ini-ph { width: 22px; height: 22px; line-height: 22px; }
  #cbt-init .ini-t { flex-direction: row; align-items: center; gap: 5px; font-size: 12px; min-width: 0; } #cbt-init .ini-t b { display: inline; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
  #cbt-init .ini-t span { opacity: .8; margin-left: auto; }
  #cbt-init .ini-h { font-size: 10px; text-align: left; padding-left: 2px; }
}
/* a phone held sideways: a narrow column at the right edge */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 759px) {
  #cbt { grid-template-columns: auto 1fr auto; }
  #cbt-init { grid-column: 3; grid-row: 2 / span 2; max-height: 100%; }
  #cbt-head { grid-column: 1 / -1; }
}

/* the party list (public/js/play-group.js) */
#party-chip .grp-list { margin-top: 6px; background: rgba(20,16,12,.94); border: 2px solid #6a5a3a; border-radius: 10px; padding: 8px; width: 240px; max-width: calc(100vw - 30px); }
.grp-m { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-items: center; margin-bottom: 6px; }
.grp-n { grid-column: 1; font-size: 13px; } .grp-ops { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 3px; }
.grp-hp { grid-column: 1; height: 5px; background: #2a2018; border-radius: 3px; overflow: hidden; } .grp-hp i { display: block; height: 100%; background: #46d85a; }
.btn.tiny { padding: 2px 6px; font-size: 12px; min-height: 0; }
.cl.npcline { color: #f2e2b0; }

/* ready to level up: a gold arrow on the Hero button */
.badge.lvl { background: #f2c230; color: #3a2400; box-shadow: 0 0 0 2px #7a5200 inset; animation: lvlPulse 1.2s ease-in-out infinite; }
@keyframes lvlPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
/* whose turn it is on the initiative tracker: a pulsing gold dot and a bright outline */
#cbt-init .ini { position: relative; }
#cbt-init .ini.now { outline: 2px solid #ffd25a; outline-offset: -1px; }
#cbt-init .ini.now::before { content: ''; position: absolute; left: 2px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #ffd25a; box-shadow: 0 0 0 1.5px #3a2a08, 0 0 6px #ffd25a; animation: iniDot 1s ease-in-out infinite; }
@keyframes iniDot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* the Proficiencies list on the character sheet */
.profs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; } .profs .chips { margin-top: 2px; }

/* Building Spots: the house picker */
.spot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.spot-m { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; cursor: pointer; margin: 0; }
.spot-m img { width: 100%; max-width: 80px; image-rendering: pixelated; }
.spot-m.sel { outline: 3px solid var(--gold); }
.bad-t { color: #e8604c; }

/* ales: 3 and the world sways, 4 it sways more, 5 you can hardly see past the blur and the ripples (an SVG filter in index.html) */
@keyframes sway1 { 0%, 100% { transform: rotate(-1.2deg) translateX(-5px); } 50% { transform: rotate(1.2deg) translateX(5px); } }
@keyframes sway2 { 0%, 100% { transform: rotate(-2.6deg) translate(-9px, 3px) scale(1.02); } 33% { transform: rotate(1.8deg) translate(7px, -4px) scale(1.04); } 66% { transform: rotate(-.8deg) translate(4px, 5px) scale(1.01); } }
html.drunk-3 #stage { animation: sway1 4s ease-in-out infinite; }
html.drunk-4 #stage { animation: sway2 2.6s ease-in-out infinite; filter: blur(2px) saturate(1.2); }
html.drunk-5 #stage { animation: sway2 1.9s ease-in-out infinite; filter: blur(4.5px) saturate(1.6); }
/* the wave sits on the map itself: a phone browser that cannot use SVG filters on a page just skips it (on #stage it would drop the blur too) */
html.drunk-5 #hub { filter: url(#drunkwave); }
/* a second blurred, wobbling layer over the map (backdrop-filter works on phones, where a plain blur on a canvas is sometimes weak) */
html.drunk-4 #stage::after, html.drunk-5 #stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); background: radial-gradient(ellipse at center, transparent 45%, rgba(90, 40, 10, .25)); animation: drunkveil 3s ease-in-out infinite; }
html.drunk-5 #stage::after { -webkit-backdrop-filter: blur(6px) saturate(1.4); backdrop-filter: blur(6px) saturate(1.4); background: radial-gradient(ellipse at center, transparent 30%, rgba(90, 40, 10, .45)); animation-duration: 1.6s; }
@keyframes drunkveil { 0%, 100% { transform: translate(0, 0) scale(1.02); } 33% { transform: translate(6px, -4px) scale(1.04); } 66% { transform: translate(-5px, 3px) scale(1.03); } }
@media (prefers-reduced-motion: reduce) { html.drunk-3 #stage, html.drunk-4 #stage { animation-duration: 12s; } }

/* a reaction question in a fight (play-combat.js reactPop) */
#react-pop { position: fixed; left: 50%; top: max(var(--deadTop, 60px), calc(var(--topH, 0px) + 12px)); transform: translateX(-50%); z-index: 1600; width: min(92vw, 420px); padding: 12px; background: #ecdbad; color: #3a2814; border: 3px solid #24160b; box-shadow: 0 0 0 3px #c8963a, 6px 6px 0 3px #000; display: flex; flex-direction: column; gap: 8px; }
#react-pop .rp-t { font-family: Georgia, serif; font-weight: 800; font-size: 18px; color: #a3302a; }
#react-pop .rp-p { font-size: 14px; }
#react-pop .rp-bar { height: 6px; background: #24160b; } #react-pop .rp-bar i { display: block; height: 100%; background: #dcae3c; animation: rpbar linear forwards; }
@keyframes rpbar { from { width: 100%; } to { width: 0; } }

/* a fight on the open map: no box, the map fills the screen width (play-combat.js fitField) */
#cbt.field > canvas { border: 0; border-radius: 0; align-self: stretch; background: #0e1220; touch-action: none; }
#cbt-zoom { display: none; }
#cbt.field #cbt-zoom { display: flex; flex-direction: column; gap: 4px; position: absolute; right: 64px; top: calc(var(--arenaTop, 60px) + 6px); z-index: 4; }
#cbt.field.picking #cbt-zoom { display: none; }
/* the ability window (play-combat.js abInfo) */
#cbt-abinfo { position: fixed; inset: 0; z-index: 1600; background: rgba(8,10,18,.45); display: flex; align-items: center; justify-content: center; padding: 14px; }
#cbt-abinfo .insp-win { position: relative; width: min(100%, 380px); max-height: 80vh; overflow-y: auto; background: #ecdbad; color: #3a2814; border: 3px solid #24160b; box-shadow: 0 0 0 3px #c8963a, 6px 6px 0 3px #000; padding: 10px 14px 12px; }
#cbt-abinfo h3 { margin: 0 28px 6px 0; font-size: 18px; color: #5b3d1f; display: flex; align-items: center; gap: 6px; }
#cbt-abinfo .insp-x { position: absolute; top: 6px; right: 6px; min-height: 0; padding: 2px 8px; }
#cbt-abinfo .insp-sec { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #8a5a10; margin: 8px 0 2px; }
#cbt-abinfo .xs { margin: 2px 0; }

/* a fight starts on the open map: a white flash (play.js flashScreen) */
.fight-flash { position: fixed; inset: 0; z-index: 3000; background: #fff; pointer-events: none; animation: fightflash .55s ease-out forwards; }
@keyframes fightflash { 0% { opacity: 0; } 12% { opacity: .95; } 100% { opacity: 0; } }

/* a fight on the open map: the turn order sits inside the map's top right corner (there is no box beside it any more), the zoom buttons to its left */
#cbt.field #cbt-init, #cbt.field #cbt-init.empty { left: auto; right: 6px; top: calc(var(--arenaTop, 44px) + 6px); max-height: calc(var(--arena, 320px) - 12px); }
@media (max-width: 759px) { #cbt.field #cbt-zoom { right: 56px; } }
@media (min-width: 760px) { #cbt.field #cbt-zoom { right: 138px; } }
/* phones: the chat pop-ups stack at the top of the screen, so the reaction prompt sits lower down, clear of them */
@media (max-width: 759px), (orientation: landscape) and (max-height: 520px) {
  #react-pop { top: 40vh; top: 40dvh; }
}
/* the live Armor Class in a fight (Shield, Shield of Faith... included): always next to your turn info */
#cbt-info .ac-live { font-weight: 800; color: #9fd0ff; background: rgba(20, 30, 50, .65); border: 1px solid #4a6a9a; padding: 1px 6px; border-radius: 3px; }

/* a name in the chat you can tap to whisper to (the Message spell) */
.cl .pm-name { cursor: pointer; text-decoration: underline dotted; }

/* a whisper (the Message spell): its own strong colours, readable on the dark pop-ups and the light chat window alike */
.cl.chat.pm { background: #2c1846; color: #fff; border-left: 3px solid #c9a0ff; border-radius: 6px; padding: 3px 7px; margin: 2px 0; }
.cl.chat.pm b, .cl.chat.pm .dim { color: #ffd76a; }

/* ---------- the floating fight bar (2026-10-18): plaques over the battlefield, no panel behind them ---------- */
#cbt-ctl { background: none; }
.fbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; justify-content: center; pointer-events: none; }
.fbar > * { pointer-events: auto; }
.fb { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 6px 12px 6px 8px; text-align: left; cursor: pointer; flex: 1 1 150px; max-width: 240px;
  color: #f6e8c6; background: #6e4527; border: 3px solid #24160b; box-shadow: inset 0 2px 0 #9a6a3e, inset 0 -3px 0 #3e2412, 0 3px 0 rgba(0,0,0,.45); font: inherit; }
.fb:active { transform: translateY(1px); box-shadow: inset 0 3px 0 #3e2412, inset 0 -1px 0 #9a6a3e; }
.fb-i { flex: 0 0 auto; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.fb-i .ico, .fb-i img { width: 36px; height: 36px; image-rendering: pixelated; }
.fb-emo { font-size: 26px; line-height: 1; }
.fb-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.fb-t b { font-family: var(--head, Georgia, serif); font-size: 18px; color: #fff3d6; text-shadow: 0 1px 0 #24160b; white-space: nowrap; }
.fb-t small { font-size: 11px; color: #f0dcb4; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb.on, .fb-split.on > .fb.main { background: #8a3a24; box-shadow: inset 0 2px 0 #c0705a, inset 0 -3px 0 #4a160c, 0 0 0 3px #ffd25a; }
.fb.dis, .fb-split.dis > .fb.main { opacity: .5; }
.fb.gold { background: #dcae3c; color: #3a2608; box-shadow: inset 0 2px 0 #ffe58c, inset 0 -3px 0 #8a5f10, 0 3px 0 rgba(0,0,0,.45); }
.fb.gold .fb-t b { color: #2a1a06; text-shadow: 0 1px 0 rgba(255,240,170,.7); font-size: 21px; } .fb.gold .fb-t small { color: #4a3210; }
.fb.end { flex: 0 1 200px; }
.fb.back { flex: 0 0 auto; min-width: 74px; background: #4a2c16; justify-content: center; } .fb.back .fb-emo { font-size: 30px; }
.fb-sep { width: 3px; align-self: stretch; margin: 6px 4px; background: rgba(36,22,11,.55); border-radius: 2px; }
.fb-split { display: flex; flex: 1.4 1 220px; max-width: 320px; }
.fb-split > .fb.main { flex: 1 1 auto; max-width: none; border-right-width: 2px; }
.fb-swap { position: relative; flex: 0 0 64px; display: flex; align-items: center; justify-content: center; background: #5a3820; border: 3px solid #24160b; border-left-width: 1px; box-shadow: inset 0 2px 0 #8a5a30, inset 0 -3px 0 #2e1a0c, 0 3px 0 rgba(0,0,0,.45); cursor: pointer; padding: 0; }
.fb-swap .ico, .fb-swap img { width: 32px; height: 32px; image-rendering: pixelated; }
.fb-swap .fb-sw { position: absolute; right: 3px; bottom: 2px; } .fb-swap .fb-sw img, .fb-swap .fb-sw .ico { width: 16px; height: 16px; }
.fb-swap.dis { opacity: .45; } .fb-swap.on { box-shadow: inset 0 0 0 3px #ffd25a; }
@media (max-width: 759px) {
  .fbar { gap: 5px; } .fb { flex: 1 1 128px; min-height: 50px; padding: 4px 8px 4px 5px; gap: 5px; }
  .fb-i, .fb-i .ico, .fb-i img { width: 28px; height: 28px; } .fb-t b { font-size: 15px; } .fb.gold .fb-t b { font-size: 16px; } .fb-t small { font-size: 10px; }
  .fb-split { flex: 1 1 100%; max-width: none; } .fb.end { flex: 1 1 100%; } .fb-sep { display: none; }
}
/* a fight on the open map: the battlefield fills the screen, everything else floats on it */
#cbt.field { position: relative; }
#cbt.field > #cbt-ctl { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 5; }
#cbt.field > #cbt-head { position: absolute; top: calc(var(--arenaTop, 0px) + 6px); left: 50%; transform: translateX(-50%); z-index: 5; pointer-events: none; min-width: 200px; text-align: center; }
#cbt.field > #cbt-head .banner-msg { pointer-events: auto; }
#cbt.field > #cbt-info { position: absolute; left: 6px; right: 6px; bottom: calc(var(--ctlH, 70px) + 12px); z-index: 5; background: rgba(20, 14, 8, .62); border: 0; clip-path: none; color: #f6e8c6; box-shadow: none; pointer-events: auto; }
#cbt.field > #cbt-info:empty { display: none; }
#cbt.field.picking > #cbt-ctl { position: static; }
.fbar.tactics .fb { flex: 1 1 140px; }
.banner-msg .ds { display: inline-block; width: 1.3em; text-align: center; opacity: .3; } .banner-msg .ds.ok { opacity: 1; color: #6ad08a; } .banner-msg .ds.no { opacity: 1; color: #ff7a6a; }
.fbar.tactics .fb { flex: 1 1 118px; max-width: 200px; min-height: 46px; padding: 4px 8px 4px 5px; gap: 5px; }
.fbar.tactics .fb-i, .fbar.tactics .fb-i .ico, .fbar.tactics .fb-i img { width: 26px; height: 26px; } .fbar.tactics .fb-emo { font-size: 20px; }
.fbar.tactics .fb-t b { font-size: 15px; } .fbar.tactics .fb-t small { font-size: 10px; }
.fbar.tactics .fb.back { min-width: 60px; flex: 0 0 auto; }
.fbar.tactics .fb.end { flex: 0 1 190px; min-height: 46px; }
.fbar.tactics { flex-wrap: nowrap; align-items: stretch; }
.fbar.tactics .fb-grid { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 6px; }
.fbar.tactics > .fb.end { flex: 0 0 170px; }
@media (max-width: 759px) { .fbar.tactics { flex-wrap: wrap; } .fbar.tactics > .fb.end { flex: 1 1 100%; } }
.fbar.tactics .fb { flex: 1 1 100px; min-height: 44px; padding: 3px 6px 3px 4px; gap: 4px; }
.fbar.tactics .fb-i, .fbar.tactics .fb-i .ico, .fbar.tactics .fb-i img { width: 22px; height: 22px; }
.fbar.tactics .fb-t b { font-size: 14px; } .fbar.tactics .fb-t small { font-size: 9.5px; max-width: 150px; }
.fbar.tactics > .fb.end { align-self: flex-end; flex: 0 0 160px; }
@media (min-width: 1000px) { .fbar.tactics .fb { flex-basis: 128px; } }
@media (max-width: 759px) {
  .fbar > .fb, .fbar > .fb.end { flex: 1 1 40%; max-width: none; }
  .fbar.tactics .fb-grid > .fb { flex: 1 1 30%; max-width: none; }
  .fbar.tactics > .fb.end { flex: 1 1 100%; align-self: stretch; }
}
/* companions on the Hero sheet */
.comp-pic { width: 48px; height: 48px; image-rendering: pixelated; background: #3f8a3a; border-radius: 6px; flex: 0 0 auto; margin-right: 8px; }
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; margin-top: 6px; }
.comp-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 2px solid #7a5a2e; background: #f1e2b8; color: #3a2814; cursor: pointer; font: inherit; }
.comp-opt .comp-pic { width: 40px; height: 40px; margin: 0; } .comp-opt b { font-size: 12px; } .comp-opt small { font-size: 10px; opacity: .75; }
.comp-opt.sel { outline: 3px solid #d89a2a; background: #f8ecc8; }
.fbar.comp .fb-who { display: flex; flex-direction: column; justify-content: center; padding: 4px 10px; background: rgba(20, 14, 8, .72); color: #f6e8c6; border: 2px solid #24160b; min-width: 120px; }
.fbar.comp .fb-who b { font-family: var(--head, Georgia, serif); font-size: 16px; } .fbar.comp .fb-who small { font-size: 10px; opacity: .85; }
@media (max-width: 759px) { .fbar.comp { flex-wrap: wrap; } .fbar.comp .fb-who { flex: 1 1 100%; } }
/* the fight bar's plaques as pictures (public/assets/ui/plaque*.png, nine-slice like the buttons) */
html.ui-art .fb, html.ui-art .fb-swap { border: 6px solid transparent; border-image-source: var(--ui-plaque); border-image-slice: 8 fill; border-image-width: 8px; border-image-repeat: stretch; background: none; box-shadow: 0 3px 0 rgba(0,0,0,.45); }
html.ui-art .fb:active, html.ui-art .fb-swap:active { border-image-source: var(--ui-plaque-down); box-shadow: none; }
html.ui-art .fb.on, html.ui-art .fb-split.on > .fb.main { border-image-source: var(--ui-plaque-on); background: none; box-shadow: 0 0 0 3px #ffd25a; }
html.ui-art .fb.gold { border-image-source: var(--ui-plaque-gold); background: none; }
html.ui-art .fb.back, html.ui-art .fb-swap { border-image-source: var(--ui-plaque-dark); background: none; }

/* the Bag's equipment slots (a paper doll) */
.eqgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 6px 0; }
.eq-mid { grid-row: span 3; display: flex; align-items: center; justify-content: center; min-height: 0; }
.eq-doll { width: 64px; height: 128px; image-rendering: pixelated; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.eqs { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 5px 4px 6px; border-radius: 8px; border: 2px solid var(--line); background: var(--panel2); color: inherit; font: inherit; cursor: pointer; }
.eqs.empty { border-style: dashed; opacity: .8; }
.eqs.sel { outline: 3px solid var(--gold); outline-offset: 1px; }
.eqs.uncommon { border-color: var(--uncommon); } .eqs.rare { border-color: var(--rare); } .eqs.epic { border-color: var(--epic); }
.eqs-l { font-size: 10px; letter-spacing: .5px; text-transform: uppercase; opacity: .75; white-space: nowrap; }
.eqs-i { font-size: 26px; line-height: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.eqs-i img { width: 32px; height: 32px; image-rendering: pixelated; }
.eqs-ghost { opacity: .3; filter: grayscale(1); }
.eqs-n { font-size: 11px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq-panel .eq-pick { gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid rgba(0,0,0,.08); }
