* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
}

body {
    background: #080a08;
    color: #e7e7d7;

    font-family: "Courier New", Courier, monospace;

    overflow: hidden;
}


/* =========================
   MAIN LAYOUT
========================= */

#game-layout {
    width: 100vw;
    height: 100vh;

    display: grid;

    grid-template-columns:
        minmax(190px, 240px)
        1fr
        minmax(230px, 300px);

    gap: 12px;

    padding: 12px;
}


/* =========================
   PANELS
========================= */

.panel {
    position: relative;

    border: 1px solid #d8d8c8;

    background: #0b0d0b;

    min-width: 0;
    min-height: 0;
}

.panel h2 {
    position: absolute;

    top: -10px;
    left: 12px;

    margin: 0;
    padding: 0 7px;

    background: #080a08;

    color: #ffffff;

    font-size: 14px;
    font-weight: normal;
}

.panel-content {
    padding: 22px 14px;
}

.panel-content p {
    margin: 0 0 12px 0;
}

.panel-content hr {
    border: none;
    border-top: 1px solid #444;

    margin: 18px 0;
}


/* =========================
   GAME
========================= */

.game-panel {
    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.game-header {
    height: 34px;

    flex-shrink: 0;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 0 12px;

    border-bottom: 1px solid #444;

    font-size: 12px;
}

#seed-display {
    color: #888;
}

#game-canvas {
    display: block;

    flex: 1;

    width: 100%;
    height: 100%;

    background: #050705;

    image-rendering: pixelated;
}

/* =========================
   MINIMAP
========================= */

#minimap-panel {
    position: absolute;

    right: 12px;
    bottom: 40px;

    width: 194px;

    padding: 6px;

    z-index: 8;

    border: 1px solid #777;

    background: rgba(5, 7, 5, 0.94);

    pointer-events: none;
}

#minimap-title {
    margin-bottom: 5px;

    color: #999;

    font-size: 10px;
    letter-spacing: 0.5px;
}

#minimap-canvas {
    display: block;

    width: 180px;
    height: 180px;

    background: #050705;

    image-rendering: pixelated;
}

#controls {
    height: 28px;

    flex-shrink: 0;

    display: flex;
    align-items: center;

    padding: 0 10px;

    border-top: 1px solid #444;

    color: #777;

    font-size: 11px;
}

/* =========================
   WORLD MAP
========================= */

.world-map-window {
    position: absolute;

    top: 34px;
    left: 0;
    right: 0;
    bottom: 28px;

    z-index: 30;

    display: flex;
    flex-direction: column;

    background: #050705;
}

.world-map-header {
    height: 32px;

    flex-shrink: 0;

    display: flex;
    align-items: center;

    gap: 14px;

    padding: 0 10px;

    border-bottom: 1px solid #444;

    color: #e7e7d7;

    font-size: 11px;
}

#world-map-info {
    flex: 1;

    color: #888;

    text-align: center;
}

.world-map-close {
    border: none;

    background: transparent;
    color: #aaa;

    font-family: inherit;

    cursor: pointer;
}

.world-map-close:hover {
    color: #ffffff;
}

#world-map-canvas {
    display: block;

    width: 100%;
    height: 100%;

    flex: 1;

    background: #050705;

    image-rendering: pixelated;
}

.world-map-controls {
    height: 26px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-top: 1px solid #333;

    color: #777;

    font-size: 10px;
}

/* =========================
   LOG
========================= */

#log-panel {
    padding-top: 14px;
}

#game-log {
    height: 100%;

    padding: 12px;

    overflow-y: auto;

    font-size: 13px;
    line-height: 1.5;
}

.log-entry {
    margin-bottom: 6px;
}

.log-old {
    color: #777;
}

/* =========================
   GAME WINDOWS
========================= */

.hidden {
    display: none !important;
}

/* =========================
   DEATH SCREEN
========================= */

.death-screen {
    position: fixed;

    inset: 0;

    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #000000;

    color: #ffffff;

    font-size: 18px;
    letter-spacing: 3px;

    text-align: center;

    cursor: default;
    user-select: none;
}

.game-window {
    position: absolute;

    top: 46px;
    right: 12px;

    width: 360px;
    max-width: calc(100% - 24px);

    max-height: calc(100% - 88px);

    z-index: 20;

    border: 1px solid #d8d8c8;

    background: #0b0d0b;

    overflow: hidden;
}


.game-window-header {
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 9px;

    border-bottom: 1px solid #444;

    color: #ffffff;

    font-size: 13px;
}


.game-window-close {
    border: none;

    background: transparent;

    color: #aaa;

    font-family: inherit;

    cursor: pointer;
}


.game-window-close:hover {
    color: #ffffff;
}


.game-window-content {
    max-height: calc(100vh - 150px);

    padding: 12px;

    overflow-y: auto;

    font-size: 12px;
    line-height: 1.5;
}


.settlement-section {
    margin-top: 14px;

    padding-top: 10px;

    border-top: 1px solid #333;
}


.settlement-section-title {
    margin-bottom: 7px;

    color: #999;
}


