/* Eldmar client. Layout: the game screen and chat on the left, a stone-and-rust side panel on the right;
   one column on phones. One deliberate dark look, so colours are fixed rather than theme-switched. */
:root {
  color-scheme: dark;
  --bg: #0d0b0a;
  --panel: #1c1715;
  --panel-2: #120f0e;
  --line: #3a2a20;
  --rust: #6e3a24;
  --gold: #d9b56a;
  --text: #d6cbb8;
  --muted: #a8998a;
  --hp: #9b2a22;
  --mana: #2b4f8f;
  --food: #8a6a2a;
  --good: #8fd18a;
  --bad: #ff6b5e;
  --say: #f0e05a;
  --npc: #9fd0ff;
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --font-log: "VT323", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-bottom, 0px));
}
[hidden] { display: none !important; }
button { font-family: var(--font-body); color: var(--gold); background: transparent; border: 1px solid var(--rust); padding: 7px 14px; font-size: 15px; cursor: pointer; border-radius: 0; min-height: 40px; }
button:hover:not(:disabled) { background: var(--panel); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--rust); color: #f6ead2; border-color: var(--rust); }
button.primary:hover:not(:disabled) { background: #85472c; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input, select { font-family: var(--font-body); font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; border-radius: 0; width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
a { color: var(--gold); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--gold); margin: 0; text-wrap: balance; }

