@font-face { font-family: "Alegreya AO"; src: url("../assets/fonts/AlegreyaSansAO.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Cardo"; src: url("../assets/fonts/Cardo.ttf") format("truetype"); font-display: block; }

:root {
  /* Colours, sizes and frame metrics come from the active theme (css/theme-*.css). */
  --font-ui: "Alegreya AO", "Segoe UI", sans-serif;
  --font-title: "Cardo", Georgia, serif;
  /* The play area shows 33x23 tiles; the sidebar takes what is left, within 360..560 px. */
  --sidebar-w: clamp(360px, calc(1920px - (1080px - var(--navbar-h)) * 1056 / 736), 560px);
  --fit: 1;
}

* { box-sizing: border-box; }
html { margin: 0; height: 100%; overflow: hidden; background: transparent; }
/* The stage (core/stage.js): everything is laid out on it, fixed descendants included, and the
   window around it is black. */
body {
  position: fixed; left: 0; top: 0; width: 1920px; height: 1080px; margin: 0; overflow: hidden; contain: layout;
  background: transparent; box-shadow: 0 0 0 4000px #000;
  font: var(--size-base)/var(--leading) var(--font-ui); color: var(--text);
  user-select: none; -webkit-user-select: none; cursor: var(--cursor);
}
/* A plain browser has no game underneath, so stand something dark in for it. */
html.mock { background: #26301f radial-gradient(circle at 40% 55%, #3d4a2c, #1a2114 75%); }
/* The browser build: the world is a canvas under the page, and a tab is not a window to minimise. */
html.web { background: #000; }
html.web .winbtn.minimize { display: none; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; font-weight: normal; }
img { -webkit-user-drag: none; }
.pixel { image-rendering: pixelated; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-sunken); }
::-webkit-scrollbar-thumb { background: var(--border-dim); border: 2px solid var(--bg-sunken); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ── Text ── */
.title { font: var(--size-title)/1.15 var(--font-title); color: var(--gold); }
.heading { font: var(--size-heading)/1.2 var(--font-title); color: var(--gold); }
.small { font-size: var(--size-small); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.gold { color: var(--gold); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.center { text-align: center; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.num { font-variant-numeric: tabular-nums; }
.section-h {
  display: flex; align-items: center; gap: 6px; margin: 10px 0 4px;
  font: var(--size-small) var(--font-title); letter-spacing: .06em; text-transform: uppercase; color: var(--gold);
}
.section-h::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hint { font-size: var(--size-small); color: var(--text-muted); margin: 0 0 6px 26px; }
.rule { height: 1px; border: 0; margin: 6px 0; background: linear-gradient(90deg, transparent, var(--border) 15%, var(--border-light) 50%, var(--border) 85%, transparent); }

/* ── Layout helpers ── */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1 1 0; min-width: 0; min-height: 0; }
.wrap { flex-wrap: wrap; }
.end { justify-content: flex-end; }
.between { justify-content: space-between; }
.scroll { overflow: auto; }

/* ── Buttons ── */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 12px; white-space: nowrap;
  background: none; color: var(--text);
}
.btn:disabled { opacity: .45; cursor: var(--cursor); }
.btn.small { min-height: 28px; padding: 0 6px; font-size: var(--size-small); }
.btn.wide { width: 100%; }
.btn.caps { text-transform: uppercase; letter-spacing: .05em; }
.link { background: none; border: 0; padding: 4px 6px; color: var(--gold-dim); font-size: var(--size-small); }
.link:hover:not(:disabled) { color: var(--border-light); text-decoration: underline; }
.link:disabled { opacity: .45; cursor: var(--cursor); }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  background: var(--bg-raised-low); border: 1px solid var(--border-dim); border-radius: 3px; color: var(--gold-dim);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border); color: var(--border-light); }
.icon-btn:active:not(:disabled), .icon-btn[aria-pressed="true"] { background: var(--bg-pressed); color: var(--accent); border-color: var(--border); }
.icon-btn:disabled { opacity: .4; cursor: var(--cursor); }
.icon-btn svg { width: 20px; height: 20px; }
.chip {
  min-height: 32px; padding: 2px 10px; background: var(--bg-raised-low); border: 1px solid var(--border-dim);
  border-radius: 3px; color: var(--text);
}
.chip:hover { background: var(--bg-hover); border-color: var(--border); }
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--bg-raised); border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border-dark); }
.chip[aria-checked="true"]::before { content: "✓ "; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid currentColor; border-radius: 9px; font-size: 13px; line-height: 17px; }