.settlement-row {
    display: flex;
    justify-content: space-between;

    gap: 12px;

    margin-bottom: 4px;
}


.settlement-resident {
    margin-bottom: 5px;
}

.settlement-action-button,
.settlement-list-button,
.settlement-back-button,
.person-relation-button {
    font-family: inherit;
}


.settlement-action-button {
    width: 100%;

    padding: 8px 10px;

    border: 1px solid #777;

    background: #111411;
    color: #f1d680;

    text-align: left;

    cursor: pointer;
}


.settlement-action-button:hover {
    background: #191d19;
    color: #ffffff;
}


.settlement-list-button {
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: flex-start;

    gap: 2px;

    margin-bottom: 5px;
    padding: 7px 8px;

    border: 1px solid #333;

    background: transparent;
    color: #e7e7d7;

    text-align: left;

    cursor: pointer;
}


.settlement-list-button:hover {
    border-color: #888;

    background: #111411;
}


.settlement-list-detail {
    color: #888;

    font-size: 11px;
}


.settlement-back-button {
    margin-bottom: 12px;

    padding: 3px 0;

    border: none;

    background: transparent;
    color: #999;

    cursor: pointer;
}


.settlement-back-button:hover {
    color: #ffffff;
}


.settlement-row-stack {
    align-items: flex-start;
}


.settlement-row-stack > div {
    max-width: 65%;

    text-align: right;
}


.person-relation-button {
    display: block;

    margin: 0 0 3px auto;
    padding: 0;

    border: none;

    background: transparent;
    color: #f1d680;

    cursor: pointer;
}


.person-relation-button:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* =========================
   NPC INTERACTION
========================= */

.npc-action-button,
.dialogue-topic-button {
    width: 100%;

    margin-bottom: 5px;
    padding: 7px 9px;

    border: 1px solid #555;

    background: #111411;
    color: #f1d680;

    font-family: inherit;
    font-size: 12px;

    text-align: left;

    cursor: pointer;
}


.npc-action-button:hover,
.dialogue-topic-button:hover {
    border-color: #aaa;

    background: #191d19;
    color: #ffffff;
}


/* =========================
   DIALOGUE
========================= */

.dialogue-history {
    margin-top: 4px;
}


.dialogue-line {
    margin-bottom: 12px;
}


.dialogue-speaker {
    margin-bottom: 3px;

    color: #999;

    font-size: 11px;
}


.dialogue-text {
    color: #e7e7d7;

    line-height: 1.5;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 900px) {

    #game-layout {
        grid-template-columns: 170px 1fr;
    }

    #log-panel {
        display: none;
    }
}

/* =========================
   TRADE
========================= */

.trade-summary {
    display: flex;
    justify-content: space-between;

    gap: 12px;

    margin-bottom: 12px;

    color: #aaa;
}


.trade-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 7px 0;

    border-bottom: 1px solid #252825;
}


.trade-item-info {
    min-width: 0;
}


.trade-button {
    flex-shrink: 0;

    padding: 5px 8px;

    border: 1px solid #555;

    background: #111411;
    color: #f1d680;

    font-family: inherit;
    font-size: 11px;

    cursor: pointer;
}


.trade-button:hover:not(:disabled) {
    border-color: #aaa;

    color: #ffffff;
}


.trade-button:disabled {
    color: #555;

    border-color: #333;

    cursor: default;
}


/* =========================
   CHARACTER ACTIONS
========================= */

.character-action-button {
    width: 100%;

    margin-top: 6px;
    padding: 6px 8px;

    border: 1px solid #555;

    background: #111411;
    color: #e7e7d7;

    font-family: inherit;

    cursor: pointer;
}


.character-action-button:hover {
    border-color: #aaa;
    color: #ffffff;
}


/* =========================
   INVENTORY
========================= */

.inventory-summary {
    margin-bottom: 10px;

    color: #aaa;
}


.inventory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 8px 0;

    border-bottom: 1px solid #292c29;

}


.inventory-item-main {
    min-width: 0;
}


.inventory-item-actions {
    display: flex;

    gap: 5px;

    flex-shrink: 0;
}


.inventory-action-button {
    padding: 5px 8px;

    border: 1px solid #555;

    background: #111411;
    color: #f1d680;

    font-family: inherit;
    font-size: 11px;

    cursor: pointer;
}


.inventory-action-button:hover {
    border-color: #aaa;

    color: #ffffff;
}

/* =========================
   CRAFTING FILTERS
========================= */

.crafting-filter-row {
    display: flex;

    gap: 6px;

    margin-top: 12px;
    margin-bottom: 8px;
}


.crafting-search-input,
.crafting-category-select {
    min-width: 0;

    padding: 6px 7px;

    border: 1px solid #444;

    background: #0b0d0b;
    color: #e7e7d7;

    font-family: inherit;
    font-size: 11px;
}


.crafting-search-input {
    flex: 1;
}


.crafting-category-select {
    max-width: 130px;
}


.crafting-search-input:focus,
.crafting-category-select:focus {
    outline: none;

    border-color: #888;
}


.inventory-action-button:disabled {
    border-color: #333;

    color: #555;

    cursor: default;
}