/* Dragon Kingdoms. Night over a dragon's hoard: violet-black stone, hoard gold, wyrm teal. */
:root {
  --ink: #14121a;
  --panel: #1d1a25;
  --panel-2: #262231;
  --edge: #353044;
  --text: #eae3d2;
  --muted: #a19ab0;
  --gold: #e0b354;
  --gold-deep: #9c7426;
  --ember: #e2623b;
  --blood: #c8414f;
  --wyrm: #58b8a6;
  --display: 'Marcellus', 'Palatino Linotype', Georgia, serif;
  --ui: 'Barlow Semi Condensed', 'Segoe UI', system-ui, sans-serif;
  --radius: 4px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 400 16px/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; }
h2 { font-size: 1.125rem; letter-spacing: .01em; }
p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
a { color: var(--gold); }

button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: .4rem .8rem;
  font-weight: 500;
}
button:hover:not(:disabled) { border-color: var(--gold-deep); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #201804;
  font-weight: 700;
  padding: .6rem 1.2rem;
}
button.primary:hover:not(:disabled) { background: #f0c66b; border-color: #f0c66b; }
button.quiet { background: none; border-color: transparent; color: var(--muted); padding: .25rem .5rem; }
button.quiet:hover:not(:disabled) { color: var(--text); border-color: var(--edge); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input {
  background: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: .55rem .7rem;
  width: 100%;
}
input[type="checkbox"] { width: auto; accent-color: var(--gold); }
.hint { color: var(--muted); font-size: .875rem; }

.bar { display: block; height: 6px; background: #0d0b12; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--wyrm); border-radius: 3px; transition: width .18s ease-out; }

.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 3px; overflow: hidden; }
.seg > * {
  border: 0; border-radius: 0; background: none; color: var(--muted);
  padding: .3rem .7rem; font-size: .875rem; font-weight: 600; text-decoration: none;
}
.seg > * + * { border-left: 1px solid var(--edge); }
.seg > [aria-pressed="true"], .seg > [aria-selected="true"] { background: var(--panel-2); color: var(--gold); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  height: 56px; padding: 0 1rem;
  background: var(--panel); border-bottom: 1px solid var(--edge);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--gold); text-decoration: none; font-family: var(--display); font-size: 1.25rem; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.who { display: flex; flex-direction: column; line-height: 1.15; }
.who span { color: var(--muted); font-size: .875rem; }
.xp { flex: 1; min-width: 120px; max-width: 420px; }
.xp span { color: var(--muted); font-size: .8125rem; }
.purse { display: flex; align-items: center; gap: .35rem; color: var(--gold); font-weight: 700; font-size: 1.125rem; margin-left: auto; white-space: nowrap; }
.purse svg { width: 18px; height: 18px; }
.logout { margin: 0; }

/* ---------- board ---------- */
.board {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 56px);
}
.col { display: flex; flex-direction: column; gap: 1rem; min-height: 0; }
.col-hero { overflow-y: auto; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: .875rem 1rem; }
.panel > h2, .panel-head { margin-bottom: .625rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.vitals { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin: 0; }
.vitals dt { color: var(--muted); }
.vitals dd { margin: 0; text-align: right; font-weight: 600; }

.skills { margin-top: .625rem; display: grid; gap: .5rem; }
.skills li { display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem; color: var(--muted); }
.skills .bar { grid-column: 1 / -1; height: 4px; }
.skills .bar i { background: var(--edge); }
.skills .training { color: var(--text); }
.skills .training .bar i { background: var(--wyrm); }
.skills .training .skill-name::after { content: ' (training)'; color: var(--wyrm); font-size: .8125rem; }
.skill-value { font-weight: 600; }

.gear { display: grid; gap: 2px; }
.gear-slot {
  display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: baseline; gap: .5rem;
  width: 100%; text-align: left; background: none; border: 0; border-radius: 2px; padding: .3rem .25rem; font-weight: 400;
}
button.gear-slot:hover { background: var(--panel-2); }
.gear-kind { color: var(--muted); font-size: .875rem; }
.gear-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear-power { color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.gear .empty .gear-name { color: var(--muted); font-weight: 400; font-style: italic; }

/* ---------- centre: tabs ---------- */
.col-main { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); gap: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--edge); padding: 0 .5rem; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: .75rem 1rem; color: var(--muted); font-family: var(--display); font-size: 1.0625rem;
}
.tabs button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.tabpane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabpane[hidden] { display: none; }

/* ---------- arena ---------- */
.arena {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--edge);
  background:
    radial-gradient(ellipse 60% 90% at 50% 0%, rgba(226, 98, 59, .10), transparent 70%),
    var(--panel);
}
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
.versus { font-family: var(--display); color: var(--muted); font-size: 1.125rem; min-width: 5.5rem; text-align: center; }
.fighter { display: flex; align-items: center; gap: .875rem; min-width: 0; }
.fighter-foe { flex-direction: row-reverse; text-align: right; }
.fighter-info { flex: 1; min-width: 0; display: grid; gap: .15rem; }
.fighter-name { font-family: var(--display); font-weight: 400; font-size: 1.375rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fighter-sub, .hp-text { color: var(--muted); font-size: .875rem; }
.bar.hp { height: 10px; margin-top: .25rem; }
.bar.hp i { background: var(--blood); }
.fighter-you .bar.hp i { background: var(--wyrm); }
.fighter-foe .bar.hp i { margin-left: auto; }
.sigil { flex: none; width: 64px; }
.sigil svg { display: block; width: 100%; }
.sigil text { font-family: var(--display); }
.sigil-elite { filter: drop-shadow(0 0 8px rgba(224, 179, 84, .6)); }

.advice { margin-top: .875rem; color: var(--muted); }
.advice.verdict-deadly, .advice.verdict-out { color: #e9a0a8; }
.arena-actions { margin-top: .875rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.battle-log {
  margin-top: .875rem; max-height: 132px; overflow-y: auto;
  background: var(--ink); border: 1px solid var(--edge); border-radius: 3px;
  padding: .5rem .75rem; font-size: .9375rem;
}
.battle-log b { color: var(--muted); font-weight: 500; display: inline-block; min-width: 1.75rem; }
.log-crit { color: var(--gold); font-weight: 600; }
.log-miss, .log-foe { color: var(--muted); }

.outcome {
  margin-top: .875rem; padding: .75rem 1rem; border-left: 3px solid var(--muted);
  background: var(--panel-2); border-radius: 0 3px 3px 0; display: grid; gap: .15rem;
}
.outcome strong { font-family: var(--display); font-weight: 400; font-size: 1.25rem; }
.outcome-win { border-left-color: var(--gold); }
.outcome-win strong { color: var(--gold); }
.outcome-loss { border-left-color: var(--blood); }
.outcome-loss strong { color: #e9a0a8; }
.event { font-weight: 600; }
.event-skill { color: var(--wyrm); }
.event-level, .event-gold, .event-quest { color: var(--gold); }

/* ---------- bestiary ---------- */
.bestiary { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bestiary-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .875rem; cursor: pointer; }
.monsters { flex: 1; overflow-y: auto; padding: 0 .75rem .75rem; }
.monster {
  display: grid; grid-template-columns: 30px minmax(0, 1.4fr) 7.5rem minmax(0, 1.2fr) 6.5rem;
  align-items: center; gap: .75rem; width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: 3px; padding: .35rem .5rem; font-weight: 400;
}
.monster:hover { background: var(--panel-2); border-color: transparent; }
.monster.selected { background: var(--panel-2); border-color: var(--gold-deep); }
.monster .sigil { width: 30px; }
.monster-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monster-level, .monster-loot { color: var(--muted); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verdict { font-size: .8125rem; font-weight: 700; text-align: center; padding: .1rem .4rem; border-radius: 2px; border: 1px solid currentColor; }
.verdict-free, .verdict-safe { color: var(--wyrm); }
.verdict-risky { color: var(--gold); }
.verdict-deadly { color: var(--blood); }
.verdict-out { color: #6f6880; }

/* ---------- market ---------- */
.market-slots { display: flex; flex-wrap: wrap; gap: .375rem; padding: 1rem 1.25rem .5rem; }
.market-slots button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.market-current { padding: .25rem 1.25rem .75rem; color: var(--muted); }
.wares { flex: 1; overflow-y: auto; padding: 0 .75rem .75rem; }
.ware { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: .5rem; border-bottom: 1px solid var(--edge); }
.ware-main { display: grid; }
.ware-note { color: var(--muted); font-size: .875rem; }
.ware .price { color: var(--gold); font-weight: 600; white-space: nowrap; }
.ware-actions { display: flex; gap: .375rem; min-width: 7.5rem; justify-content: flex-end; }
.ware.best { background: rgba(224, 179, 84, .07); }
.ware.best .ware-note { color: var(--gold); }
.ware.locked strong { color: var(--muted); }
.empty-note { padding: 2rem 1rem; color: var(--muted); text-align: center; }

/* ---------- rankings ---------- */
#tab-rankings { overflow-y: auto; padding: .5rem 1.25rem 1rem; }
.ranks { width: 100%; border-collapse: collapse; }
.ranks th { text-align: left; color: var(--muted); font-weight: 500; font-size: .875rem; padding: .5rem; border-bottom: 1px solid var(--edge); }
.ranks td { padding: .45rem .5rem; border-bottom: 1px solid var(--edge); }
.ranks td:first-child { color: var(--muted); width: 4rem; }
.ranks tr.me td { color: var(--gold); font-weight: 600; }

/* ---------- map ---------- */
.coords { color: var(--muted); font-weight: 600; }
.panel-map { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; }
.panel-map .panel-head, .panel-map .hint { grid-column: 1 / -1; margin: 0; }
.panel-map .hint { order: 5; }
.map {
  display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px;
  aspect-ratio: 1; padding: 6px; border-radius: 3px;
  background: #0f1512; border: 1px solid var(--edge);
}
.cell { background: #1b2a22; border-radius: 1px; }
.cell.mark { background: #1b2a22; box-shadow: inset 0 0 0 2px var(--gold-deep); }
.cell.here { background: var(--ember); box-shadow: 0 0 0 2px rgba(226, 98, 59, .35), 0 0 12px rgba(226, 98, 59, .8); position: relative; z-index: 1; }
.dpad { display: grid; grid-template-columns: repeat(3, 2.25rem); grid-template-rows: repeat(3, 2.25rem); gap: 2px; }
.dpad button { padding: 0; font-family: var(--display); }
.dpad [data-dir="north"] { grid-area: 1 / 2; }
.dpad [data-dir="west"]  { grid-area: 2 / 1; }
.dpad [data-dir="east"]  { grid-area: 2 / 3; }
.dpad [data-dir="south"] { grid-area: 3 / 2; }

/* ---------- chat ---------- */
.panel-chat { flex: 1; min-height: 220px; display: flex; flex-direction: column; }
.online { border: 1px solid var(--edge); border-radius: 3px; margin-bottom: .5rem; max-height: 120px; overflow-y: auto; }
.online li { display: flex; justify-content: space-between; align-items: center; padding: 0 .5rem 0 0; color: var(--muted); font-size: .875rem; }
.chat { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: .3rem; font-size: .9375rem; overflow-wrap: anywhere; }
.chat time { color: #6f6880; font-size: .75rem; margin-right: .4rem; }
.chat-name { background: none; border: 0; padding: 0; margin-right: .35rem; color: var(--gold); font-weight: 600; }
.chat-name:hover { text-decoration: underline; }
.chat-mine .chat-name { color: var(--text); }
.chat-system { color: var(--muted); font-style: italic; }
.chat-loot { color: var(--wyrm); }
.chat-emote { color: #c9b6e6; font-style: italic; }
.chat-whisper { color: #e6a6c4; }
.chat-whisper .chat-name { color: inherit; }
.chat-form { display: flex; gap: .375rem; margin-top: .625rem; }

/* ---------- kingdom, town, clan, staff ---------- */
.tabpane.scroll { overflow-y: auto; padding: .5rem 1.25rem 1.25rem; display: block; }
.tabpane.scroll[hidden] { display: none; }
.block { padding: 1rem 0; border-bottom: 1px solid var(--edge); }
.block:last-child { border-bottom: 0; }
.block h3 { font-family: var(--display); font-weight: 400; font-size: 1.25rem; margin: 0 0 .5rem; color: var(--gold); }
.block .vitals { max-width: 26rem; margin-bottom: .5rem; }
.block .wares { padding: 0; overflow: visible; }
.block .hint { max-width: 46rem; }
.row { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .625rem; align-items: center; }
.row input, .row select { width: auto; flex: 1 1 9rem; max-width: 16rem; }
select { background: var(--ink); color: var(--text); border: 1px solid var(--edge); border-radius: 3px; padding: .5rem .6rem; font: inherit; max-width: 100%; }
.plain { display: grid; gap: .35rem; }
.plain li button { margin-left: .375rem; }
.notice { margin-top: 1rem; padding: .6rem .9rem; border-left: 3px solid var(--gold); background: var(--panel-2); }
.tabs { overflow-x: auto; }
.tabs button { white-space: nowrap; }
.chips { display: flex; gap: .875rem; flex-wrap: wrap; color: var(--muted); font-size: .875rem; }
.chip b { color: var(--text); }
.relics { display: flex; flex-wrap: wrap; gap: .375rem; }
.relics li { border: 1px solid var(--edge); border-radius: 2px; padding: .1rem .5rem; font-size: .875rem; color: var(--wyrm); }
.travel { grid-column: 1 / -1; order: 6; display: flex; flex-wrap: wrap; gap: .375rem; }
.travel button { font-size: .875rem; padding: .3rem .6rem; }
.cell.gate { background: #1b2a22; box-shadow: inset 0 0 0 2px var(--wyrm); }
.monster.dragon { border-color: var(--gold-deep); background: rgba(224, 179, 84, .06); }
.monster.dragon .monster-name { color: var(--gold); }
.chat-clan { color: #8fd0a0; }
.chat-auction { color: #e0c48a; }
.chat-clan .chat-name, .chat-auction .chat-name { color: inherit; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 20; width: min(92vw, 420px); }
.toast { background: var(--panel-2); border: 1px solid var(--edge); border-left: 3px solid var(--muted); border-radius: 3px; padding: .6rem .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); transition: opacity .3s; }
.toast-error { border-left-color: var(--blood); }
.toast-gold { border-left-color: var(--gold); }
.toast.leaving { opacity: 0; }

.mobile-nav { display: none; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .board { grid-template-columns: 280px minmax(0, 1fr); height: auto; }
  .col-world { grid-column: 1 / -1; flex-direction: row; }
  .col-world > * { flex: 1; }
  .panel-chat { max-height: 320px; }
  .monsters, .wares { max-height: 60vh; }
}
@media (max-width: 760px) {
  body.game { padding-bottom: 56px; }
  .topbar { gap: .75rem; height: auto; padding: .5rem .75rem; flex-wrap: wrap; }
  .brand span, .xp span { display: none; }
  .xp { order: 5; flex-basis: 100%; max-width: none; }
  .board { display: block; padding: .5rem; }
  .col { display: none; }
  body[data-view="hero"] .col-hero, body[data-view="main"] .col-main, body[data-view="world"] .col-world { display: flex; }
  .col-world { flex-direction: column; }
  .panel-chat { height: 46vh; max-height: none; }
  .duel { grid-template-columns: 1fr; gap: .5rem; }
  .versus { text-align: left; }
  .fighter-foe { flex-direction: row; text-align: left; }
  .fighter-foe .bar.hp i { margin-left: 0; }
  .sigil { width: 44px; }
  .monster { grid-template-columns: 26px minmax(0, 1fr) auto; row-gap: 0; }
  .monster .sigil { grid-row: span 2; width: 26px; }
  .monster-loot { grid-column: 2; }
  .monster .verdict { grid-column: 3; grid-row: 1 / span 2; }
  .ware { grid-template-columns: 1fr auto; }
  .ware-actions { grid-column: 1 / -1; justify-content: stretch; }
  .ware-actions button { flex: 1; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; height: 56px; z-index: 10;
    background: var(--panel); border-top: 1px solid var(--edge);
  }
  .mobile-nav button { border: 0; border-radius: 0; background: none; color: var(--muted); font-weight: 600; }
  .mobile-nav button[aria-pressed="true"] { color: var(--gold); box-shadow: inset 0 2px 0 var(--gold); }
  .toasts { bottom: 68px; }
}

/* ---------- the gate (landing page) ---------- */
body.gate {
  min-height: 100%;
  background:
    radial-gradient(ellipse 70% 55% at 85% 100%, rgba(226, 98, 59, .16), transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 0%, rgba(88, 184, 166, .08), transparent 70%),
    var(--ink);
}
.gate-wrap {
  max-width: 1120px; margin: 0 auto; min-height: 100vh;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 4rem;
  align-items: center; padding: 3rem 1.5rem;
}
.gate-pitch h1 { font-size: clamp(3.25rem, 9vw, 6.5rem); line-height: .95; color: var(--gold); letter-spacing: -.01em; }
.lede { margin-top: 1.5rem; max-width: 34rem; font-size: 1.1875rem; color: #d2cabb; }
.gate-card { margin-top: 2rem; max-width: 24rem; background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 1.25rem; }
.gate-card .seg { display: flex; margin-bottom: 1rem; }
.gate-card .seg > * { flex: 1; text-align: center; padding: .5rem; font-size: 1rem; }
.gate-card form { display: grid; gap: .875rem; }
.gate-card label { display: grid; gap: .3rem; color: var(--muted); font-size: .9375rem; }
.gate-card .hint { margin-top: .875rem; }
.form-error { margin-bottom: .875rem; padding: .5rem .75rem; border-left: 3px solid var(--blood); background: rgba(200, 65, 79, .12); }

.climb h2 { font-size: 1.5rem; color: var(--muted); margin-bottom: 1rem; }
.climb ol { border-left: 1px solid var(--edge); }
.climb li {
  position: relative; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: .8rem 0 .8rem 1.5rem; border-bottom: 1px solid var(--edge);
  opacity: calc(1 - var(--i) * .1);
}
.climb li::before { content: ''; position: absolute; left: -4px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border-radius: 50%; background: var(--edge); }
.climb li:first-child::before { background: var(--ember); box-shadow: 0 0 10px var(--ember); }
.climb li:last-child { opacity: 1; }
.climb li:last-child::before { background: var(--gold); }
.rung-name { font-family: var(--display); font-size: 1.25rem; }
.climb li:first-child .rung-name { color: var(--ember); }
.rung-level { color: var(--muted); white-space: nowrap; }
.climb .hint { margin-top: .75rem; padding-left: 1.5rem; }
@media (max-width: 820px) {
  .gate-wrap { grid-template-columns: 1fr; gap: 2.5rem; padding: 2rem 1.25rem; }
}

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