:root {
    /* Centralized color variables */
    --primary-blue: #4a6a8a;
    --primary-blue-hover: #3a5a7a;
    --primary-red: #b55a5a;
    --primary-red-hover: #a54a4a;
    --primary-green: #85bb65;
    --primary-green-hover: #75bc55;
    --pale-yellow: #d4c466;
    --primary-gray: #6a6a6a;
    --primary-gray-hover: #5a5a5a;
    --focus-blue: #007acc;
    --tab-gray: #e0e0e0;
    --battlemap-square: #323232;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
    overflow-y: scroll; /* Always show vertical scrollbar */
}

/* General word wrapping utility class */
.word-wrap {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Battle Map Styles */
.battle-legend .legend-item:hover {
    border-color: #666;
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

.battle-legend .legend-item:active {
    cursor: grabbing;
}

.hex-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hex-cell {
    position: absolute;
    width: 40px;
    height: 46px;
    background: transparent;
    border: 1px solid #333;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.hex-cell:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hex-cell.occupied {
    background: rgba(255, 255, 255, 0.05);
}

.map-item {
    position: absolute;
    cursor: move;
    user-select: none;
    z-index: 10;
}

.map-item:hover {
    /* z-index: 20; - Removed to prevent z-index changes on hover */
}

.map-item .hex-unit {
    width: 40px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.map-item.single-hex .hex-unit {
    background: #cccccc;
    color: #333;
}

.map-item.two-hex .hex-unit {
    background: #cccccc;
    color: #333;
}

.map-item .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    z-index: 30;
}

.map-item .label-input {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    width: 60px;
    text-align: center;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    /* Calculator tab mobile layout */
    #calculator-tab .tab-content > div > div {
        margin-bottom: 20px;
    }
    
    #calculator-tab .tab-content > div > div:last-child {
        margin-bottom: 0;
    }
    
    /* Disabled melee fields styling */
    .melee-field-disabled {
        opacity: 0.5 !important;
        color: #888 !important;
    }
    
    .melee-field-disabled .melee-field-disabled {
        background-color: #1a1a1a !important;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .tabs {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .tab {
        flex: 1;
        min-width: 120px;
        font-size: 14px !important;
        padding: 10px 8px;
    }
    
    .character-item, .player-item, .rule-item {
        margin-bottom: 15px;
        padding: 15px;
    }
    
    .player-item {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .character-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .player-item .player-info {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .player-item .player-info .player-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .player-item .player-info .player-name {
        text-align: center;
        grid-column: 1;
        grid-row: 1;
    }
    
    .player-item .player-info .player-controls {
        justify-content: center;
    }
    
    .player-item .player-info .player-main {
        flex-direction: column;
        gap: 10px;
    }
    
    .player-item .player-info .player-portrait {
        align-self: center;
        margin: 10px 0;
    }
    
    .player-item .player-info .player-content {
        width: 100%;
    }
    
    /* Removed conflicting rule */
    
    .player-item .player-info {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .player-item .player-info .player-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 15px;
        width: 100%;
    }
    
    .player-item .player-info .player-name {
        font-weight: bold;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .player-item .player-info .player-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    
    .player-item .player-info .player-controls .btn {
        margin-bottom: 0;
        flex: 0 0 auto;
        text-align: center;
    }
    
    .player-item .player-info .player-main {
        display: flex;
        gap: 15px;
        align-items: flex-start;
    }
    
    .player-item .player-info .player-portrait {
        flex-shrink: 0;
        margin-top: 10px;
        width: 60px;
        height: 60px;
    }
    
    .player-item .player-info .player-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .player-item .player-info .player-attributes,
    .player-item .player-info .player-wealth {
        flex: 1;
    }
    
    .player-item .player-info .btn {
        margin-bottom: 8px;
        flex: 1;
        text-align: center;
    }
    
    .player-item .player-info .player-wealth {
        display: inline;
        flex-direction: unset;
        gap: unset;
    }
    
    .player-item .player-info .player-wealth div {
        margin-bottom: 2px;
    }
    
    .player-item .player-info .player-wealth div:last-child {
        margin-bottom: 0;
    }
    
    /* Fix button centering in mobile view by removing margin-left from first button */
    .player-item > div:last-child .btn-small:first-child {
        margin-left: 0;
    }
    
    /* Fix centering for buttons that wrap to new rows in mobile view */
    .player-item > div:last-child .btn-small {
        margin-left: 0;
    }
    
    .character-controls, .player-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
    }
    
    .player-item > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
    }
    
    .player-item .btn {
        margin-bottom: 8px;
        flex: 1;
        text-align: center;
    }
    
    .btn {
        padding: 10px 14px;
        font-size: 14px;
        min-width: auto;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-small {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
    }
    
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 12px;
        min-height: 44px; /* iOS touch target */
    }
    
    .form-group textarea {
        min-height: 80px;
    }
    
    .character-reactions {
        flex-direction: column;
        gap: 10px;
    }
    
    .reaction-item {
        flex-direction: column;
        gap: 5px;
    }
    
    .reaction-select {
        width: 100%;
        padding: 8px;
        font-size: 16px;
    }
    
    .transaction-history {
        margin-top: 15px;
    }
    
    .transaction-item {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 10px;
    }
    
    .transaction-item > div:first-child {
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }
    
    .transaction-item > div:last-child {
        display: flex;
        align-items: center;
        gap: 5px;
        margin-top: 5px;
    }
    
    .rules-list {
        gap: 15px;
    }
    
    .rule-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .rule-actions {
        display: flex;
        gap: 5px;
    }
    
    /* Configuration tab mobile layout */
    #configuration-tab > div {
        margin-bottom: 30px;
    }
    
    #configuration-tab .flex {
        flex-direction: column;
        gap: 20px;
    }
    
    #configuration-tab > div > div {
        min-width: auto;
    }
    
    /* Search input mobile optimization */
    #rule-search, #lore-search {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }
    
    /* Fix header padding in mobile view */
    .header > div {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .header .btn {
        align-self: center;
        margin: 0;
        padding: 8px 12px;
        min-height: auto;
        height: auto;
        line-height: 1.2;
    }
    
    /* Fix player attributes display in mobile view */
    .player-attributes {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 10px;
        font-size: 14px;
        color: #b0b0b0;
    }
    
    .player-attributes span {
        background-color: #2a2a2a;
        padding: 2px 6px;
        border-radius: 3px;
        border: 1px solid #444;
        text-align: center;
    }
    
    /* Mobile button padding fixes */
    .player-controls .btn {
        padding: 4px 6px !important;
        font-size: 11px !important;
    }
    
    /* Experience system styles */
    .player-name-experience {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .player-experience {
        padding: 2px 6px;
        border-radius: 3px;
        border: 1px solid var(--primary-blue-hover);
        text-align: center;
        font-weight: bold;
        color: var(--primary-blue);
        min-width: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .experience-history {
    background-color: #1a1a1a;
    border-radius: 6px;
    margin-top: 10px;
    display: none !important; /* Force hide by default */
}

.experience-history.show {
    display: block !important; /* Force show when active */
}
    
    .experience-item {
        padding: 10px;
        border-bottom: 1px solid #444;
        font-size: 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .experience-item:last-child {
        border-bottom: 1px solid #444;
    }
    
    .experience-amount {
    color: var(--primary-blue);
    font-weight: bold;
}

/* Show Experience and Show Transactions button styling - FORCE REFRESH: Restored primary-blue color */
.btn-show-experience,
.btn-show-transactions {
    background-color: var(--primary-blue) !important;
    border-color: var(--primary-blue) !important;
}
    
    /* Mobile experience history styling (matching transaction history) */
    .experience-history {
        margin-top: 15px;
    }
    
    .experience-item {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 10px;
    }
    
    .experience-item > div:first-child {
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }
    
    .experience-item > div:last-child {
        display: flex;
        align-items: center;
        gap: 5px;
        margin-top: 5px;
    }
}

.header {
    background-color: #2d2d2d;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.login-form {
    background-color: #2d2d2d;
    padding: 30px;
    border-radius: 8px;
    max-width: 400px;
    margin: 100px auto;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"], input[type="password"], select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #3a3a3a;
    color: #e0e0e0;
    font-size: 16px; /* Prevent zoom on iOS */
}

input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--focus-blue);
}

.btn {
    background-color: var(--primary-blue);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--primary-blue-hover);
}

