:root {
  --night: #0b0d17; --night-2: #121527; --night-3: #1a1e36; --line: #2a2f52;
  --silver: #d9dcef; --silver-dim: #9aa0c3; --ember: #e2593b; --ember-soft: #f08a5d; --gold: #e6c36a;
  --hp: #d8463b; --mp: #4b7be5; --xp: #c9a54a;
  --common: #d9dcef; --uncommon: #5fd27a; --rare: #5aa2ff; --epic: #b878ff; --legendary: #ff9f3a; --mythic: #ff4d5e;
  --serif: "Cormorant Garamond", Georgia, serif; --sans: Inter, system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--silver); font: 15px/1.5 var(--sans); }
body { overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: var(--night-3); color: var(--silver); padding: .5em 1em; }
button:hover { border-color: var(--silver-dim); }
button.primary { background: linear-gradient(180deg, #2b3170, #1d2152); border-color: #4a54a8; }
button.primary:hover { border-color: var(--silver); }
button.ghost { background: transparent; }
button.small { font-size: 13px; padding: .3em .7em; }
button.big { font-size: 18px; padding: .7em 1.6em; margin-top: 1.5em; }
input, select, textarea { font: inherit; color: var(--silver); background: var(--night-2); border: 1px solid var(--line); border-radius: 6px; padding: .5em .7em; width: 100%; }
input:focus { outline: 1px solid var(--silver-dim); }
label { display: block; margin: .6em 0; color: var(--silver-dim); font-size: 13px; }
label input { margin-top: .25em; }
label.check { display: flex; gap: .6em; align-items: flex-start; }
label.check input { width: auto; margin-top: .2em; }
label.wide { max-width: 640px; }
.err { color: var(--ember-soft); min-height: 1.4em; margin: .5em 0; }
.muted { color: var(--silver-dim); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .02em; margin: .2em 0; }
h1 { font-size: 56px; }
h2 { font-size: 28px; }

/* sky */
#sky { position: fixed; inset: 0; z-index: -1; background: radial-gradient(ellipse at 70% -10%, #1f2550 0%, var(--night) 60%); }
#sky::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(1px 1px at 10% 20%, #fff8 50%, transparent 51%), radial-gradient(1px 1px at 30% 70%, #fff6 50%, transparent 51%), radial-gradient(1px 1px at 55% 35%, #fff7 50%, transparent 51%), radial-gradient(1px 1px at 80% 15%, #fff5 50%, transparent 51%), radial-gradient(1px 1px at 90% 60%, #fff6 50%, transparent 51%), radial-gradient(1px 1px at 20% 90%, #fff4 50%, transparent 51%); background-size: 400px 300px; }
#sky .moon { position: absolute; border-radius: 50%; }   /* scoped: #log p.moon must stay in normal flow */
body:has(#play:not(.hidden)) #sky { display: none; }   /* in-game the log/sidebars are opaque; the fixed sky only shows on menu screens */
.lunara { width: 180px; height: 180px; right: 8%; top: 6%; background: radial-gradient(circle at 35% 35%, #f4f5ff, #b9bdd8 55%, #7d82a6); box-shadow: 0 0 80px #c8cdf055; opacity: .5; }
.vex { width: 46px; height: 46px; right: calc(8% + 200px); top: 14%; background: radial-gradient(circle at 35% 35%, #ffb08a, #e2593b 60%, #8a2a18); box-shadow: 0 0 40px #e2593b88; opacity: .7; }

/* auth */
#auth { display: grid; place-items: center; height: 100%; position: relative; }
.landing-art { position: absolute; inset: 0; background: url("/static/landing.jpg") center/cover no-repeat; }
.landing-art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 0% 100%, #0b0d17e0 0%, #0b0d1799 30%, transparent 60%); }
/* the art carries the logo top-left, so the card sits bottom-left over the rooftops */
#auth { align-items: end; }
.auth-card { position: relative; width: min(420px, 92vw); padding: 1.6em 1.8em; background: #0e1124e0; border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); justify-self: start; margin: 0 0 6vh 5vw; }
.auth-card h1 { font-size: 30px; margin: 0; }
.auth-card .tag { font-size: 17px; margin: .1em 0 0; }
.auth-card .tabs { margin: .7em 0 .2em; }
.auth-card label { margin: .4em 0; }
.auth-card .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8em; }
.auth-card .note { font-size: 12.5px; margin: .1em 0 .4em; }
.auth-card .err { min-height: 1em; margin: .3em 0 0; }
.auth-card { width: min(540px, 92vw) !important; }
#auth ~ #sky, body:has(#auth:not(.hidden)) #sky .moon { display: none; }
.tag { font-family: var(--serif); font-size: 20px; color: var(--silver-dim); margin-top: 0; }
.tabs { display: flex; gap: .3em; margin: 1.2em 0 .6em; }
.tab, .ptab { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--silver-dim); }
.tab.on, .ptab.on { color: var(--silver); border-bottom-color: var(--ember); }

/* bars */
.bar { display: flex; align-items: center; gap: 1em; padding: .8em 1.4em; border-bottom: 1px solid var(--line); background: #0b0d17cc; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 700; flex: 1; }
.badge { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; border: 1px solid var(--gold); color: var(--gold); padding: .15em .6em; border-radius: 99px; }

/* select */
.screen { height: 100%; }
#select, #builder, #renderScreen { display: flex; flex-direction: column; overflow: auto; }
.select-wrap, .render-wrap { padding: 2em 3vw; max-width: 1100px; width: 100%; margin: 0 auto; }
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1em; margin: 1em 0 1.5em; }
.char-card { background: var(--night-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.char-card .pic { aspect-ratio: 3/4; background: var(--night-3) center/cover; display: grid; place-items: center; font-family: var(--serif); font-size: 64px; color: var(--line); }
.char-card .info { padding: .8em 1em; }
.char-card h3 { font-size: 22px; }
.char-card .actions { display: flex; gap: .4em; padding: 0 1em 1em; flex-wrap: wrap; }

/* builder */
.steps { display: flex; gap: .2em; padding: .6em 1.4em; border-bottom: 1px solid var(--line); overflow-x: auto; }
.steps button { background: transparent; border: none; color: var(--silver-dim); white-space: nowrap; }
.steps button.on { color: var(--silver); border-bottom: 2px solid var(--ember); border-radius: 0; }
.steps button.done::before { content: "✓ "; color: var(--uncommon); }
.builder-body { flex: 1; display: grid; grid-template-columns: 1fr 320px; gap: 1.5em; padding: 1.5em 3vw; min-height: 0; }
.builder-main { overflow: auto; }
.builder-preview { background: var(--night-2); border: 1px solid var(--line); border-radius: 12px; padding: 1.2em; align-self: start; position: sticky; top: 0; }
.builder-foot { display: flex; align-items: center; gap: 1em; padding: .8em 3vw; border-top: 1px solid var(--line); background: #0b0d17ee; }
.builder-foot .err { flex: 1; margin: 0; }
.cards { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8em; }
.pick { text-align: left; align-self: start; vertical-align: top; background: var(--night-2); border: 1px solid var(--line); border-radius: 10px; padding: .9em 1em; display: block; width: 100%; }
.pick.on { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember) inset; }
.pick.locked { opacity: .45; cursor: not-allowed; }
.pick h3 { font-size: 21px; margin: 0 0 .2em; }
.pick .mods { font: 12px var(--mono); color: var(--gold); }
.pick p { margin: .3em 0; font-size: 13.5px; color: var(--silver-dim); }
.pick .trait { color: var(--silver); font-size: 13px; }
.subpicks { display: flex; flex-wrap: wrap; gap: .4em; margin-top: .6em; }
.subpicks button.on { border-color: var(--ember); }
.growth { display: grid; grid-template-columns: 34px 1fr; gap: 2px 6px; font: 11px var(--mono); margin-top: .5em; align-items: center; }
.growth i { display: block; height: 6px; background: var(--silver-dim); border-radius: 3px; }
.statgrid { display: grid; grid-template-columns: 60px 40px 120px 1fr; gap: .5em 1em; align-items: center; max-width: 560px; }
.statgrid .v { font: 600 18px var(--mono); text-align: center; }
.statgrid .btns button { padding: .2em .7em; }
.statgrid .hint { color: var(--silver-dim); font-size: 13px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1.2em; }
.preview-line { font-size: 13px; color: var(--silver-dim); margin: .25em 0; }
.preview-line b { color: var(--silver); }

/* render */
.row { display: flex; align-items: center; gap: 1em; }
.render-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1em; margin-top: 1.4em; }
.render-grid figure { margin: 0; background: var(--night-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.render-grid figure.chosen { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.render-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.render-grid figcaption { padding: .6em; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.render-grid figure.rendering { border-color: var(--line); }
.render-grid .wash {
  aspect-ratio: 3/4; position: relative; overflow: hidden;
  background: linear-gradient(120deg, #1d1b4a, #4b2a7a, #1f5f8b, #2d8a8a, #8a5a2d, #7a2a5a, #1d1b4a);
  background-size: 400% 400%; animation: wash 6s ease-in-out infinite;
}
.render-grid .wash::before {             /* slow-drifting colour blooms */
  content: ""; position: absolute; inset: -40%;
  background: radial-gradient(circle at 30% 30%, rgba(255,210,140,.35), transparent 35%),
              radial-gradient(circle at 70% 60%, rgba(140,180,255,.35), transparent 40%),
              radial-gradient(circle at 40% 80%, rgba(220,140,255,.3), transparent 35%);
  animation: bloom 9s linear infinite; filter: blur(8px);
}
.render-grid .wash::after {              /* a light sweep across the canvas */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.18) 50%, transparent 70%);
  transform: translateX(-100%); animation: sweep 2.4s ease-in-out infinite;
}
.render-grid figure.rendering figcaption { color: var(--muted, #9aa); }
@keyframes wash { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes bloom { to { transform: rotate(360deg); } }
@keyframes sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .render-grid .wash, .render-grid .wash::before, .render-grid .wash::after { animation: none; } }
.render-grid .blocked { padding: 2em 1em; color: var(--ember-soft); font-size: 13px; }

/* play */
#play { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; grid-template-rows: 100vh; height: 100vh; overflow: hidden; }
#sidebar, #panel { height: 100vh; background: #0d1022; border-right: 1px solid var(--line); padding: 1em; overflow-y: auto; }
#panel { border-right: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.portrait { aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: var(--night-3); border: 1px solid var(--line); position: relative; }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-portrait { position: absolute; inset: 0; display: grid; place-items: center; font: 600 72px var(--serif); color: var(--line); }
#sbName { margin-top: .5em; font-size: 26px; }
#sbLine { margin: 0 0 .6em; font-size: 13px; }
.bar-row { display: grid; grid-template-columns: 26px 1fr 84px; align-items: center; gap: .5em; font: 12px var(--mono); margin: .3em 0; }
.bar-row b { text-align: right; font-weight: 500; }
.meter { height: 9px; background: var(--night-3); border-radius: 5px; overflow: hidden; border: 1px solid #ffffff10; }
.meter i { display: block; height: 100%; width: 0; transition: width .4s; }
.meter.hp i { background: linear-gradient(90deg, #8f241c, var(--hp)); }
.meter.mp i { background: linear-gradient(90deg, #26408f, var(--mp)); }
.meter.xp i { background: linear-gradient(90deg, #7d6326, var(--xp)); }
.meter.tg i { background: var(--ember); }
.target { margin: .6em 0; font-size: 12px; color: var(--ember-soft); }
table.stats { width: 100%; border-collapse: collapse; margin: .8em 0; font: 13px var(--mono); }
table.stats td { padding: .15em .2em; }
table.stats td:nth-child(even) { text-align: right; color: var(--silver); }
table.stats td:nth-child(odd) { color: var(--silver-dim); }
table.stats button { padding: 0 .4em; font-size: 11px; margin-left: .3em; }
.points { font-size: 12px; color: var(--gold); }
.coin { font: 13px var(--mono); color: var(--gold); }
.effects span { display: inline-block; font-size: 11px; border: 1px solid var(--line); border-radius: 99px; padding: 0 .5em; margin: 0 .2em .2em 0; }
.time { font-size: 12px; color: var(--silver-dim); margin-top: 1em; }

#center { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; background: var(--night); }
#center { --log-font: var(--mono); --log-size: 15px; }
.log-bar { display: flex; justify-content: flex-end; align-items: center; gap: 1em; padding: .35em 1.4em; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--silver-dim); }
.log-bar select { font-size: 12px; padding: .15em .4em; width: auto; }
.log-bar .size-ctl { display: inline-flex; align-items: center; gap: .4em; }
.log-bar .size-ctl button { padding: .1em .55em; font-size: 12px; }
.log-bar .size-ctl b { min-width: 2.6em; text-align: center; font-weight: 500; }
#log { flex: 1; min-height: 0; overflow-y: auto; padding: 1em 1.4em; font-family: var(--log-font); font-size: var(--log-size); line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
#log p { margin: 0 0 .35em; }
#cmdForm { display: flex; gap: .5em; padding: .7em 1em; border-top: 1px solid var(--line); background: #0b0d17; }
#cmd { font-family: var(--log-font); font-size: max(14px, calc(var(--log-size) * .95)); }

#log .echo { color: #6f76a8; }
#log .locale-name { color: var(--gold); font: 600 19px var(--serif); margin-top: .7em; }
#log .locale-desc { color: var(--silver); }
#log .paths { color: #8fb3ff; }
#log .npc, #log .npc-say { color: #9fe0c0; }
#log .mob { color: #e7b07c; } #log .boss { color: var(--ember); font-weight: 600; }
#log .player { color: #c6b3ff; }
#log .item, #log .loot { color: var(--silver); }
#log .hit { color: #f2e6c9; } #log .hurt { color: var(--ember-soft); } #log .miss { color: #7c82a8; }
#log .kill { color: #ffd27a; } #log .xp, #log .coin { color: var(--gold); }
#log .warn { color: #ff9a7a; } #log .info, #log .help, #log .status { color: var(--silver); }
#log .levelup, #log .skill-up { color: #ffe08a; font-weight: 600; }
#log .rare { color: var(--legendary); font-weight: 600; }
#log .rite, #log .narration, #log .moon { color: #c9cdf5; font-family: var(--serif); font-size: 17px; font-style: italic; }
#log .quest { color: #7fe3ff; } #log .discover, #log .zone { color: #a6ffcf; }
#log .say, #log .say-self { color: #e8e8ff; } #log .shout { color: #ffcf8a; } #log .tell { color: #ff9ae6; } #log .cohort { color: #9ad6ff; }
#log .pvp, #log .faint { color: var(--ember); font-weight: 600; }
#log .parsed { color: #5a6090; font-size: 12px; }
.r-common { color: var(--common); } .r-uncommon { color: var(--uncommon); } .r-rare { color: var(--rare); } .r-epic { color: var(--epic); } .r-legendary { color: var(--legendary); } .r-mythic { color: var(--mythic); text-shadow: 0 0 8px #ff4d5e88; }

.pane { flex: 1; overflow-y: auto; font-size: 13.5px; }
.pane h4 { font: 600 16px var(--serif); color: var(--gold); margin: .9em 0 .3em; }
.pane ul { list-style: none; padding: 0; margin: 0; }
.pane li { padding: .25em 0; border-bottom: 1px solid #ffffff08; display: flex; justify-content: space-between; gap: .5em; align-items: center; }
.pane li button { font-size: 11px; padding: .1em .5em; }
.pane .zone-line { color: var(--silver-dim); font-size: 12px; }
#sbSkills, #sbInv { margin-top: .8em; border-top: 1px solid var(--line); padding-top: .4em; }
#sbSkills h4, #sbInv h4 { font: 600 14px var(--serif); color: var(--gold); margin: .6em 0 .25em; }
#sbSkills ul, #sbInv ul { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
#sbSkills li, #sbInv li { padding: .18em 0; border-bottom: 1px solid #ffffff08; display: flex; justify-content: space-between; gap: .5em; align-items: center; }
#sbSkills li button, #sbInv li button { font-size: 10.5px; padding: .05em .45em; }
.pvp-tag { color: var(--ember); font-weight: 600; }
.mini-hp { width: 50px; height: 5px; background: var(--night-3); border-radius: 3px; overflow: hidden; display: inline-block; }
.mini-hp i { display: block; height: 100%; background: var(--ember); }
#leaveBtn { margin-top: .6em; }

@media (max-width: 560px) { .auth-card .two { grid-template-columns: 1fr; } }
@media (max-width: 1100px) {
  #play { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  #center { height: auto; }
  #sidebar, #panel { height: auto; }
  #sidebar { display: grid; grid-template-columns: 90px 1fr; gap: .2em 1em; border-right: none; border-bottom: 1px solid var(--line); max-height: 34vh; }
  #sidebar .portrait { grid-row: span 3; }
  #panel { border-left: none; border-top: 1px solid var(--line); max-height: 30vh; }
  .builder-body { grid-template-columns: 1fr; }
  .auth-card { justify-self: center; margin: 0 0 3vh 0; }
  .landing-art { background-position: 22% top; }
}
.render-pick { gap: 1.2em; margin-top: .8em; }
.render-pick label { margin: 0; }
.render-pick select { min-width: 220px; margin-top: .25em; display: block; }

/* guide links */
.guide-link { margin: .8em 0 0; font-size: 13px; }
.guide-link a, a.ghost-link { color: var(--gold); text-decoration: none; }
.guide-link a:hover, a.ghost-link:hover { text-decoration: underline; }
.bar a.ghost-link { margin-right: 1em; font-size: 14px; }
#panel a.guide-btn { display: block; text-align: center; font-size: 13px; margin: .6em 0 .3em; }
/* zone map pane + slide-out */
#pMap { overflow: auto; }
#pMap .map-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5em; }
#pMap .map-head h4 { margin: .2em 0; }
#pMap .map-zone { color: var(--silver-dim); font-size: 12px; }
#pMap svg { display: block; margin-top: .4em; touch-action: none; cursor: grab; user-select: none; overflow: visible; }
#pMap svg:active { cursor: grabbing; }
#pMap .map-tools { display: inline-flex; gap: .25em; }
#pMap .map-tools button { padding: .05em .5em; font-size: 12px; }
#pMap .mnode circle { fill: #1d2133; stroke: var(--line); stroke-width: 1.5; }
#pMap .mnode.visited circle { stroke: #4a5cb8; }
#pMap .mnode.here circle { fill: #3d55b8; stroke: #bcd0ff; stroke-width: 2.5; filter: drop-shadow(0 0 7px #7da2ff); }
#pMap .mnode:not(.here) { opacity: .75; }
#pMap .mnode text { fill: #ffffff; font-size: 11px; text-anchor: middle; paint-order: stroke; stroke: #0b0d17; stroke-width: 3px; }
#pMap .mnode.unvisited { opacity: .45; }
#pMap .medge { stroke: #2b3150; stroke-width: 1.5; }
#pMap .medge-label { fill: var(--silver-dim); font-size: 9px; text-anchor: middle; }
#pMap .mexit { stroke: #7da2ff; stroke-width: 1.5; stroke-dasharray: 4 3; }
#pMap .mexit-label { fill: #7da2ff; font-size: 10px; }
#pMap .map-hint { color: var(--silver-dim); font-size: 11px; margin-top: .4em; }
body.map-open #panel { position: fixed; top: 0; right: 0; bottom: 0; height: 100vh; width: min(640px, calc(100vw - 300px)); min-width: 320px; z-index: 6; box-shadow: -12px 0 40px #000a; background: #0d1022; }
body.map-open::after { content: ""; position: fixed; inset: 0; right: min(640px, calc(100vw - 300px)); z-index: 5; }  /* click-away area */
#pHere .avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: .4em; border: 1px solid var(--line); cursor: zoom-in; }
#lightbox { position: fixed; inset: 0; background: #000c; z-index: 20; display: none; flex-direction: column; align-items: center; justify-content: center; gap: .6em; cursor: zoom-out; }
#lightbox img { max-width: min(480px, 90vw); max-height: 80vh; border-radius: 12px; border: 1px solid var(--line); }
#pMap .wzone { fill: #141830; stroke: var(--line); }
#pMap .wzone.here { stroke: #7da2ff; filter: drop-shadow(0 0 6px #7da2ff88); }
#pMap .wzone-name { fill: var(--gold); font: 600 13px var(--serif); text-anchor: middle; }
#pMap .wnode { fill: #fff; font-size: 9px; text-anchor: middle; paint-order: stroke; stroke: #0b0d17; stroke-width: 2px; }
#pMap #mapWorld.on { background: #2b3a7a; color: #fff; }

#sbToggles h4 { font: 600 14px var(--serif); color: var(--gold); margin: .7em 0 .3em; }
#sbToggles .trow { display: flex; justify-content: space-between; align-items: center; gap: .5em; padding: .2em 0; font-size: 12.5px; }
#sbToggles .trow button { font-size: 10.5px; padding: .05em .5em; }

#sbToggles .fleenum { color: #fff; min-width: 3ch; text-align: center; }
#sbToggles .fleenum.dim { color: var(--silver-dim); }
