:root {
  --ink: #141a1c;
  --stone: #1e2629;
  --stone-2: #28322f;
  --line: #3a4541;
  --bone: #e8dfc8;
  --bone-dim: #a9a18c;
  --torch: #e5a443;
  --torch-glow: rgba(229, 164, 67, .35);
  --blood: #c0564a;
  --good: #7fc26a;

  --r-common: #b8b2a4;
  --r-uncommon: #6fc25a;
  --r-rare: #5b9be6;
  --r-epic: #b774e6;
  --r-legendary: #f0973c;

  --display: "Grenze Gotisch", "Alegreya Sans", serif;
  --body: "Alegreya Sans", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ink);
  color: var(--bone);
  font: 17px/1.5 var(--body);
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }

.btn {
  background: var(--stone-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .55em 1.1em;
  font-weight: 500;
}
.btn:hover { border-color: var(--bone-dim); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--torch);
  border-color: var(--torch);
  color: #231606;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { background: #f0b457; border-color: #f0b457; }
.btn-primary:disabled { background: var(--stone-2); border-color: var(--line); color: var(--bone-dim); opacity: 1; }
.btn-small { padding: .3em .75em; font-size: .9rem; }
.link-btn {
  background: none; border: 0; padding: .25em 0;
  color: var(--bone-dim); text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--bone); }
.link-btn.danger:hover { color: var(--blood); }

/* ---------- Login ---------- */
/* The front page: a torch-lit wall, the logo on top, the sign-up panel in the middle, a menu of
   RPG buttons on the left and the hero turning on the right. On narrow screens it stacks. */
.auth {
  --brass: #b08a4e; --brass-dim: #6e5431; --iron: #16110c;
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 26rem); justify-content: center;
  grid-template-areas: "head" "hero" "panel" "menu";
  gap: 1.5rem; padding: 2rem 16px 5rem; min-height: 100vh; box-sizing: border-box;
}
.auth::before { content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse 26% 60% at 50% 58%, rgba(10, 8, 6, .55), rgba(10, 8, 6, 0) 85%),
              linear-gradient(rgba(10, 8, 6, .05), rgba(10, 8, 6, .1) 60%, rgba(10, 8, 6, .6)), url(assets/front-bg.webp) center / cover, var(--ink); }
.front-fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.front-head { grid-area: head; text-align: center; }
.front-head .brand-auth { justify-content: center; }
.front-head .auth-lede { margin: .5rem auto 0; max-width: 44rem; text-wrap: balance; text-shadow: 0 1px 3px #000; }
.front-panel { grid-area: panel; position: relative; padding: 1.4rem 1.5rem 1.5rem; border-radius: 3px;
  background: linear-gradient(rgba(30, 24, 18, .94), rgba(16, 13, 10, .96));
  border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .7), inset 0 0 40px rgba(0, 0, 0, .55), 0 0 0 4px var(--iron), 0 0 0 5px var(--brass-dim), 0 24px 60px rgba(0, 0, 0, .75); }