.btn-danger {
    background-color: var(--primary-red);
}

.btn-danger:hover {
    background-color: var(--primary-red-hover);
}

.btn-success {
    background-color: var(--primary-green);
}

.btn-success:hover {
    background-color: var(--primary-green-hover);
}

.btn-gray {
    background-color: var(--primary-gray);
}

.btn-gray:hover {
    background-color: var(--primary-gray-hover);
}

.btn-small {
    padding: 4px 8px;
    font-size: 10px;
    margin-left: 5px;
}

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-gray);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: none;
    z-index: 1000;
    transition: background-color 0.2s;
}

.scroll-to-top:hover {
    background-color: var(--primary-gray-hover);
}

.tabs {
    display: flex;
    background-color: #2d2d2d;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab {
    flex: 1;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    background-color: #3a3a3a;
    border: none;
    color: #e0e0e0;
    font-size: 16px;
}

.tab.active {
    background-color: var(--primary-blue);
}

.tab-content {
    background-color: #2d2d2d;
    padding: 15px;
    border-radius: 0 0 8px 8px;
    display: none;
}

.tab-content.active {
    display: block;
}

.character-group {
    background-color: #444444;
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    border-left: 4px solid var(--primary-blue);
}

/* Only show move cursor on desktop */
@media (min-width: 769px) and (hover: hover) {
    .character-group {
        cursor: move;
    }
}

