:root {
  --bg: #0e1110;
  --panel: #161b19;
  --line: #2a332f;
  --text: #d6e2da;
  --muted: #7d8c84;
  --accent: #7ee0a1;
  --warn: #e07e7e;
  --room: #22302a;
  --room-visited: #2b4236;
  --room-current: #7ee0a1;
  --font: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
h1 { font-size: 16px; margin: 0; color: var(--accent); letter-spacing: .05em; }
.stats { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.stats b { color: var(--accent); }
.pill { padding: 2px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); }
.pill.on { color: var(--accent); border-color: var(--accent); }
.pill.off { color: var(--warn); border-color: var(--warn); }
button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 10px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }

main { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.4fr) 280px; height: calc(100% - 46px); }
@media (max-width: 1100px) { main { grid-template-columns: 1fr; height: auto; } #mapwrap { height: 60vh; } #terminal { height: 60vh; } }

#terminal { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
#log { flex: 1; overflow-y: auto; padding: 12px 16px; white-space: pre-wrap; }
#log .cmd { color: var(--accent); margin-top: 10px; }
#log .heading { font-weight: bold; color: #fff; }
#cmdform { display: flex; align-items: center; border-top: 1px solid var(--line); padding: 8px 12px; gap: 8px; }
.prompt { color: var(--accent); }
#cmd { flex: 1; background: transparent; border: none; color: var(--text); font: inherit; outline: none; }

#mapwrap { position: relative; min-height: 0; border-right: 1px solid var(--line); }
.maptools { position: absolute; top: 8px; left: 8px; display: flex; gap: 8px; align-items: center; background: rgba(14,17,16,.85); padding: 4px 8px; border-radius: 6px; z-index: 1; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }
#map .edge { stroke: #4f6b5c; stroke-width: 3; }
#map .edge.inferred { stroke-dasharray: 4 4; }
#map .stub { stroke: #4f6b5c; stroke-width: 2; stroke-dasharray: 2 3; }
#map .blocked { stroke: var(--warn); stroke-width: 2; }
#map .room rect { fill: var(--room-visited); stroke: #3d5a4b; stroke-width: 1.5; rx: 6; }
#map .room.current rect { stroke: var(--room-current); stroke-width: 3; }
#map .room.dark rect { fill: #151a18; }
#map .room text { fill: var(--text); font: 11px var(--font); text-anchor: middle; pointer-events: none; }
#map .room .badge { font-size: 12px; fill: var(--accent); }
#map .room .itemdot { fill: #e0c97e; }
#map .ghost rect { fill: none; stroke: #26302b; stroke-dasharray: 3 3; }
#map .ghost text { display: none; }
#map .player { fill: var(--room-current); }

aside { overflow-y: auto; }
.panel { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 15px; margin: 0 0 6px; color: #fff; }
.panel h3 { font-size: 12px; margin: 12px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 2px 0; }
.list li.empty { color: var(--muted); font-style: italic; }
.list li.click { cursor: pointer; }
.list li.click:hover { color: var(--accent); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; margin: 6px 4px 0 0; border-radius: 3px; background: var(--room); color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 3px; vertical-align: middle; border: 1px solid var(--line); }
.list li.stale { color: var(--warn); font-size: 12px; margin-top: 6px; }

.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.seg button.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
#view3d { position: absolute; inset: 0; }
#view3d canvas { display: block; }
#hint3d { white-space: nowrap; position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 12px; background: rgba(14,17,16,.75); padding: 3px 10px; border-radius: 99px; pointer-events: none; }
#mapwrap:not(.is3d) .only3d { display: none; }
#mapwrap.is3d .only2d { display: none; }

/* ---- reachable tiles, route, you-are-here ---- */
#map .tileglow { fill: none; stroke-width: 4; filter: url(#glow); pointer-events: none; }
#map .tileglow.near { stroke: #7ee0a1; opacity: .95; }
#map .tileglow.reach { stroke: #7ee0a1; opacity: .45; }
#map .tileglow.maybe { stroke: #e0c97e; opacity: .4; stroke-dasharray: 6 5; }
#map .tileglow.onroute { stroke: #6fd3ff; opacity: 1; stroke-width: 6; }
#map .route { stroke: #bfeaff; stroke-width: 3; stroke-linecap: round; pointer-events: none; }
#map .route-glow { stroke: #6fd3ff; stroke-width: 12; opacity: .55; filter: url(#glow); stroke-linecap: round; pointer-events: none; }
#map .here-pulse { fill: none; stroke: var(--room-current); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; pointer-events: none; }
@keyframes pulse { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.15); opacity: 0; } }
#map .room { cursor: pointer; }
#map .room.target rect { stroke: #6fd3ff; stroke-width: 3; }
#map .room.selected rect { stroke: #bfeaff; stroke-width: 2; stroke-dasharray: 4 3; }
#map .room .you { fill: var(--room-current); font-size: 9px; font-weight: bold; letter-spacing: .08em; }

/* ---- route box in the room panel ---- */
.routebox { margin-top: 10px; padding: 8px 10px; border: 1px solid #2f5566; border-radius: 6px; background: #12202a; }
.routebox .dirs { color: #bfeaff; margin: 4px 0 8px; word-break: break-word; }
.small { font-size: 12px; margin-top: 6px; }
button.primary { background: #1d4256; border-color: #6fd3ff; color: #e6f7ff; }
button.primary:hover { background: #255571; }
.small-btn { float: right; font-size: 12px; padding: 1px 8px; }

/* ---- travel banner ---- */
.travel { position: absolute; left: 12px; right: 12px; bottom: 40px; background: rgba(14,20,24,.94); border: 1px solid #2f5566; border-radius: 8px; padding: 8px 12px; z-index: 2; max-width: 560px; margin: 0 auto; }
.travel.arrived { border-color: var(--accent); }
.travel.stopped, .travel.stuck, .travel.failed { border-color: var(--warn); }
.travel-head { display: flex; align-items: center; gap: 6px; }
.travel-head .spacer { flex: 1; }
.travel-msg { margin-top: 4px; }
.travel-events { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.travel-events li.reload, .travel-events li.replan { color: #bfeaff; }
.travel-events li.stop { color: var(--warn); }
.travel button.primary { margin-top: 8px; }

/* ---- saves ---- */
.list li.cp { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.list li.cp .cpname { grid-column: 1; }
.list li.cp .muted { grid-column: 1; font-size: 11px; }
.list li.cp button { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 12px; }
.list li.cp.auto .cpname { color: var(--muted); }

/* ---- canonical map: undiscovered rooms (Reveal map) ---- */
#map .room.undiscovered rect { fill: transparent; stroke: #3b4a43; stroke-dasharray: 4 3; }
#map .room.undiscovered text { fill: #56655d; }
#map .edge.hidden { stroke: #2c3832; stroke-width: 1.5; stroke-dasharray: 3 4; }
.pill.warn { color: #e0c97e; border-color: #e0c97e; }
.visual { margin: 8px 0 0; font-style: italic; color: #bfd6c8; border-left: 2px solid var(--accent); padding-left: 8px; }

/* ---- about dialog (static browser build) ---- */
dialog#about { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; max-width: min(560px, calc(100vw - 32px)); padding: 16px 20px; }
dialog#about::backdrop { background: rgba(0,0,0,.6); }
dialog#about h2 { font-size: 16px; margin: 0 0 8px; color: var(--accent); }
dialog#about h3 { font-size: 12px; margin: 14px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
dialog#about p { margin: 0 0 8px; }
dialog#about a { color: var(--accent); }
dialog#about form { margin-top: 12px; text-align: right; }
