:root {
  --bg: #0b0a10;
  --panel: #14121c;
  --panel2: #1b1826;
  --border: #2a2638;
  --text: #d8d3e6;
  --dim: #8a83a3;
  --gold: #f2c14e;
  --green: #7bd88f;
  --red: #ff6b6b;
  --blue: #74b9ff;
  --purple: #b28dff;
  --orange: #ff9f43;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 13px; }
button { font-family: inherit; }

.app { display: grid; grid-template-rows: 44px minmax(0, 1fr) 340px; grid-template-columns: minmax(0, 1fr) 380px; height: 100%; overflow: hidden; gap: 1px; background: var(--border); }
.hud { grid-column: 1 / 3; background: var(--panel); display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; min-width: 0; }
.hud .title { color: var(--gold); font-weight: 700; letter-spacing: 0.5px; }
.hud .act { color: var(--dim); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.hud > span:not(.act):not(.spacer) { flex: 0 0 auto; }
.hud .spacer { flex: 1; }
.hud .gold { color: var(--gold); }
.hud button, .hud select { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.hud button:hover { border-color: var(--gold); color: var(--gold); }
.hud select { max-width: 220px; flex: 0 1 auto; }
@media (max-width: 1300px) { .hud .act { display: none; } .hud select { max-width: 160px; } }

.dungeon { background: var(--bg); position: relative; overflow: hidden; }
.dungeon canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.dungeon .legend { position: absolute; right: 12px; bottom: 10px; background: rgba(20,18,28,0.75); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; color: var(--dim); font-size: 11px; pointer-events: none; }
.dungeon .legend b { color: var(--text); font-weight: 400; }

.repo { background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.repo section { border-bottom: 1px solid var(--border); padding: 8px 10px; overflow: auto; }
.repo section h4 { margin: 0 0 6px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.repo .files { flex: 1 1 40%; min-height: 120px; }
.repo .log { flex: 1 1 45%; min-height: 120px; }
.repo .refs { flex: 0 0 auto; max-height: 120px; }
.repo .file { padding: 1px 4px; cursor: pointer; white-space: nowrap; border-radius: 3px; }
.repo .file:hover { background: var(--panel2); }
.repo .file.sel { background: var(--panel2); outline: 1px solid var(--border); }
.repo .file .st { display: inline-block; width: 14px; color: var(--dim); }
.repo .file.modified { color: var(--orange); }
.repo .file.staged { color: var(--green); }
.repo .file.both { color: var(--green); }
.repo .file.untracked { color: var(--red); }
.repo .file.conflict { color: var(--red); font-weight: 700; }
.repo .file.deleted { color: var(--red); text-decoration: line-through; }
.repo .file.ignored { color: var(--dim); opacity: 0.6; }
.repo .commit { padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo .commit.head { color: var(--gold); }
.repo .commit.void { color: var(--dim); opacity: 0.55; }
.repo .commit .h { color: var(--purple); margin-right: 6px; }
.repo .commit .r { color: var(--green); margin-left: 6px; }
.repo .commit .r.remote { color: var(--blue); }
.repo .commit .r.tag { color: var(--gold); }
.repo .state { color: var(--dim); }
.repo .state b { color: var(--gold); font-weight: 400; }
.repo .state .warn { color: var(--red); }
.repo pre.view { flex: 0 0 auto; max-height: 160px; overflow: auto; margin: 0; padding: 8px 10px; background: var(--bg); color: var(--dim); white-space: pre-wrap; border-bottom: 1px solid var(--border); font-size: 12px; }

.bottom { grid-column: 1 / 3; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 1px; background: var(--border); min-height: 0; overflow: hidden; }
.term { background: #0d0c12; padding: 6px 8px 8px; min-width: 0; min-height: 0; overflow: hidden; }
.term .xterm { height: 100%; }

.gamelog { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.gamelog .quest { padding: 10px 14px 8px; border-bottom: 1px solid var(--border); background: var(--panel2); }
.gamelog .qtitle { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.gamelog .qcount { float: right; }
.gamelog .cleared { color: var(--gold); font-weight: 700; padding: 6px 0; display: flex; align-items: center; gap: 12px; }
.gamelog .nextbtn { background: var(--gold); color: #1a1408; border: 0; border-radius: 5px; padding: 8px 16px; font-weight: 700; font-family: inherit; font-size: 14px; cursor: pointer; animation: pulse 1.6s ease-in-out infinite; }
.gamelog .nextbtn:hover { filter: brightness(1.1); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,193,78,0.5); } 50% { box-shadow: 0 0 0 8px rgba(242,193,78,0); } }
.gamelog .now { background: #221d33; border-left: 3px solid var(--gold); border-radius: 0 6px 6px 0; padding: 8px 12px 10px; }
.gamelog .now .label { color: var(--gold); font-size: 10px; letter-spacing: 2px; margin-bottom: 4px; }
.gamelog .now .goal { color: var(--text); font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.gamelog .now .how div { color: var(--green); font-size: 14px; padding: 2px 0; }
.gamelog .now .how div:first-child { font-size: 16px; }
.gamelog .rest { margin-top: 8px; display: flex; gap: 12px; color: #4a4560; font-size: 11px; }
.gamelog .rest .done { color: var(--green); }
.gamelog .rest .cur { color: var(--gold); }
.gamelog .lines { flex: 1; min-height: 0; overflow: auto; padding: 8px 14px 16px; }
.gamelog .line { padding: 3px 0 3px 22px; position: relative; line-height: 1.45; white-space: pre-wrap; }
.gamelog .line::before { position: absolute; left: 2px; }
.gamelog .line.story { color: #c9bfe6; }
.gamelog .line.story::before { content: '✦'; color: var(--purple); }
.gamelog .line.goal { color: var(--green); }
.gamelog .line.goal::before { content: '◆'; }
.gamelog .line.hint { color: var(--gold); background: rgba(242,193,78,0.06); border-radius: 4px; margin: 2px 0; }
.gamelog .line.hint::before { content: '☼'; }
.gamelog .line.monster { color: var(--red); }
.gamelog .line.monster::before { content: '☠'; }
.gamelog .line.win { color: var(--gold); font-weight: 700; }
.gamelog .line.win::before { content: '★'; }
.gamelog .line.warn { color: var(--orange); }
.gamelog .line.warn::before { content: '⚠'; }
.gamelog .line.chapter { color: var(--dim); text-transform: uppercase; letter-spacing: 1px; font-size: 11px; margin-top: 14px; padding-left: 0; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.gamelog .line.chapter::before { content: none; }

.hud button.bookbtn { border-color: var(--purple); color: var(--purple); }

.book-overlay { position: fixed; inset: 0; background: rgba(5,4,10,0.82); z-index: 50; display: flex; align-items: center; justify-content: center; }
.book { width: min(1100px, 92vw); height: min(760px, 88vh); background: #181425; border: 1px solid #4a3f6b; border-radius: 10px; display: grid; grid-template-columns: 300px 1fr; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.book .side { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.book .side h2 { margin: 0; padding: 14px 16px; color: var(--gold); font-size: 15px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.book .side h2 button { background: none; border: 1px solid var(--border); color: var(--dim); border-radius: 4px; cursor: pointer; padding: 2px 8px; }
.book .side .list { overflow: auto; flex: 1; padding: 6px; }
.book .side .entry { padding: 6px 10px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.book .side .entry:hover { background: var(--panel2); }
.book .side .entry.sel { background: #2a2340; }
.book .side .entry.locked { color: #4a4560; cursor: default; }
.book .side .entry .nm { color: var(--dim); font-size: 11px; }
.book .side .entry.locked .nm { color: #3a3550; }
.book .side .count { padding: 8px 16px; color: var(--dim); font-size: 11px; border-top: 1px solid var(--border); }
.book .page { padding: 24px 28px; overflow: auto; }
.book .page h1 { margin: 0 0 4px; color: var(--gold); font-size: 22px; }
.book .page .cmd { color: var(--purple); font-size: 16px; margin-bottom: 18px; }
.book .page h3 { margin: 18px 0 6px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.book .page p { margin: 0; line-height: 1.5; }
.book .page pre { margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--green); white-space: pre-wrap; }
.book .page .empty { color: var(--dim); margin-top: 40px; line-height: 1.6; }
/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */

/**
 *  Default styles for xterm.js
 */

.xterm {
    cursor: text;
    position: relative;
    user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
    outline: none;
}

.xterm .xterm-helpers {
    position: absolute;
    top: 0;
    /**
     * The z-index of the helpers must be higher than the canvases in order for
     * IMEs to appear on top.
     */
    z-index: 5;
}

.xterm .xterm-helper-textarea {
    padding: 0;
    border: 0;
    margin: 0;
    /* Move textarea out of the screen to the far left, so that the cursor is not visible */
    position: absolute;
    opacity: 0;
    left: -9999em;
    top: 0;
    width: 0;
    height: 0;
    z-index: -5;
    /** Prevent wrapping so the IME appears against the textarea at the correct position */
    white-space: nowrap;
    overflow: hidden;
    resize: none;
}

.xterm .composition-view {
    /* TODO: Composition position got messed up somewhere */
    background: #000;
    color: #FFF;
    display: none;
    position: absolute;
    white-space: nowrap;
    z-index: 1;
}

.xterm .composition-view.active {
    display: block;
}

.xterm .xterm-viewport {
    /* On OS X this is required in order for the scroll bar to appear fully opaque */
    background-color: #000;
    overflow-y: scroll;
    cursor: default;
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
}

.xterm .xterm-screen {
    position: relative;
}

.xterm .xterm-screen canvas {
    position: absolute;
    left: 0;
    top: 0;
}

.xterm .xterm-scroll-area {
    visibility: hidden;
}

.xterm-char-measure-element {
    display: inline-block;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: -9999em;
    line-height: normal;
}

.xterm.enable-mouse-events {
    /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
    cursor: default;
}

.xterm.xterm-cursor-pointer,
.xterm .xterm-cursor-pointer {
    cursor: pointer;
}

.xterm.column-select.focus {
    /* Column selection mode */
    cursor: crosshair;
}

.xterm .xterm-accessibility:not(.debug),
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
    pointer-events: none;
}

.xterm .xterm-accessibility-tree:not(.debug) *::selection {
  color: transparent;
}

.xterm .xterm-accessibility-tree {
  user-select: text;
  white-space: pre;
}

.xterm .live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.xterm-dim {
    /* Dim should not apply to background, so the opacity of the foreground color is applied
     * explicitly in the generated class and reset to 1 here */
    opacity: 1 !important;
}

.xterm-underline-1 { text-decoration: underline; }
.xterm-underline-2 { text-decoration: double underline; }
.xterm-underline-3 { text-decoration: wavy underline; }
.xterm-underline-4 { text-decoration: dotted underline; }
.xterm-underline-5 { text-decoration: dashed underline; }

.xterm-overline {
    text-decoration: overline;
}

.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }

.xterm-strikethrough {
    text-decoration: line-through;
}

.xterm-screen .xterm-decoration-container .xterm-decoration {
	z-index: 6;
	position: absolute;
}

.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
	z-index: 7;
}

.xterm-decoration-overview-ruler {
    z-index: 8;
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: none;
}

.xterm-decoration-top {
    z-index: 2;
    position: relative;
}