.character-group.dragging {
    opacity: 0.5;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.group-name {
    font-size: 18px;
    font-weight: bold;
    color: var(--tab-gray);
}

.character {
    background-color: #1a1a1a;
    margin: 10px 0;
    border-radius: 6px;
    border: 1px solid #444;
}

.character-header {
    padding: 15px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.character-info {
    flex: 1;
}

.character-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.character-details {
    font-weight: normal;
    font-size: 14px;
}

.character-controls {
    display: flex;
    gap: 5px;
}

.character-info {
    color: #b0b0b0;
    font-size: 16px;
}

.gender-badge {
    background-color: #6a6a6a;
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    margin: 0 5px;
    display: inline-block;
}

.badge-badge {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    margin: 0;
    display: inline-block;
    font-weight: bold;
}

.badge-epsilon {
    background-color: #f4f4a3;
    color: #333;
    margin-right: 4px;
}

.badge-psi {
    background-color: #ffd700;
    color: #333;
    margin-right: 4px !important;
}

.ethnicity-text {
    color: #b0b0b0;
    margin-right: 5px;
}

.star-icon {
    color: #ffd700;
    font-size: 16px;
}

.star-badge {
    color: #ffd700;
    font-size: 16px;
    margin-left: 5px;
}

.rules-list {
    border-radius: 6px;
    overflow: hidden;
}

.rule-item {
    padding: 15px;
    border-bottom: 1px solid #444;
}

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

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.rule-title {
    flex: 1;
    font-size: 20px;
}

.rule-reference {
    color: #888;
    font-weight: normal;
    margin-left: 5px;
}

.rule-actions {
    display: flex;
    gap: 5px;
}

.rule-description {
    color: #b0b0b0;
    font-style: italic;
    line-height: 1.5;
}

.character-description {
    padding: 10px 15px;
    color: #888;
    font-style: italic;
}

.player-description {
    color: #888;
    font-style: italic;
    margin-bottom: 15px;
}

.character-reactions {
    padding: 5px 15px 10px 15px;
    margin-left: 20px;
    clear: both;
}

.reaction-item {
    margin: 0 0 5px 0;
    display: inline-block;
    margin-right: 15px;
}

.reaction-label {
    font-size: 14px;
    margin-right: 5px;
}

.reaction-select {
    font-size: 14px;
    padding: 2px 4px;
    width: auto;
    min-width: 80px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #2d2d2d;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #e0e0e0;
}

.player-list {
    background-color: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
}

.player-item {
    padding: 15px;
    border-bottom: 1px solid #444;
    justify-content: space-between;
}

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

/* Removed conflicting rule */

.player-name {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 22px;
}

.player-wealth {
    font-size: 18px;
    margin-bottom: 10px;
}

.player-wealth .positive {
    color: var(--primary-green);
    font-weight: bold;
}

.player-wealth .negative {
    color: var(--primary-red);
    font-weight: bold;
}

.player-wealth .neutral {
    color: #b0b0b0;
}

.player-wealth .player-expenses.zero {
    color: #b0b0b0;
    font-weight: bold;
}

.player-wealth .player-expenses.nonzero {
    color: var(--primary-red);
    font-weight: bold;
}

.player-attributes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 14px;
    color: #b0b0b0;
}

.player-attributes span {
    background-color: #2a2a2a;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #444;
}

.player-inactive {
    opacity: 0.5;
}



.transaction-history {
    background-color: #1a1a1a;
    border-radius: 6px;
    margin-top: 10px;
    display: none;
}

.transaction-item {
    padding: 10px;
    border-bottom: 1px solid #444;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.transaction-item:last-child {
    border-bottom: 1px solid #444;
}

.transaction-amount {
    font-weight: bold;
}

.transaction-amount.positive {
    color: var(--primary-green);
}

.transaction-amount.negative {
    color: var(--primary-red);
}

.error {
    color: var(--primary-red);
    margin-bottom: 15px;
}

.success {
    color: var(--primary-green);
    margin-bottom: 15px;
}

/* Search clear button styles */
.search-clear-btn {
    position: absolute;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #666;
    border: none;
    border-radius: 50%;
    color: #333;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Battle map specific styles */
.battle-map-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    overflow: hidden;
}

.battle-legend {
    margin-bottom: 15px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 8px;
    border: 1px solid #444;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: grab;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.legend-item:active {
    cursor: grabbing;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #666;
}

.legend-label {
    font-size: 12px;
    color: #e0e0e0;
    min-width: 60px;
}

.legend-size {
    font-size: 10px;
    color: #888;
    min-width: 30px;
}

/* Calculator tab specific styles */
#calculator-tab .tab-content {
    display: flex;
    gap: 20px;
}

