/* --- Stats Panel (Sidebar) --- */
#stats-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #222;
    padding-bottom: 2px;
}

.stat-label {
    color: var(--phosphor-secondary);
}

/* --- Progress Bars --- */
.stat-bar-container {
    margin-top: 5px;
}

.stat-label-bar {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    margin-bottom: 2px;
    color: #ccc;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background-color: #222;
    border: 1px solid #444;
}

.progress-bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.hp-fill {
    background-color: #d93d3d;
    box-shadow: 0 0 5px #ff0000;
}

.res-fill {
    background-color: #3d7bd9;
    box-shadow: 0 0 5px #0088ff;
}

/* --- Text Colors --- */
.text-stamina {
    color: #4caf50;
    font-weight: bold;
}

.text-mana {
    color: #2196f3;
    font-weight: bold;
}

.text-favor {
    color: #ffc107;
    font-weight: bold;
}


/* --- Character Sheet Paper Theme --- */
#character-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.paper-sheet {
    width: 595px;
    /* A4 width */
    height: 842px;
    /* A4 height */
    background-image: url('../assets/static_images/charsheet_bg.png');
    background-size: cover;
    background-position: center;
    border: none;
    box-shadow: none;
    padding: 50px 50px 40px 60px;
    position: relative;
    display: flex;
    flex-direction: column;
    color: #2b1d0e;
    font-family: 'MedievalSharp', cursive;
}

/* Close Button (Ink X) */
#close-char-sheet {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 2.5em;
    color: #3e2723;
    opacity: 0.7;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
}

#close-char-sheet:hover {
    color: #8b0000;
    opacity: 1;
    transform: scale(1.1);
}

/* Header */
.sheet-header {
    text-align: center;
    border-bottom: 2px solid #5c4033;
    margin-bottom: 5px;
    padding-bottom: 5px;
    flex: 0 0 auto;
}

.sheet-header h1 {
    margin: 0;
    font-size: 2.6em;
    color: #3e2723;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
    position: relative;
    display: inline-block;
}

.sheet-header h1::before,
.sheet-header h1::after {
    content: '— ✧ —';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.4em;
    color: #8d6e63;
    opacity: 0.6;
    letter-spacing: normal;
}

.sheet-header h1::before {
    left: -70px;
}

.sheet-header h1::after {
    right: -70px;
}

.sheet-subtitle {
    font-size: 1.1em;
    color: #5d4037;
    font-style: italic;
    margin-top: 0;
    opacity: 0.8;
}

/* Body */
.sheet-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 15px;
    overflow: hidden;
}

/* Section 1: Vitals & Portrait */
.sheet-section-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 5px;
}

.char-portrait-frame {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid #3e2723;
    /* Dark Wood */
    outline: 2px solid #d4af37;
    /* Gold Highlight */
    outline-offset: -6px;
    padding: 0;
    background: #fff;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.4),
        inset 0 0 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    margin-left: 30px;
}

.char-portrait-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 60%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
}

#char-sheet-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(0.2) contrast(1.1);
}

.sheet-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

/* Paper Tabs */
.sheet-tabs-nav {
    display: flex;
    justify-content: flex-start;
    gap: 25px;
    border-bottom: 2px solid #5c4033;
    margin-bottom: 5px;
    padding-bottom: 2px;
    /* Close to icon for active line */
    padding-left: 10px;
}

.paper-tab {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paper-tab img {
    width: 55px;
    height: 55px;
    object-fit: contain;
    filter: sepia(0.3) contrast(1.2);
    opacity: 0.8;
    transition: all 0.2s;
}

.paper-tab:hover img {
    opacity: 1;
    transform: scale(1.1);
    filter: none;
}

.paper-tab.active img {
    opacity: 1;
    filter: none;
}

.paper-tab.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #2b1d0e;
}

/* Content Container */
.sheet-content-container {
    flex: 1;
    overflow-y: hidden;
    position: relative;
}

