:root {
  --bg: #0b0f0a;
  --bg2: #141c12;
  --win-top: #22311d;
  --win-bot: #10170e;
  --gold: #c9b27a;
  --gold-hi: #f0dca0;
  --text: #ece4cf;
  --muted: #9c9479;
  --party: #4fc3b0;
  --enemy: #e0584a;
  --neutral: #e0c04a;
  --good: #7fd36a;
  --bad: #ef6a5a;
  --corrupt: #b07ce8;
  --sel: #ffe27a;
  --pixel: 'Press Start 2P', monospace;
  --body: 'VT323', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg) radial-gradient(ellipse at top, #1c2a18 0%, var(--bg) 70%) fixed;
  color: var(--text); font-family: var(--body); font-size: 20px; line-height: 1.15;
}
a { color: var(--gold-hi); }
h1, h2, h3 { font-family: var(--pixel); font-weight: normal; color: var(--gold-hi); margin: 0 0 10px; }
h2 { font-size: 14px; } h3 { font-size: 11px; letter-spacing: 1px; }
p { margin: 6px 0 10px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.view { display: none; min-height: 100%; }
.view.active { display: block; }
#view-battle.active { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* JRPG windows */
.window {
  background: linear-gradient(180deg, var(--win-top), var(--win-bot));
  border: 3px solid var(--gold); border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #0006, 0 6px 18px #0009;
  padding: 12px 14px;
}
.btn {
  font-family: var(--pixel); font-size: 10px; color: var(--text); text-decoration: none; display: inline-block;
  background: linear-gradient(#36492e, #1c2818); border: 2px solid var(--gold); border-radius: 4px;
  padding: 8px 12px; cursor: pointer; box-shadow: 0 2px 0 #000; text-align: center; line-height: 1.3;
}
@media (hover: hover) { .btn:hover { background: linear-gradient(#4a6340, #26361f); color: #fff; } }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: linear-gradient(#8a6d2e, #4f3d16); }
@media (hover: hover) { .btn.primary:hover { background: linear-gradient(#a8873c, #644d1c); } }
.btn.danger { background: linear-gradient(#7a2e26, #401512); }
.btn.ghost { background: transparent; border-color: #c9b27a77; }
.btn.small { font-size: 8px; padding: 6px 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea {
  font-family: var(--body); font-size: 20px; color: var(--text); background: #0a0e09; border: 2px solid #5a5236;
  border-radius: 3px; padding: 4px 8px; width: 100%;
}
textarea { font-family: ui-monospace, monospace; font-size: 13px; }
label { display: block; color: var(--muted); }
label input, label select { margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.chip { font-family: var(--pixel); font-size: 9px; padding: 4px 8px; border: 2px solid var(--gold); border-radius: 3px; background: #0008; }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 28px; }

/* home */
.home-wrap { max-width: 1100px; margin: 0 auto; padding: 40px 16px; }
.logo { font-size: clamp(22px, 5vw, 46px); text-align: center; color: var(--gold-hi); text-shadow: 4px 4px 0 #000, 0 0 24px #c9b27a55; margin-bottom: 36px; }
.logo span { display: block; font-size: .35em; color: var(--muted); margin-top: 14px; letter-spacing: 4px; }
.logo-row { display: flex; justify-content: center; align-items: center; gap: clamp(16px, 5vw, 56px); margin-bottom: 36px; }
.logo-row .logo { margin-bottom: 0; }
/* a candle from the UI pack either side of the title; its warm light flickers */
.candle { position: relative; flex: none; width: 32px; height: 64px; background: url(../assets/ui/candle.png) center / 32px 64px no-repeat; image-rendering: pixelated; }
.candle::before { content: ''; position: absolute; left: 50%; top: 10px; width: 90px; height: 90px; margin-left: -45px; margin-top: -45px; border-radius: 50%;
  background: radial-gradient(#ffb34740, #ff8a2a14 45%, transparent 70%); animation: flicker 2.3s steps(1) infinite; pointer-events: none; }
.candle:last-child::before { animation-duration: 1.7s; animation-delay: -.6s; }
@keyframes flicker { 0% { opacity: 1; } 18% { opacity: .75; } 31% { opacity: .95; } 47% { opacity: .7; } 62% { opacity: 1; } 80% { opacity: .82; } }
@media (max-width: 560px) { .candle { display: none; } }
.credits { margin: 28px auto 0; max-width: 760px; text-align: center; font-size: 17px; line-height: 1.4; color: var(--muted); opacity: .8; }
.credits a { color: var(--gold); }
/* pixel icons from the UI pack in buttons, shown at whole multiples of their size */
img.px { display: block; flex: none; image-rendering: pixelated; }
.btn.ico { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#leave.ico { padding-top: 4px; padding-bottom: 4px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.gm-battle { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px dashed #5a5236; padding-top: 8px; margin-top: 8px; }

/* pages */
.page { max-width: 1000px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 16px; }
.page-head h2 { margin: 0; }
.upload-row { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.char-item { display: flex; gap: 10px; align-items: center; background: #0006; border: 1px solid #5a5236; border-radius: 4px; padding: 8px; }
.char-item canvas, .char-item img { width: 48px; height: 48px; image-rendering: pixelated; flex: none; border-radius: 3px; object-fit: cover; }
.char-item .meta { flex: 1; min-width: 0; }
.char-item .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnings { color: #f3c96b; font-size: 18px; }
.warnings li { margin: 2px 0; }
.sheet-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; margin-top: 10px; }
.rules-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 70vh; overflow: auto; }
.rule { background: #0006; border-left: 3px solid var(--gold); padding: 6px 10px; }
.rule b { color: var(--gold-hi); }
.rule .lv { margin: 2px 0 0 10px; }
.rule small { color: var(--muted); }
#rules-tabs .btn.on { background: linear-gradient(#8a6d2e, #4f3d16); }

/* battle */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #000a; border-bottom: 2px solid var(--gold); gap: 8px; flex-wrap: wrap; }
.tb-left, .tb-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.b-name { font-family: var(--pixel); font-size: 12px; color: var(--gold-hi); }
.gm-bar { display: none; gap: 8px; align-items: center; padding: 6px 12px; background: #1a1209cc; border-bottom: 1px solid #5a5236; flex-wrap: wrap; }
body.is-gm .gm-bar { display: flex; }
body:not(.is-gm) .gm-only { display: none !important; }
.battle { flex: 1; display: grid; grid-template-columns: 1fr 360px; gap: 10px; padding: 10px; min-height: 0; }
.board-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.board-wrap { flex: 1; overflow: auto; background: #050705; border: 3px solid var(--gold); border-radius: 6px; box-shadow: 0 0 0 2px #000; min-height: 240px; position: relative; }
#board { display: block; image-rendering: pixelated; cursor: pointer; margin: auto; }
.board-wrap { display: flex; }
.board-tools { display: flex; gap: 6px; align-items: center; }
#zoom-fit svg, #zoom-me svg { display: block; }
.zoom-level { font-family: var(--pixel); font-size: 9px; color: var(--gold-hi); min-width: 46px; text-align: center; }
/* Wide screens: the zoom bar sits on the map's top left corner (the GM drawer covers the right side) */
@media (min-width: 1001px) {
  .board-col { position: relative; }
  .board-tools { position: absolute; z-index: 2; top: 11px; left: 11px; right: 30px; pointer-events: none; flex-wrap: wrap; }
  .board-tools .btn, .zoom-level { pointer-events: auto; height: 32px; min-width: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
    background: #000c; box-shadow: 0 0 0 2px #000; }
  .board-tools .btn { font-size: 9px; }
  @media (hover: hover) { .board-tools .btn:hover { background: linear-gradient(#4a6340, #26361f); } }
  .board-tools .btn:disabled { opacity: 1; color: #6c6656; border-color: #5a5236; }
  .board-tools .btn:disabled img { opacity: .4; }
  .zoom-level { border: 2px solid #5a5236; border-radius: 4px; margin: 0 -4px; }
  #zoom-fit { margin-left: 6px; }
  #hover-info { pointer-events: none; margin-left: 6px; padding: 3px 8px; background: #000b; border-radius: 3px; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #hover-info:empty { display: none; }
  /* dragging the map with the mouse */
  body.panning, body.panning #board { cursor: grabbing; }
}
.side-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.order-win ol { list-style: none; margin: 0; padding: 0; max-height: 26vh; overflow: auto; }
.order-win li { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 3px; cursor: pointer; }
.order-win li.cur { background: #c9b27a33; outline: 1px solid var(--gold); }
.order-win li.dead { opacity: .4; text-decoration: line-through; }
.order-win li canvas { width: 24px; height: 24px; image-rendering: pixelated; }
.order-win li .hpbar { flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.party-c { color: var(--party); } .enemy-c { color: var(--enemy); } .neutral-c { color: var(--neutral); }
.card-win { overflow: auto; max-height: 36vh; }
.card-win .head { display: flex; gap: 10px; align-items: center; }
.card-win .head canvas, .card-win .head img { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 3px; object-fit: cover; }
.attrs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 8px; font-size: 18px; margin: 6px 0; }
.attrs span b { color: var(--gold-hi); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tag { font-size: 16px; background: #0008; border: 1px solid #5a5236; border-radius: 3px; padding: 0 6px; }
.tag.cond { border-color: #a35; color: #f9b; }
.tag.ok { border-color: #496; }
.hpbar { height: 8px; background: #300; border: 1px solid #000; position: relative; min-width: 40px; }
.hpbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#9be36f, #3f9a2a); }
.hpbar.low i { background: linear-gradient(#f3c96b, #b07a1a); }
.hpbar.crit i { background: linear-gradient(#ff7a6a, #a12a1a); }
.log-win { flex: 1; min-height: 160px; display: flex; flex-direction: column; }
#log { flex: 1; overflow: auto; font-size: 17px; line-height: 1.1; }
#log div { padding: 1px 0; border-bottom: 1px solid #ffffff08; }
#log .k-round { color: var(--gold-hi); text-align: center; margin-top: 6px; }
#log .k-turn { color: var(--gold); }
#log .k-roll { color: #cfd8e8; }
#log .k-roll.ok::before { content: '✔ '; color: var(--good); }
#log .k-roll.fail::before { content: '✘ '; color: var(--bad); }
#log .k-damage { color: #ff9b8a; }
#log .k-heal { color: var(--good); }
#log .k-corruption { color: var(--corrupt); }
#log .k-death { color: #ff5a4a; font-weight: bold; }
#log .k-condition { color: #e8b8f0; }
#log .k-gm { color: #888; font-style: italic; }
#log .k-info { color: #bbb; }
#log .k-private { color: #8fd3ff; }

/* command menu */
.command { min-height: 120px; display: flex; gap: 12px; }
.command .cmd-cats { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.command .cmd-list { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; align-content: start; max-height: 180px; overflow: auto; }
.command .cmd-desc { width: 280px; font-size: 17px; color: #d8d0b8; border-left: 1px dashed #5a5236; padding-left: 10px; overflow: auto; max-height: 180px; }
.cmd {
  font-family: var(--body); font-size: 19px; text-align: left; color: var(--text); background: transparent; border: 0; padding: 2px 6px 2px 18px;
  cursor: pointer; position: relative; border-radius: 3px;
}
.cmd.on { background: #c9b27a22; }
.cmd.on::before { content: '▶'; position: absolute; left: 2px; color: var(--gold-hi); font-size: 14px; top: 4px; }
@media (hover: hover) {
  .cmd:hover { background: #c9b27a22; }
  .cmd:hover::before { content: '▶'; position: absolute; left: 2px; color: var(--gold-hi); font-size: 14px; top: 4px; }
}
.cmd:disabled { color: #6c6656; cursor: not-allowed; }
.cmd .cost { color: var(--muted); font-size: 15px; margin-left: 6px; }
.turn-pips { display: flex; gap: 6px; margin: 4px 0 6px; font-size: 16px; }
.pip { padding: 0 6px; border: 1px solid #5a5236; border-radius: 3px; }
.pip.on { border-color: var(--good); color: var(--good); }
.pip.off { color: #666; text-decoration: line-through; }
.targeting { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.end-turn { margin-top: 6px; }
.targeting b { font-family: var(--pixel); font-size: 10px; color: var(--sel); }

/* modals and drawer */
.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; }
.prompt-box { max-width: 520px; border-color: var(--gold-hi); animation: pop .15s ease-out; }
.prompt-box .opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); z-index: 40; overflow: auto; border-radius: 0; }
.drawer .tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.drawer .tabs .btn.on { background: linear-gradient(#8a6d2e, #4f3d16); }
.drawer section { display: flex; flex-direction: column; gap: 8px; }
.drawer .close { position: absolute; top: 8px; right: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.opt-row { display: flex; gap: 8px; align-items: flex-start; }
.opt-row input { width: auto; margin-top: 5px; }
.tiles-pal { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tiles-pal button { padding: 2px; background: #000; border: 2px solid #333; cursor: pointer; color: var(--text); font-family: var(--body); font-size: 14px; }
.tiles-pal button.on { border-color: var(--sel); }
.tiles-pal canvas { width: 100%; image-rendering: pixelated; display: block; }
.combatant-row { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid #ffffff10; padding: 4px 0; }
.combatant-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combatant-row input { width: 60px; padding: 0 4px; }
.combatant-row select { width: auto; flex: none; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; }
.toast { background: #1d0c0a; border: 2px solid var(--bad); padding: 6px 12px; border-radius: 4px; animation: pop .15s; }
.toast.ok { border-color: var(--good); background: #0c1d0a; }
.dice-pop { position: fixed; z-index: 45; pointer-events: none; font-family: var(--pixel); font-size: 18px; padding: 10px 14px; border: 3px solid var(--gold); background: #000d; border-radius: 6px; animation: pop .15s; }
.dice-pop.ok { border-color: var(--good); } .dice-pop.fail { border-color: var(--bad); }
.dice-pop small { display: block; font-family: var(--body); font-size: 16px; color: var(--muted); margin-top: 4px; max-width: 280px; }

/* narrow screens and touch: mobile.css */
.row input, .row select { width: auto; }
.scene-notes { margin: 6px 0; padding-left: 18px; line-height: 1.45; }
.scene-notes li { margin-bottom: 4px; }
.reserve { border-bottom: 1px solid #ffffff10; padding-bottom: 4px; }
.balance-sum { border: 1px solid #5a5236; background: #0006; border-radius: 3px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.balance-sum .btn { align-self: flex-start; margin-top: 4px; }
.verdict { border: 1px solid currentColor; border-radius: 3px; padding: 0 5px; font-size: 16px; }
.verdict.v-easy { color: var(--party); } .verdict.v-fair { color: var(--good); }
.verdict.v-hard { color: var(--neutral); } .verdict.v-deadly { color: var(--bad); }
.small-print { font-size: 16px; line-height: 1.2; }
.reserve .combatant-row { border-bottom: none; }

/* ---------- game mode / test mode ---------- */
.mode-chip { cursor: default; }
.mode-chip.saved { border-color: var(--good); color: var(--good); cursor: pointer; }
.mode-chip.practice { border-color: var(--neutral); color: var(--neutral); animation: practice-pulse 2.4s ease-in-out infinite; }
@keyframes practice-pulse { 50% { box-shadow: 0 0 10px #e0c04a66; } }
.mode-btns { display: inline-flex; gap: 8px; }
.gm-battle-btns { white-space: nowrap; }
body.split #view-battle.active { width: 55vw; }
.preview { position: fixed; top: 0; right: 0; bottom: 0; width: 45vw; z-index: 30; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 0; }
.preview.hidden { display: none; }
.preview-head { display: flex; gap: 6px; align-items: center; }
.preview-head select { flex: 1; min-width: 0; }
.preview iframe { flex: 1; width: 100%; border: 2px solid var(--gold); background: var(--bg); }
body.is-preview #leave { display: none; }
@media (max-width: 900px) {
  body.split #view-battle.active { width: auto; }
  .preview { width: 100%; top: 40vh; }
}
.mode-btns .btn.on { background: linear-gradient(#8a6d2e, #4f3d16); }
/* planning ahead while someone else acts */
.cmd-cats.planning { border-left: 2px solid #8a7a3a; padding-left: 6px; }
.plan-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; font-size: 16px; }
.plan-queue { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; font-size: 16px; }
.plan-end { font-size: 16px; margin: 2px 0 4px; }
body.is-preview #btn-music { display: none; }

/* ---------- advance a character (js/advance.js) ---------- */
.adv-head { display: grid; grid-template-columns: 1fr auto; gap: 10px 18px; align-items: start; }
.adv-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.adv-id canvas, .adv-id img { width: 64px; height: 64px; image-rendering: pixelated; flex: none; border-radius: 3px; object-fit: cover; }
.adv-id .meta { min-width: 0; }
.adv-id h2 { margin-bottom: 6px; overflow-wrap: anywhere; }
.adv-stats { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.adv-xp { display: flex; gap: 10px; align-items: center; border: 2px solid var(--gold); border-radius: 4px; padding: 6px 12px; background: #0008; line-height: 1; }
.adv-xp-n { font-family: var(--pixel); font-size: 26px; color: var(--gold-hi); text-shadow: 2px 2px 0 #000; }
.adv-corr { display: flex; flex-direction: column; font-size: 18px; border: 1px solid #5a5236; border-radius: 3px; padding: 4px 10px; background: #0006; }
.adv-corr b { color: var(--corrupt); }
.adv-corr.high { border-color: var(--corrupt); }
.adv-add, .adv-head > .row { grid-column: 1 / -1; }
.adv-add label { color: var(--text); }
.adv-add .row { margin-top: 4px; }
input.adv-n { width: 90px; flex: none; }
input.adv-note { flex: 1; min-width: 0; width: auto; }
.adv-tabs { margin-top: 0; }
.adv-tabs .btn.on { background: linear-gradient(#8a6d2e, #4f3d16); }
.adv-hint { margin: 8px 0; }
.adv-search { margin-bottom: 8px; }
.adv-list { display: flex; flex-direction: column; gap: 6px; }
.adv-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; background: #0006; border: 1px solid #5a5236; border-left-width: 3px; border-radius: 3px; padding: 6px 10px; cursor: pointer; }
.adv-row.owned { border-left-color: var(--gold); background: #c9b27a14; }
.adv-main { min-width: 0; }
.adv-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.adv-name b { color: var(--gold-hi); }
.adv-name .tag { font-size: 15px; }
.tag.corrupt { border-color: var(--corrupt); color: var(--corrupt); }
.pips { color: var(--gold); letter-spacing: 2px; font-size: 16px; }
.adv-desc { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adv-desc.full { white-space: normal; }
.adv-note-line { font-size: 17px; color: #d8c890; }
.adv-row .warnings { font-size: 17px; }
.adv-details { margin-top: 4px; font-size: 17px; display: flex; flex-direction: column; gap: 3px; border-top: 1px dashed #5a5236; padding-top: 4px; cursor: auto; }
.adv-details .lv { padding-left: 8px; border-left: 2px solid transparent; }
.adv-details .lv.next { border-left-color: var(--good); }
.adv-details .lv.have { opacity: .75; }
.adv-act { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.adv-act select { width: auto; font-size: 18px; }
.adv-done { white-space: nowrap; border-color: #5a5236; color: var(--gold-hi); }
.adv-history { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.adv-log { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; border-bottom: 1px solid #ffffff10; padding: 3px 0; font-size: 18px; }
.adv-log.undone .adv-log-text { text-decoration: line-through; text-decoration-color: #9c947999; color: var(--muted); }
.adv-award-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 12px; margin: 8px 0; }
.corrupt-text { color: var(--corrupt); }
#lib-list .char-item { flex-wrap: wrap; }
#lib-list .char-item .meta { flex: 1 1 120px; }
.char-btns { display: flex; gap: 6px; margin-left: auto; align-items: center; }
@media (max-width: 640px) {
  .adv-head { grid-template-columns: 1fr; }
  .adv-stats { flex-direction: row; flex-wrap: wrap; }
  .adv-stats > * { flex: 1; }
  .adv-row { grid-template-columns: 1fr; }
  .adv-act { justify-content: flex-start; }
  .adv-desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .adv-desc.full { display: block; }
  .adv-log { grid-template-columns: 1fr auto; }
  .adv-log > .muted { grid-column: 1 / -1; font-size: 16px; }
}

/* ---------------- accounts ---------------- */
body:not(.acct-gm) .acct-gm-only { display: none !important; }
body:not(.acct-player) .acct-player-only { display: none !important; }
.login-box { max-width: 420px; margin: 0 auto; }
.login-box code { color: var(--gold-hi); font: inherit; }
.who-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: flex-end; margin: -20px 0 16px; }
.who-bar:empty { display: none; }
.who-links { display: flex; gap: 6px; flex-wrap: wrap; }
.gm-chip { margin-left: 8px; font-size: 8px; padding: 2px 6px; vertical-align: middle; }
.acct-list { display: flex; flex-direction: column; gap: 8px; }
.acct-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #0006; border: 1px solid #5a5236; border-radius: 4px; padding: 8px 10px; }
.acct-main { flex: 1 1 220px; min-width: 0; }
.ledger { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow: auto; }
.ledger-row { display: grid; grid-template-columns: minmax(110px, auto) minmax(90px, auto) 1fr auto; gap: 10px; font-size: 18px; padding: 2px 0; border-bottom: 1px solid #5a523633; }
.ledger-row .pos { color: var(--good); } .ledger-row .neg { color: var(--bad); }
.pw-show { font-size: 22px; letter-spacing: 1px; text-align: center; }
@media (max-width: 560px) {
  .who-bar { justify-content: flex-start; margin-top: -24px; }
  .ledger-row { grid-template-columns: 1fr auto; }
  .ledger-row > :nth-child(3) { grid-column: 1 / -1; }
}

/* ---------------- Challenge Ladder ---------------- */
.home-grid > .window:nth-child(4) { animation-delay: .24s; }
.ladder-home { border-color: #d8a040; }
.ladder-intro p:first-child { margin-top: 0; }
.chip.tier { font-size: 7px; padding: 3px 6px; white-space: nowrap; }
.chip.tier.t1 { border-color: #6fb35a; color: #a8e08a; } .chip.tier.t2 { border-color: #8ab84a; color: #c8e08a; }
.chip.tier.t3 { border-color: #c9b27a; color: #f0dca0; } .chip.tier.t4 { border-color: #d89a40; color: #f0c070; }
.chip.tier.t5 { border-color: #d8703a; color: #f0a070; } .chip.tier.t6 { border-color: #d84a3a; color: #ff8a70; }
.chip.tier.t7 { border-color: #a83a6a; color: #f08ab0; } .chip.tier.t8 { border-color: #8a4ad8; color: #c8a0ff; background: #2a104a; }
.boss-chip, .chip.ladder-chip.boss { border-color: #f0c040; color: #ffe27a; background: #3a1a0a; font-size: 7px; padding: 3px 6px; }
.hero-row { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-pick { display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: #0006; border: 2px solid #c9b27a55; border-radius: 4px; padding: 6px 10px 6px 6px; min-width: 200px; }
.hero-pick img, .hero-pick canvas { width: 40px; height: 40px; object-fit: cover; image-rendering: pixelated; border-radius: 3px; }
.hero-pick span { display: flex; flex-direction: column; } .hero-pick small { font-size: 16px; }
.hero-pick.on { border-color: var(--sel); background: #3a3410aa; box-shadow: 0 0 10px #ffe27a44; }
.ladder-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.ladder-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rung { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 2px solid transparent; border-radius: 3px; cursor: pointer; background: #0004; }
.rung-no { font-family: var(--pixel); font-size: 10px; width: 26px; text-align: right; color: var(--gold); }
.rung-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rung-name b, .rung-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rung-name small { font-size: 15px; }
.rung-mark { width: 22px; text-align: center; }
.rung.cleared .rung-mark { color: var(--good); }
.rung.open { background: #3a3410aa; } .rung.open .rung-mark { color: var(--sel); }
.rung.locked { opacity: .5; }
.rung.boss { background: linear-gradient(90deg, #3a1a0acc, #0004); }
.rung.sel { border-color: var(--sel); opacity: 1; }
@media (hover: hover) { .rung:hover { border-color: #c9b27a88; } }
.level-win { position: relative; }
.level-win h2 { margin: 6px 0 0; font-size: 13px; line-height: 1.5; }
.level-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level-no { font-family: var(--pixel); font-size: 9px; color: var(--muted); }
.map-thumb { width: 100%; height: auto; image-rendering: pixelated; border: 2px solid #000; border-radius: 3px; display: block; margin: 6px 0; }
.foes { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.foes li { display: flex; align-items: center; gap: 8px; }
.foes li.boss b { color: #ffe27a; }
.foes canvas { flex: none; }
.big-go { font-size: 11px; padding: 10px 14px; }
.boss-ribbon { font-family: var(--pixel); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: #1a0e04; background: linear-gradient(90deg, #f0c040, #ffe27a, #f0c040);
  padding: 5px 10px; margin: -4px -4px 8px; border-radius: 2px; text-align: center; box-shadow: 0 2px 0 #000; }
.window.boss, .lc-box.boss { border-color: #f0c040; box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #0006, 0 6px 18px #0009, 0 0 22px #f0a03055; }
table.score { width: 100%; border-collapse: collapse; }
table.score th { font-family: var(--pixel); font-size: 8px; color: var(--gold); text-align: left; padding: 4px 6px; border-bottom: 2px solid #c9b27a55; }
table.score td { padding: 4px 6px; border-bottom: 1px solid #ffffff12; }
table.score tr.top1 td { color: #ffe27a; } table.score tr.top2 td { color: #e0e0e8; } table.score tr.top3 td { color: #e0a070; }
.ladder-score .btn.danger { margin-top: 10px; }
/* in the battle: the card before and after the fight */
.ladder-card { position: fixed; inset: 0; z-index: 46; display: flex; align-items: center; justify-content: center; padding: 16px; background: #000a; pointer-events: auto; }
.ladder-card .lc-box { position: relative; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto;
  background: linear-gradient(180deg, var(--win-top), var(--win-bot)); border: 3px solid var(--gold); border-radius: 6px; padding: 16px; animation: rise .35s cubic-bezier(.2, 1.2, .4, 1) both; }
.ladder-card h2 { font-size: 13px; line-height: 1.5; margin: 8px 0 2px; }
.ladder-card .fold { position: absolute; top: 6px; right: 6px; }
.ladder-card.folded { inset: auto 0 0 0; background: none; pointer-events: none; padding: 8px; align-items: flex-end; }
.ladder-card.folded .lc-box { pointer-events: auto; max-height: 64px; overflow: hidden; animation: none; }
.lc-result { font-family: var(--pixel); font-size: 18px; letter-spacing: 3px; text-align: center; margin: 4px 0 8px; text-shadow: 3px 3px 0 #000; }
.lc-box.won { border-color: #7fd36a; } .lc-box.won .lc-result { color: #a8f08a; }
.lc-box.lost { border-color: #ef6a5a; } .lc-box.lost .lc-result { color: #ff8a7a; }
.new-best { font-family: var(--pixel); font-size: 10px; color: #ffe27a; animation: glow 1.6s ease-in-out infinite; }
.chip.ladder-chip { border-color: #d8a040; color: #f0dca0; }
.ladder-giveup { margin-left: 4px; }
body.is-ladder #btn-mychars, body.is-ladder #b-code, body.is-ladder .gm-bar, body.is-ladder #btn-gm { display: none !important; }
.banner.boss span { color: #ffe27a; text-shadow: 3px 3px 0 #000, 0 0 18px #f0a030; } .banner.boss small { color: #ffe27a; font-size: 22px; }
.banner.win span { color: #a8f08a; } .banner.lost span { color: #ff8a7a; }
@media (max-width: 760px) {
  .ladder-grid { grid-template-columns: minmax(0, 1fr); }
  .level-win { order: -1; }
  table.score .wide { display: none; }
  .hero-pick { min-width: 0; flex: 1 1 100%; }
}
.lc-box .level-head { padding-right: 34px; }
.banner.big.boss.show { animation-duration: 2.2s; }
.banner.big.boss.show span { animation-duration: 2.2s; }