#calculator-tab .tab-content > div:first-child {
    flex: 2;
}

#calculator-tab .tab-content > div:last-child {
    flex: 1;
    min-width: 300px;
}

.combat-modifiers-section {
    background-color: #1a1a1a;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.combat-modifiers-section h4 {
    margin-bottom: 15px;
    color: #e0e0e0;
    font-size: 18px;
}

.modifier-group {
    margin-bottom: 20px;
}

.modifier-group h5 {
    margin-bottom: 10px;
    color: #b0b0b0;
    font-size: 16px;
}

.modifier-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px;
    background: #2a2a2a;
    border-radius: 4px;
}

.modifier-item:last-child {
    margin-bottom: 0;
}

.modifier-label {
    flex: 1;
    color: #e0e0e0;
}

.modifier-value {
    font-weight: bold;
    color: #e0e0e0;
    min-width: 40px;
    text-align: center;
}

.modifier-input {
    width: 80px;
    padding: 4px 8px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 4px;
    text-align: center;
}

.modifier-select {
    padding: 4px 8px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 4px;
    min-width: 120px;
}

/* Damage tracker specific styles */
.damage-tracker-section {
    background-color: #1a1a1a;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.damage-tracker-section h3 {
    margin-bottom: 15px;
    color: #e0e0e0;
    font-size: 18px;
}

.damage-tracker-player {
    background-color: #222;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.damage-tracker-custom {
    background-color: #222;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

/* Configuration tab specific styles */
#configuration-tab .flex {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

#configuration-tab .flex > div {
    flex: 1;
    min-width: 0;
}

#configuration-tab .flex > div > div {
    background-color: #1a1a1a;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

#configuration-tab .flex > div > div:last-child {
    margin-bottom: 0;
}

#configuration-tab h3 {
    margin-bottom: 15px;
    color: #e0e0e0;
    font-size: 18px;
}

