/* ===== Taskmaster base styles ===== */
:root {
  --bg: #15121c;
  --bg-2: #1e1a28;
  --panel: #262033;
  --line: #3a3150;
  --text: #ece6d8;
  --muted: #a49cb3;
  --gold: #e3b45a;
  --gold-dark: #b8873a;
  --red: #d25f5f;
  --green: #6fbf73;
  --radius: 10px;
  --sidebar-w: 300px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* Reserve the page scrollbar's space too, so nothing shifts when it comes and goes. */
html { scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}
h1, h2 { font-family: var(--font-display); font-weight: normal; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; color: var(--gold); letter-spacing: .02em; }
a { color: inherit; }
.muted { color: var(--muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: .7rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 600; }
.btn-primary:hover { background: #f0c46c; }

/* ===== Title / menu screens ===== */
.title-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #2c2340 0%, var(--bg) 70%);
}
.title-card {
  text-align: center;
  padding: 3rem 2.5rem;
  width: min(420px, 92vw);
}
.title-card.wide { width: min(560px, 92vw); }
.game-title {
  font-size: clamp(2.6rem, 8vw, 4rem);
  color: var(--gold);
  text-shadow: 0 2px 0 var(--gold-dark), 0 6px 24px rgba(227,180,90,.25);
  margin-bottom: .25rem;
}
.page-title { font-size: 2rem; color: var(--gold); }
.tagline { color: var(--muted); margin: 0 0 2.5rem; }
.menu { display: flex; flex-direction: column; gap: .9rem; }
.menu.row { flex-direction: row; justify-content: center; margin-top: 2rem; }

.save-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; }
.save-slot {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

/* ===== Game layout ===== */
.game { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-display); font-size: 1.4rem; color: var(--gold); text-decoration: none; }
.char-summary { display: flex; align-items: center; gap: .75rem; font-size: .95rem; }
.char-level { color: var(--gold); }
.xp-bar { width: 140px; height: 8px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.xp-fill { height: 100%; background: var(--gold); transition: width .3s; }

.layout { flex: 1; display: flex; position: relative; min-height: 0; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .25s ease, border-color .25s;
}
.sidebar.collapsed { width: 0; border-right-color: transparent; }
.sidebar-tabs { display: flex; flex-direction: column; padding: .75rem; gap: .25rem; border-bottom: 1px solid var(--line); min-width: var(--sidebar-w); }
.tab {
  text-align: left;
  padding: .55rem .8rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--gold); background: var(--panel); border-color: var(--line); }

.panels { padding: 1rem; overflow-y: auto; min-width: var(--sidebar-w);
  /* Always keep room for the scrollbar, so the layout doesn't jump when details make the panel scroll. */
  scrollbar-gutter: stable; }
.panel { display: none; }
.panel.active { display: block; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: .45rem 1rem; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; }

.slots { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.slots li { display: flex; justify-content: space-between; padding: .5rem .7rem; background: var(--panel); border-radius: 8px; }
.slots em { color: var(--muted); font-style: normal; }

.inv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.inv-cell { aspect-ratio: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }

.journal { padding-left: 1.2rem; margin: 0; display: grid; gap: .5rem; font-size: .92rem; }
.journal time { color: var(--muted); font-size: .8rem; margin-right: .4rem; }

.sidebar-toggle {
  position: absolute;
  top: 1rem;
  left: var(--sidebar-w);
  transform: translateX(-50%);
  z-index: 5;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--gold);
  font-size: .7rem;
  cursor: pointer;
  transition: left .25s ease, transform .25s ease;
}
.sidebar-toggle:hover { border-color: var(--gold); }
.sidebar-toggle.collapsed { left: 0; transform: translateX(6px) rotate(180deg); }

/* ===== Main area ===== */
.main {
  flex: 1;
  padding: 1.5rem;
  display: grid;
  gap: 1.25rem;
  align-content: start;
  min-width: 0;
}
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }

.avatar-area { display: flex; align-items: center; gap: 1.5rem; }
.avatar {
  width: 160px; height: 160px; flex-shrink: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle, #34294a, var(--panel));
  border: 2px solid var(--gold-dark);
  border-radius: 50%;
  color: var(--muted);
}
.avatar.adventuring { animation: bob 1.6s ease-in-out infinite; border-color: var(--gold); }
@keyframes bob { 50% { transform: translateY(-4px); } }
.scene-title { color: var(--text); font-size: 1.4rem; }

