/* ===== CSS VARIABLES ===== */
:root {
    --bg-color: #0A0A0A;
    --container-bg: #0C1A1B;
    --accent-bg: #2B4347;
    --text-color: #B8FCFB;
    --primary-accent: #FA7054;
    --border-color: #2B4347;
    --button-bg: #2B4347;
    --button-text: #B8FCFB;
    --error-color: #FA7054;
    --success-color: #B8FCFB;
}

/* ===== E-INK OPTIMIZATIONS ===== */
/* E-ink optimization styles - applied via body class when enabled in settings */
body.eink-mode {
    /* E-ink light palette for better contrast on e-ink displays */
    --bg-color: #F5F5F5;        /* Off-white background */
    --container-bg: #FFFFFF;     /* Pure white containers */
    --accent-bg: #E8E8E8;        /* Light gray accents */
    --text-color: #1A1A1A;       /* Deep black text */
    --primary-accent: #000000;   /* Pure black buttons */
    --border-color: #666666;     /* Medium gray borders */
    --button-bg: #DDDDDD;        /* Light gray buttons */
    --button-text: #1A1A1A;      /* Dark button text */
    --error-color: #000000;      /* Black for errors */
    --success-color: #1A1A1A;    /* Dark for success */
}

body.eink-mode .modal-btn.secondary,
body.eink-mode .menu-btn.secondary {
    color: var(--text-color);    /* Ensure dark text on light backgrounds */
}

body.eink-mode *,
body.eink-mode *::before,
body.eink-mode *::after {
    animation: none !important;
    transition: none !important;
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: 0.02em;
    color: var(--text-color);
    background-color: var(--bg-color);
    padding: 20px;
    max-width: 700px;
    margin: 0 auto;
}

/* ===== HEADER ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.settings-btn {
    background: var(--primary-accent);
    color: var(--bg-color);
    border: none;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    min-height: 13px;
    border-radius: 2px;
}

.settings-btn:hover {
    opacity: 0.9;
}

.settings-btn:active {
    opacity: 0.8;
}

/* ===== NARRATIVE AREA ===== */
#narrative {
    position: relative;
    min-height: 300px;
    padding: 30px 20px;
    margin-bottom: 20px;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 2px;
}

#narrative::after {
    content: 'LOG: ' attr(data-log-number);
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--border-color);
    text-transform: uppercase;
}

#narrative p {
    margin-bottom: 1.5em;
    line-height: 2;
}

/* Markdown formatting within narrative */
#narrative h1,
#narrative h2,
#narrative h3 {
    font-weight: bold;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    line-height: 1.4;
}

#narrative h1 {
    font-size: 26px;
}

#narrative h2 {
    font-size: 24px;
}

#narrative h3 {
    font-size: 22px;
}

#narrative em {
    font-style: italic;
}

#narrative strong {
    font-weight: bold;
}

#narrative ul,
#narrative ol {
    margin: 1em 0;
    padding-left: 2em;
}

#narrative li {
    margin-bottom: 0.5em;
}

#narrative code {
    font-family: 'Courier New', monospace;
    background: var(--border-color);
    padding: 2px 6px;
}

#narrative blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 20px;
    margin: 1em 0;
    font-style: italic;
}

/* ===== DICE ROLL DISPLAY ===== */
#dice-result {
    background: var(--accent-bg);
    color: var(--text-color);
    padding: 16px 20px;
    margin: 20px 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    line-height: 2;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    white-space: pre-line;
}

#dice-result.hidden {
    display: none;
}

/* ===== ACTIONS ===== */
#actions {
    margin-bottom: 30px;
    padding: 20px 0;
}

#actions h2 {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-color);
    margin-bottom: 10px;
    line-height: 2;
}

#options {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 18px;
}

.action-btn {
    width: 100%;
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    padding: 20px;
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    font-family: 'IBM Plex Mono', monospace;
    text-align: left;
    cursor: pointer;
    min-height: 60px;
    line-height: 1.8;
    letter-spacing: 0.02em;
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.action-btn:hover {
    background: var(--primary-accent);
    color: var(--bg-color);
    opacity: 0.7;
}

.action-btn:active {
    background: var(--primary-accent);
    color: var(--bg-color);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.difficulty-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    opacity: 1;
}

.action-metadata {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    font-style: normal;
    font-weight: 500;
    opacity: 1;
    white-space: nowrap;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Custom action input */
#custom-action-form {
    display: flex;
    gap: 1px;
    margin-top: 18px;
}

#custom-action-form.hidden {
    display: none;
}

