/* Veilborn — bruise, ash, rust and old iron. */
:root {
  --void: #0b0910;
  --bruise-900: #130e1b;
  --bruise-800: #1c1527;
  --bruise-700: #2a1f3a;
  --bruise-500: #4b3663;
  --bruise-300: #8a73a6;
  --ash-50: #ece7e1;
  --ash-200: #c9c1b8;
  --ash-400: #8f8780;
  --ash-600: #5d5752;
  --rust: #9a5331;
  --rust-bright: #c46d3e;
  --iron: #3a3d45;
  --veil: #86e3c8;
  --veil-dim: #3f8f7b;
  --blood: #a33a47;
  --ember: #e7a25a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, "Segoe UI", Roboto, sans-serif;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -20%, #3a2448 0%, transparent 60%),
    linear-gradient(180deg, var(--bruise-900), var(--void) 70%);
  background-attachment: fixed;
  color: var(--ash-200);
  font: 17px/1.65 var(--serif);
}
a { color: var(--veil); text-decoration-color: var(--veil-dim); }
a:hover { color: #b6f2df; }
h1, h2, h3 { color: var(--ash-50); font-weight: 600; letter-spacing: .01em; line-height: 1.2; }
em { color: var(--veil); font-style: italic; }
.muted { color: var(--ash-400); }
.small { font-size: .85rem; }

/* ── Top bar ───────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1.25rem;
  border-bottom: 1px solid rgba(138, 115, 166, .18);
  background: rgba(11, 9, 16, .6);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: .5rem; align-items: center; color: var(--ash-50); text-decoration: none; font-variant: small-caps; letter-spacing: .15em; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; font-family: var(--sans); font-size: .9rem; }
.topbar nav a { text-decoration: none; }
.topbar form { margin: 0; }
.who { color: var(--ash-200); }

/* ── Buttons & forms ───────────────────────────────── */
.btn, button.btn {
  display: inline-block;
  padding: .65rem 1.3rem;
  border: 1px solid var(--rust);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #7b3f25, #5a2c19);
  color: var(--ash-50);
  font: 600 .95rem var(--sans);
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.15); color: var(--ash-50); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; border-color: var(--bruise-500); color: var(--ash-200); }
/* .btn.btn-* so these sizes win over "button.btn" above */
.btn.btn-small { padding: .35rem .8rem; font-size: .8rem; }
button.link { background: none; border: 0; color: var(--ash-400); font: inherit; cursor: pointer; padding: 0; }
button.link:hover { color: var(--ash-50); }

input:not([type=radio]) {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--bruise-700);
  border-radius: var(--radius);
  background: rgba(11, 9, 16, .7);
  color: var(--ash-50);
  font: 1rem var(--sans);
}
input:focus { outline: 2px solid var(--veil-dim); outline-offset: 1px; border-color: transparent; }
label { display: block; font: .85rem var(--sans); color: var(--ash-400); letter-spacing: .03em; }
label input { margin-top: .3rem; }
.stack { display: grid; gap: 1rem; }
.error { color: #f0a2ab; background: rgba(163, 58, 71, .15); border-left: 3px solid var(--blood); padding: .5rem .8rem; border-radius: 0 var(--radius) var(--radius) 0; }
.flash { margin: 0; padding: .6rem 1.25rem; font: .9rem var(--sans); }
.flash-error { background: rgba(163, 58, 71, .25); color: #f6c2c8; }

.panel { margin: 3rem auto; padding: 2rem; background: rgba(28, 21, 39, .75); border: 1px solid rgba(138, 115, 166, .2); border-radius: 10px; }
.panel.narrow { max-width: 420px; }
.panel.wide { max-width: 1100px; }
.panel h1 { margin-top: 0; }

.tag { display: inline-block; padding: .05rem .45rem; border-radius: 99px; background: rgba(134, 227, 200, .1); color: var(--veil); font: .72rem var(--sans); letter-spacing: .02em; white-space: nowrap; }
.tag-item { background: rgba(196, 109, 62, .14); color: var(--ember); }

/* ── Landing ───────────────────────────────────────── */
.hero { position: relative; max-width: 720px; margin: 0 auto; padding: 4rem 1.5rem 5rem; text-align: center; }
.veil-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 60px, rgba(134, 227, 200, .025) 60px 62px, transparent 62px 140px);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 60%, transparent);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-30px) skewX(-2deg); } to { transform: translateX(30px) skewX(2deg); } }
.hero-emblem { filter: drop-shadow(0 0 18px rgba(134, 227, 200, .35)); }
.title { margin: .5rem 0 0; font-size: clamp(2.8rem, 8vw, 4.6rem); font-variant: small-caps; letter-spacing: .22em; text-shadow: 0 0 30px rgba(134, 227, 200, .2); }
.subtitle { margin: .25rem 0 2.5rem; color: var(--bruise-300); font-style: italic; letter-spacing: .05em; }
.lore { text-align: left; font-size: 1.08rem; }
.lore p { margin: 0 0 1.1rem; }
.lore blockquote { margin: 2rem 0 0; padding: 1rem 1.5rem; border-left: 2px solid var(--veil-dim); color: var(--ash-50); font-style: italic; }
.cta { display: flex; gap: 1rem; justify-content: center; margin-top: 2.5rem; flex-wrap: wrap; }