/* Rules tab specific styles */
#rules-tab .rules-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#rules-tab .rule-item {
    background-color: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #444;
}

/* Rules tab styling */
#rules-tab {
    display: none;
}

#rules-tab.active {
    display: block;
}

/* Lore tab styling */
#lore-tab {
    display: none;
}

#lore-tab.active {
    display: block;
}

/* Rules styling - restored from original */
.rules-list {
    border-radius: 6px;
    overflow: hidden;
}

.rule-item {
    padding: 15px;
    border-bottom: 1px solid #444;
    background-color: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #444;
    margin-bottom: 15px;
}

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

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.rule-title {
    flex: 1;
    font-size: 20px;
    color: #e0e0e0;
}

.rule-actions {
    display: flex;
    gap: 5px;
}

.rule-description {
    color: #b0b0b0;
    font-style: italic;
    line-height: 1.5;
}

/* Lore styling - mirroring rules but without reference field */
.lore-list {
    border-radius: 6px;
    overflow: hidden;
}

.lore-item {
    padding: 15px;
    border-bottom: 1px solid #444;
    background-color: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #444;
    margin-bottom: 15px;
}

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

.lore-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.lore-title {
    flex: 1;
    font-size: 20px;
    color: #e0e0e0;
}

.lore-actions {
    display: flex;
    gap: 5px;
}

.lore-description {
    color: #b0b0b0;
    font-style: italic;
    line-height: 1.5;
}

/* Mobile styling for both rules and lore */
@media (max-width: 768px) {
    .rule-header, .lore-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .rule-actions, .lore-actions {
        justify-content: flex-start;
    }
}

/* Character tab specific styles */
#characters-tab .character-group {
    margin-bottom: 20px;
}

#characters-tab .character-group:last-child {
    margin-bottom: 0;
}

/* Players tab specific styles */
#players-tab .player-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Battle map tab specific styles */
#battle-map-tab .battle-map-container {
    margin-bottom: 20px;
}

/* Calculator tab specific styles */
#calculator-tab .combat-modifiers-section:last-child {
    margin-bottom: 0;
}

/* Modal specific styles */
.modal-content h3 {
    margin-bottom: 20px;
    color: #e0e0e0;
    font-size: 20px;
}

/* Portrait modal specific styles */
.portrait-modal-content {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 80% !important;
    max-height: 80% !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    text-align: center !important;
    z-index: 1002 !important;
}

/* Portrait modal close button positioning */
.portrait-modal-content .close {
    float: none !important;
    position: absolute !important;
    top: -15px !important;
    right: 5px !important;
}

.modal-content .form-group {
    margin-bottom: 20px;
}

.modal-content .form-group:last-child {
    margin-bottom: 0;
}

/* Button group styles */
.btn-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-group .btn {
    margin: 0;
}

/* Form styles */
.form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-row .form-group:last-child {
    flex: 0 0 auto;
}

/* Status indicators */
.status-active {
    color: var(--primary-green);
    font-weight: bold;
}

.status-inactive {
    color: var(--primary-red);
    font-weight: bold;
}

/* Wealth display styles */
.wealth-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wealth-amount {
    font-size: 18px;
    font-weight: bold;
}

.wealth-change {
    font-size: 14px;
    color: #888;
}

/* Transaction styles */
.transaction-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #333;
}

.transaction-row:last-child {
    border-bottom: none;
}

.transaction-details {
    flex: 1;
}

.transaction-actions {
    display: flex;
    gap: 5px;
}

/* Search and filter styles */
.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 8px 30px 8px 8px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 4px;
}

.search-clear-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Dropdown styles */
.dropdown-container {
    position: relative;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background: #2a2a2a;
}

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

/* Utility classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.ml-10 {
    margin-left: 10px;
}

.mr-10 {
    margin-right: 10px;
}

.p-10 {
    padding: 10px;
}

.p-15 {
    padding: 15px;
}

.p-20 {
    padding: 20px;
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .tab-content.active {
        display: block !important;
    }
}

/* Player Layout - Added at end to ensure precedence */
.player-item .player-info {
    display: flex !important;
    flex-direction: column !important;
}