#custom-action-input {
    flex: 1;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    font-family: 'IBM Plex Mono', monospace;
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    letter-spacing: 0.02em;
    min-height: 36px;
}

#custom-action-input::placeholder {
    color: var(--text-color);
    opacity: 0.8;
}

#custom-action-submit {
    background: var(--primary-accent);
    color: var(--bg-color);
    border: none;
    padding: 0 30px;
    font-size: 22px;
    font-weight: 300;
    font-family: 'IBM Plex Mono', monospace;
    cursor: pointer;
    min-width: 82px;
    min-height: 36px;
    letter-spacing: 0.02em;
}

#custom-action-submit:hover {
    opacity: 0.9;
}

#custom-action-submit:active {
    opacity: 0.8;
}

/* ===== INFO PANEL ===== */
#info-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    gap: 0px;
}

.info-item {
    flex: 1;
    padding: 18px 14px;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    background: transparent;
    border-left: 1px solid var(--border-color);
    justify-content: space-between;
}

.info-item:last-child {
    border-right: 1px solid var(--border-color);
}

.info-item:has(.info-icon) {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.info-label, .info-sublabel {
    font-size: 0.8rem;
    font-weight: 200;
    color: var(--text-color);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.3;
}

.info-value {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-color);
    line-height: 1.3;
    letter-spacing: 0.02em;
    margin-bottom: -5px;
}

.info-subvalue {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-color);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.3;
}

.info-icon {
    font-size: 2rem;
    line-height: 1;
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-divider-vertical {
    width: 1px;
    background: var(--border-color);
}

.info-divider-horizontal {
    height: 1px;
    background: var(--border-color);
}

/* ===== PANELS (Skills, Inventory, Menu) ===== */
.collapsible-panel {
    margin-bottom: 20px;
    background: var(--container-bg);
    border-radius: 2px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 11px;
    cursor: pointer;
    min-height: 33px;
}

.panel-label {
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-color);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.panel-toggle {
    border: 1px solid var(--primary-accent);
    background-color: transparent;
    color: var(--text-color);
    padding: 1px 5px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    min-height: 13px;
}

#mute-btn.panel-toggle {
    border: 1px solid var(--primary-accent);
    background-color: transparent;
    color: var(--text-color);
}

.panel-toggle:hover {
    opacity: 0.9;
}

#mute-btn.panel-toggle:hover {
    opacity: 0.9;
}

.panel-toggle:active {
    opacity: 0.8;
}

#mute-btn.panel-toggle:active {
    opacity: 0.8;
}

.panel-content {
    display: none;
    padding: 10px 0;
}

#skills-content.panel-content {
    padding: 20px 10px;
}

/* Skill panel */
.panel-content.open {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 40px;
}

/* Inventory panel */
#inventory-items.panel-content.open {
    gap: 1px;
}

.skill-item {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    align-items: flex-end;
    gap: 5px;
}

.skill-name {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-color);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.skill-points {
    margin-bottom: -5px;
    font-size: 2rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-color);
    line-height: 1.3;
    text-align: right;
    letter-spacing: 0.02em;
}

.inventory-item {
    padding: 6px 10px;
    background-color: var(--accent-bg);
    border-bottom: 1px solid var(--border-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    color: var(--text-color);
}

.inventory-item:last-child {
    border-bottom: none;
}

/* Game menu buttons */
#game-menu {
    display: flex;
    gap: 10px;
    flex-direction: column;
    margin-top: 62px;
}

.menu-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    min-height: 36px;
    text-align: center;
    border-radius: 2px;
}

.menu-btn.primary {
    border: 1px solid var(--primary-accent);
    background-color: transparent;
    color: var(--text-color);
}

.menu-btn.primary:hover {
    opacity: 0.9;
}

.menu-btn.primary:active {
    opacity: 0.8;
}