/* ── Inputs ── */
input, textarea, select { font: inherit; color: var(--text); }
.input, textarea.input, select.input {
  width: 100%; min-height: 36px; padding: 4px 8px; background: var(--bg-sunken);
  border: 1px solid var(--border-dim); border-radius: 3px; user-select: text; -webkit-user-select: text;
}
.input::placeholder { color: var(--text-dim); }
.input:hover { border-color: var(--border-dark); }
.input:focus { border-color: var(--border-light); outline: none; }
.input:disabled { opacity: .5; }
.input.invalid { border-color: var(--danger); }
textarea.input { resize: none; line-height: 1.3; }
select.input { appearance: none; padding-right: 26px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold-dim) 50%), linear-gradient(135deg, var(--gold-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option { background: var(--bg); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 3px; }
.field > span, label.lbl { font-size: var(--size-small); color: var(--text-muted); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input {
  appearance: none; width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 2px; display: grid; place-items: center;
}
.check input:checked::after { content: ""; width: 9px; height: 5px; border: solid var(--accent); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.check input:disabled { opacity: .45; }
input[type="range"] { appearance: none; height: 18px; background: transparent; cursor: pointer; flex: 1; min-width: 80px; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: var(--bar-track); border: 1px solid var(--border-dim); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 18px; margin-top: -7px; background: var(--gold-dim); border: 1px solid var(--border-light); border-radius: 2px; }
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; }
.tab {
  min-height: 34px; padding: 0 10px; background: none; color: var(--text-muted);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); }

/* ── Bars ── */
.bar { position: relative; height: 24px; background: var(--bar-track); border: 1px solid var(--border-dark); border-radius: 2px; overflow: hidden; }
/* A bar that asks something when pressed (health: /promedio) lights its edge under the pointer. */
.bar.pressable:hover { border-color: var(--accent); }
.bar > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--c, var(--bar-xp)); transition: width .18s ease-out; }
.bar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 6px; font-size: 14px; color: #fff; text-shadow: 0 0 2px #000, 0 1px 1px #000; white-space: nowrap; }
.bar.thin { height: 10px; }
.bar.h18 { height: 18px; } .bar.h18 > span { font-size: 13px; }
.bar.h15 { height: 15px; } .bar.h15 > span { font-size: 12px; }