/* Brass corner pieces: an L-bracket with a stud */
.panel-corner { position: absolute; width: 30px; height: 30px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M2 28V2h26' fill='none' stroke='%23d9b06a' stroke-width='3'/%3E%3Cpath d='M7 23V7h16' fill='none' stroke='%236e5431' stroke-width='1.5'/%3E%3Ccircle cx='6' cy='6' r='3.2' fill='%23e5c27f' stroke='%233a2a14'/%3E%3C/svg%3E") no-repeat; }
.panel-corner.tl { top: -7px; left: -7px; }
.panel-corner.tr { top: -7px; right: -7px; transform: scaleX(-1); }
.panel-corner.bl { bottom: -7px; left: -7px; transform: scaleY(-1); }
.panel-corner.br { bottom: -7px; right: -7px; transform: scale(-1, -1); }
.front-panel .auth-switch { margin-top: -.2rem; }

.front-menu { grid-area: menu; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; align-content: start; }
.rpg-btn { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; box-sizing: border-box; width: 100%;
  font: 700 .98rem/1.1 Cinzel, var(--display); letter-spacing: .04em; color: #f0d9a8; text-decoration: none; text-align: left;
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(0, 0, 0, .6); cursor: pointer; border-radius: 2px;
  background: linear-gradient(#43362a, #2a2119 55%, #1d1712);
  border: 1px solid var(--brass);
  box-shadow: inset 0 1px 0 rgba(255, 225, 170, .22), inset 0 -3px 0 rgba(0, 0, 0, .45), 0 0 0 3px var(--iron), 0 0 0 4px var(--brass-dim), 0 6px 14px rgba(0, 0, 0, .55);
  transition: color .15s, box-shadow .15s, transform .1s; }
.rpg-btn svg { flex: none; width: 1.3rem; height: 1.3rem; fill: none; stroke: #d9b06a; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.rpg-btn:hover, .rpg-btn:focus-visible { color: var(--torch); outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 225, 170, .3), inset 0 -3px 0 rgba(0, 0, 0, .45), 0 0 0 3px var(--iron), 0 0 0 4px var(--torch), 0 0 18px var(--torch-glow); }
.rpg-btn:hover svg, .rpg-btn:focus-visible svg { stroke: var(--torch); }
.rpg-btn:active { transform: translateY(1px); }
.rpg-btn[hidden] { display: none; }
.front-legal { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .3rem 1rem; justify-content: center; margin: .6rem 0 0; font-size: .8rem; color: var(--bone-dim); text-shadow: 0 1px 2px #000; }
.front-legal a { color: var(--bone-dim); }
.front-legal a:hover { color: var(--torch); }

@media (min-width: 64rem) {
  .auth { grid-template-columns: minmax(12rem, 1fr) minmax(0, 27rem) minmax(12rem, 1fr);
    grid-template-areas: "head head head" "menu panel hero"; column-gap: clamp(1.5rem, 4vw, 4rem); padding-top: 2.5rem; }
  .front-menu { grid-template-columns: minmax(0, 15rem); justify-content: end; }
  .front-legal { justify-content: flex-start; }
}
.logo {
  font: 700 clamp(3.5rem, 12vw, 5.5rem)/1 var(--display);
  margin: 0;
  color: var(--torch);
  text-shadow: 0 0 28px var(--torch-glow);
}
.auth-lede { color: var(--bone-dim); margin: .75rem 0 2rem; }
.auth-form { display: grid; gap: 1rem; }
.auth-switch { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); }
.auth-switch button {
  background: none; border: 0; padding: .4em 0; margin-bottom: -1px;
  color: var(--bone-dim); border-bottom: 2px solid transparent;
}
.auth-switch button[aria-selected="true"] { color: var(--bone); border-color: var(--torch); }
.auth-form label { display: grid; gap: .3rem; font-size: .95rem; color: var(--bone-dim); }
.auth-form input {
  font: inherit; color: var(--bone);
  background: var(--stone); border: 1px solid var(--line); border-radius: 4px;
  padding: .6em .75em;
}
.form-error { color: var(--blood); min-height: 1.5em; margin: 0; }
.auth-switch { margin-bottom: 1rem; }
.auth-form label.invalid input { border-color: var(--blood); }
.field-error { color: var(--blood); font-size: .82rem; min-height: 0; }
.field-error:empty { display: none; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 4.2rem; }
.pw-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--bone-dim); font-size: .85rem; padding: .3rem .4rem;
}
.pw-toggle:hover { color: var(--bone); }
.pw-meter { display: block; height: 5px; border-radius: 3px; background: var(--ink); overflow: hidden; margin-top: .15rem; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; background: var(--blood); }
.pw-meter i[data-score="2"] { background: var(--torch); }
.pw-meter i[data-score="3"], .pw-meter i[data-score="4"] { background: var(--good); }
.pw-rules { list-style: none; margin: .2rem 0 0; padding: 0; font-size: .82rem; color: var(--bone-dim); display: grid; gap: .1rem; }
.pw-rules li::before { content: "○ "; }
.pw-rules li.ok { color: var(--good); }
.pw-rules li.ok::before { content: "✓ "; }
.auth-form label.check { display: flex; flex-direction: row; align-items: center; gap: .5rem; color: var(--bone); font-size: .95rem; cursor: pointer; }
.auth-form label.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--torch); margin: 0; }
.gender-pick { display: flex; gap: .7rem; border: 0; padding: 0; margin: 0; }
.gender-pick legend { padding: 0; margin-bottom: .35rem; font-size: .9rem; color: var(--bone-dim); }
.auth-form .gender-pick label { flex: 1; display: flex; justify-content: center; padding: .55rem .4rem;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--bone-dim); font-weight: 700; }
.gender-pick input { position: absolute; opacity: 0; pointer-events: none; }
/* The hero being made turns on the right, as tall as the panel (sizePreview); above the panel on narrow screens */
.hero-preview { grid-area: hero; display: flex; justify-content: center; }
.auth:has(#register-form[hidden]) .hero-preview { display: none; }
.hero-preview video { display: block; height: 16rem; width: auto; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .6)); }
/* Without transparent video (Safari) it is drawn on the page colour: fade its edges into a shadow */
.hero-preview.solid { background: radial-gradient(closest-side, rgba(20, 26, 28, .95), rgba(20, 26, 28, 0)); }
.hero-preview.solid video {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(transparent, #000 5%, #000 95%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(transparent, #000 5%, #000 95%, transparent);
  mask-composite: intersect; }
@media (min-width: 64rem) {
  .hero-preview { justify-content: flex-start; }
  .auth:has(#register-form[hidden]) .hero-preview { display: flex; }
}
.auth-form .gender-pick label:has(input:checked) { border-color: var(--torch); color: var(--torch); box-shadow: 0 0 0 1px var(--torch), 0 0 14px var(--torch-glow); }
.auth-form .gender-pick label:has(input:focus-visible) { outline: 2px solid var(--torch); outline-offset: 2px; }
.ts-box:empty { display: none; }
.ts-box { display: flex; justify-content: center; }
.code-title { font: 700 1.6rem/1.1 var(--display); color: var(--torch); margin: 0; }
.code-lede { margin: 0; color: var(--bone-dim); }
.code-lede strong { color: var(--bone); }
.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: .45rem; }
.code-boxes input {
  width: 100%; min-width: 0; aspect-ratio: 4 / 5; text-align: center; padding: 0;
  font: 700 1.9rem/1 Georgia, serif; color: #ffe2a8;
  background: #1a1510; border: 1px solid #8a6a2a; border-radius: 8px; box-shadow: inset 0 0 12px rgba(229,164,67,.2);
}
.code-boxes input:focus { outline: 2px solid var(--torch); outline-offset: 1px; }
.code-actions { display: flex; justify-content: space-between; gap: 1rem; margin: 0; flex-wrap: wrap; }
.link-btn:disabled { opacity: .5; cursor: default; text-decoration: none; }

/* ---------- Layout ---------- */
.game {
  display: grid;
  grid-template-columns: 27rem 1fr;
  min-height: 100vh;
}
.sheet {
  /* Rendered castle wall (art/render.py: render_sidebar). The image is 1:3.2, so its height is
     known from the column width; the last stretch fades into the wall colour for long pages. */
  --wall-h: calc(27rem * 3.2);
  background:
    linear-gradient(rgba(8,7,6,0) calc(var(--wall-h) - 14rem), #100e0c var(--wall-h)) top / 100% var(--wall-h) no-repeat,
    linear-gradient(rgba(8,7,6,.12), rgba(8,7,6,.12)),
    url(assets/sidebar.webp) top center / 100% auto no-repeat,
    #100e0c;
  border-right: 1px solid var(--line);
  padding: 1.5rem 1.1rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.stage { padding: 1.25rem 2rem 3rem; min-width: 0; }

/* ---------- Character sheet ---------- */
.hero-name {
  font: 700 2.4rem/1.05 var(--display);
  margin: 0;
  overflow-wrap: anywhere;
}
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #a8712a, var(--torch)); transition: width .8s ease; }
.sheet-title { font: 500 1.5rem/1 var(--display); margin: .5rem 0 0; }
#logout { align-self: flex-start; }
.sheet-foot { display: flex; justify-content: space-between; margin: auto 0 0; }
.app-dialog { width: min(36rem, calc(100vw - 32px)); }
.app-grid { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: start; margin-bottom: 1rem; }
.app-qr { width: 11rem; height: 11rem; border-radius: 10px; border: 3px solid #8a6a2a; image-rendering: pixelated; }
.app-step { margin: 0 0 .6rem; font-size: .95rem; }
.app-link { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .9rem; }
.app-link a { color: var(--torch); overflow-wrap: anywhere; }
.app-note { font-size: .82rem; color: var(--bone-dim); margin: 0 0 1rem; }
@media (max-width: 560px) { .app-grid { grid-template-columns: 1fr; justify-items: center; } }

/* Next goal: the one thing to aim for, lit like the torch */
.goal {
  border: 1px solid #5a4a2a; border-radius: 6px; padding: .9rem 1rem 1rem;
  background: linear-gradient(180deg, rgba(229,164,67,.10), rgba(229,164,67,.02));
}
.goal-name { margin: 0 0 .4rem; font-weight: 700; }
.goal-steps { list-style: none; margin: 0 0 .5rem; padding: 0; font-size: .92rem; display: grid; gap: .2rem; }
.goal-steps li::before { content: "○ "; color: var(--bone-dim); }
.goal-steps li.ok { color: var(--bone-dim); }
.goal-steps li.ok::before { content: "✓ "; color: var(--good); }
.goal-reward { margin: 0; font-size: .88rem; color: var(--bone-dim); }
.chip-text { font-size: .8rem; font-weight: 700; color: var(--chip); margin-left: .25rem; }

/* ---------- Character window (after the classic MMO character pane) ---------- */
.cw {
  --frame: #8c8f96; --frame-dark: #3b3d42; --gold-text: #ffd24a; --pane: rgba(8, 9, 11, .62);
  position: relative;
  background: #1b1b1c url(assets/stone.webp) center / cover;
  border: 3px solid var(--frame-dark);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #6d7077, inset 0 0 0 3px #222, 0 10px 30px rgba(0,0,0,.55);
  padding: .8rem .75rem 0;
  color: #f1ede3;
  margin-top: 2.2rem;
}
.cw-head { position: relative; padding: 0 0 .6rem 5.4rem; min-height: 4.6rem; }
.cw-portrait {
  position: absolute; left: -.9rem; top: -2.4rem; width: 5.6rem; height: 5.6rem; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a4150, #0c0e12);
  border: 3px solid #c9a34a; box-shadow: 0 0 0 2px #2a1d08, 0 4px 12px rgba(0,0,0,.7);
  object-fit: cover;
}
.cw-namebar {
  background: linear-gradient(#2a2b2f, #141517); border: 1px solid #55585f; border-radius: 4px;
  padding: .2rem .6rem; margin-bottom: .3rem;
}
.cw .hero-name { font: 700 1.15rem/1.3 Cinzel, var(--body); margin: 0; color: #fff; text-align: center; overflow-wrap: anywhere; }
.cw-level, .cw-title { margin: 0; text-align: center; color: var(--gold-text); font-size: .9rem; line-height: 1.3; text-shadow: 0 1px 1px #000; }
.cw-title { color: #e8e3d4; font-size: .85rem; }
.cw-standing {
  display: flex; justify-content: center; gap: 1rem; width: 100%; margin: .3rem 0 0; padding: .15rem .4rem;
  background: rgba(0,0,0,.35); border: 1px solid #5a4a2a; border-radius: 4px; font-size: .78rem; color: #cfc9b8;
}
.cw-standing b { color: #ffd24a; font-weight: 700; margin-left: .2rem; }
.cw-standing:hover { border-color: #ffd24a; }
.cw-xp {
  position: relative; height: 14px; margin: .45rem 0 0; border: 1px solid #55585f; border-radius: 3px;
  background: #0b0b0c; overflow: hidden;
}
.cw-xp .xp-fill { height: 100%; background: linear-gradient(#7a4fd0, #4b2a8e); }
.cw-xp span { position: absolute; inset: 0; font-size: .7rem; line-height: 12px; text-align: center; color: #fff; text-shadow: 0 1px 1px #000; }

.paperdoll { display: grid; grid-template-columns: 2.9rem 1fr 2.9rem; gap: .45rem; }
.slot-col { display: grid; gap: .3rem; align-content: start; }
.slot {
  position: relative; width: 2.9rem; height: 2.9rem; padding: 0; border-radius: 5px;
  background: #0d0e10; border: 2px solid #4a4d53;
  box-shadow: inset 0 0 0 1px #000, 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
}
.slot img { width: 100%; height: 100%; display: block; background: radial-gradient(circle at 50% 40%, #2e3440, #0d0e10 75%); }
.slot img.ghost { filter: grayscale(1) brightness(.8); opacity: .3; background: none; }
.slot:hover, .slot:focus-visible { border-color: #d8d8d8; outline: none; }
.slot.filled { border-color: var(--q); box-shadow: inset 0 0 0 1px #000, 0 0 6px color-mix(in srgb, var(--q) 45%, transparent); }
.q-common { --q: #9d9d9d; } .q-uncommon { --q: #1eff00; } .q-rare { --q: #0070dd; } .q-epic { --q: #a335ee; } .q-legendary { --q: #ff8000; }

.model {
  position: relative; border-radius: 6px; min-height: 18.6rem;
  background: radial-gradient(ellipse at 50% 70%, var(--flame-glow, rgba(255, 190, 110, .18)), rgba(0,0,0,.35) 70%);
  box-shadow: inset 0 0 18px rgba(0,0,0,.8);
  display: grid; place-items: end center; overflow: hidden;
}
.model-turn {
  position: relative; z-index: 1; height: 17rem; max-width: 100%; margin-bottom: 1rem;
  aspect-ratio: var(--fw, 275) / var(--fh, 429);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.6));
  cursor: grab; touch-action: pan-y; user-select: none;
}
/* One sprite sheet per layer, all the same size, stacked in dressing order (body first). */
.model-layer {
  position: absolute; inset: 0;
  background-repeat: no-repeat; background-size: calc(var(--frames, 1) * 100%) 100%;
  background-position: calc(var(--frame, 0) / max(1, var(--frames, 1) - 1) * 100%) 0;
}
.model-layer[hidden] { display: none; }
/* With depth sheets the layers are composited per pixel on a canvas (DepthView in app.js) */
.model-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.model-turn.depth .model-canvas { display: block; }
.model-turn.depth .model-layer { visibility: hidden; }
.model-shine { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; opacity: .55; }
/* The hero breathes: a slow, slight rise and fall */
@media (prefers-reduced-motion: no-preference) {
  .model-turn { animation: breathe 4.6s ease-in-out infinite alternate; transform-origin: 50% 100%; }
}
@keyframes breathe { from { transform: scale(1, 1); } to { transform: scale(1.004, 1.008); } }
.model-turn.dragging { cursor: grabbing; }
.rotate-btns { position: absolute; left: .3rem; top: .3rem; display: flex; gap: .25rem; z-index: 2; }
.rot {
  width: 1.9rem; height: 1.9rem; padding: 0; border-radius: 50%; font-size: 1rem; line-height: 1;
  color: #ffd24a; background: radial-gradient(circle at 40% 35%, #4a3a1c, #1a1307); border: 2px solid #8a6a2a;
  box-shadow: 0 2px 4px rgba(0,0,0,.6);
}
.rot:hover { border-color: #ffd24a; }
.model::after {
  content: ""; position: absolute; left: 50%; bottom: .5rem; width: 58%; height: 1.4rem; transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,.7), transparent 70%); z-index: 0;
}
.model-badges { position: absolute; right: .3rem; top: .3rem; display: grid; gap: .3rem; }
.badge {
  display: grid; place-items: center; width: 2.4rem; padding: .2rem 0; border-radius: 4px;
  background: rgba(0,0,0,.6); border: 1px solid #55585f; font-size: .72rem; line-height: 1.1;
}
.badge span { font-weight: 700; color: var(--gold-text); }
.badge b { color: #fff; }
.badge-star { font-size: .95rem; }

.stat-panels { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .45rem; }
.stat-panel { background: var(--pane); border: 1px solid #4a4d53; border-radius: 4px; padding: .3rem .4rem .35rem; min-width: 0; }
.stat-select, .pf-stat {
  width: 100%; font: 700 .8rem var(--body); color: #fff; background: linear-gradient(#34363b, #1a1b1e);
  border: 1px solid #6d7077; border-radius: 3px; padding: .15rem .3rem; margin-bottom: .25rem;
}
.stat-panel dl { margin: 0; }
.stat-panel div { display: flex; justify-content: space-between; gap: .3rem; font-size: .78rem; line-height: 1.45; }
.stat-panel dt { color: var(--gold-text); white-space: nowrap; }
.stat-panel dd { margin: 0; color: #fff; white-space: nowrap; }
.stat-panel dd.up { color: #1eff00; }

.weapons { display: flex; justify-content: center; gap: .4rem; margin: .5rem 0 .6rem; }

.cw-pane[hidden] { display: none; }
.pane-title { font: 700 1.2rem Cinzel, var(--body); color: var(--gold-text); margin: .2rem 0 .2rem; }
.pane-note { margin: 0 0 .6rem; font-size: .85rem; color: #d7d2c4; }
/* Every tab of the character window has the same height as the Character tab (31rem), so the
   window never jumps; longer tabs like Talents scroll inside. */
#cw-char { height: 31rem; margin-bottom: .6rem; }
#cw-attr, #cw-talents, #cw-currency {
  height: 31rem; overflow-y: auto; overscroll-behavior: contain;
  background: var(--pane); border: 1px solid #4a4d53; border-radius: 6px; padding: .6rem .7rem; margin-bottom: .6rem;
  scrollbar-width: thin; scrollbar-color: #6d6250 transparent;
}
#cw-attr::-webkit-scrollbar, #cw-talents::-webkit-scrollbar, #cw-currency::-webkit-scrollbar { width: 6px; }
#cw-attr::-webkit-scrollbar-thumb, #cw-talents::-webkit-scrollbar-thumb, #cw-currency::-webkit-scrollbar-thumb { background: #6d6250; border-radius: 3px; }
.stat-list { margin: 0; }
.stat-list div { display: flex; justify-content: space-between; align-items: center; padding: .5rem .2rem; border-bottom: 1px solid #3b3d42; }
.stat-list dt { display: flex; align-items: center; gap: .5rem; color: var(--gold-text); }
.stat-list dt img { width: 1.8rem; height: 1.8rem; }
.stat-list dd { margin: 0; font-weight: 700; }
.stat-list .gold { color: var(--gold-text); }
.cur-star { width: 1.8rem; text-align: center; font-size: 1.2rem; }

/* Bottom tabs, hanging under the frame */
.cw-tabs { display: flex; gap: .2rem; margin: 0 -.2rem -1.75rem; position: relative; top: 0; }
.cw-tabs button {
  position: relative; flex: 1; padding: .35rem .2rem .4rem; font-size: .78rem; font-weight: 700;
  color: var(--gold-text); background: linear-gradient(#26272b, #111214);
  border: 2px solid var(--frame-dark); border-top: 0; border-radius: 0 0 8px 8px;
  box-shadow: inset 0 0 0 1px #5a5d63;
}
.cw-tabs button[aria-selected="true"] { color: #fff; background: linear-gradient(#3a3c42, #1f2023); transform: translateY(2px); }
.cw-tabs .dot { position: absolute; top: .25rem; right: .3rem; width: 7px; height: 7px; border-radius: 50%; background: #1eff00; box-shadow: 0 0 6px #1eff00; }

.questlog {
  margin-top: 2.4rem;
  /* See-through, so the banner on the wall behind shows. */
  background: linear-gradient(rgba(14,12,10,.42), rgba(14,12,10,.58));
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
  border: 3px solid #3b3d42; border-radius: 10px;
  box-shadow: inset 0 0 0 2px #6d7077, inset 0 0 0 3px #222, 0 10px 30px rgba(0,0,0,.55);
  padding: .6rem .7rem .7rem;
}
.ql-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem; }
.ql-head img { width: 2.3rem; height: 2.3rem; }
.ql-head h2 { margin: 0; font: 700 1.1rem Cinzel, var(--body); color: #ffd24a; text-shadow: 0 1px 2px #000; }
.ql-ready {
  margin-left: auto; font-size: .75rem; font-weight: 700; color: #0b1a05; background: #7ccf5a;
  border-radius: 999px; padding: .1rem .55rem; box-shadow: 0 0 10px rgba(124,207,90,.6);
}
.ql-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.ql-item {
  display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: center;
  background: rgba(8,9,11,.72); border: 1px solid #4a4d53; border-radius: 6px; padding: .45rem .5rem;
}
.ql-item.ready { border-color: #7ccf5a; box-shadow: 0 0 10px rgba(124,207,90,.25); }
.ql-open { display: grid; gap: .15rem; text-align: left; background: none; border: 0; padding: 0; min-width: 0; color: #f1ede3; }
.ql-name { font-weight: 700; color: #ffd24a; font-size: .92rem; }
.ql-stars { font-style: normal; font-size: .72rem; color: #ffb43a; letter-spacing: .05em; margin-left: .2rem; }
.ql-stars .dim, .dg-time .dim, .ql-locked .dim { color: #4d4a44; }
.ql-step { font-size: .8rem; color: #d7d2c4; }
.ql-ahead { display: block; margin-top: .3rem; font-size: .76rem; color: var(--bone-dim); }
.ql-ahead b { color: var(--bone); }
.ql-bar { position: relative; height: 13px; border-radius: 3px; background: #0b0b0c; border: 1px solid #3b3d42; overflow: hidden; margin-top: .15rem; }
.ql-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#c98a2c, #8a5512); }
.ql-item.ready .ql-bar i { background: linear-gradient(#6fcf4a, #2f7a1c); }
.ql-bar em { position: relative; display: block; font-style: normal; font-size: .66rem; line-height: 11px; text-align: center; color: #fff; text-shadow: 0 1px 1px #000; }
.ql-turnin, .quest-dialog [data-turnin] {
  background: linear-gradient(#4f8f34, #2a5a1a); border-color: #7ccf5a; color: #fff; font-weight: 700;
  box-shadow: 0 0 10px rgba(124,207,90,.45);
}
.ql-locked, .ql-done { font-size: .8rem; color: #b9b4a6; padding: .15rem .2rem; }
.ql-locked strong { color: #d7d2c4; }

/* Quest log tabs and bounties */
.ql-tabs { display: flex; gap: .3rem; margin: 0 0 .5rem; }
.ql-tabs button {
  flex: 1; padding: .3rem .2rem; font: 700 .76rem var(--body); white-space: nowrap; color: #cfc3a8;
  background: linear-gradient(#26272b, #141517); border: 1px solid #3b3d42; border-radius: 5px;
}
.ql-tabs button[aria-selected="true"] { color: #ffe2a8; border-color: #8a6a2a; background: linear-gradient(#3a2e1e, #231b12); }
.ql-tabs b { color: #7ccf5a; }
.ql-period { display: flex; justify-content: space-between; margin: .3rem .1rem .3rem; font: 700 .85rem Cinzel, var(--body); color: #ffd24a; }
.ql-period span { font: 400 .75rem var(--body); color: #b9b4a6; }
.ql-bounties .ql-list + .ql-period { margin-top: .7rem; }
.ql-reward { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; font-size: .74rem; color: var(--torch); }
.ql-reward img { width: 1.1rem; height: 1.1rem; }
.ql-item.claimed { opacity: .5; }
.ql-claimed { color: #7ccf5a; font-weight: 700; padding: 0 .4rem; }

/* Enchanter */
.ench-wallet { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: .6rem 0 .25rem; }
.ench-wallet span { display: flex; align-items: center; gap: .35rem; font-weight: 700; font-size: 1.05rem; }
.ench-wallet small { font-weight: 400; font-size: .8rem; color: var(--bone-dim); }
.ench-wallet img { width: 2rem; height: 2rem; }
.ench-cost { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
.cost {
  display: inline-flex; align-items: center; gap: .15rem; font-size: .85rem; font-weight: 700;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .45rem .05rem .1rem;
}
.cost img { width: 1.4rem; height: 1.4rem; }
.cost.short { color: var(--blood); border-color: rgba(192,86,74,.5); }
.cost.gain { color: var(--good); }
.ench-max { font-size: .85rem; color: var(--r-legendary); font-weight: 700; }
.ench { color: #7ccf5a; font-weight: 700; }
.item-meta .up { color: var(--good); }
#tab-enchant .items li, #tab-shop .items li { background: rgba(14,12,10,.55); padding-left: .5rem; padding-right: .5rem; }

/* Deeds, reward choice and materials */
.ql-deed.ql-town { color: #9fd18a; border-color: #4f7a3c; }
.ql-go { background: linear-gradient(#3a3020, #1f1a12); border-color: #8a6a2a; color: #ffe2a8; }
.q-go { margin-left: .4rem; font-size: .82rem; color: var(--torch); }
.ql-deed { font-style: normal; font-size: .66rem; font-weight: 700; color: #cfc3a8; border: 1px solid #6d6250; border-radius: 3px; padding: 0 .25rem; margin-left: .2rem; vertical-align: 1px; }
.q-final.choosing { border-color: #7ccf5a; background: rgba(124,207,90,.07); }
.q-options { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: stretch; }
.q-option { display: grid; gap: .5rem; align-content: space-between; border: 1px solid var(--line); border-radius: 6px; padding: .55rem; background: rgba(0,0,0,.25); }
.q-or { align-self: center; font-size: .85rem; color: var(--bone-dim); }
.q-mats { display: grid; gap: .25rem; }
.mat { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .92rem; }
.mat img { width: 2rem; height: 2rem; }
.cur-head { margin: .9rem .2rem .1rem; font: 700 .85rem Cinzel, var(--body); color: #ffd24a; }
.cur-note { margin: .5rem .2rem 0; font-size: .78rem; color: #b9b4a6; }
@media (max-width: 520px) { .q-options { grid-template-columns: 1fr; } .q-or { justify-self: center; } }

/* Quest details */
.q-steps { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0; counter-reset: step; }
.q-steps li {
  counter-increment: step; display: grid; grid-template-columns: 1.6rem 1fr; gap: .1rem .5rem;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.q-steps li::before {
  content: counter(step); grid-row: span 2; width: 1.4rem; height: 1.4rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--ink); border: 1px solid var(--line);
}
.q-steps li.done::before { content: "✓"; background: #1f3d14; border-color: #7ccf5a; color: #7ccf5a; }
.q-steps li.done span { color: var(--bone-dim); text-decoration: line-through; text-decoration-color: rgba(185,180,166,.4); }
.q-steps li.current::before { border-color: var(--torch); color: var(--torch); }
.q-steps li.ready::before { border-color: #7ccf5a; color: #7ccf5a; }
.q-steps li.future { opacity: .55; }
.q-steps em { grid-column: 2; font-style: normal; font-size: .8rem; color: var(--torch); }
.q-steps b { color: var(--torch); }
.q-final { border: 1px solid #5a4a2a; border-radius: 6px; padding: .6rem .7rem; margin-bottom: 1rem; background: rgba(229,164,67,.07); }
.q-final > span { display: block; font-size: .8rem; color: var(--torch); margin-bottom: .35rem; }

/* Quest hints on dungeon cards, in the dungeon dialog and in the run report */
.quest-mark {
  position: absolute; top: .55rem; right: .7rem; display: flex; align-items: center; gap: .25rem;
  font-size: .72rem; font-weight: 700; color: #ffe2a8; background: rgba(0,0,0,.6);
  border: 1px solid #8a6a2a; border-radius: 999px; padding: .05rem .5rem .05rem .15rem;
}
.quest-mark img { width: 1.3rem; height: 1.3rem; }
.counts-for, .report-quests { border: 1px solid #5a4a2a; border-radius: 6px; padding: .5rem .7rem; margin: 0 0 1rem; background: rgba(229,164,67,.06); }
.counts-for > span, .report-quests > span { display: block; font-size: .8rem; color: var(--torch); margin-bottom: .25rem; }
.counts-for p, .report-quests p { margin: .15rem 0; font-size: .88rem; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.counts-for img, .report-quests img { width: 1.3rem; height: 1.3rem; }
.counts-for b, .report-quests b { color: var(--torch); }
.counts-for .miss { color: var(--bone-dim); font-size: .82rem; }
.report-quests p.ready b, .report-quests em { color: #7ccf5a; font-style: normal; font-weight: 700; }
.mobile-nav button.has-dot { position: relative; }
.mobile-nav button.has-dot::after {
  content: ""; position: absolute; top: .1rem; right: 28%; width: 9px; height: 9px; border-radius: 50%;
  background: #7ccf5a; box-shadow: 0 0 6px #7ccf5a;
}

.services {
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .9rem;
}
.services button {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  background: linear-gradient(#26272b, #141517); border: 2px solid #3b3d42; border-radius: 8px;
  box-shadow: inset 0 0 0 1px #5a5d63; padding: .45rem .6rem; color: var(--gold-text, #ffd24a); font-weight: 700;
}
.services button:hover:not(:disabled) { border-color: #8c8f96; }
.services button:disabled { cursor: default; filter: grayscale(.7); opacity: .7; }
.services img { width: 2.5rem; height: 2.5rem; flex: none; }
.services span { display: grid; line-height: 1.2; color: #ffd24a; }
.services small { font-weight: 400; font-size: .75rem; color: #b9b4a6; }

/* Item tooltip */
.tooltip {
  position: fixed; z-index: 50; max-width: 16rem; pointer-events: none;
  background: rgba(6, 8, 20, .94); border: 1px solid #8a8fa0; border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0,0,0,.6); padding: .5rem .65rem; display: grid; gap: .1rem; font-size: .85rem;
}
.tooltip strong { font-size: .95rem; }
.tooltip .tip-power { color: #fff; }
.tooltip .tip-meta { color: #b9b4a6; }
.tooltip .tip-sell { color: #ffd24a; }

/* Compare tooltip: hovered item next to what is worn now */
.tooltip.compare { display: flex; gap: .5rem; max-width: 34rem; padding: 0; background: none; border: 0; box-shadow: none; }
.cmp-card {
  display: grid; gap: .1rem; align-content: start; min-width: 12rem; max-width: 16rem;
  background: rgba(6, 8, 20, .95); border: 1px solid #8a8fa0; border-radius: 5px; padding: .5rem .65rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.6); font-size: .85rem;
}
.cmp-now { opacity: .92; border-color: #5a5f70; }
.cmp-tag { font-style: normal; font-size: .72rem; color: #b9b4a6; }
.cmp-rows { margin: .35rem 0 0; }
.cmp-rows div { display: flex; justify-content: space-between; gap: .8rem; }
.cmp-rows dt { color: #b9b4a6; }
.cmp-rows dd { margin: 0; color: #fff; }
.cmp-up { color: #1eff00; font-weight: 700; }
.cmp-down { color: #ff4a3d; font-weight: 700; }
.cmp-same { color: #b9b4a6; }
.cmp-verdict { margin: .35rem 0 0; font-weight: 700; color: #b9b4a6; }
.cmp-verdict.up { color: #1eff00; }
.cmp-verdict.down { color: #ff4a3d; }
.item-main { cursor: default; border-radius: 6px; }
.item-main:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }

/* ---------- Attributes and talents panes ---------- */
.plus-btn {
  width: 2rem; height: 2rem; border-radius: 5px; font-size: 1.15rem; line-height: 1; flex: none;
  background: linear-gradient(#3d6e2a, #1f3d14); border: 1px solid #7ccf5a; color: #fff;
}
.plus-btn:disabled { background: #111; border-color: #3b3d42; color: #6b6b6b; cursor: not-allowed; }
.attr-list { list-style: none; padding: 0; margin: .4rem 0; }
.attr-list li { display: grid; grid-template-columns: 1fr 2rem auto; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid #3b3d42; }
.attr-list strong { display: block; color: #ffd24a; }
.attr-list span { font-size: .8rem; color: #cfc9b8; }
.attr-val { font-size: 1.3rem; text-align: right; }
.reset-line { margin: .6rem 0 0; font-size: .85rem; }
.tree h3 { font: 700 .95rem Cinzel, var(--body); margin: .6rem 0 .3rem; color: #ffd24a; }
.talent {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center;
  border: 1px solid #3b3d42; border-radius: 5px; padding: .35rem .5rem; margin-bottom: .3rem; background: rgba(0,0,0,.35);
}
.talent strong { display: block; font-size: .88rem; }
.talent strong small { font-weight: 400; color: #b9b4a6; margin-left: .25rem; }
.talent span { display: block; font-size: .78rem; color: #cfc9b8; }
.talent.learned { border-color: #7ccf5a; }
.talent.learned strong small { color: #1eff00; }
.talent.locked { opacity: .5; }

/* ---------- Slot dialog & merchant ---------- */
.slot-actions { display: flex; gap: .5rem; margin: -.5rem 0 1rem; }
.sub-title { font: 500 1.35rem/1.1 var(--display); margin: 1.5rem 0 .5rem; }
.panel-title { font: 700 2.2rem/1 var(--display); margin: .25rem 0 0; }
.report .items.compact { margin: 0 0 1.25rem; display: block; }
.items.compact li { grid-template-columns: 1fr auto auto; }
.item-main { display: flex; gap: .7rem; align-items: center; min-width: 0; }
.item-icon {
  width: 2.6rem; height: 2.6rem; flex: none; overflow: hidden;
  border: 2px solid var(--q, #4a4d53); border-radius: 5px;
  background: radial-gradient(circle at 50% 40%, #2e3440, #0d0e10 75%);
}
.item-icon img { width: 100%; height: 100%; display: block; }
.worn-tag { font-size: .72rem; font-weight: 500; color: var(--ink); background: var(--bone-dim); border-radius: 3px; padding: 0 .3rem; margin-left: .3rem; vertical-align: middle; }

/* Town lock notice while the hero is out in a dungeon */
.town-lock {
  display: flex; align-items: center; gap: .6rem; margin: .6rem 0 1rem; max-width: 52rem;
  padding: .5rem .8rem; border: 1px solid #5a4a2a; border-radius: 8px; font-size: .9rem; color: #ffe2a8;
  background: linear-gradient(90deg, rgba(229,164,67,.16), rgba(229,164,67,.04));
}
.town-lock[hidden] { display: none; }
.town-lock img { width: 2rem; height: 2rem; flex: none; }
.questlog .town-lock { font-size: .8rem; margin: 0 0 .5rem; }
.in-dungeon .slot::after {
  content: "🔒"; position: absolute; right: 1px; bottom: 0; font-size: .6rem; opacity: .75; pointer-events: none;
}

/* Sell the whole backpack */
.sell-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-gold {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-weight: 700; color: #231606;
  background: linear-gradient(#f3c15a, #c8871f); border: 1px solid #8a5a12;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.35);
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(#ffd479, #d8962a); }
.btn-gold:disabled { background: var(--stone-2); border-color: var(--line); color: var(--bone-dim); box-shadow: none; }
.btn-gold img { width: 1.5rem; height: 1.5rem; margin: -.3rem 0; }
.sell-rarity { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.2rem 0 1rem; }
.sell-rarity > span { font-size: .88rem; color: var(--bone-dim); margin-right: .2rem; }
.rar-btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .4rem .3rem .7rem; font-weight: 700; font-size: .88rem;
  background: rgba(10,9,8,.7); border: 1px solid var(--q); border-radius: 999px;
  box-shadow: inset 0 0 10px color-mix(in srgb, var(--q) 18%, transparent);
}
.rar-btn b { min-width: 1.5rem; padding: 0 .35rem; border-radius: 999px; background: color-mix(in srgb, var(--q) 30%, #111); color: #fff; font-size: .8rem; }
.rar-btn:hover:not(:disabled) { box-shadow: inset 0 0 14px color-mix(in srgb, var(--q) 35%, transparent), 0 0 8px color-mix(in srgb, var(--q) 40%, transparent); }
.rar-btn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.sellall-dialog { width: min(34rem, calc(100vw - 32px)); }
.sellall-head { display: flex; gap: .8rem; align-items: center; }
.sellall-head img { width: 3.6rem; height: 3.6rem; flex: none; }
.sellall-head h2 { margin: 0; }
.sellall-head .outcome { margin: .2rem 0 0; }
.sellall-offer {
  display: flex; align-items: center; gap: .6rem; margin: 1.1rem 0 .9rem; padding: .7rem .9rem;
  border: 1px solid #8a6a2a; border-radius: 10px;
  background: radial-gradient(ellipse at 20% 50%, rgba(255,190,90,.22), rgba(229,164,67,.05) 70%);
}
.sellall-offer img { width: 3rem; height: 3rem; filter: drop-shadow(0 0 8px rgba(255,190,90,.5)); }
.sellall-offer strong { font: 700 2.2rem/1 var(--display); color: #ffd24a; text-shadow: 0 0 14px rgba(255,190,90,.4); }
.sellall-offer span { color: var(--bone-dim); }
.report ul.sellall-grid {
  list-style: none; padding: .4rem; margin: 0 0 .5rem; display: grid; gap: .35rem;
  grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); max-height: 11.5rem; overflow-y: auto;
  background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px;
}
.sellall-grid li {
  position: relative; aspect-ratio: 1; border: 2px solid var(--q); border-radius: 5px;
  background: radial-gradient(circle at 50% 40%, #2e3440, #0d0e10 75%);
}
.sellall-grid img { width: 100%; height: 100%; display: block; }
.sellall-grid b { position: absolute; right: 1px; bottom: 0; font-size: .62rem; color: #7ccf5a; text-shadow: 0 1px 2px #000; }
.sellall-mix { margin: 0 0 1rem; font-size: .88rem; font-weight: 700; }
.sellall-warn { border: 1px solid rgba(192,86,74,.6); border-radius: 8px; padding: .6rem .8rem; margin-bottom: 1rem; background: rgba(192,86,74,.1); }
.report .sellall-warn ul { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; font-size: .9rem; }
.sellall-warn .check { display: flex; align-items: center; gap: .5rem; font-weight: 700; cursor: pointer; }
.sellall-warn .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--torch); }
.sellall-warn .up { color: var(--good); font-weight: 700; }
.sellall-warn .worn-warn { color: var(--torch); font-weight: 700; }
.sellall-actions { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }

/* Leaderboard score */
.my-rank {
  display: grid; grid-template-columns: auto auto 1fr; gap: .5rem 1.6rem; align-items: center; max-width: 52rem;
  margin: .6rem 0 .8rem; padding: .8rem 1rem; border: 1px solid #8a6a2a; border-radius: 10px;
  background: linear-gradient(90deg, rgba(229,164,67,.16), rgba(14,12,10,.7));
}
.my-rank:empty { display: none; }
.my-rank span { display: block; font-size: .8rem; color: var(--bone-dim); }
.mr-rank strong, .mr-score strong { font: 700 2rem/1 var(--display); color: #ffd24a; }
.mr-rank em { font-style: normal; font-size: .85rem; color: var(--bone-dim); margin-left: .3rem; }
.mr-parts, .score-tip { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .2rem .8rem; font-size: .82rem; }
.mr-parts span, .score-tip span { display: flex; justify-content: space-between; gap: .5rem; color: var(--bone-dim); }
.mr-parts b, .score-tip b { color: var(--bone); }
.score-help { max-width: 52rem; margin-bottom: 1rem; font-size: .9rem; }
.score-help summary { cursor: pointer; color: var(--torch); }
.score-help p { color: var(--bone-dim); margin: .5rem 0; }
.score-help ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .2rem; }
.board-score { position: relative; font-weight: 700; color: #ffd24a; cursor: help; }
.score-tip {
  display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; width: 15rem; text-align: left; font-weight: 400;
  grid-template-columns: 1fr; padding: .5rem .7rem; background: rgba(6,8,20,.96); border: 1px solid #8a8fa0; border-radius: 5px; box-shadow: 0 6px 18px rgba(0,0,0,.6);
}
.board-score:hover .score-tip, .board-score:focus .score-tip { display: grid; }
@media (max-width: 700px) { .my-rank { grid-template-columns: auto auto; } .mr-parts { grid-column: 1 / -1; } }

/* Sortable leaderboard headers */
#board-head th { padding: 0; }
#board-head button {
  width: 100%; display: inline-flex; align-items: center; justify-content: inherit; gap: .3rem;
  background: none; border: 0; padding: .4rem .6rem; font: inherit; color: var(--bone-dim); text-align: inherit;
}
#board-head th:not(:nth-child(2)):not(:first-child) button { justify-content: flex-end; }
#board-head button:hover { color: var(--bone); }
#board-head i { width: .6rem; font-style: normal; font-size: .7rem; opacity: 0; }
#board-head th.sorted button { color: var(--torch); font-weight: 700; }
#board-head th.sorted i { opacity: 1; }
#board-head th[aria-sort="descending"] i::before { content: "▼"; }
#board-head th[aria-sort="ascending"] i::before { content: "▲"; }

/* Admin */
#tab-admin { --c-visits: #c07f1c; --c-unique: #5a92d6; }
.admin-link { color: var(--torch); }
.admin-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .6rem; margin: .5rem 0 1rem; }
.admin-tile { display: grid; gap: .1rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,12,10,.7); }
.admin-tile span { font-size: .8rem; color: var(--bone-dim); }
.admin-tile strong { font: 700 1.9rem/1.1 var(--body); color: var(--bone); }
.admin-tile em { font-style: normal; font-size: .8rem; color: var(--bone-dim); }
.admin-card { border: 1px solid var(--line); border-radius: 8px; background: rgba(14,12,10,.7); padding: .3rem 1rem 1rem; margin-bottom: 1rem; }
.admin-card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; font-size: .85rem; color: var(--bone-dim); }
.chart-legend i, .chart-tip i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.visit-chart { position: relative; height: 13rem; margin: .4rem 0 .6rem; padding-left: 2.4rem; }
.vc-grid { position: absolute; inset: 0 0 1.4rem 2.4rem; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.vc-grid div { border-top: 1px solid rgba(255,255,255,.07); position: relative; height: 0; }
.vc-grid span { position: absolute; right: calc(100% + .4rem); top: -.55rem; font-size: .72rem; color: var(--bone-dim); }
.vc-bars { position: absolute; inset: 0 0 0 2.4rem; display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; }
.vc-day { display: grid; grid-template-rows: 1fr 1.4rem; min-width: 0; border-radius: 4px; outline-offset: 1px; }
.vc-day.hot { background: rgba(255,255,255,.04); }
.vc-pair { display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 12%; }
.vc-pair i { flex: 1; max-width: 12px; min-height: 0; border-radius: 4px 4px 0 0; }
.vc-v { background: var(--c-visits); }
.vc-u { background: var(--c-unique); }
.vc-day > span { font-size: .66rem; color: var(--bone-dim); text-align: center; white-space: nowrap; overflow: hidden; align-self: center; }
.vc-day:nth-child(odd) > span { visibility: hidden; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; display: grid; gap: .15rem; font-size: .85rem;
  background: rgba(6,8,20,.95); border: 1px solid #8a8fa0; border-radius: 5px; padding: .45rem .6rem; box-shadow: 0 6px 18px rgba(0,0,0,.6);
}
.chart-tip b { margin-left: .4rem; }
.chart-table summary { cursor: pointer; font-size: .85rem; color: var(--bone-dim); }
.chart-table table, .admin-ranges { border-collapse: collapse; font-size: .88rem; margin-top: .5rem; }
.chart-table td, .chart-table th, .admin-ranges td, .admin-ranges th { padding: .25rem .8rem .25rem 0; text-align: right; }
.chart-table th:first-child, .chart-table td:first-child, .admin-ranges th:first-child { text-align: left; }
.admin-ranges th { font-weight: 400; color: var(--bone-dim); }
.admin-ranges { width: 100%; max-width: 32rem; margin-top: .8rem; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.admin-list em { margin-left: auto; font-style: normal; font-size: .8rem; color: var(--bone-dim); }
.admin-dim { color: var(--bone-dim); font-size: .85rem; font-weight: 400; }
.dot-on { width: .55rem; height: .55rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); align-self: center; }
.st-verified { color: var(--good); font-size: .82rem; }
.st-unverified { color: var(--torch); font-size: .82rem; }
.st-no-e-mail { color: var(--bone-dim); font-size: .82rem; }
@media (max-width: 820px) { .admin-cols { grid-template-columns: 1fr; } }
.admin-who { all: unset; cursor: pointer; font-weight: 700; color: var(--bone); border-bottom: 1px dotted var(--bone-dim); }
.admin-who:hover { color: var(--torch); border-color: var(--torch); }
.admin-who:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
.admin-q { width: 100%; max-width: 24rem; padding: .45rem .7rem; font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 6px; margin-bottom: .3rem; }
.admin-q:focus { outline: 2px solid var(--torch); outline-offset: 1px; }
.st-banned { color: var(--blood); font-size: .82rem; font-weight: 700; }
.st-paused { color: var(--torch); font-size: .82rem; font-weight: 700; }
.st-active { color: var(--good); font-size: .82rem; }
.user-dialog { width: min(36rem, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 1.4rem 1.5rem; }
.ud-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; }
.ud-head h2 { margin: 0; overflow-wrap: anywhere; }
.ud-head h2:focus { outline: none; }
.ud-status { font-size: .95rem; }
.ud-reason { margin: .3rem 0 0; color: var(--bone-dim); font-style: italic; }
.user-dialog .sub-title { margin: 1.1rem 0 .3rem; }
.ud-facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; font-size: .92rem; }
.ud-facts dt { color: var(--bone-dim); }
.ud-facts dd { margin: 0; overflow-wrap: anywhere; }
.ud-field { display: grid; gap: .25rem; font-size: .9rem; margin-bottom: .7rem; }
.ud-field input, .ud-pause select { font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; }
.ud-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.ud-pause { display: inline-flex; gap: .4rem; }
.btn-danger { background: rgba(192,86,74,.18); border-color: var(--blood); color: #f0b3aa; }
.btn-danger:hover:not(:disabled) { background: rgba(192,86,74,.32); }
.ud-delete { margin-top: 1rem; border: 1px solid rgba(192,86,74,.5); border-radius: 8px; padding: .5rem .8rem; }
.ud-delete summary { cursor: pointer; color: #f0b3aa; font-weight: 700; }
.ud-delete p { font-size: .88rem; color: var(--bone-dim); margin: .5rem 0; }
.ud-close { margin-top: 1rem; text-align: right; }
@media (max-width: 520px) { .ud-facts { grid-template-columns: 1fr; gap: 0; } .ud-facts dd { margin-bottom: .35rem; } }


/* Account page */
.acct-facts { display: grid; gap: 0; max-width: 34rem; margin: .8rem 0 0; }
.acct-facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
.acct-facts dt { color: var(--bone-dim); }
.acct-facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; text-align: right; }
.acct-facts em { font-weight: 400; color: var(--bone-dim); }
.acct-block { max-width: 34rem; margin-top: 1.2rem; padding: .2rem 1rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,12,10,.55); }
.acct-block .sub-title { margin-top: .8rem; }
.acct-form { max-width: none; }
.sheet-foot { flex-wrap: wrap; gap: .5rem 1rem; }

/* Raids */
.raid-banner {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; max-width: 42rem;
  margin-bottom: 1rem; padding: .6rem .9rem; border: 1px solid #c98a2c; border-radius: 8px;
  background: linear-gradient(90deg, rgba(14,11,8,.92) 0%, rgba(14,11,8,.82) 55%, rgba(40,22,8,.55) 100%), url(assets/raids/camp.webp) center / cover;
  box-shadow: 0 0 18px rgba(255,150,50,.2);
}
.raid-banner strong { color: #ffd24a; }
.raid-banner p { margin: .1rem 0 0; font-size: .85rem; color: #e8dfc8; }
.raid-faces { display: flex; }
.raid-faces img { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid #c98a2c; margin-left: -.6rem; background: #1a1510; }
.raid-faces img:first-child { margin-left: 0; }
.raid-dialog { width: min(40rem, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.raid-dialog > *:not(.raid-hero-img) { margin-left: 1.5rem; margin-right: 1.5rem; }
.raid-hero-img { position: relative; height: 12rem; overflow: hidden; }
.raid-hero-img img { width: 100%; height: 100%; object-fit: cover; }
.raid-hero-img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 40%, var(--stone) 100%); }
.raid-kicker { position: absolute; left: 1.5rem; bottom: 2.6rem; margin: 0; z-index: 1; font-size: .85rem; color: #ffe2a8; text-shadow: 0 1px 4px #000; }
.raid-hero-img h2 { position: absolute; left: 1.5rem; bottom: .4rem; margin: 0; z-index: 1; text-shadow: 0 2px 8px #000; }
.report ul.raid-party { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .8rem; margin-bottom: .8rem; }
.raid-party li { display: grid; justify-items: center; text-align: center; gap: .15rem; font-size: .8rem; }
.raid-party img { width: 4.2rem; height: 4.2rem; border-radius: 50%; border: 2px solid #5a4a2a; background: radial-gradient(#3a3020, #120e09); }
.raid-party li.leader img { border-color: #ffd24a; box-shadow: 0 0 12px rgba(255,210,74,.45); }
.raid-party strong { color: var(--bone); line-height: 1.2; }
.raid-party span { color: var(--bone-dim); }
.raid-speech { position: relative; margin-top: 0; margin-bottom: 1rem; padding: .7rem .9rem; border-radius: 10px; background: #1a1510; border: 1px solid #5a4a2a; min-height: 5.2rem; }
.raid-speech::before { content: ""; position: absolute; top: -8px; left: 2.6rem; border: 8px solid transparent; border-top: 0; border-bottom-color: #5a4a2a; }
.raid-speech span { font-size: .8rem; color: #ffd24a; font-weight: 700; }
.raid-speech p { margin: .2rem 0 0; font-style: italic; color: #f1ede3; }
.raid-card { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; margin-bottom: 1rem; background: rgba(0,0,0,.25); }
.raid-card h3 { font: 700 1.35rem/1.1 var(--display); color: var(--torch); margin: 0; }
.raid-desc { margin: .3rem 0; font-size: .9rem; color: var(--bone-dim); }
.raid-meta { margin: 0 0 .5rem; font-size: .85rem; font-weight: 700; }
.report ol.raid-bosses { list-style: none; padding: 0; margin: 0 0 .7rem; display: grid; gap: .3rem; }
.raid-bosses li { display: grid; grid-template-columns: 1fr 6rem 2.6rem; gap: .6rem; align-items: center; font-size: .88rem; }
.rb-bar { height: 8px; border-radius: 4px; background: #0b0b0c; border: 1px solid var(--line); overflow: hidden; }
.rb-bar i { display: block; height: 100%; background: linear-gradient(90deg, #c0564a, #e5a443, #7fc26a); background-size: 6rem 100%; }
.raid-bosses b { text-align: right; }
.raid-bosses.done li { grid-template-columns: 1.4rem 1fr auto; }
.raid-bosses.done li.win span { color: var(--good); font-weight: 700; }
.raid-bosses.done li.lose span { color: var(--blood); font-weight: 700; }
.raid-bosses.done li.skip { opacity: .5; }
.raid-bosses.done em { font-style: normal; font-size: .8rem; color: var(--bone-dim); }
.raid-rewards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.raid-rewards div { display: grid; }
.raid-rewards .wide { grid-column: 1 / -1; }
.raid-rewards span { font-size: .78rem; color: var(--bone-dim); }
.raid-rewards strong { font-size: .92rem; }
.raid-rewards .gold { color: var(--torch); }
.raid-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.3rem; }
.raid-note { font-size: .8rem; color: var(--bone-dim); margin-top: .6rem; margin-bottom: 1.3rem; }
.raid-warn { font-size: .85rem; color: #ffe2a8; border-left: 3px solid #c98a2c; padding-left: .6rem; margin: 0 0 1rem; }
.raid-tag { font: 700 .75rem var(--body); color: #231606; background: #e5a443; border-radius: 4px; padding: .1rem .4rem; vertical-align: middle; }
.journal-party { display: inline-flex; vertical-align: middle; margin-left: .4rem; }
.journal-party img { width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 1px solid #c98a2c; margin-left: -.4rem; background: #1a1510; }
.report-raid { display: grid; grid-template-columns: 5rem 1fr; gap: .7rem; align-items: center; margin-top: 1rem; padding: .5rem; border: 1px solid #c98a2c; border-radius: 8px; background: rgba(255,150,50,.1); }
.report-raid img { width: 5rem; height: 3.2rem; object-fit: cover; border-radius: 5px; }
.report-raid p { margin: 0; font-size: .9rem; }
.report-mats { margin-bottom: 1rem; }
@media (max-width: 560px) {
  .report ul.raid-party { grid-template-columns: repeat(2, 1fr); }
  .raid-rewards { grid-template-columns: 1fr 1fr; }
  .raid-banner { grid-template-columns: auto 1fr; } .raid-banner .btn { grid-column: 1 / -1; }
}

/* Nudge for heroes without an e-mail */
.secure-hero {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; max-width: 42rem;
  margin-bottom: 1rem; padding: .6rem .9rem; border: 1px solid #8a6a2a; border-radius: 8px;
  background: linear-gradient(90deg, rgba(229,164,67,.14), rgba(229,164,67,.04));
}
.secure-hero img { width: 2.4rem; height: 2.4rem; }
.secure-hero strong { color: var(--torch); }
.secure-hero p { margin: .1rem 0 0; font-size: .88rem; color: var(--bone-dim); }
.email-dialog { width: min(28rem, calc(100vw - 32px)); }
.email-dialog h2 { margin: 0; }
@media (max-width: 520px) { .secure-hero { grid-template-columns: auto 1fr; } .secure-hero .btn { grid-column: 1 / -1; } }

/* Next goal banner on the dungeon tab */
.goal-title { font: 500 1.3rem/1 var(--display); margin: 0 0 .5rem; color: var(--torch); }
#tab-descent .goal { margin-bottom: 1.25rem; max-width: 42rem; }

/* ---------- Dungeon backdrop (game area only, never behind the character window) ---------- */
.stage { position: relative; isolation: isolate; }
.stage-bg { position: fixed; top: 0; bottom: 0; left: 27rem; right: 0; z-index: -1; overflow: hidden; background: var(--ink); }
.bg-layer {
  position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease;
  background-size: cover; background-position: center;
}
.bg-layer::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(14,12,10,.25), rgba(14,12,10,.8) 80%),
    linear-gradient(rgba(14,12,10,.55), rgba(14,12,10,.7));
}
.bg-layer.show { opacity: 1; }

/* ---------- Brand header with burning torches ---------- */
.brand { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.brand-logo {
  margin: 0; font: 700 clamp(2.2rem, 4vw, 3rem)/1 var(--display); color: var(--torch);
  text-shadow: 0 0 18px rgba(229,164,67,.45), 0 2px 0 #3a2208;
}
.brand-game { margin: .25rem 0 .9rem; }
.brand-game .torch, .brand-auth .torch { --h: 6rem; }
.brand-auth { justify-content: flex-start; gap: .6rem; }
.brand-auth .logo { font-size: clamp(3rem, 11vw, 4.6rem); }
/* A 12-frame flame sprite (see art/render.py). Size is set from sprites.json. */
.torch {
  --h: 4.2rem;
  position: relative; flex: none;
  height: var(--h); width: calc(var(--h) * var(--fw, 96) / var(--fh, 192));
  background-repeat: no-repeat; background-size: calc(var(--frames, 12) * 100%) 100%;
  animation: flame 1.1s steps(11) infinite;
}
.torch::before {
  content: ""; position: absolute; left: 50%; top: 12%; width: 5rem; height: 5rem; transform: translate(-50%, -30%);
  background: radial-gradient(circle, rgba(255,150,50,.38), rgba(255,120,30,0) 65%);
  animation: glow 2.3s ease-in-out infinite alternate; pointer-events: none; z-index: -1;
}
@keyframes flame { from { background-position: 0 0; } to { background-position: 100% 0; } }
@keyframes glow { from { opacity: .7; transform: translate(-50%, -30%) scale(.92); } to { opacity: 1; transform: translate(-50%, -30%) scale(1.06); } }

/* ---------- Tabs: carved stone plaques ---------- */
.tabs {
  display: flex; gap: .6rem; justify-content: center; margin-bottom: 1.5rem; padding: .5rem;
  background: linear-gradient(#1c1a18, #121110); border: 1px solid #3a342c; border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 6px 18px rgba(0,0,0,.4);
}
.tabs button {
  display: flex; align-items: center; gap: .55rem; padding: .45rem 1.1rem .45rem .5rem;
  font: 700 1rem Cinzel, var(--body); color: #cfc3a8;
  background: linear-gradient(#2e2a25, #1d1a17); border: 1px solid #4a4238; border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -2px 0 rgba(0,0,0,.4);
  transition: border-color .15s, box-shadow .15s;
}
.tabs button img { width: 2.3rem; height: 2.3rem; filter: saturate(.8) brightness(.9); }
.tabs button:hover { border-color: #7a6a52; }
.tabs button[aria-selected="true"] {
  color: #ffe2a8; border-color: var(--torch);
  background: linear-gradient(#3a2e1e, #231b12);
  box-shadow: inset 0 0 14px rgba(229,164,67,.25), 0 0 14px rgba(229,164,67,.25);
}
.tabs button[aria-selected="true"] img { filter: none; }
.count { font-size: .85rem; color: var(--bone-dim); font-family: var(--body); }

/* ---------- Dungeon list: one rendered scene per dungeon ---------- */
.descent { display: grid; gap: .8rem; }
.stratum {
  position: relative;
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: 1.25rem;
  align-items: center;
  width: 100%;
  min-height: 8.5rem;
  text-align: left;
  border: 1px solid #3a342c;
  border-radius: 10px;
  padding: 1.1rem 1.4rem 1.1rem 1.25rem;
  background:
    linear-gradient(90deg, rgba(10,9,8,.92) 0%, rgba(10,9,8,.72) 38%, rgba(10,9,8,.15) 70%, rgba(10,9,8,.35) 100%),
    var(--banner, none) right center / cover no-repeat, #15130f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 6px 16px rgba(0,0,0,.35);
  overflow: hidden;
  transition: filter .15s, border-color .15s, transform .15s;
}
.stratum .depth, .stratum-name { text-shadow: 0 2px 6px #000; }
.stratum .chips { align-self: end; }
button.stratum:hover:not(:disabled) { filter: brightness(1.15); border-color: #8a7654; transform: translateY(-1px); }
button.stratum:disabled { cursor: default; }
.stratum.dimmed { filter: brightness(.45) saturate(.5); }
.stratum.active { border-color: var(--torch); box-shadow: 0 0 18px rgba(229,164,67,.3); }
.stratum.locked .stratum-name, .stratum.locked .depth { opacity: .55; }

/* Difficulty chips on each layer: coloured when open, greyed when locked */
.chips { list-style: none; margin: 0; padding: 0; display: flex; gap: .4rem; }
.chip {
  display: grid; text-align: center; min-width: 4.6rem;
  padding: .3rem .5rem; border-radius: 4px;
  background: rgba(0,0,0,.35); border: 1px solid var(--chip);
  font-size: .8rem; line-height: 1.25;
}
.chip span { color: var(--chip); font-weight: 700; }
.chip strong { font-size: .95rem; }
.chip-easy { --chip: #7fc26a; }
.chip-medium { --chip: #e5a443; }
.chip-hard { --chip: #d8604f; }
.chip-blocked { --chip: #5a625d; color: #7d847f; }
.star { color: var(--r-legendary); font-weight: 400; }

.depth {
  font: 700 1.9rem/1 var(--display);
  color: var(--bone);
  text-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.depth small { display: block; font: 400 .8rem/1.2 var(--body); color: var(--bone-dim); margin-top: .2rem; }
.stratum-name { font: 500 1.45rem/1.1 var(--display); margin: 0 0 .3rem; }
.stratum-boss { margin: 0; font-size: .9rem; color: var(--bone-dim); }

/* The torch moving through the chosen dungeon */
.stratum.active { filter: none; }
.torch-track {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: rgba(0,0,0,.4);
}
.torch-track i {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--torch);
}
.torch-track i::after {
  content: ""; position: absolute; right: -7px; top: -5px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ffd98a;
  box-shadow: 0 0 10px 4px var(--torch), 0 0 30px 10px var(--torch-glow);
  animation: flicker 1.8s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; transform: scale(1); }
  45% { opacity: .82; transform: scale(.9); }
  60% { opacity: .95; transform: scale(1.06); }
}

/* ---------- Journal during a run ---------- */
.journal { margin-top: 1.75rem; max-width: 42rem; }
.journal-title { font: 500 2rem/1.1 var(--display); margin: 0; }
.journal-time { margin: .3rem 0 1rem; color: var(--bone-dim); font-size: 1.05rem; }
.journal-time strong { color: var(--torch); font-size: 1.5rem; }
.events { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); display: grid; gap: .45rem; }
.events li { position: relative; }
.events li::before {
  content: ""; position: absolute; left: calc(-1rem - 5px); top: .6em;
  width: 8px; height: 8px; border-radius: 50%; background: var(--line);
}
.events li:last-child::before { background: var(--torch); }
.events time { color: var(--bone-dim); font-size: .85rem; margin-right: .5rem; }
.events .waiting { color: var(--bone-dim); font-style: italic; }
.journal-actions { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; margin-top: 1.5rem; }

/* ---------- Item lists ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel-note { margin: 0; color: var(--bone-dim); }
.items { list-style: none; margin: 0; padding: 0; max-width: 52rem; }
.items li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center;
  padding: .7rem 0; border-bottom: 1px solid var(--line);
}
.items .empty { display: block; color: var(--bone-dim); border: 0; padding: 1rem 0; }
.item-name { font-weight: 700; }
.item-meta { font-size: .88rem; color: var(--bone-dim); }
.item-stat { text-align: right; min-width: 5rem; }
.item-stat strong { font-size: 1.15rem; }
.item-stat .delta { display: block; font-size: .85rem; }
.delta.up { color: var(--good); }
.delta.down { color: var(--blood); }
.item-actions { display: flex; gap: .5rem; }
.items li.sold { opacity: .4; }

.r-common { color: var(--r-common); }
.r-uncommon { color: var(--r-uncommon); }
.r-rare { color: var(--r-rare); }
.r-epic { color: var(--r-epic); }
.r-legendary { color: var(--r-legendary); }

/* ---------- Report ---------- */
.report {
  background: var(--stone); color: var(--bone);
  border: 1px solid var(--line); border-radius: 6px;
  width: min(30rem, calc(100vw - 32px));
  padding: 1.75rem;
}
.report::backdrop { background: rgba(5, 8, 9, .75); }
.report h2 { font: 700 2.2rem/1.05 var(--display); margin: 0 0 .25rem; }
.report .outcome { color: var(--bone-dim); margin: 0 0 1.25rem; }
.report .outcome.win { color: var(--good); }
.report-gains { display: flex; gap: 2rem; margin-bottom: 1.25rem; }
.report-gains div { display: grid; }
.report-gains span { font-size: .85rem; color: var(--bone-dim); }
.report-gains strong { font-size: 1.5rem; }
.levelup {
  font: 700 1.9rem/1.1 var(--display);
  color: var(--torch);
  text-shadow: 0 0 20px var(--torch-glow);
  margin: 0 0 1rem;
  animation: rise .7s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.report ul { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .4rem; }
.report form { margin: 0; }

/* ---------- Dungeon info ---------- */
.dg-label { margin: 1rem 0 .4rem; font-size: .85rem; color: var(--bone-dim); }
.segs { display: grid; gap: .4rem; }
.segs-3 { grid-template-columns: repeat(3, 1fr); }
.segs-4 { grid-template-columns: repeat(4, 1fr); }
.seg {
  display: grid; background: var(--ink); border: 1px solid var(--line); border-radius: 4px;
  padding: .5rem .4rem; font-weight: 700; line-height: 1.2;
}
.seg small { font-weight: 400; font-size: .78rem; color: var(--bone-dim); }
.seg:hover { border-color: var(--bone-dim); }
.seg[aria-pressed="true"] { border-color: var(--torch); background: #2e2718; box-shadow: inset 0 0 0 1px var(--torch); }
.seg-easy[aria-pressed="true"] { border-color: #7fc26a; background: #1f2b1b; box-shadow: inset 0 0 0 1px #7fc26a; }
.seg-hard[aria-pressed="true"] { border-color: #d8604f; background: #2e1a17; box-shadow: inset 0 0 0 1px #d8604f; }
.report ul.reqs { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 0; }
.reqs li {
  display: grid; grid-template-columns: 1fr auto 6.5rem; gap: .75rem; align-items: baseline;
  padding: .35rem 0 .35rem 1.4rem; border-bottom: 1px solid var(--line); position: relative;
}
.reqs li::before { position: absolute; left: 0; font-weight: 700; }
.reqs li.ok::before { content: "✓"; color: var(--good); }
.reqs li.no::before { content: "✗"; color: var(--blood); }
.reqs li.warn::before { content: "!"; color: var(--torch); left: .25rem; }
.reqs li.no strong { color: var(--blood); }
.reqs em { font-style: normal; font-size: .85rem; color: var(--bone-dim); text-align: right; }
.dungeon-info { width: min(36rem, calc(100vw - 32px)); }
.dg-time { margin: 0 0 .35rem; color: var(--bone-dim); font-size: .9rem; }
.dg-desc { color: var(--bone-dim); margin: .4rem 0 1.4rem; }
.report-gains small { font-size: .8rem; color: var(--bone-dim); }
.dg-loot { margin: 0 0 .5rem; font-weight: 500; }
.dg-odds { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .25rem 1.25rem; }
.dg-odds li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: .15rem 0; font-size: .92rem; }
.dg-boss { margin: 0 0 1.5rem; font-size: .95rem; color: var(--bone-dim); }
.dg-boss strong { color: var(--bone); }
.dungeon-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; }
.btn-big { font-size: 1.1rem; padding: .8em 1.6em; }

/* ---------- Trophies ---------- */
.trophy {
  border: 1px solid #5a4a2a; border-radius: 4px; padding: .6rem .8rem; margin: 0 0 1.1rem;
  background: rgba(229,164,67,.07);
}
.trophy span { font-size: .82rem; color: var(--torch); }
.trophy p { margin: .2rem 0 0; font-size: .95rem; }
.trophy em { color: var(--bone-dim); margin: 0 .2rem; }
.trophy.claimed { border-color: var(--line); background: none; }
.trophy.claimed p { color: var(--r-legendary); }
.trophy-won {
  display: grid; gap: .1rem; margin: 0 0 1.25rem; padding: .8rem 1rem;
  border: 1px solid var(--torch); border-radius: 4px; background: rgba(229,164,67,.1);
  animation: rise .7s ease-out;
}
.trophy-won span { font-size: .82rem; color: var(--torch); }
.trophy-won strong { font: 700 1.5rem/1.15 var(--display); }
.trophy-won em { font-style: normal; font-size: .9rem; color: var(--bone-dim); }

/* ---------- Leaderboard ---------- */
.board-wrap { overflow-x: auto; max-width: 52rem; }
@media (min-width: 701px) { .board-wrap { overflow: visible; } }   /* lets the score breakdown pop out */
.board { width: 100%; border-collapse: collapse; font-size: .95rem; }
.board th { text-align: right; font-weight: 400; font-size: .85rem; color: var(--bone-dim); padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
.board td { text-align: right; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.board th:nth-child(2), .board td:nth-child(2) { text-align: left; }
.board th:first-child, .board td:first-child { text-align: left; width: 2.5rem; color: var(--bone-dim); }
.board-name { font-weight: 700; }
.board tr.me td { background: rgba(229,164,67,.08); }
.board tr.me .board-name { color: var(--torch); }
.board tbody tr:nth-child(-n+3) td:first-child { color: var(--torch); font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(150%);
  background: var(--stone-2); border: 1px solid var(--line); border-radius: 4px;
  padding: .6rem 1.1rem; transition: transform .25s ease, visibility .25s;
  max-width: calc(100vw - 32px);
  visibility: hidden;
}
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.error { border-color: var(--blood); }

/* ---------- Mobile: app-style layout with a bottom navigation bar ---------- */
.mobile-nav { display: none; }
@media (max-width: 820px) {
  body { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  .game { grid-template-columns: 1fr; }
  .sheet { border-right: 0; padding: calc(1rem + env(safe-area-inset-top)) 16px 1.5rem; --wall-h: 320vw; }
  .stage { padding: calc(.75rem + env(safe-area-inset-top)) 16px 2rem; }
  body[data-m="hero"] .stage, body:not([data-m="hero"]) .sheet { display: none; }
  .stage-bg { left: 0; }
  .tabs { display: none; }
  .brand-game { margin: 0 0 .9rem; }
  .brand-game .torch { --h: 4.4rem; }
  .brand-logo { font-size: 2.1rem; }
  .trees { grid-template-columns: 1fr; }
  .stratum { grid-template-columns: 3.6rem 1fr; padding: .9rem; gap: .5rem .8rem; min-height: 9.5rem; }
  .chips { grid-column: 1 / -1; }
  .chip { flex: 1; min-width: 0; }
  .report { padding: 1.25rem; }
  .items li { grid-template-columns: 1fr auto; }
  .item-actions { grid-column: 1 / -1; }
  #logout { margin-top: 0; }
  #game[hidden] ~ .mobile-nav { display: none; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    background: linear-gradient(#1c1a18, #0e0d0c); border-top: 1px solid #4a4238;
    box-shadow: 0 -6px 18px rgba(0,0,0,.5);
  }
  .mobile-nav button {
    display: grid; justify-items: center; gap: .1rem; padding: .2rem 0; background: none; border: 0;
    font: 700 .68rem var(--body); color: #a99d86;
  }
  .mobile-nav img { width: 2.1rem; height: 2.1rem; border-radius: 6px; filter: saturate(.7) brightness(.85); }
  .mobile-nav button[aria-current] { color: #ffe2a8; }
  .mobile-nav button[aria-current] img { filter: none; box-shadow: 0 0 0 2px var(--torch), 0 0 12px rgba(229,164,67,.5); }
  .toast { bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
}

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

/* ---------- Beta tag and Bugs & Feedback ---------- */
.logo-stack { display: grid; justify-items: center; }
.brand-auth .logo-stack { justify-items: start; }
.beta-tag {
  margin-top: .35rem; padding: .1rem .7rem; border-radius: 999px;
  font: 700 .8rem/1.3 var(--body); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); background: var(--torch); box-shadow: 0 0 12px var(--torch-glow);
}
.fb-btn {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 45;
  display: flex; align-items: center; gap: .45rem; padding: .5rem .85rem .5rem .6rem;
  font: 700 .85rem var(--body); color: var(--bone); cursor: pointer;
  background: rgba(30,38,41,.94); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.fb-btn svg { width: 1.3rem; height: 1.3rem; color: var(--torch); }
.fb-btn:hover { border-color: var(--torch); }
.fb-btn:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
.fb-dialog { width: min(32rem, calc(100vw - 32px)); }
.fb-kinds { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; border: 0; padding: 0; margin: 0; }
.fb-kinds legend { padding: 0; margin-bottom: .3rem; font-size: .9rem; color: var(--bone-dim); }
.fb-kinds label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }
.fb-kinds input { accent-color: var(--torch); }
.fb-dialog textarea {
  font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line);
  border-radius: 4px; padding: .6rem .7rem; resize: vertical; min-height: 7rem;
}
.fb-note { margin: 0; font-size: .85rem; color: var(--bone-dim); }
.fb-share { display: grid; grid-template-columns: auto 1fr; gap: .1rem .45rem; align-items: center; cursor: pointer; font-size: .92rem; }
.fb-share input { accent-color: var(--torch); }
.fb-share small { grid-column: 2; font-size: .8rem; color: var(--bone-dim); }
.fb-actions { display: flex; align-items: center; gap: 1rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
@media (max-width: 820px) {
  /* Icon only, above the bottom tab bar. */
  .fb-btn span { display: none; }
  .fb-btn { padding: .6rem; }
  body:has(#game:not([hidden])) .fb-btn { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
}

/* ---------- Links to the privacy policy and terms ---------- */
.legal-note { margin: 0; font-size: .82rem; color: var(--bone-dim); }
.legal-note a, .legal-links a { color: var(--bone-dim); text-decoration: underline; text-underline-offset: 2px; }
.legal-note a:hover, .legal-links a:hover { color: var(--torch); }
.legal-links { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: 1.6rem 0 0; font-size: .8rem; color: var(--bone-dim); }
.sheet-foot + .legal-links { margin-top: .4rem; justify-content: center; }
.acct-delete { margin-top: 1.2rem; }
.acct-delete .auth-form { margin-top: .6rem; }
.panel-note a { color: var(--torch); }

/* ---------- Settings (gear, top right) ---------- */
.game { position: relative; }
.top-actions { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; z-index: 30; display: flex; gap: .5rem; }
.settings-btn {
  position: relative;
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem; padding: 0; cursor: pointer;
  color: var(--bone-dim); background: rgba(30,38,41,.85); border: 1px solid var(--line); border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.settings-btn svg { width: 1.4rem; height: 1.4rem; transition: transform .3s ease; }
.settings-btn:hover { color: var(--torch); border-color: var(--torch); }
.settings-btn:hover svg { transform: rotate(45deg); }
.settings-btn:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
.settings-dialog { width: min(24rem, calc(100vw - 32px)); }
.settings-dialog h2 { margin-bottom: .1rem; }
.settings-dialog .outcome { margin-bottom: 1rem; }
.settings-list { display: grid; gap: .5rem; }
.settings-list a, .settings-list button {
  display: grid; gap: .1rem; text-align: left; width: 100%; padding: .7rem .9rem; cursor: pointer;
  font: inherit; color: var(--bone); background: var(--stone-2); border: 1px solid var(--line); border-radius: 6px;
}
.settings-list button[hidden], .settings-list a[hidden] { display: none; }
.settings-list button span, .settings-list a span { font-weight: 700; }
.settings-list a { text-decoration: none; box-sizing: border-box; }
.settings-list button small, .settings-list a small { font-size: .82rem; color: var(--bone-dim); }
.settings-list button:hover, .settings-list a:hover { border-color: var(--torch); }
.settings-list button:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
.settings-list .admin-link span { color: var(--torch); }
.settings-list .settings-logout { background: none; }
.settings-dialog .legal-links { justify-content: center; margin-top: 1.2rem; }

/* ---------- Item affixes ---------- */
.tip-affix { color: #8fd07a; font-weight: 700; font-size: .85rem; }
.item-affix { font-size: .78rem; color: #8fd07a; }

/* ---------- Introduction: welcome, tour, first steps ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.welcome-dialog { width: min(30rem, calc(100vw - 32px)); }
.welcome-points { margin: 0 0 1.2rem; padding-left: 1.2rem; color: var(--bone); }
.welcome-points li { margin-bottom: .3rem; }
.welcome-points li::marker { color: var(--torch); }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem; margin-bottom: .8rem; }

.tour { position: fixed; inset: 0; z-index: 200; }
.tour.no-hole { background: rgba(5, 8, 9, .7); }
.tour-hole {
  position: fixed; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(5, 8, 9, .7), 0 0 0 2px var(--torch), 0 0 22px var(--torch-glow);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-pop {
  position: fixed; width: min(22rem, calc(100vw - 32px)); padding: 1rem 1.1rem;
  background: var(--stone); color: var(--bone); border: 1px solid var(--torch); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.tour-pop:focus { outline: none; }
.tour-pop h2 { font: 700 1.6rem/1.1 var(--display); color: var(--torch); margin: .1rem 0 .4rem; }
.tour-pop p { margin: 0 0 .8rem; line-height: 1.5; }
.tour-count { font-size: .78rem; color: var(--bone-dim); margin: 0 !important; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.tour-actions span { display: flex; gap: .4rem; }

.first-steps { border: 1px solid var(--torch); border-radius: 8px; padding: .7rem 1rem .8rem; margin-bottom: 1rem; background: rgba(229,164,67,.07); }
.fs-head { display: flex; justify-content: space-between; align-items: baseline; }
.fs-hide { font-size: .8rem; }
.fs-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .35rem; }
.fs-list li { display: flex; gap: .6rem; align-items: flex-start; color: var(--bone-dim); }
.fs-list li strong { font-weight: 600; }
.fs-list li small { display: block; font-size: .82rem; color: var(--bone); margin-top: .1rem; }
.fs-check { flex: none; display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; border: 1px solid var(--line); font-size: .78rem; font-weight: 700; }
.fs-list li.done { color: var(--bone-dim); }
.fs-list li.done strong { text-decoration: line-through; text-decoration-color: rgba(169,161,140,.6); }
.fs-list li.done .fs-check { background: var(--good); border-color: var(--good); color: var(--ink); }
.fs-list li.next { color: var(--bone); }
.fs-list li.next .fs-check { border-color: var(--torch); color: var(--torch); box-shadow: 0 0 8px var(--torch-glow); }
.fs-done { margin: .6rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--good); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .tour-hole { transition: none; } }

/* ---------- Messages ---------- */
.inbox-btn svg { transition: none; }
.inbox-btn:hover svg { transform: none; }
.inbox-count {
  position: absolute; top: -4px; right: -4px; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px;
  display: grid; place-items: center; font: 700 .7rem/1 var(--body); color: #fff; background: var(--blood);
  box-shadow: 0 0 0 2px var(--ink);
}
.inbox-count[hidden] { display: none; }
.settings-btn.has-dot::after { content: ""; position: absolute; top: 1px; right: 1px; width: .6rem; height: .6rem; border-radius: 50%; background: var(--blood); box-shadow: 0 0 0 2px var(--ink); }
.set-count { display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; margin-left: .3rem; border-radius: 999px; background: var(--blood); color: #fff; font-size: .72rem; vertical-align: middle; }
.set-count[hidden] { display: none; }

.inbox-dialog { width: min(36rem, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 1.3rem 1.4rem; }
.inbox-head { margin-bottom: .6rem; }
.inbox-head h2, #at-title { font: 700 1.7rem/1.15 var(--display); margin: .1rem 0 0; overflow-wrap: anywhere; }
.inbox-back { font-size: .85rem; }
.msg-list, .ai-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.msg-row {
  display: grid; grid-template-columns: .6rem 1fr auto; align-items: center; gap: .7rem; width: 100%; text-align: left; cursor: pointer;
  padding: .6rem .75rem; font: inherit; color: var(--bone); background: var(--stone-2); border: 1px solid var(--line); border-radius: 6px;
}
.msg-row:hover { border-color: var(--torch); }
.msg-row:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
.msg-dot { width: .55rem; height: .55rem; border-radius: 50%; }
.msg-row.unread .msg-dot { background: var(--torch); box-shadow: 0 0 6px var(--torch-glow); }
.msg-row.unread strong { color: var(--bone); }
.msg-main { display: grid; gap: .1rem; min-width: 0; }
.msg-top { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.msg-top strong { font-weight: 600; color: #d7d0bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview { font-size: .84rem; color: var(--bone-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview b { color: #d7d0bd; font-weight: 600; }
.msg-row em { font-style: normal; font-size: .78rem; color: var(--bone-dim); white-space: nowrap; }
.msg-chip { flex: none; font-size: .68rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; border: 1px solid currentColor; }
.msg-chip-bug { color: #e0786b; } .msg-chip-feedback { color: #8fb6ea; } .msg-chip-feature { color: #b995e6; } .msg-chip-message { color: var(--torch); }
.msg-empty { display: grid; justify-items: center; text-align: center; padding: 1.4rem .5rem; }
.msg-empty svg { width: 3rem; height: 3rem; color: var(--bone-dim); margin-bottom: .3rem; }
.msg-empty p { margin: .1rem 0; }

.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; font-size: .85rem; color: var(--bone-dim); margin: .3rem 0 .8rem; }
.msg-meta a { color: var(--torch); }
.msg-thread { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .6rem; }
.msg { display: flex; gap: .5rem; align-items: flex-end; }
.msg.from-me { justify-content: flex-end; }
.msg-avatar { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--ink); border: 1px solid var(--torch); }
.msg-avatar img { width: 1.25rem; height: 1.25rem; }
.msg-bubble { max-width: 85%; padding: .55rem .75rem .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--stone-2); }
.from-team .msg-bubble, .from-player .msg-bubble { border-bottom-left-radius: 3px; }
.from-team .msg-bubble { border-color: rgba(229, 164, 67, .55); background: rgba(229, 164, 67, .08); }
.from-me .msg-bubble { border-bottom-right-radius: 3px; background: rgba(90, 146, 214, .12); border-color: rgba(90, 146, 214, .45); }
.msg-from { margin: 0 0 .2rem; font-size: .78rem; font-weight: 700; color: #d7d0bd; }
.msg-from time { font-weight: 400; color: var(--bone-dim); margin-left: .35rem; }
.msg-body { font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg-reply { display: grid; gap: .5rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.msg-reply[hidden] { display: none; }
.msg-reply textarea, #compose-form textarea, #compose-form input {
  font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .55rem .7rem; resize: vertical;
}
.msg-reply textarea:disabled { opacity: .5; }
.msg-reply .btn { justify-self: start; }
.msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.msg-anon { font-size: .88rem; color: var(--torch); }
.msg-forum { font-size: .88rem; margin: .4rem 0; }
.msg-forum a { color: var(--torch); }
.at-publish { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line, rgba(255,255,255,.12)); }
.at-publish h3 { margin: 0; font: 700 1.2rem/1.2 var(--display); }
.msg-seen { font-size: .82rem; margin: -.3rem 0 .6rem; }
.ud-msg { margin: 1rem 0 0; }

.admin-inbox { border-color: rgba(229, 164, 67, .5); }
.ai-tabs { display: flex; gap: .3rem; }
.ai-tabs button { padding: .25rem .7rem; font: 600 .82rem var(--body); color: var(--bone-dim); background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.ai-tabs button[aria-selected="true"] { color: var(--ink); background: var(--torch); border-color: var(--torch); }
.ai-tabs b { font-weight: 700; }
.ai-list { margin-top: .6rem; max-height: 26rem; overflow-y: auto; }
@media (max-width: 520px) { .msg-row { grid-template-columns: .6rem 1fr; } .msg-row em { grid-column: 2; } .msg-bubble { max-width: 92%; } }
.ai-broadcast { font-size: .85rem; padding: .3rem .7rem; }

/* TEMPORARY: the one-time man-or-woman choice for heroes made before sign-up asked (migration v25) */
.gender-dialog { width: min(30rem, calc(100vw - 32px)); }
.gender-cards { display: flex; gap: .8rem; border: 0; padding: 0; margin: .4rem 0 .6rem; }
.gender-cards label { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .6rem .4rem .5rem;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--bone-dim); font-weight: 700; }
.gender-cards img { height: 11rem; width: auto; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .55)); }
.gender-cards input { position: absolute; opacity: 0; pointer-events: none; }
.gender-cards label:has(input:checked) { border-color: var(--torch); color: var(--torch); box-shadow: 0 0 0 1px var(--torch), 0 0 14px var(--torch-glow); }
.gender-cards label:has(input:focus-visible) { outline: 2px solid var(--torch); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Supporting the game and cosmetics (lib/payments.php, lib/cosmetics.php) ---------- */
/* Torch flames: the one flame sprite, recoloured */
body[data-flame=blue] .torch { filter: hue-rotate(185deg) saturate(1.3); }
body[data-flame=green] .torch { filter: hue-rotate(75deg) saturate(1.2); }
body[data-flame=soul] .torch { filter: hue-rotate(245deg) saturate(1.4); }
body[data-flame=gold] .torch { filter: hue-rotate(18deg) saturate(1.5) brightness(1.2); }
/* The chosen flame also tints the light around the hero on the sheet */
body[data-flame=blue] .model { --flame-glow: rgba(90, 160, 255, .26); }
body[data-flame=green] .model { --flame-glow: rgba(110, 230, 120, .22); }
body[data-flame=soul] .model { --flame-glow: rgba(170, 100, 255, .26); }
body[data-flame=gold] .model { --flame-glow: rgba(255, 215, 110, .28); }
/* Portrait frames */
.cw-portrait[data-frame=silver] { border-color: #d5dae2; box-shadow: 0 0 0 2px #3b3f46, 0 0 12px rgba(213, 218, 226, .45), 0 4px 12px rgba(0,0,0,.7); }
.cw-portrait[data-frame=ember] { border-color: #e0612a; box-shadow: 0 0 0 2px #3a1406, 0 0 16px rgba(240, 100, 40, .6), 0 4px 12px rgba(0,0,0,.7); }
.cw-portrait[data-frame=gold] { border-color: #ffd36a; box-shadow: 0 0 0 2px #4a3308, 0 0 18px rgba(255, 200, 90, .7), 0 4px 12px rgba(0,0,0,.7); }
/* Badges by names */
.badge-patron, .badge-supporter { font-size: .8em; vertical-align: .1em; }
.badge-patron { color: #ffd36a; text-shadow: 0 0 6px rgba(255, 200, 90, .6); }
.badge-supporter { color: #cfd6e0; }
.board-title { display: block; color: var(--bone-dim); font-size: .75rem; font-style: italic; }
.report-hourglass { margin: .4rem 0 0; color: #ffd24a; }
#hasten small { color: var(--bone-dim); font-weight: 400; }

.support-dialog { width: min(46rem, calc(100vw - 32px)); }
.support-dev { margin: .2rem 0 .6rem; padding: .45rem .7rem; border: 1px dashed var(--torch); border-radius: 8px; color: var(--torch); font-size: .9rem; }
.support-closed { color: var(--blood); }
.support-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: .8rem; margin: .6rem 0 1rem; }
.tier { display: flex; flex-direction: column; gap: .35rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .02); }
.tier h4 { margin: 0; font: 700 1.05rem/1.2 Cinzel, var(--body); color: var(--bone); }
.tier p { margin: 0; font-size: .88rem; color: var(--bone-dim); }
.tier .tier-price { font-size: 1.25rem; font-weight: 700; color: var(--torch); }
.tier .tier-price small { font-size: .8rem; font-weight: 400; color: var(--bone-dim); }
.tier .tier-note { font-size: .8rem; }
.tier .btn, .tier .tier-owned { margin-top: auto; }
.tier .tier-owned { color: #ffd24a; font-weight: 700; }
.tier-patron { border-color: rgba(255, 211, 106, .55); box-shadow: 0 0 18px rgba(255, 200, 90, .12); }
.support-looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.look-card { display: flex; flex-direction: column; gap: .25rem; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; }
.look-card small { color: var(--bone-dim); font-size: .78rem; }
.look-card em { color: #ffd24a; font-style: normal; font-size: .85rem; margin-top: auto; }
.look-card .btn { margin-top: auto; align-self: flex-start; }
.look-swatch { display: block; height: 2.2rem; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .12); }
.look-swatch[data-look=wintersworn] { background: linear-gradient(135deg, #0c1224, #1d2c52 50%, #5fd4ff 51%, #1d2c52 56%, #0c1224); box-shadow: inset 0 0 10px rgba(80, 200, 255, .6); }
.look-swatch[data-look=frost] { background: linear-gradient(135deg, #a9d3fa, #e8f6ff 45%, #6aa8d8); }
.look-swatch[data-look=obsidian] { background: linear-gradient(135deg, #050506, #1b1b1f 60%, #e0521a); }
.look-swatch[data-look=royal] { background: linear-gradient(135deg, #e6e6ea, #f5c75a 55%, #8a0a16); }
.look-swatch[data-look=blue] { background: radial-gradient(circle at 50% 80%, #bfe8ff, #2f7de0 45%, #0b1830); }
.look-swatch[data-look=green] { background: radial-gradient(circle at 50% 80%, #d4ffc4, #3fbf4a 45%, #0b2210); }
.support-consent, .support-public { display: flex; gap: .55rem; align-items: flex-start; font-size: .88rem; color: var(--bone-dim); margin: .4rem 0; }
.support-consent input, .support-public input { margin-top: .2rem; }
.support-foot { font-size: .82rem; color: var(--bone-dim); }
.wardrobe-dialog { width: min(28rem, calc(100vw - 32px)); }
.wardrobe-dialog select { width: 100%; font: inherit; color: var(--bone); background: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; }
.wardrobe-dialog .ud-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.patrons-dialog { width: min(26rem, calc(100vw - 32px)); }
.patrons-list { list-style: none; padding: 0; margin: .5rem 0 1rem; columns: 2; }
.patrons-list li { padding: .2rem 0; }

/* The Innkeeper: in the services row (full width) and as a sign in the Merchant panel */
.services .svc-inn { grid-column: 1 / -1; }
.inn-sign { display: flex; align-items: center; gap: .8rem; width: 100%; margin: .2rem 0 .8rem; padding: .6rem .8rem; text-align: left;
  background: linear-gradient(100deg, rgba(229, 164, 67, .14), rgba(229, 164, 67, .03)); border: 1px solid rgba(229, 164, 67, .45); border-radius: 10px; color: var(--bone); cursor: pointer; }
.inn-sign:hover { border-color: var(--torch); }
.inn-sign span { display: grid; flex: 1; line-height: 1.25; }
.inn-sign strong { font-family: Cinzel, var(--body); color: #ffd24a; }
.inn-sign small { color: var(--bone-dim); font-size: .85rem; }
.inn-sign em { font-style: normal; font-weight: 700; color: var(--torch); white-space: nowrap; }
.inn-head { display: flex; gap: .8rem; align-items: flex-start; }
.inn-head img { flex: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }
.inn-head h2 { margin: 0; }
.inn-greet { margin: .3rem 0 .4rem; font-style: italic; color: var(--bone-dim); font-size: .92rem; }

/* Another hero's profile: the character window, read-only, in a dialog */
.profile-dialog { width: min(27rem, calc(100vw - 24px)); padding-top: 2.6rem; }
.profile-cw { margin-top: 0; }
.profile-cw .hero-name { font: 700 1.15rem/1.3 Cinzel, var(--body); margin: 0; color: #fff; text-align: center; overflow-wrap: anywhere; }
.pf-standing { cursor: default; }
.pf-facts { margin: 0; padding: 0 0 .7rem; text-align: center; font-size: .78rem; color: #b9b4a6; }
.profile-cw .slot:disabled { cursor: default; }
.board-who { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.board-who:hover, .board-who:focus-visible { color: var(--torch); text-decoration: underline; outline: none; }

/* ---------- Drops in the run report: verdict + Wear / Backpack choice ---------- */
.report ul.drops li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem .8rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.report ul.drops li > span:first-child { display: grid; min-width: 0; }
.report ul.drops small { font-size: .8rem; color: var(--bone-dim); }
.drop-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.drop-ctl .delta { font-size: .85rem; color: var(--bone-dim); }
.drop-ctl .delta.up { color: var(--good); }
.drop-ctl .delta.down { color: var(--blood); }
.trophy-won .drop-ctl { margin-top: .4rem; }
.drop-choice { display: inline-flex; }
.drop-choice .btn { border-radius: 0; }
.drop-choice .btn:first-child { border-radius: 4px 0 0 4px; }
.drop-choice .btn:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.drop-choice .btn[aria-pressed="true"] { cursor: default; }

/* ---------- Duels ---------- */
.duel-banner {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; max-width: 42rem;
  margin-bottom: 1rem; padding: .6rem .9rem; border: 1px solid var(--blood); border-radius: 8px;
  background: linear-gradient(90deg, rgba(14,11,8,.94), rgba(50,16,12,.75));
  box-shadow: 0 0 18px rgba(192,86,74,.22);
}
.duel-banner img { width: 2.4rem; height: 2.4rem; }
.duel-banner strong { color: #ffb19f; }
.duel-banner p { margin: .1rem 0 0; font-size: .85rem; color: var(--bone); }
@media (max-width: 520px) { .duel-banner { grid-template-columns: auto 1fr; } .duel-banner .btn { grid-column: 1 / -1; } }

.duels { max-width: 46rem; margin: 0 0 1.4rem; padding: .2rem 1rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,12,10,.55); }
.duels-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1rem; }
.duels-head .sub-title { margin: .8rem 0 .2rem; }
.duels-record { margin: 0; color: var(--torch); font-size: .95rem; }
.duels-open { margin-left: auto; font-size: .9rem; color: var(--bone-dim); display: flex; gap: .35rem; align-items: center; }
.duels-help { font-size: .85rem; color: var(--bone-dim); margin: .2rem 0 .7rem; }
.duel-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.duel-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .3rem .8rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.duel-list li:last-child { border-bottom: 0; }
.duel-list li > span:first-child { min-width: 0; }
.duel-list small { display: block; font-size: .8rem; color: var(--bone-dim); }
.duel-list li.won strong { color: var(--good); }
.duel-list li.lost strong { color: var(--blood); }
.duel-list li.duel-in strong, .duel-list li.new strong { color: #ffb19f; }
.duel-list li.faded { color: var(--bone-dim); }
.duel-list li.empty { color: var(--bone-dim); }
.duel-acts { display: flex; gap: .4rem; }

.pf-duel { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .4rem .8rem; margin: 0 0 .6rem; font-size: .88rem; }
.pf-duel-rec { display: inline-flex; align-items: center; gap: .35rem; color: var(--bone); }
.pf-duel-rec img { width: 1.3rem; height: 1.3rem; }
.pf-duel-note { flex-basis: 100%; text-align: center; color: var(--bone-dim); font-size: .82rem; }

.duel-dialog { width: min(36rem, calc(100vw - 24px)); }
.duel-odds { display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: .6rem; margin: 0 0 .8rem; }
.duel-odds span { color: var(--bone-dim); font-size: .9rem; }
.duel-odds strong { font: 700 2rem/1 var(--display); color: var(--torch); }
.duel-odds em { color: var(--bone-dim); }
.duel-answer { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 1rem; }
.duel-arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: center; margin: .6rem 0 .8rem; }
.duel-vs { font: 700 1.6rem/1 var(--display); color: var(--blood); }
.duel-fighter { display: grid; justify-items: center; text-align: center; gap: .15rem; min-width: 0; }
.duel-fighter img { width: 4.2rem; height: 4.2rem; border-radius: 50%; border: 2px solid var(--line); object-fit: cover; }
.duel-fighter.me img { border-color: var(--torch); }
.duel-fighter strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-fighter small { font-size: .75rem; color: var(--bone-dim); }
.duel-fighter.hit img { animation: duel-hit .35s ease-out; }
@keyframes duel-hit { 0% { transform: translateX(0); filter: brightness(1.8) saturate(.4); } 30% { transform: translateX(-5px); } 60% { transform: translateX(4px); } 100% { transform: none; filter: none; } }
.duel-hp { position: relative; width: 100%; height: 1.1rem; margin-top: .2rem; border: 1px solid var(--line); border-radius: 3px; background: rgba(0,0,0,.4); overflow: hidden; }
.duel-hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#b84a3e, #7a2a22); transition: width .4s ease-out; }
.duel-fighter.me .duel-hp i { background: linear-gradient(#78b860, #3f7a30); }
.duel-hp b { position: relative; display: block; text-align: center; font-size: .75rem; line-height: 1.05rem; }
.report ol.duel-log { list-style: none; padding: .4rem .6rem; margin: 0 0 .8rem; max-height: 13rem; overflow-y: auto; display: grid; gap: .2rem;
  font-size: .88rem; border: 1px solid var(--line); border-radius: 6px; background: rgba(0,0,0,.25); }
.duel-log li { animation: rise .3s ease-out; }
.duel-log li.theirs { color: #e3b8ae; }
.duel-log li.mine { color: var(--bone); }
.duel-verdict { font: 700 2.2rem/1.1 var(--display); margin: 0; }
.duel-verdict.win { color: var(--good); text-shadow: 0 0 18px rgba(127,194,106,.4); }
.duel-verdict.lose { color: var(--blood); }
.duel-end .outcome { margin: .2rem 0 .8rem; }
#duel-skip { margin-bottom: .8rem; }

/* ---------- World boss ---------- */
.world-boss {
  max-width: 42rem; margin-bottom: 1rem; padding: .9rem 1rem .8rem; border: 1px solid #7a3a2a; border-radius: 8px;
  background: linear-gradient(90deg, rgba(12,9,7,.95) 0%, rgba(12,9,7,.85) 60%, rgba(30,12,8,.55) 100%), var(--wb-art) center / cover;
  box-shadow: 0 0 22px rgba(200,70,40,.18);
}
.wb-kicker { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: #ff9d7a; }
.world-boss h3 { font: 700 1.7rem/1.1 var(--display); margin: .1rem 0 .2rem; color: var(--bone); }
.wb-desc { margin: 0 0 .6rem; font-size: .88rem; color: var(--bone-dim); }
.wb-hp { position: relative; height: 1.4rem; border: 1px solid #5a2a20; border-radius: 4px; background: rgba(0,0,0,.55); overflow: hidden; }
.wb-hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#c8432f, #7a1f14); transition: width .6s ease-out; }
.wb-hp b { position: relative; display: block; text-align: center; font-size: .8rem; line-height: 1.35rem; text-shadow: 0 1px 2px #000; }
.wb-meta, .wb-mine { margin: .45rem 0 0; font-size: .88rem; }
.wb-meta { color: var(--bone-dim); }
.wb-mine b { color: var(--torch); }
.wb-share { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; margin-top: .7rem;
  padding: .5rem .7rem; border: 1px solid var(--torch); border-radius: 6px; background: rgba(229,164,67,.12); font-size: .9rem; }
.wb-top { margin-top: .6rem; font-size: .88rem; }
.wb-top summary { cursor: pointer; color: var(--bone-dim); }
.wb-top ol { margin: .4rem 0 0; padding-left: 1.4rem; display: grid; gap: .1rem; max-width: 22rem; }
.wb-top li span { float: right; color: var(--bone-dim); }
.wb-top li.me .board-who { color: var(--torch); }
.wb-rules { margin: .5rem 0 0; color: var(--bone-dim); font-size: .82rem; }
.wb-mine .link-btn { margin-left: .3rem; font-size: .85rem; }
.wb-attack { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-top: .6rem; font-size: .88rem; color: var(--bone-dim); }