.menu-btn.secondary {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.menu-btn.secondary:hover {
    opacity: 0.9;
}

.menu-btn.secondary:active {
    opacity: 0.8;
}

/* ===== LOADING AND ERRORS ===== */
#loading {
    display: none;
    text-align: center;
    padding: 40px;
    font-size: 22px;
    color: var(--accent-color);
}

#loading.visible {
    display: block;
}

#error-message {
    display: none;
    background: var(--error-color);
    color: var(--bg-color);
    padding: 20px 30px;
    margin: 20px 0;
    border: 2px solid var(--text-color);
}

#error-message.visible {
    display: block;
}

#error-message.success {
    background: var(--success-color);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 40px;
}

.modal-content {
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    border-radius: 22px;
    text-align: center;
}

.modal-content h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-content input[type="password"],
.modal-content select {
    width: 100%;
    padding: 12px 15px;
    font-size: 14px;
    font-family: 'IBM Plex Mono', monospace;
    background: var(--accent-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    border-radius: 2px;
}

.modal-content label {
    display: block;
    margin-bottom: 10px;
}

/* Checkbox labels - display as row with checkbox on right */
.modal-content label[for="auto-save-toggle"],
.modal-content label[for="eink-mode-toggle"] {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    font-weight: normal;
    cursor: pointer;
    padding: 15px 0;
}

.modal-content input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Radio button styling */
.modal-content input[type="radio"] {
    margin: 0;
    margin-right: 10px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.modal-btn {
    flex: 1;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--primary-accent);
    padding: 12px 20px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 36px;
    border-radius: 2px;
}

.modal-btn:hover {
    opacity: 0.9;
}

.modal-btn:active {
    opacity: 0.8;
}

.modal-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.modal-btn.secondary:hover {
    opacity: 0.9;
}

.modal-btn.secondary:active {
    opacity: 0.8;
}

/* Game over stats */
.stats-summary {
    margin: 20px 0;
    padding: 20px;
    background: var(--accent-bg);
    border: 1px solid var(--border-color);
}

.stats-summary h3 {
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1rem;
}

.stat-line span:first-child {
    opacity: 0.7;
}

.stat-line span:last-child {
    font-weight: 500;
}

/* Save slots */
.save-slot {
    border: 2px solid var(--border-color);
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
}

.save-slot:hover {
    background: var(--border-color);
    opacity: 0.5;
}

.save-slot:active {
    background: var(--border-color);
}

.save-slot.empty {
    opacity: 0.6;
}

.save-slot-header {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    margin-bottom: 10px;
}

.save-slot-info {
    font-size: 16px;
    color: var(--accent-color);
}

/* Skill point slider */
#points-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 10px;
    background: var(--border-color);
    outline: none;
}

#points-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    background: var(--button-bg);
    cursor: pointer;
}

#points-slider::-moz-range-thumb {
    width: 30px;
    height: 30px;
    background: var(--button-bg);
    cursor: pointer;
    border: none;
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none;
}

.alchemical-symbol {
    transform: translateY(-2px);
}

.flex-row {
    display: flex;
    gap: 9px;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-label {
    display: block;
    margin-bottom: 15px;
}

.settings-label-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.settings-description {
    font-size: 16px;
    font-weight: normal;
    color: var(--accent-color);
}

.settings-action-section {
    margin-top: 30px;
}

.model-loading-container {
    background: var(--accent-bg);
    color: var(--text-color);
    padding: 20px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
}

.model-loading-progress {
    margin-top: 10px;
    font-size: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    body {
        padding: 15px;
        font-size: 14px;
    }

    h1 {
        font-size: 24px;
    }

    #narrative {
        padding: 20px 15px;
    }

    .modal-content {
        padding: 20px;
    }

    .info-label {
        font-size: 0.8rem;
    }

    .info-divider-vertical {
        display: none;
    }

    .info-divider-horizontal {
        display: block;
    }

    .panel-content.open {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    #inventory-items.panel-content.open {
        gap: 1px;
    }

    .action-btn {
        align-items: flex-start;
        font-size: 0.8rem;
    }

    #custom-action-input {
        font-size: 0.8rem;
    }
}

/* ===== PRINT ===== */
@media print {
    .settings-btn,
    #actions,
    #game-menu,
    .modal {
        display: none;
    }
}