.player-item .player-info .player-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 15px !important;
    width: 100% !important;
}

.player-item .player-info .player-name {
    font-weight: bold !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
}

.player-item .player-info .player-controls {
    display: flex !important;
    gap: 5px !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
}

.player-item .player-info .player-controls .btn {
    margin-bottom: 0 !important;
    flex: 0 0 auto !important;
    text-align: center !important;
}

.player-item .player-info .player-main {
    display: flex !important;
    gap: 15px !important;
    align-items: flex-start !important;
}

.player-item .player-info .player-portrait {
    flex-shrink: 0 !important;
    margin-top: 10px !important;
    width: 60px !important;
    height: 60px !important;
}

.player-item .player-info .player-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

.player-item .player-info .player-attributes,
.player-item .player-info .player-wealth {
    flex: 1 !important;
}

.player-item .player-info .player-content .btn {
    margin-bottom: 8px !important;
    flex: 1 !important;
    min-width: 120px !important;
    text-align: center !important;
}

/* Action buttons styling - separate from content buttons */
.player-item .player-info > div:last-child .btn {
    margin-bottom: 0 !important;
    flex: 0 0 auto !important;
    min-width: auto !important;
}

/* Mobile Player Layout Overrides */
@media (max-width: 768px) {
    .player-item .player-info .player-header {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
    }
    
    .player-item .player-info .player-controls {
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 10px !important;
    }
    
    /* Mobile player-controls buttons - use smaller padding */
    .player-item .player-info .player-controls .btn {
        padding: 4px 6px !important;
        font-size: 11px !important;
        min-height: 36px !important;
    }
    
    .player-item .player-info .player-main {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .player-item .player-info .player-portrait {
        align-self: center !important;
        margin: 10px 0 !important;
    }
    
    .player-item .player-info .player-content {
        width: 100% !important;
    }
    
    /* Mobile action buttons - make them take full width */
    .player-item .player-info > div:last-child .btn {
        flex: 1 !important;
        margin-bottom: 8px !important;
    }
    
    /* Mobile experience history styling - match transaction history exactly */
    .experience-history {
        margin-top: 15px;
    }
    
    .experience-history.show {
        display: block !important;
    }
    
    .experience-item {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 10px;
    }
    
    .experience-item > div:first-child {
        margin-bottom: 5px;
    }
    
    .experience-item > div:last-child {
        margin-top: 5px;
    }
    
    /* Mobile transaction history styling */
    .transaction-history {
        margin-top: 15px;
    }
    
    .transaction-history.show {
        display: block !important;
    }
    
    .transaction-item {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 10px;
    }
    
    .transaction-item > div:first-child {
        margin-bottom: 5px;
    }
    
    .transaction-item > div:last-child {
        margin-top: 5px;
    }
}

/* Character status styles */
.character-dead {
    opacity: 0.5;
}

.skull-icon {
    color: #666;
    font-size: 16px;
}

/* Desktop Experience System Styles */
.player-item .player-info .player-header .player-name-experience {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-item .player-info .player-header .player-experience {
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--primary-blue-hover);
    text-align: center;
    font-weight: bold;
    color: var(--primary-blue);
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.experience-history {
    background-color: #1a1a1a;
    border-radius: 6px;
    margin-top: 10px;
    display: none;
}

.experience-item {
    padding: 10px;
    border-bottom: 1px solid #444;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.experience-item:last-child {
    border-bottom: 1px solid #444;
}

.experience-amount {
    color: var(--primary-blue);
    font-weight: bold;
}

/* Transaction history styling */
.transaction-history {
    background-color: #1a1a1a;
    border-radius: 6px;
    margin-top: 10px;
    display: none !important; /* Force hide by default */
}

.transaction-history.show {
    display: block !important; /* Force show when active */
}

.transaction-item {
    padding: 10px;
    border-bottom: 1px solid #444;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.transaction-item:last-child {
    border-bottom: 1px solid #444;
}

.transaction-amount {
    font-weight: bold;
}

.transaction-amount.positive {
    color: var(--primary-green);
}

.transaction-amount.negative {
    color: var(--primary-red);
}