.panel { background: var(--panel); border: 1px solid var(--rust); box-shadow: inset 0 0 0 3px var(--panel-2), inset 0 0 0 4px var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.panel > h2 { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }

/* ---------- account screens ---------- */
.front { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; padding-top: 4vh; }
.front header { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.front header h1 { font-size: clamp(34px, 7vw, 56px); letter-spacing: 10px; }
.front header h1 a, .topbar h1 a { color: inherit; text-decoration: none; }
.front header p { margin: 0; color: var(--muted); max-width: 60ch; line-height: 1.5; }
.front .grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .front .grid { grid-template-columns: minmax(0, 1fr); } }
form.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }
.note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.features { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.chars { display: flex; flex-direction: column; gap: 8px; }
.char { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.char img, .voc img { width: 48px; height: 48px; image-rendering: pixelated; }
.char strong { display: block; color: var(--text); font-size: 17px; }
.char span { color: var(--muted); font-size: 14px; }
.vocs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.voc { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; text-align: left; font-size: 13px; color: var(--muted); line-height: 1.35; min-height: 0; }
.voc strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 2px; }
.voc[aria-pressed="true"] { border-color: var(--gold); background: #241d18; }

/* ---------- game ---------- */
.game { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.topbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; border-bottom: 1px solid var(--rust); padding-bottom: 8px; }
.topbar h1 { font-size: 22px; letter-spacing: 5px; }
.topbar .who { color: var(--muted); font-size: 15px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 12px; align-items: start; }
@media (max-width: 940px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.play { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.screen { position: relative; width: 100%; max-width: max(320px, calc((100vh - 330px) * 480 / 352)); margin: 0 auto; aspect-ratio: 480 / 352; background: #000; border: 1px solid var(--rust); box-shadow: 0 0 0 4px var(--panel-2); }
.screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: crosshair; }
.window { position: absolute; right: 8px; top: 8px; width: min(300px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; background: var(--panel); border: 1px solid var(--rust); box-shadow: inset 0 0 0 3px var(--panel-2), inset 0 0 0 4px var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.window h3 { font-size: 13px; letter-spacing: 1px; }
.window .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.window .head button { min-height: 32px; padding: 2px 10px; }
.items { display: flex; flex-wrap: wrap; gap: 6px; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 3, 2, 0.8); padding: 16px; }
.overlay .panel { max-width: 380px; width: 100%; }
.overlay h2 { color: var(--bad); font-size: 26px; letter-spacing: 3px; text-align: center; }
.overlay p { margin: 0; line-height: 1.45; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.actions .group { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .group button { min-height: 44px; }
.dpad { display: none; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); gap: 4px; }
.dpad button { padding: 0; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; -webkit-user-select: none; user-select: none; }
.dpad span { visibility: hidden; }
@media (max-width: 940px), (pointer: coarse) { .dpad { display: grid; } .actions .group { display: grid; grid-template-columns: repeat(2, minmax(88px, 1fr)); } }
.chat { background: var(--panel-2); border: 1px solid var(--rust); display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 6px 6px 0; flex-wrap: wrap; }
.tabs button { min-height: 32px; padding: 3px 12px; font-size: 14px; color: var(--muted); border-color: var(--line); }
.tabs button[aria-selected="true"] { background: var(--rust); color: #f6ead2; border-color: var(--rust); }
.tabs button.unread { color: var(--gold); }
.log { height: 160px; overflow-y: auto; padding: 6px 10px; font-family: var(--font-log); font-size: 18px; line-height: 20px; }
.log div { overflow-wrap: anywhere; }
.log .info { color: var(--gold); } .log .warn { color: #f0a84a; } .log .damage { color: var(--bad); } .log .advance, .log .exp { color: var(--good); }
.log .loot { color: var(--text); } .log .world { color: #e6a0ff; } .log .say { color: var(--say); } .log .npc { color: var(--npc); } .log .spell { color: #f29a2e; } .log .yell { color: #ffd27a; }
.chat form { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid var(--line); }
.chat form label { flex-direction: row; align-items: center; }
.chat select { width: auto; font-size: 14px; padding: 6px; }
.chat input { flex: 1; min-width: 0; font-family: var(--font-log); font-size: 19px; padding: 4px 8px; }
.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.minimap-row { display: flex; gap: 12px; align-items: flex-start; }
.minimap-row canvas { width: 120px; height: 88px; image-rendering: pixelated; border: 1px solid var(--line); background: #000; flex: none; }
.place { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; }
.place strong { color: var(--text); font-weight: 500; }
.bar { position: relative; height: 20px; background: var(--bg); border: 1px solid var(--line); }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; }
.bar span { position: absolute; left: 8px; top: 1px; font-size: 13px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #000; font-variant-numeric: tabular-nums; }
.bar.hp i { background: var(--hp); } .bar.mana i { background: var(--mana); } .bar.exp i { background: #6a5a2a; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.icons { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.icons span { font-size: 12px; padding: 1px 6px; border: 1px solid var(--line); color: var(--muted); }
.icons .battle { color: #f0a84a; border-color: #7a5420; } .icons .pzlock { color: var(--bad); border-color: var(--hp); } .icons .pz { color: var(--good); border-color: #3a6a32; }
.icons .skull-w { color: #fff; border-color: #888; } .icons .skull-r { color: #ff4a3d; border-color: #9b2a22; } .icons .haste { color: var(--npc); border-color: #3a5a7a; } .icons .light { color: #ffd27a; border-color: #7a5a20; }
.skills { display: flex; flex-direction: column; gap: 5px; }
.skill { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 14px; }
.skill .v { font-variant-numeric: tabular-nums; } .skill .n { color: var(--muted); }
.skill .p { grid-column: 1 / -1; height: 3px; background: var(--bg); } .skill .p i { display: block; height: 100%; width: 0; background: var(--gold); }
.equip { display: grid; grid-template-columns: repeat(3, 48px); gap: 6px; }
.slot { width: 48px; height: 48px; padding: 0; min-height: 0; background: var(--panel-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; font-size: 10px; color: #8a7d70; line-height: 1.1; text-align: center; }
.slot img { width: 40px; height: 40px; image-rendering: pixelated; pointer-events: none; }
.slot b { position: absolute; right: 2px; bottom: 0; font-size: 12px; color: #fff; text-shadow: 1px 1px 0 #000; font-variant-numeric: tabular-nums; }
.slot.empty-label { color: #6e6258; }
.bag { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.bag .slot { width: auto; height: auto; aspect-ratio: 1; }
.bag-tools { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.bag-tools button { min-height: 32px; padding: 2px 10px; font-size: 13px; }
.bag-tools button[aria-pressed="true"] { background: var(--rust); color: #f6ead2; }
.bagwin { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line, rgba(0,0,0,.2)); }
.bagwin .bag { margin-top: 6px; }
.bag-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.slot.is-bag { outline: 2px dashed rgba(242, 201, 76, .55); outline-offset: -3px; }
.slot.is-open { outline: 2px solid #f2c94c; }
.slot.drop-over { background: rgba(242, 201, 76, .25); }
.bag.drop-over { background: rgba(242, 201, 76, .12); border-radius: 6px; }
.shop-list { display: flex; flex-direction: column; gap: 4px; }
.shop-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 56px auto; gap: 6px; align-items: center; font-size: 14px; }
.shop-row img { width: 32px; height: 32px; image-rendering: pixelated; }
.shop-row input { padding: 4px; font-size: 14px; }
.shop-row button { min-height: 32px; padding: 2px 8px; font-size: 13px; }
.shop-row small { color: var(--muted); display: block; }
.help { font-size: 14px; line-height: 1.45; }
.help summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 2px; color: var(--gold); text-transform: uppercase; }
.help ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.help kbd { font-family: var(--font-log); font-size: 17px; color: var(--gold); }
.toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.75); color: #f6ead2; padding: 4px 12px; font-size: 14px; pointer-events: none; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.top-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; font-variant-numeric: tabular-nums; }
.top-list span { color: var(--muted); }
.log .small { color: #f6ead2; } .log .blue { color: #8ab6ff; } .log .orange { color: #f2a33a; } .log .look { color: var(--good); } .log .monster { color: #f2a33a; }
.screen.aiming canvas { cursor: cell; }
.slot.aim { outline: 2px solid var(--gold); outline-offset: -2px; }

/* outfit window */
.outfit-win { width: min(360px, calc(100% - 16px)); }
.outfit-top { display: flex; gap: 10px; align-items: center; }
.outfit-top canvas { width: 128px; height: 128px; image-rendering: pixelated; background: var(--bg); border: 1px solid var(--line); flex: none; }
.outfit-pick { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.outfit-pick .row { display: flex; gap: 6px; align-items: center; }
.outfit-pick strong { flex: 1; text-align: center; color: var(--gold); }
.outfit-pick button { min-height: 32px; padding: 2px 10px; }
.outfit-pick label { display: flex; flex-direction: row; gap: 6px; align-items: center; font-size: 14px; }
.palette { display: grid; grid-template-columns: repeat(19, 1fr); gap: 1px; }
.palette button { min-height: 0; height: 15px; padding: 0; border: 1px solid #000; }
.palette button[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: -1px; z-index: 1; }
.fight-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.fight-modes button { padding: 4px 2px; font-size: 13px; min-height: 30px; }
.fight-modes button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }

/* ---------- 0.7: containers, menus, battle list, party, VIP, channels, windows ---------- */
.top-buttons button { min-height: 34px; padding: 3px 12px; font-size: 14px; }
.cwin { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.cwin.depot .bag-tools span:first-child { color: var(--gold); }
.cwin .bag-tools span:last-child { display: flex; gap: 4px; }
.slot.has { touch-action: none; cursor: grab; }
.slot.inner { opacity: 0.85; transform: scale(0.85); }
.drag-ghost { position: fixed; width: 40px; height: 40px; image-rendering: pixelated; pointer-events: none; z-index: 50; opacity: 0.85; }
.ctx { position: fixed; z-index: 40; min-width: 190px; background: var(--panel); border: 1px solid var(--rust); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 0 0 2px var(--panel-2); padding: 4px; display: flex; flex-direction: column; }
.ctx button { border: 0; text-align: left; min-height: 32px; padding: 4px 10px; font-size: 14px; color: var(--text); }
.ctx button:hover, .ctx button:focus-visible { background: var(--rust); color: #f6ead2; outline: none; }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; width: 100%; }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: '▾'; color: var(--muted); font-size: 12px; }
details.fold:not([open]) > summary::after { content: '▸'; }
details.fold > summary h2 { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.battle { display: flex; flex-direction: column; gap: 3px; max-height: 260px; overflow-y: auto; }
.battle .bl { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 8px; align-items: center; text-align: left; min-height: 30px; padding: 3px 8px; font-size: 14px; color: var(--text); border-color: var(--line); }
.battle .bl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.battle .bl > i { height: 5px; background: #000; display: block; }
.battle .bl > i > i { display: block; height: 100%; }
.battle .bl.k-n span { color: var(--npc); } .battle .bl.k-p span { color: #e8e2d0; }
.battle .bl.target { border-color: #ff2a1a; box-shadow: inset 0 0 0 1px #ff2a1a; }
.battle .bl.follow { border-color: #3fd14a; box-shadow: inset 0 0 0 1px #3fd14a; }
.battle-filter label { flex-direction: row; gap: 6px; align-items: center; }
.battle-filter input, .vip-add input { width: auto; }
.party-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.party-row.muted { color: var(--muted); }
.party-row button, #party .row button { min-height: 30px; padding: 2px 10px; font-size: 13px; }
.vip { display: flex; flex-direction: column; gap: 2px; }
.vip-row { display: flex; justify-content: space-between; align-items: center; }
.vip-row .link { color: var(--bad); }
.vip-row.on .link:first-child { color: var(--good); }
button.link { border: 0; background: none; padding: 2px 4px; min-height: 26px; text-align: left; font-size: 14px; color: var(--gold); }
button.link.small { color: var(--muted) !important; }
.vip-add { flex-wrap: nowrap; }
.vip-add input { flex: 1; min-width: 0; font-size: 14px; padding: 5px 8px; }
.vip-add button { min-height: 34px; padding: 2px 12px; }
.tabs button.pm { color: #c8a8ff; }
.tabs button.pm .x { color: var(--muted); }
#chat-pm { border-style: dashed; }
.chat form .note { white-space: nowrap; }
.log .pm-in { color: #c8a8ff; } .log .pm-out { color: #a48ad8; } .log .ch-trade { color: #ffd27a; } .log .ch-help { color: #9fe0c0; } .log .ch-guild { color: #8fd18a; } .log .ch-party { color: #9fd0ff; }
.window.wide { width: min(440px, calc(100% - 16px)); }
.window textarea { font-family: var(--font-log); font-size: 18px; color: var(--text); background: var(--bg); border: 1px solid var(--line); padding: 6px 8px; width: 100%; resize: vertical; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-cols .items .slot { width: 40px; height: 40px; }
.ok-mark { color: var(--good); font-size: 13px; min-height: 1.2em; display: block; }
.quest-list { display: flex; flex-direction: column; gap: 6px; }
.quest summary { cursor: pointer; color: var(--text); font-weight: 700; }
.quest.done summary { color: var(--muted); }
.mission { padding: 4px 0 4px 14px; border-left: 2px solid var(--line); margin-top: 4px; }
.mission strong { color: var(--gold); font-size: 14px; }
.mission.done strong { color: var(--good); }
.mission p { margin: 2px 0 0; font-size: 14px; line-height: 1.4; color: var(--text); }
.spell-list table { width: 100%; border-collapse: collapse; font-size: 14px; }
.spell-list th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 3px 4px; }
.spell-list td { padding: 3px 4px; border-bottom: 1px solid var(--panel-2); font-variant-numeric: tabular-nums; }
.spell-list tr.unlearned td { color: var(--muted); }
.spell-list .link { font-family: var(--font-log); font-size: 17px; padding: 0; min-height: 0; }
.hotkey-list { display: flex; flex-direction: column; gap: 4px; }
.hotkey-row { display: grid; grid-template-columns: 34px 110px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.hotkey-row strong { color: var(--gold); font-size: 14px; }
.hotkey-row select, .hotkey-row input { font-size: 14px; padding: 4px 6px; }
.hotkey-row [hidden] + select:not([hidden]) { grid-column: auto; }
@media (max-width: 520px) { .hotkey-row { grid-template-columns: 34px 1fr; } .trade-cols { grid-template-columns: 1fr; } }
.spell-list td:nth-child(3), .spell-list td:nth-child(5) { white-space: nowrap; }
/* on a phone the windows get the whole screen instead of the small game view */
@media (max-width: 600px) {
  .screen .window { position: fixed; left: 8px; right: 8px; top: 8px; width: auto; max-height: calc(100vh - 16px); z-index: 30; }
  .spell-list { overflow-x: auto; }
}