/* ── Character creation ────────────────────────────── */
.name-field { max-width: 360px; }
.origins { border: 0; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.origins legend { font: .85rem var(--sans); color: var(--ash-400); margin-bottom: .5rem; padding: 0; }
.origin { position: relative; cursor: pointer; }
.origin input { position: absolute; opacity: 0; }
.origin-card {
  display: flex; flex-direction: column; gap: .4rem; height: 100%;
  padding: 1rem; border-radius: 8px;
  border: 1px solid var(--bruise-700);
  background: rgba(11, 9, 16, .55);
  color: var(--ash-200);
  font: .88rem/1.5 var(--serif);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.origin:hover .origin-card { border-color: var(--bruise-500); transform: translateY(-2px); }
.origin input:checked + .origin-card { border-color: var(--veil-dim); box-shadow: 0 0 0 1px var(--veil-dim), 0 0 24px rgba(134, 227, 200, .12); }
.origin input:focus-visible + .origin-card { outline: 2px solid var(--veil); }
.origin-crime { font-size: 1.25rem; color: var(--ash-50); font-variant: small-caps; letter-spacing: .08em; }
.origin-title { color: var(--bruise-300); font-style: italic; margin-top: -.35rem; }
.origin-trait { color: var(--ember); font-size: .82rem; }
.origin-stats { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; padding-top: .4rem; }

/* ── Play ──────────────────────────────────────────── */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; max-width: 1240px; margin: 0 auto; padding: 1.5rem; }
@media (max-width: 900px) { .game { grid-template-columns: 1fr; } }

.scene { min-width: 0; }
.scene-art { margin: 0; border-radius: 10px; overflow: hidden; border: 1px solid rgba(138, 115, 166, .2); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); background: var(--bruise-900); aspect-ratio: 20 / 9; }
.scene-art img { display: block; width: 100%; height: 100%; object-fit: cover; animation: fadein .6s ease; }
@keyframes fadein { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: none; } }
.scene-head { margin: 1.25rem 0 .5rem; }
.region { margin: 0; font: .78rem var(--sans); text-transform: uppercase; letter-spacing: .18em; color: var(--bruise-300); }
.safe { color: var(--ember); }
.scene-head h1 { margin: .15rem 0 0; font-size: 2rem; }
.scene-text p { margin: 0 0 1rem; max-width: 68ch; }