/* ── Banners, lists, tables ── */
.banner { padding: 6px 12px; background: #0c0a08d9; border: 1px solid var(--border-dim); border-radius: 3px; text-align: center; min-height: 34px; }
.banner.error { background: #3a0f0bd9; border-color: var(--danger); color: #ffd9d3; }
.banner.error::before { content: "⚠ "; }
.list-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 2px 8px; text-align: left; background: none; border: 1px solid transparent; border-radius: 2px; }
.list-row:nth-child(odd) { background: #ffffff06; }
button.list-row:hover { background: var(--bg-hover); }
.list-row[aria-selected="true"] { background: var(--bg-raised); border-color: var(--border); color: var(--accent); }
.empty { padding: 18px 10px; text-align: center; color: var(--text-muted); font-size: var(--size-small); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.kv > :first-child { color: var(--text-muted); }
.kv > :last-child { text-align: right; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 5px var(--good); }
.dot.bad { background: var(--danger); }
.dot.wait { background: var(--warn); }
.slot {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; background: var(--bg-sunken);
  border: 1px solid var(--hairline); border-radius: 2px; display: grid; place-items: center; overflow: hidden;
}
button.slot:hover { border-color: var(--border); }
.slot[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* Icons arrive at the art's full resolution and are scaled smoothly into the cell. */
.slot img { width: 100%; height: 100%; object-fit: contain; }
.slot.drop { border-color: var(--accent); background: var(--bg-hover); }
.slot .amt { position: absolute; right: 2px; bottom: 0; font-size: 12px; color: #fff; text-shadow: 0 0 2px #000, 0 1px 1px #000; }
.slot .eq { position: absolute; left: 2px; top: 0; font-size: 11px; color: var(--accent); text-shadow: 0 0 2px #000; }
.slot.unusable img { filter: sepia(1) saturate(5) hue-rotate(-50deg); }
/* A bag row the account's plan does not open: what it holds can be taken out, nothing put in. */
.slot.locked { background: repeating-linear-gradient(135deg, #0000 0 6px, #ffffff0a 6px 12px); border-style: dashed; }
.slot.locked img { opacity: .55; }
.slot .lock { position: absolute; right: 2px; top: 1px; color: var(--muted, #aaa); opacity: .8; line-height: 0; pointer-events: none; }
.slot.locked:not(:has(img)) .lock { right: 50%; top: 50%; transform: translate(50%, -50%); opacity: .55; }
.grid { display: grid; gap: 3px; grid-auto-rows: max-content; }

/* ── Cursors: the pointer itself says what the next click does ── */
:root {
  --cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2228%22%20height%3D%2228%22%20viewBox%3D%220%200%2028%2028%22%3E%3Cpath%20d%3D%22M3%202l0%2019%205-4.6%203.4%208%203.3-1.4-3.4-7.9%206.9-.4z%22%20fill%3D%22%23f4e3b4%22%20stroke%3D%22%2317130a%22%20stroke-width%3D%221.6%22%20stroke-linejoin%3D%22round%22/%3E%3C/svg%3E") 3 2, default;
  --cursor-target: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%3E%3Cg%20stroke%3D%22%230b0c10%22%20stroke-width%3D%224.2%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Cg%20stroke%3D%22%23f4e3b4%22%20stroke-width%3D%222%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%221.6%22%20fill%3D%22%23f4e3b4%22/%3E%3C/svg%3E") 16 16, crosshair;
  --cursor-target-yes: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%3E%3Cg%20stroke%3D%22%230b0c10%22%20stroke-width%3D%224.2%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Cg%20stroke%3D%22%2358a6ff%22%20stroke-width%3D%222%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%221.6%22%20fill%3D%22%2358a6ff%22/%3E%3C/svg%3E") 16 16, crosshair;
  --cursor-target-no: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%3E%3Cg%20stroke%3D%22%230b0c10%22%20stroke-width%3D%224.2%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Cg%20stroke%3D%22%23ff5a4d%22%20stroke-width%3D%222%22%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%229%22/%3E%3Cpath%20d%3D%22M16%202v8M16%2022v8M2%2016h8M22%2016h8%22/%3E%3C/g%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2216%22%20r%3D%221.6%22%20fill%3D%22%23ff5a4d%22/%3E%3C/svg%3E") 16 16, crosshair;
}
body { cursor: var(--cursor); }
/* Picking a target in the world: plain for a shot, a tile or a player; a spell's is blue with the
   mana to cast it and red without (hud/input.js keeps the two attributes). */
.play[data-aim]:not([data-aim=""]) { cursor: var(--cursor-target); }
.play[data-aim="spell"][data-afford="yes"], .play[data-aim="tile"][data-afford="yes"] { cursor: var(--cursor-target-yes); }
.play[data-aim="spell"][data-afford="no"], .play[data-aim="tile"][data-afford="no"] { cursor: var(--cursor-target-no); }