.sheet-tab-pane {
    display: none;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.sheet-tab-pane.active {
    display: block;
}

/* Paper Lists */
.paper-list {
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    /* overflow-y: auto;  <-- REMOVED to prevent default scrollbar */
    overflow: hidden;
    /* Default to hidden, specific lists can override if needed */
    scrollbar-width: thin;
    scrollbar-color: #5c4033 transparent;
}

.paper-list::-webkit-scrollbar {
    width: 8px;
}

.paper-list::-webkit-scrollbar-thumb {
    background-color: #5c4033;
    border-radius: 4px;
}

.paper-list li {
    font-size: 1.1em;
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid rgba(62, 39, 35, 0.2);
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
    color: #4e342e;
}

/* Inventory Grid */
.sheet-section-inventory {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Inventory Grid (Vertical Flow, Split Columns) */
.inventory-split-container {
    display: flex;
    flex-direction: row;
    gap: 40px;
    height: 100%;
    width: 100%;
}

.inventory-col {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.inventory-col li {
    font-size: 1.1em;
    border-bottom: 1px dotted rgba(62, 39, 35, 0.6);
    color: #4e342e;
    width: 100%;
    height: 31px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 30px;
}

/* Equipment List */
.equipment-paper-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 40px;
    overflow: hidden;
    /* Prevent scrollbar here too */
}

.equipment-paper-list li {
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
    border-bottom: 1px dotted rgba(62, 39, 35, 0.6);
    padding-bottom: 2px;
}

/* Specific Items */
.eq-item {
    color: #6d4c41;
    font-style: italic;
}

.eq-item.equipped {
    color: #2b1d0e;
    font-weight: bold;
    font-style: normal;
}

/* Sheet Footer */
.sheet-footer {
    margin-top: 10px;
    text-align: center;
    font-size: 0.8em;
    color: #8d6e63;
    border-top: 1px solid #d7ccc8;
    padding-top: 5px;
}

/* Stat Blocks */
.stat-block label {
    display: block;
    font-weight: bold;
    margin-bottom: 2px;
    color: #3e2723;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 1px;
}

.stat-value-box {
    position: relative;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: left;
}

.resource-vials-box {
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Generic Vial Progress Bar System */
.vial-container {
    position: relative;
    width: 320px;
    height: 48px;
    margin: 2px 0;
}

.vial-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    pointer-events: none;
}

.vial-fill-area {
    position: absolute;
    top: 11px;
    /* Centered vertically (48-26)/2 */
    left: 21%;
    width: 65%;
    height: 26px;
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 1;
    border-radius: 4px;
}

.vial-fill {
    height: 100%;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.vial-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.25) 25%,
            rgba(255, 255, 255, 0.5) 50%,
            rgba(255, 255, 255, 0.25) 75%,
            rgba(255, 255, 255, 0) 100%);
    animation: vial-swirl-rev 5.2s ease-in-out infinite alternate;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 1;
}

.vial-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.25) 25%,
            rgba(255, 255, 255, 0.5) 50%,
            rgba(255, 255, 255, 0.25) 75%,
            rgba(255, 255, 255, 0) 100%);
    animation: vial-swirl 3s ease-in-out infinite alternate;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 2;
}

@keyframes vial-swirl {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(50%);
    }
}

@keyframes vial-swirl-rev {
    0% {
        transform: translateX(50%);
    }

    100% {
        transform: translateX(0);
    }
}

.vial-glass {
    position: absolute;
    top: 11px;
    left: 21%;
    width: 65%;
    height: 26px;
    background-image: url('../assets/ui_icons/barglass_icon.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    /* Subtle glass effect */
}

.vial-text {
    position: absolute;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    z-index: 5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* Resource Specifics */
.hp-vial-bg {
    background-image: url('../assets/ui_icons/healthbar_icon.png');
}

.stamina-vial-bg {
    background-image: url('../assets/ui_icons/staminabar_icon.png');
}

.mana-vial-bg {
    background-image: url('../assets/ui_icons/manabar_icon.png');
}

.favor-vial-bg {
    background-image: url('../assets/ui_icons/favorbar_icon.png');
}

.hp-fill {
    background: linear-gradient(to right, #8b0000, #ff0000);
}

.stamina-fill {
    background: linear-gradient(to right, #1b5e20, #4caf50);
}

.mana-fill {
    background: linear-gradient(to right, #0d47a1, #2196f3);
}

.favor-fill {
    background: linear-gradient(to right, #f57f17, #ffeb3b);
}

.ink-bar-bg {
    height: 10px;
    background: rgba(62, 39, 35, 0.1);
    margin-top: 4px;
    border: 1px solid rgba(62, 39, 35, 0.2);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ink-bar-fill {
    height: 100%;
    transition: width 0.4s ease-out;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bar-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.85em;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    z-index: 5;
    white-space: nowrap;
    left: 0;
}

.red-ink {
    color: #8b0000;
}

.blue-ink {
    color: #0d47a1;
}

.hp-fill {
    background: linear-gradient(to right, #800000, #d32f2f);
}

.stamina-fill {
    background: linear-gradient(to right, #1b5e20, #4caf50);
}

.mana-fill {
    background: linear-gradient(to right, #0d47a1, #2196f3);
}

.favor-fill {
    background: linear-gradient(to right, #ff8f00, #ffc107);
}

.blue-ink {
    color: #0d47a1;
}

/* Center & Right: Lists and Grids */
.inventory-paper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    overflow-y: auto;
    padding: 5px;
}

.paper-slot {
    aspect-ratio: 1;
    border: 1px solid #8d6e63;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    word-break: break-all;
    padding: 2px;
}

.paper-slot:hover {
    background: rgba(255, 255, 255, 0.5);
    border-color: #3e2723;
    transform: scale(1.02);
}

.slot-icon {
    width: 90%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.3));
}

.slot-qty {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.8em;
    color: #3e2723;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    padding: 0 4px;
    min-width: 15px;
    text-align: center;
}

/* Scrollbars for the paper sheet */
.sheet-body ::-webkit-scrollbar {
    width: 6px;
}

.sheet-body ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.sheet-body ::-webkit-scrollbar-thumb {
    background: #8d6e63;
    border-radius: 3px;
}

.scroll-list {
    flex: 1;
    overflow-y: auto;
}

/* Reuse existing list styles but ensure they work here */
#char-sheet-equipment li,
#char-sheet-inventory li {
    padding: 8px;
    border-bottom: 2px solid rgba(62, 39, 35, 0.5);
    /* More prominent ink line */
}