.outcome { margin: 1rem 0 1.25rem; padding: .9rem 1.1rem; border-radius: var(--radius); background: rgba(42, 31, 58, .55); border-left: 3px solid var(--bruise-500); }
.outcome p { margin: 0; }
.outcome .result { margin-top: .4rem; color: var(--ash-50); font-style: italic; }
.line { font: .85rem var(--sans); }
.line-good { color: #9fd9a8; }
.line-bad { color: #f0a2ab; }
.line-veil { color: var(--veil); }

.choices { display: grid; gap: .55rem; margin: 1.5rem 0; max-width: 68ch; }
.choice {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  width: 100%; padding: .8rem 1rem;
  border: 1px solid var(--bruise-700); border-radius: var(--radius);
  background: rgba(19, 14, 27, .8);
  color: var(--ash-50); text-align: left;
  font: 1rem var(--serif); cursor: pointer;
  transition: border-color .15s, background .15s, padding-left .15s;
}
.choice::before { content: "›"; color: var(--rust-bright); margin-right: .2rem; }
.choice span:first-child { flex: 1; }
.choice:hover { border-color: var(--rust); background: rgba(42, 31, 58, .8); padding-left: 1.2rem; }
.check { font: .72rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--ember); white-space: nowrap; }
.here { font: .85rem var(--sans); color: var(--ash-400); }
.here .label { color: var(--bruise-300); }

/* ── Sidebar ───────────────────────────────────────── */
.sidebar { display: grid; gap: 1rem; align-content: start; }
.card { padding: 1rem 1.1rem; border-radius: 10px; background: rgba(28, 21, 39, .75); border: 1px solid rgba(138, 115, 166, .16); }
.card h2 { margin: 0; font-size: 1.2rem; }
.card h3 { margin: 0 0 .6rem; font: 600 .75rem var(--sans); text-transform: uppercase; letter-spacing: .16em; color: var(--bruise-300); }
.card p { margin: 0; }
.char-head { display: flex; gap: .75rem; align-items: center; margin-bottom: .9rem; }

.bar { display: grid; grid-template-columns: 2.6rem 1fr 3rem; gap: .5rem; align-items: center; font: .78rem var(--sans); margin-bottom: .4rem; }
.bar-label { color: var(--ash-400); text-transform: uppercase; letter-spacing: .08em; }
.bar-value { text-align: right; color: var(--ash-50); }
.bar-track { height: 8px; border-radius: 99px; background: rgba(11, 9, 16, .8); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.bar-fill.hp { background: linear-gradient(90deg, #6e2230, var(--blood)); }
.bar-fill.veil { background: linear-gradient(90deg, var(--veil-dim), var(--veil)); box-shadow: 0 0 8px rgba(134, 227, 200, .5); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .9rem 0 0; }
.stats div { padding: .35rem .4rem; border-radius: var(--radius); background: rgba(11, 9, 16, .5); text-align: center; }
.stats dt { font: .62rem var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--ash-400); }
.stats dd { margin: 0; color: var(--ash-50); font-size: 1.05rem; }
.stats small { color: var(--veil); font: .68rem var(--sans); }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .92rem; }
.items li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; cursor: help; }

.online-wrap { margin-bottom: .6rem; }
.online-wrap summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; user-select: none; }
.online-wrap summary::-webkit-details-marker { display: none; }
.online-wrap summary h3 { margin: 0; }
.online-wrap .count {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .05rem .55rem; border-radius: 99px;
  border: 1px solid rgba(134, 227, 200, .35);
  background: rgba(134, 227, 200, .08);
  color: var(--veil); font: 600 .75rem var(--sans);
  transition: background .15s, border-color .15s;
}
.online-wrap .count::after { content: "▾"; font-size: .7rem; transition: transform .15s; }
.online-wrap[open] .count::after { transform: rotate(180deg); }
.online-wrap summary:hover .count { background: rgba(134, 227, 200, .18); border-color: var(--veil); }
.online-wrap summary:focus-visible { outline: 2px solid var(--veil-dim); outline-offset: 3px; border-radius: 4px; }
.online { list-style: none; margin: .5rem 0 0; padding: .4rem .5rem; border-radius: var(--radius); background: rgba(11, 9, 16, .4); display: grid; gap: .15rem; max-height: 7.5rem; overflow-y: auto; font: .8rem var(--sans); }
.online li { display: flex; justify-content: space-between; gap: .5rem; }
.online strong { color: var(--ash-50); font-weight: 500; }
.online span { color: var(--ash-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-log { list-style: none; margin: 0; padding: .5rem; height: 260px; overflow-y: auto; background: rgba(11, 9, 16, .6); border-radius: var(--radius); font: .82rem/1.45 var(--sans); }
.msg { margin-bottom: .3rem; word-wrap: break-word; }
.msg time { color: var(--ash-600); font-size: .7rem; margin-right: .4rem; }
.msg strong { color: var(--ember); font-weight: 600; margin-right: .35rem; }
.msg strong.me { color: var(--veil); }
.msg-system { color: var(--bruise-300); font-style: italic; }
.chat-form { display: flex; gap: .4rem; margin-top: .5rem; }
.chat-form input { padding: .45rem .6rem; font-size: .85rem; }

/* ── Progression ───────────────────────────────────── */
.bar-fill.xp { background: linear-gradient(90deg, #6b4a20, var(--ember)); }
.line-level { color: var(--ember); font-weight: 600; }
.line-info { color: var(--ash-400); }
.line-round { color: var(--bruise-300); font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; margin-top: .4rem; }
.train { margin: .7rem 0 0; padding: .6rem .7rem; border-radius: var(--radius); background: rgba(231, 162, 90, .08); border: 1px solid rgba(231, 162, 90, .3); }
.train p { margin: 0 0 .4rem; font: .8rem var(--sans); color: var(--ember); }
.train div { display: flex; flex-wrap: wrap; gap: .3rem; }
.flash-info { background: rgba(134, 227, 200, .12); color: #c9f5e8; }

/* ── Items ─────────────────────────────────────────── */
.item-side { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
/* The form is a flex box so the button centres with the tags instead of sitting on a text baseline */
.item-side form { margin: 0; display: flex; }
.equipped { font: .65rem var(--sans); color: var(--ember); text-transform: uppercase; letter-spacing: .08em; }
.btn.btn-tiny { padding: .05rem .5rem; font-size: .7rem; line-height: 1.4; letter-spacing: .02em; border-radius: 99px; display: inline-flex; align-items: center; }
.btn:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(.6); }

/* ── Chapter end ───────────────────────────────────── */
.chapter-end { margin: 1.5rem 0; padding: 1rem 1.2rem; max-width: 68ch; text-align: center; border: 1px solid rgba(134, 227, 200, .3); border-radius: 8px; background: rgba(134, 227, 200, .05); }
.chapter-mark { display: block; color: var(--veil); font-variant: small-caps; letter-spacing: .2em; margin-bottom: .3rem; }
.chapter-end p { margin: 0; color: var(--ash-200); font-style: italic; }

/* ── Combat ────────────────────────────────────────── */
.enemy-art { border-color: rgba(163, 58, 71, .35); box-shadow: 0 20px 50px rgba(0, 0, 0, .5), 0 0 40px rgba(163, 58, 71, .12); }
.combat .scene-head .muted { margin: .3rem 0 0; max-width: 68ch; }
.enemy-bar { grid-template-columns: 2.6rem 1fr 3.4rem; max-width: 68ch; margin-top: 1rem; }
.bar-fill.foe { background: linear-gradient(90deg, #4a1a22, var(--blood)); }
.enemy-stats { margin: .2rem 0 0; }
.combat-log { list-style: none; margin: 1rem 0; padding: .7rem .9rem; max-width: 68ch; max-height: 260px; overflow-y: auto; border-radius: var(--radius); background: rgba(11, 9, 16, .6); }
.combat-log li { margin: 0 0 .15rem; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin: 1rem 0 0; max-width: 68ch; }
.items-actions { grid-template-columns: 1fr; margin-top: .55rem; }
.action { flex-direction: column; align-items: flex-start; gap: .1rem; }
.action::before { display: none; }
.action:hover { padding-left: 1rem; }
@media (max-width: 600px) { .actions { grid-template-columns: 1fr; } }

/* ── Shop ──────────────────────────────────────────── */
.shop { margin: 1.5rem 0; padding: 1.1rem 1.2rem; max-width: 68ch; border-radius: 10px; background: rgba(28, 21, 39, .75); border: 1px solid rgba(196, 109, 62, .3); }
.shop-head { display: flex; justify-content: space-between; align-items: baseline; }
.shop-head h2 { margin: 0; font-size: 1.3rem; }
.purse { font: 600 .9rem var(--sans); color: var(--ember); }
.shop-greeting { margin: .4rem 0 .8rem; font-style: italic; }
.shop h3 { margin: 1rem 0 .4rem; font: 600 .72rem var(--sans); text-transform: uppercase; letter-spacing: .16em; color: var(--bruise-300); }
.shop form { margin: 0; }
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.shop-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem .7rem; border-radius: var(--radius); background: rgba(11, 9, 16, .5); }
.shop-item { display: grid; gap: .15rem; }
.shop-item .item-name { color: var(--ash-50); }
.shop-desc { font-size: .82rem; color: var(--ash-400); }
.shop-list .btn { white-space: nowrap; }