/* ===== Tasks ===== */
.task-form { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.task-form input, .task-form select {
  padding: .65rem .8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.task-form input { flex: 1; min-width: 180px; }
.task-form input:focus, .task-form select:focus { outline: none; border-color: var(--gold); }

.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.task {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: .75rem;
  padding: .6rem .8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.task.dragging { opacity: .4; }
.task.drag-over { border-color: var(--gold); }
.task.running { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.task.done .task-name { text-decoration: line-through; color: var(--muted); }
.handle { cursor: grab; color: var(--muted); user-select: none; }
.task-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.task.running .task-time { color: var(--gold); }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
}
.icon-btn:hover { border-color: var(--gold); }
.icon-btn.play { color: var(--green); }
.icon-btn.remove:hover { border-color: var(--red); color: var(--red); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.empty-msg { margin: .5rem 0 0; }
.empty-msg.hidden { display: none; }

/* ===== Small screens ===== */
@media (max-width: 720px) {
  :root { --sidebar-w: min(320px, 88vw); }
  /* The sidebar is a drawer that slides over the page instead of pushing it aside. */
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: var(--topbar-h, 56px); bottom: 0;
    width: var(--sidebar-w); max-width: 92vw;
    transform: translateX(0); transition: transform .25s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .45);
  }
  .layout.wide-sidebar { --sidebar-w: 92vw; }
  .sidebar.collapsed { width: var(--sidebar-w); transform: translateX(-100%); box-shadow: none; border-right-color: var(--line); }
  .sidebar .panels { flex: 1; min-height: 0; }
  .sidebar-backdrop { position: fixed; inset: var(--topbar-h, 56px) 0 0 0; z-index: 39; background: rgba(8, 6, 14, .55); }
  .sidebar-toggle { position: fixed; z-index: 41; top: calc(var(--topbar-h, 56px) + .75rem); left: min(var(--sidebar-w), 92vw); }
  .sidebar-toggle.collapsed { left: 0; }
  .main { width: 100%; min-width: 0; }
  .avatar-area { flex-direction: column; text-align: center; }
  .avatar { width: 120px; height: 120px; }
  .topbar { gap: .6rem; padding: .6rem .9rem; }
  .char-summary { flex-wrap: wrap; justify-content: flex-end; gap: .15rem .5rem; min-width: 0; max-width: 55%; font-size: .9rem; }
  .char-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .char-level { white-space: nowrap; }
  .xp-bar { flex: 0 0 100%; width: 100%; height: 6px; }
}

/* ===== Character creator ===== */
.creator-page { min-height: 100vh; background: radial-gradient(ellipse at top, #2c2340 0%, var(--bg) 70%); }
.creator {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}
.preview { text-align: center; position: sticky; top: 1.5rem; }
.avatar-box {
  aspect-ratio: 5 / 6;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.avatar-box svg { width: 100%; height: 100%; display: block; }
.preview-name { font-family: var(--font-display); font-size: 1.4rem; color: var(--gold); margin: 1rem 0 0; }
.preview-sub { margin: .2rem 0 0; }

.choices { display: grid; gap: 1.25rem; }
.field { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.field-label { font-family: var(--font-display); color: var(--gold); font-size: 1.05rem; padding: 0; }
.field input {
  padding: .7rem .85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: none; border-color: var(--gold); }
.options { display: flex; gap: .5rem; flex-wrap: wrap; }
.options.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.option {
  padding: .6rem .9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.options:not(.grid-3) .option { min-width: 120px; }
.option:hover { color: var(--text); border-color: var(--gold-dark); }
.option.selected { color: var(--gold); border-color: var(--gold); background: #33294a; }
.desc { margin: 0; min-height: 1.5em; font-size: .92rem; }
.creator-actions { justify-content: space-between; margin-top: .5rem; }

.stat-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.stat-list li { display: grid; grid-template-columns: 100px 1fr 24px 26px; align-items: center; gap: .6rem; font-size: .93rem; }
.stat-name { color: var(--muted); }
.stat-bar { height: 8px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.stat-bar span { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .25s; }
.stat-val { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.stat-diff { font-size: .8rem; }
.stat-diff.up { color: var(--green); }
.stat-diff.down { color: var(--red); }
.small { font-size: .82rem; margin: 0; }

.save-slot.filled { border-style: solid; color: var(--text); display: flex; align-items: center; gap: 1rem; text-align: left; text-decoration: none; }
.save-slot.filled:hover { border-color: var(--gold); }
.save-slot .mini-avatar { width: 48px; height: 58px; flex-shrink: 0; }
.save-slot strong { color: var(--gold); font-weight: 600; }
.avatar svg { width: 100%; height: 100%; }

@media (max-width: 1000px) {
  .creator { grid-template-columns: 1fr 1fr; }
  .choices { grid-column: 1 / -1; order: 3; }
  .preview { position: static; }
}
@media (max-width: 640px) {
  .creator { grid-template-columns: 1fr; }
  .options.grid-3 { grid-template-columns: repeat(2, 1fr); }
}
.mini-avatar svg { width: 100%; height: 100%; }
.avatar { overflow: hidden; }

/* ===== Class panel ===== */
.class-hint { margin-bottom: .9rem; }
.class-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.class-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .6rem .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.class-row strong { font-weight: 600; }
.class-row.active { border-color: var(--gold); }
.class-row.active strong { color: var(--gold); }
.class-row.locked { opacity: .55; }
.btn-small { padding: .35rem .75rem; font-size: .85rem; }
.btn:disabled { cursor: default; opacity: .7; }
.btn:disabled:hover { border-color: var(--line); }

/* ===== Navigation card ===== */
.nav-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.nav-head h2 { margin-bottom: .1rem; }
.nav-head p { margin: 0; }
.hp-wrap { display: flex; align-items: center; gap: .5rem; }
.hp-bar { width: 160px; height: 10px; background: var(--panel); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.hp-fill { height: 100%; background: linear-gradient(90deg, #b84545, #e06a5a); transition: width .3s; }
.hp-text { font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.nav-status { margin: .9rem 0 .6rem; }
.nav-status strong { color: var(--gold); font-weight: 600; }
.limping { color: var(--red); font-weight: 600; }
.nav-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }

.nav-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.nav-map {
  background: radial-gradient(ellipse at center, #2a3324 0%, #1c2219 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.nav-map svg { width: 100%; height: 100%; display: block; }
.nav-map .road { stroke: #8a7a5a; stroke-linecap: round; opacity: .8; }
.nav-map .road-len { font-family: var(--font-body); fill: #d8ccaa; text-anchor: middle; dominant-baseline: middle;
  paint-order: stroke; stroke: #1f261b; }
.nav-map .route { fill: none; stroke: var(--gold); stroke-linecap: round; }
.nav-map .loc circle { stroke: #15121c; }
.nav-map .loc.dest circle { stroke: var(--gold); }
.nav-map .loc.cleared circle { opacity: .55; }
.nav-map .loc.locked { opacity: .45; }
.nav-map .glyph { font-family: var(--font-body); font-weight: bold; fill: #15121c; text-anchor: middle; dominant-baseline: middle; }
.nav-map .loc-name { font-family: var(--font-body); fill: var(--text); text-anchor: middle;
  paint-order: stroke; stroke: #1c2219; }
.nav-map .me { fill: #fff; }
.nav-map .me-ring { fill: none; stroke: #fff; opacity: .9; animation: pulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { opacity: .25; transform: scale(1.25); } }

.nav-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; max-height: 460px; overflow-y: auto; }
.nav-row {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .6rem;
  padding: .5rem .6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.nav-row.here { border-color: #fff4; }
.nav-row.dest { border-color: var(--gold); }
.nav-row.locked .nav-info, .nav-row.locked .nav-dist { opacity: .55; }
.nav-info { min-width: 0; }
.nav-info strong { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-info .small { margin: 0; }
.type-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font: bold .72rem var(--font-body); color: #15121c; }
.nav-dist { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.nav-note { margin: .8rem 0 0; }
.nav-debug { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .9rem;
  padding: .6rem; border: 1px dashed var(--red); border-radius: 8px; }

@media (max-width: 1100px) {
  .nav-body { grid-template-columns: 1fr; }
}

/* ===== Tasks + Navigation side by side ===== */
.work-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.work-row .nav-body { grid-template-columns: 1fr; gap: .75rem; }
.work-row .nav-map { aspect-ratio: 8 / 5; }
.work-row .nav-list { max-height: 260px; }
.work-row .hp-bar { width: 110px; }
.work-row .task-form input { min-width: 140px; }

@media (max-width: 1000px) {
  .work-row { grid-template-columns: 1fr; }
}

/* ===== Navigation: map + list side by side when the card is wide ===== */
.nav-card { container-type: inline-size; }
.work-row .nav-map { max-height: 320px; width: 100%; }
@container (min-width: 620px) {
  .work-row .nav-body { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); }
  .work-row .nav-map { aspect-ratio: auto; height: 340px; max-height: none; }
  .work-row .nav-list { max-height: 340px; }
}

/* Make the hidden attribute win over display rules */
[hidden] { display: none !important; }

/* ===== HP / MP / TP bars ===== */
.vitals { display: grid; gap: .35rem; min-width: 210px; }
.res-row { display: grid; grid-template-columns: 1.8rem 1fr auto; align-items: center; gap: .5rem; font-size: .82rem; }
.res-label { font-weight: 600; color: var(--muted); }
.res-bar { height: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.res-fill { display: block; height: 100%; border-radius: 99px; transition: width .3s; }
.res-hp .res-fill { background: linear-gradient(90deg, #b84545, #e06a5a); }
.res-mp .res-fill { background: linear-gradient(90deg, #3d5fb8, #6a9be0); }
.res-tp .res-fill { background: linear-gradient(90deg, #b8873a, #e3c25a); }
.res-val { font-variant-numeric: tabular-nums; color: var(--text); min-width: 4.6rem; text-align: right; }
.panel-vitals { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); min-width: 0; }

/* ===== Inventory & gold ===== */
.gold-line { margin: 0 0 .75rem; }
.gold-line strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.coin { color: var(--gold); text-shadow: 0 0 6px rgba(227,180,90,.6); }
.inv-cell { position: relative; padding: 0; display: grid; place-items: center; font: inherit; color: inherit; cursor: default; }
.inv-cell.filled { cursor: pointer; background: #2e2640; }
.inv-cell.filled:hover, .inv-cell.filled:focus { border-color: var(--gold); outline: none; }
.inv-cell.rarity-uncommon { border-color: #4f8a5a; }
.inv-cell.rarity-rare { border-color: #4f73b8; box-shadow: inset 0 0 8px rgba(79,115,184,.4); }
.inv-icon { font-size: 1.25rem; line-height: 1; }
.inv-qty { position: absolute; right: 3px; bottom: 1px; font-size: .68rem; font-weight: 700; color: var(--text); text-shadow: 0 0 3px #000; }
.inv-detail { margin-top: .75rem; min-height: 3.6em; }
.inv-detail strong { color: var(--gold); }

/* ===== Journal entry types ===== */
.journal li.j-loot { color: #e8d49a; }
.journal li.j-event { color: #b9d4c2; }
.journal li.j-level { color: var(--gold); font-weight: 600; }
.journal li.j-combat summary { cursor: pointer; color: #f0b8a8; list-style: none; }
.journal li.j-combat summary::-webkit-details-marker { display: none; }
.journal li.j-combat summary::after { content: ' ▸'; color: var(--muted); }
.journal li.j-combat details[open] summary::after { content: ' ▾'; }
.journal .turns { margin: .35rem 0 .2rem; padding-left: .9rem; display: grid; gap: .15rem;
  font-size: .8rem; color: var(--muted); list-style: none; border-left: 2px solid var(--line); }
.res-xp .res-fill { background: linear-gradient(90deg, #7a4fb8, #b48ae0); }
.draft-badge { position: fixed; left: 12px; bottom: 12px; z-index: 50; padding: .35rem .7rem; border-radius: 99px;
  background: #5a2a2a; border: 1px solid var(--red); color: #ffd9d0; font-size: .8rem; text-decoration: none; }
.run-bar { display: block; height: 6px; margin-top: .45rem; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.run-bar span { display: block; height: 100%; background: linear-gradient(90deg, #8a3b3b, #d25f5f); transition: width .3s; }
.use-btn { margin-top: .5rem; }

/* ===== Gear tiers ===== */
.tier-common { color: #d8d4cc; }
.tier-uncommon { color: #7fd17f; }
.tier-rare { color: #6fa3f0; }
.tier-legendary { color: #f0a640; }
.tier-mythical { color: #e070f0; }
.inv-cell.tier-uncommon { border-color: #4f8a5a; }
.inv-cell.tier-rare { border-color: #4f73b8; box-shadow: inset 0 0 8px rgba(79,115,184,.4); }
.inv-cell.tier-legendary { border-color: #b8782a; box-shadow: inset 0 0 10px rgba(240,166,64,.45); }
.inv-cell.tier-mythical { border-color: #a040b8; box-shadow: inset 0 0 12px rgba(224,112,240,.5); }
.inv-cell.unusable .inv-icon { opacity: .4; }
.gear-stats { margin: .4rem 0; display: grid; gap: .15rem; font-size: .88rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .5rem; }
.gear-bonus { color: var(--green); font-weight: 500; font-size: .85rem; }
.gear-bonus.neg { color: var(--red); }
.slot-item { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: right; max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-item:hover { text-decoration: underline; }
.gear-total { margin: .75rem 0 0; }
.gear-detail { margin-top: .5rem; }
.inv-detail strong.tier-common { color: #d8d4cc; }
.inv-detail strong.tier-uncommon { color: #7fd17f; }
.inv-detail strong.tier-rare { color: #6fa3f0; }
.inv-detail strong.tier-legendary { color: #f0a640; }
.inv-detail strong.tier-mythical { color: #e070f0; }
#equip-slots li { align-items: center; gap: .6rem; }
#equip-slots li > span:first-child { flex-shrink: 0; color: var(--muted); font-size: .88rem; }
.slot-item { white-space: normal; max-width: none; line-height: 1.25; font-size: .9rem; }
.class-row.secret { border-style: dashed; opacity: .7; }
.class-row.secret strong { color: var(--muted); letter-spacing: .2em; }
.desc .perks { color: var(--green); }
.ability-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.ability { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .5rem .65rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.ability.locked { opacity: .5; }
.ab-icon { font-size: 1.2rem; }
.ab-cost { font-size: .8rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.ability .small { margin: 0; }

/* ===== Account & cloud saves ===== */
.account-box { margin-top: 1.75rem; display: grid; gap: .5rem; justify-items: center; }
.account-box:empty { display: none; }
.account-box p { margin: 0; }
.save-chip { margin-left: auto; margin-right: 1rem; padding: .3rem .7rem; border-radius: 99px; font: inherit; font-size: .82rem;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.save-chip.synced { color: var(--green); border-color: #3f6b3a; }
.save-chip.syncing { color: var(--gold); }
.save-chip.signed-out, .save-chip.expired { color: var(--gold); border-color: var(--gold-dark); }
.save-chip.error, .save-chip.offline { color: var(--red); border-color: #6a3030; }

/* ===== Inventory filters ===== */
.inv-filters { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .75rem; }
.inv-filter { padding: .25rem .55rem; border-radius: 99px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; }
.inv-filter:hover { color: var(--text); border-color: var(--gold-dark); }
.inv-filter.active { color: #1a1408; background: var(--gold); border-color: var(--gold); font-weight: 600; }
.inv-filter.empty:not(.active) { opacity: .45; }
.inv-filter .count { font-size: .7rem; opacity: .75; margin-left: .1rem; }
.inv-lv { position: absolute; left: 3px; top: 1px; font-size: .62rem; font-weight: 700; color: var(--muted); }

/* ===== Wide sidebar on the Equipment tab ===== */
.layout.wide-sidebar { --sidebar-w: min(640px, 92vw); }
.equip-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; align-items: start; }
.equip-bag { border-left: 1px solid var(--line); padding-left: 1.25rem; }
@media (max-width: 720px) {
  .equip-bag { border-left: 0; padding-left: 0; }
}

/* ---------- Shop ---------- */
.shop-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8, 6, 12, .7);
  display: grid; place-items: center; padding: 1rem; }
.shop-box { width: min(900px, 100%); max-height: calc(100vh - 2rem); overflow: auto; scrollbar-gutter: stable;
  background: var(--bg-2); border: 1px solid var(--gold-dark); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.shop-head { display: flex; align-items: flex-start; gap: 1rem; }
.shop-head > div { flex: 1; }
.shop-head h2 { margin: 0; font-family: var(--font-display); color: var(--gold); }
.shop-head p { margin: .2rem 0 0; }
.shop-head .gold-line { margin: .3rem 0 0; white-space: nowrap; }
.shop-modes { display: flex; gap: .4rem; margin: 1rem 0 .6rem; border-bottom: 1px solid var(--line); }
.shop-mode { padding: .45rem 1.1rem; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0;
  background: var(--panel); color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; margin-bottom: -1px; }
.shop-mode:hover { color: var(--text); }
.shop-mode.active { background: var(--bg-2); color: var(--gold); border-color: var(--gold-dark); border-bottom: 1px solid var(--bg-2); }
.shop-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 1rem; align-items: start; }
.shop-grid { grid-template-columns: repeat(6, 1fr); }
.shop-detail { margin-top: 0; padding: .75rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 8rem; }
.shop-detail .detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.shop-detail .warn-line { color: var(--red); margin-top: .3rem; }
.inv-price { position: absolute; left: 3px; bottom: 1px; font-size: .62rem; font-weight: 700; color: var(--gold); text-shadow: 0 0 3px #000; }
@media (max-width: 640px) {
  .shop-body { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: repeat(5, 1fr); }
}

/* Pinned (clicked) item and gear comparison */
.inv-cell.pinned { border-color: var(--gold) !important; box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(227, 180, 90, .45); }
.gear-compare { margin: .5rem 0; padding: .45rem .55rem; border: 1px dashed var(--line); border-radius: 6px; font-size: .85rem; }
.gear-compare .cmp-row { margin-top: .3rem; }
.gear-compare .cmp-slot { color: var(--muted); }
.gear-compare .cmp-diff { display: flex; flex-wrap: wrap; gap: .2rem .6rem; margin-top: .1rem; }
.gear-compare .up { color: var(--green); font-weight: 600; }
.gear-compare .down { color: var(--red); font-weight: 600; }
.gear-compare .tier-common { color: #d8d4cc; }
.gear-compare .tier-uncommon { color: #7fd17f; }
.gear-compare .tier-rare { color: #6fa3f0; }
.gear-compare .tier-legendary { color: #f0a640; }
.gear-compare .tier-mythical { color: #e070f0; }

/* ---------- Crafting ---------- */
.craft-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .4rem; }
.craft-row { width: 100%; display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; align-items: center; text-align: left;
  padding: .55rem .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; cursor: pointer; }
.craft-row:hover { border-color: var(--gold-dark); }
.craft-row.active { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.craft-icon { font-size: 1.4rem; text-align: center; }
.craft-main { display: grid; gap: .25rem; min-width: 0; }
.craft-name { display: flex; justify-content: space-between; gap: .5rem; }
.craft-lv { color: var(--gold); font-weight: 600; font-size: .85rem; }
.craft-row .res-fill { background: linear-gradient(90deg, #6a8f4a, #9fd17a); }
.craft-meta { font-size: .75rem; }
#craft-title { margin-bottom: .2rem; }
#craft-sub { margin-top: 0; }
.craft-upgrade { margin: .5rem 0; padding: .45rem .55rem; border: 1px dashed var(--line); border-radius: 6px; display: grid; gap: .2rem; }
.craft-upgrade .tier-common { color: #d8d4cc; }
.craft-upgrade .tier-uncommon { color: #7fd17f; }
.craft-upgrade .tier-rare { color: #6fa3f0; }
.craft-upgrade .tier-legendary { color: #f0a640; }
.craft-upgrade .tier-mythical { color: #e070f0; }
.warn-line { color: var(--red); }
.btn-danger { background: #7a2e2e; border-color: var(--red); color: #fff; }
.btn-quiet { opacity: .85; }

/* ---------- Journal sub-tabs: Statistics & Achievements ---------- */
.journal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.journal-head h2 { margin: 0; }
.journal-tabs { display: flex; gap: .25rem; margin-left: auto; }
.journal-tab { padding: .25rem .55rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  color: var(--muted); font: inherit; font-size: .75rem; cursor: pointer; }
.journal-tab:hover { color: var(--text); }
.journal-tab.active { color: var(--gold); border-color: var(--gold-dark); }
.stats-group { margin: 1rem 0 .35rem; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.stats-view > p:first-child { margin-top: 0; }
.stats-list { display: grid; grid-template-columns: 1fr auto; gap: .3rem .75rem; margin: 0; font-size: .9rem; }
.stats-list dt { color: var(--muted); }
.stats-list dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ach-summary { display: grid; gap: .3rem; font-size: .9rem; }
.ach-summary .res-fill, .ach-card .res-fill { background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .45rem; }
.ach-card { display: grid; grid-template-columns: 2rem 1fr; gap: .5rem; align-items: start; padding: .5rem .55rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; opacity: .7; }
.ach-card.unlocked { opacity: 1; border-color: var(--gold-dark); box-shadow: inset 0 0 0 1px rgba(227, 180, 90, .25); }
.ach-icon { font-size: 1.4rem; text-align: center; line-height: 1.6rem; filter: grayscale(1); }
.ach-card.unlocked .ach-icon { filter: none; }
.ach-body { display: grid; gap: .15rem; min-width: 0; }
.ach-body strong { font-size: .88rem; }
.ach-card.unlocked .ach-body strong { color: var(--gold); }
.ach-desc { font-size: .78rem; color: var(--muted); }
.ach-progress { display: grid; gap: .15rem; font-size: .72rem; color: var(--muted); }

/* ---------- Armory ---------- */
.inv-filter.armory { border-color: var(--gold-dark); color: var(--gold); }
.inv-filter.armory.active { background: rgba(227, 180, 90, .15); }
.bag-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.bag-head h2 { margin: 0; }
.bag-source { display: flex; gap: .25rem; }
.bag-src { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; }
.bag-src:hover { color: var(--text); }
.bag-src.active { color: var(--gold); border-color: var(--gold-dark); }
.bag-src .count { opacity: .75; }
.bag-note { margin: .35rem 0 .5rem; }
.armory-note { margin-top: .35rem; }
.save-slot.backup-slot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem;
  border: 1px dashed var(--gold-dark); border-radius: 10px; }

/* ---------- Strategy (gambits) ---------- */
.strategy-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .4rem 0 .6rem; }
.strategy-meta .pill { font-size: .75rem; padding: .15rem .55rem; border: 1px solid var(--gold-dark); border-radius: 999px; color: var(--gold); }
.gambits { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.gambit { padding: .45rem .55rem; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold-dark); border-radius: 8px; display: grid; gap: .3rem; }
.gambit.off { opacity: .5; border-left-color: var(--line); }
.gambit.blocked { border-left-color: #6a5a40; }
.gambit-line { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.gambit-num { min-width: 1.2rem; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.gambit .kw { font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.gambit .kw.then { margin-left: 1.6rem; color: var(--gold-dark); }
.gambit select, .gambit input[type="number"] { font: inherit; font-size: .82rem; padding: .2rem .35rem; background: var(--bg-2);
  color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.gambit select { max-width: 15rem; }
.gambit input[type="number"] { width: 3.6rem; }
.gambit .cond { display: inline-flex; align-items: center; gap: .25rem; }
.gambit .unit { font-size: .8rem; color: var(--muted); }
.gambit-tools { margin-left: auto; display: inline-flex; gap: .2rem; }
.icon-btn { padding: .15rem .45rem; font: inherit; font-size: .78rem; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--gold-dark); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.and-btn { font-size: .7rem; white-space: nowrap; }
.gambit-note { font-size: .75rem; color: #c9a86a; margin-left: 1.6rem; }
.practice { margin-top: 1rem; border-top: 1px solid var(--line); }
.practice-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.practice-row select { font: inherit; font-size: .85rem; padding: .3rem .4rem; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; max-width: 100%; }
.practice-out p { margin: .5rem 0 .2rem; }
.practice-log { margin: .3rem 0 0; padding-left: 0; list-style: none; max-height: 16rem; overflow-y: auto; font-size: .78rem;
  color: var(--muted); display: grid; gap: .15rem; border: 1px solid var(--line); border-radius: 6px; padding: .4rem .5rem; }

/* ---------- Quests ---------- */
.nav-quest { display: flex; align-items: center; gap: .6rem; width: 100%; margin: .2rem 0 .5rem; padding: .45rem .6rem; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold-dark); border-radius: 8px;
  color: var(--text); font: inherit; cursor: pointer; }
.nav-quest:hover { border-color: var(--gold-dark); }
.nav-quest.none { color: var(--muted); font-size: .85rem; border-left-color: var(--line); }
.nav-quest.ready { border-left-color: var(--green); box-shadow: inset 0 0 0 1px rgba(111, 207, 111, .25); }
.nav-quest .q-icon { font-size: 1.2rem; }
.nav-quest .q-main { flex: 1; display: grid; gap: .15rem; min-width: 0; }
.nav-quest .q-main strong { font-size: .9rem; }
.nav-quest .q-bar { height: 5px; background: rgba(255, 255, 255, .08); border-radius: 3px; overflow: hidden; }
.nav-quest .q-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.nav-quest.ready .q-bar span { background: var(--green); }
.nav-quest .q-count { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }
.quest-box { width: min(760px, 100%); }
.quest-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.quest { padding: .75rem .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: grid; gap: .4rem; }
.quest.active { border-color: var(--gold-dark); box-shadow: inset 3px 0 0 var(--gold); }
.quest.ready { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.quest.locked { opacity: .6; }
.quest-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.quest-head strong { font-size: 1.02rem; }
.quest-tags { display: flex; gap: .3rem; flex-wrap: wrap; }
.qtag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.qtag.done { color: var(--green); border-color: rgba(111, 207, 111, .4); }
.qtag.active { color: var(--gold); border-color: var(--gold-dark); }
.qtag.ready { color: #111; background: var(--green); border-color: var(--green); }
.quest-desc { margin: 0; font-size: .9rem; color: var(--muted); font-style: italic; }
.quest-obj { margin: 0; font-size: .92rem; }
.quest-rewards { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.rchip { font-size: .8rem; padding: .15rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2); }
.rchip.gold { color: var(--gold); }
.quest-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.ability-head { margin: .9rem 0 .2rem; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); list-style: none; }
.ability.trait .ab-cost { font-size: .72rem; color: var(--muted); }

/* Attributes tab: traits */
.attr-subhead { margin: 1.1rem 0 .45rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.attr-traits { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.attr-trait { display: grid; grid-template-columns: 1.6rem 1fr auto; gap: .5rem; align-items: center; padding: .4rem .55rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.attr-trait .t-icon { font-size: 1.1rem; text-align: center; }
.attr-trait .t-main { display: grid; gap: .1rem; min-width: 0; }
.attr-trait .t-main strong { font-size: .88rem; }
.attr-trait .t-lv { font-size: .75rem; color: var(--gold); white-space: nowrap; }
.attr-trait.locked { opacity: .45; filter: grayscale(1); }
.attr-trait.locked .t-lv { color: var(--muted); }

/* Attack / Defense under the attributes */
.stats .derived-first { border-top: 1px solid var(--line, rgba(255,255,255,.12)); padding-top: .4rem; margin-top: .3rem; }

/* ===== Animated sprites ===== */
.sprite { height: 100%; background-repeat: no-repeat; image-rendering: pixelated; }
/* Dashboard circle: 150px tall. Art taller than that is shrunk smoothly (pixelated shrinking drops pixels). */
.avatar.has-sprite { align-items: end; }
.avatar.has-sprite .sprite { height: min(150px, var(--h) * 2); margin-bottom: 2px; }
.avatar.has-sprite .sprite[style*="--h:"] { image-rendering: auto; }
.avatar.has-sprite .sprite.crisp { image-rendering: pixelated; }
.avatar.has-sprite.adventuring { animation: none; }
/* Creator / load / admin previews: the art's own size, capped to the box. */
.avatar-box .sprite { height: min(var(--h), 100%); margin: auto; }
.mini-avatar .sprite, .class-avatar .sprite { margin: 0 auto; image-rendering: auto; }
@media (max-width: 640px) { .avatar.has-sprite .sprite { height: min(112px, var(--h)); } }

/* ===== Portraits ===== */
.portrait { display: block; user-select: none; }
/* Small slots: fill, centred on the face */
.mini-avatar .portrait, .class-avatar .portrait {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%;
}
/* Dashboard circle: zoomed out so the chest armor shows (head near the top, shoulders run off the bottom) */
.avatar.has-portrait { padding: 0; position: relative; }
.avatar.has-portrait .portrait { position: absolute; width: 76%; height: auto; left: 12%; top: 7%; }
.avatar.has-portrait.adventuring { animation: bob 1.6s ease-in-out infinite; }
/* Creator / preview boxes: the whole portrait, fitted to the box */
.avatar-box .portrait { width: auto; height: 100%; max-width: 100%; object-fit: contain; margin: auto; }

/* ===== Intel pop-up ===== */
.intel-box { width: min(640px, 100%); padding: 0; overflow: auto; }
.intel-pic { display: block; width: 100%; max-height: 46vh; object-fit: cover; border-radius: 12px 12px 0 0; }
.intel-head { padding: 1rem 1.25rem 0; }
.intel-kind { margin: 0 0 .1rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); opacity: .8; }
.intel-text { padding: .25rem 1.25rem 0; line-height: 1.6; }
.intel-text p { margin: .6rem 0; }
.intel-foot { display: flex; justify-content: flex-end; padding: .75rem 1.25rem 1.25rem; }
.nav-levels-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.intel-btn { padding: .1rem .5rem; font-size: .78rem; }

/* Quick-start timer buttons under the task form */
.quick-tasks { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.25rem 0 .9rem; }
.quick-tasks .muted { margin-right: .15rem; }

/* Camps on the region map */
.nav-map .camp text { text-anchor: middle; dominant-baseline: middle; filter: drop-shadow(0 0 .6px #000); }
.nav-map .camp .camp-stem { stroke: #e8c86a; opacity: .7; }
.nav-map .camp .camp-spot { fill: #e8c86a; stroke: #2a2418; stroke-width: .3; }
.nav-map .camp.used { opacity: .35; filter: grayscale(1); }

/* ===== Equipment paper doll ===== */
.paperdoll { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem .6rem; max-width: 300px; margin: 0 auto .6rem; }
.doll-slot { display: grid; justify-items: center; gap: .2rem; min-width: 0; }
.doll-cell { width: 100%; max-width: 72px; cursor: pointer; }
.doll-cell .inv-icon { font-size: 1.7rem; }
.doll-cell .inv-icon.ghost { opacity: .18; filter: grayscale(1); }
.doll-cell.empty-slot { border-style: dashed; }
.doll-cell.blocked { opacity: .45; border-style: dashed; }
.doll-cap { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.1; }
/* Level badge on every gear box */
.inv-lv { left: 3px; top: 2px; font-size: .6rem; font-weight: 700; color: var(--text, #e8e2d0); opacity: .75; letter-spacing: .01em; }

/* Map: click a location to travel there */
.nav-map .loc.can-go { cursor: pointer; }
.nav-map .loc.can-go:hover circle { stroke: #fff; stroke-width: 1.2; filter: brightness(1.15); }
.nav-map .loc.can-go:hover .loc-name { fill: #fff; }
.quick-tasks .remove-all { margin-left: auto; }

/* ===== Logo ===== */
.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand-logo { height: 38px; width: auto; display: block; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.game-title { line-height: 0; margin-bottom: .75rem; }
/* Centred on the card's middle (which is the screen's middle), so it can be wider than the
   card on desktop yet never runs off the edge on phones (1rem gap each side). */
.title-logo { display: block; position: relative; left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100vw - 2rem)); max-width: none; height: auto; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .55)); }
.load-logo { display: block; margin: 0 auto .5rem; }
.load-logo .title-logo { width: min(360px, calc(100vw - 2rem)); }
@media (max-width: 640px) { .brand-logo { height: 28px; } }

/* Gold under HP / MP / TP in the region card */
.vitals-wrap { display: grid; gap: .35rem; min-width: 210px; }
.res-gold .res-val { color: var(--gold); font-weight: 600; }
/* Quick sessions: the label and the three buttons always stay on one line together;
   "Remove all" drops to the next line (on the right) when there isn't room. */
.qs-group { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: nowrap; white-space: nowrap; }
.quick-tasks [data-quick] { white-space: nowrap; }
@media (max-width: 480px) {
  .qs-group { gap: .3rem; }
  .qs-icon { display: none; }
  .quick-tasks [data-quick] { padding-left: .55rem; padding-right: .55rem; }
}

/* ===== Game menu (logo button) ===== */
.brand-btn { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: 6px; }
.brand-btn:hover .brand-logo { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)) brightness(1.12); }
.brand-btn:focus, .brand-btn:focus-visible { outline: none; }
.menu-box { width: min(560px, 100%); }
.menu-label { margin: 1.1rem 0 .5rem; font: 600 .78rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.theme-pick { display: grid; gap: .2rem; justify-items: start; text-align: left; padding: .6rem; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.theme-pick:hover { border-color: var(--gold-dark); }
.theme-pick.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.theme-pick strong { font-weight: 600; }
.theme-pick .small { line-height: 1.3; }
.theme-swatch { display: flex; width: 100%; height: 38px; border-radius: 5px; overflow: hidden; margin-bottom: .3rem; border: 1px solid rgba(0, 0, 0, .35); }
.theme-swatch i { flex: 1; }
.theme-swatch i:nth-child(2) { flex: 2; }
.theme-swatch[data-swatch="legacy"] i:nth-child(1) { background: #15121c; }
.theme-swatch[data-swatch="legacy"] i:nth-child(2) { background: #262033; }
.theme-swatch[data-swatch="legacy"] i:nth-child(3) { background: #e3b45a; }
.theme-swatch[data-swatch="professional"] i:nth-child(1) { background: #1d2633; }
.theme-swatch[data-swatch="professional"] i:nth-child(2) { background: #f4f6f9; }
.theme-swatch[data-swatch="professional"] i:nth-child(3) { background: #2f6fde; }
.theme-swatch[data-swatch="parchment"] i:nth-child(1) { background: #2a1d12; }
.theme-swatch[data-swatch="parchment"] i:nth-child(2) { background: radial-gradient(ellipse at center, #f1e4bf 40%, #d9c18c 100%); box-shadow: inset 0 0 0 3px #a8864c; }
.theme-swatch[data-swatch="parchment"] i:nth-child(3) { background: #8a2f1c; }
.theme-swatch[data-swatch="ironbound"] i:nth-child(1) { background: #121314; }
.theme-swatch[data-swatch="ironbound"] i:nth-child(2) { background: linear-gradient(#2b2e33, #1e2024); box-shadow: inset 0 0 0 2px #5b6168; }
.theme-swatch[data-swatch="ironbound"] i:nth-child(3) { background: #e0873a; }
.theme-swatch[data-swatch="classic"] i:nth-child(1) { background: #000; }
.theme-swatch[data-swatch="classic"] i:nth-child(2) { background: linear-gradient(#7474e0, #24248c 60%, #10104a); box-shadow: inset 0 0 0 2px #e8e8f4, inset 0 0 0 3px #3a3a5a; border-radius: 4px; }
.theme-swatch[data-swatch="classic"] i:nth-child(3) { background: #5fd0e0; }
.menu-account { margin: 0 0 .6rem; overflow-wrap: anywhere; }
.menu-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.menu-actions .btn-danger { margin-left: auto; }
@media (max-width: 480px) { .theme-grid { grid-template-columns: 1fr; } }

/* ===== Sail menu ===== */
.sail-box { width: min(560px, 100%); }
.sail-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.sail-row { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.sail-row.here { border-color: var(--gold); }
.sail-row.locked .sail-info { opacity: .6; }
.sail-info { flex: 1; min-width: 0; }
.sail-info strong { font-weight: 600; display: block; }
.sail-info p { margin: .1rem 0 0; }
.sail-row .btn { flex-shrink: 0; }
