body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
}

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

h1 {
    color: #5e3023;
    text-align: center;
    margin-bottom: 20px;
}

/* Tab Navigation Styles */
.tab-navigation {
    display: flex;
    background-color: #f8f9fa;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 0;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background-color: transparent;
    color: #6c757d;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background-color: #e9ecef;
    color: #495057;
}

.tab-button.active {
    background-color: white;
    color: #5e3023;
    font-weight: bold;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #5e3023;
}

/* Tab Content Styles */
.tab-content {
    background-color: white;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 500px;
}

.tab-pane {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adjust existing styles for tabs */
.creatures-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.settings-section .setting-group {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.settings-section label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.controls {
    text-align: center;
    margin: 20px 0;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #5e72e4;
    color: white;
}

.btn-primary:hover {
    background-color: #4c63d2;
}

.btn-success {
    background-color: #2dce89;
    color: white;
}

.btn-success:hover {
    background-color: #24a46d;
}

.btn-warning {
    background-color: #fb6340;
    color: white;
}

.btn-warning:hover {
    background-color: #fa441b;
}

.btn-danger {
    background-color: #f5365c;
    color: white;
}

.btn-danger:hover {
    background-color: #ec0c38;
}

.combat-area {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section {
    margin-bottom: 30px;
}

.encounter-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.current-turn {
    font-size: 20px;
    font-weight: bold;
    color: #5e3023;
}

.combat-clock {
    font-size: 20px;
    font-weight: bold;
    color: #5e3023;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #5e3023;
    color: white;
}

tr.current-turn-row {
    background-color: #fffacd;
    font-weight: bold;
}

tr.unconscious {
    opacity: 0.5;
    background-color: #ffcccc;
}

.hp-input {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.initiative-input {
    width: 50px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.add-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

.add-party, .add-enemy {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
}

.add-form {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    align-items: center;
}

.add-form input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    flex: 1;
}

.creature-upload {
    margin-bottom: 15px;
}

.creature-upload input[type="file"] {
    display: none;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.creature-select {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.creature-select select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.status-input {
    width: 100px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.action-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.action-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.action-duration {
    width: 50px;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.action-description {
    width: 120px;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.start-action-btn {
    padding: 3px 8px;
    font-size: 12px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.start-action-btn:hover {
    background-color: #218838;
}

.action-status {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

tr.action-busy {
    opacity: 0.7;
    background-color: #f0f0f0;
}

.party-list {
    margin-bottom: 15px;
}

.party-member {
    background: white;
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.party-member.in-encounter {
    background: #e8f5e9;
}

.history-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.encounter-item {
    background: #f8f9fa;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.encounter-item:hover {
    background: #e9ecef;
}

.encounter-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    display: none;
}

.encounter-item.expanded .encounter-details {
    display: block;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.remove-btn:hover {
    background: #c82333;
}

.enemy-search-section {
    margin-top: 15px;
}

.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.search-controls input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.search-controls input[type="number"] {
    width: 100px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.creature-table-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
    background-color: white;
}

.creature-table {
    width: 100%;
    border-collapse: collapse;
}

.creature-table th {
    background-color: #5e3023;
    color: white;
    padding: 8px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
}

.creature-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
    background-color: white;
}

.creature-table tbody tr:hover {
    background-color: #f8f9fa;
}

.btn-small {
    padding: 4px 8px;
    font-size: 14px;
}

/* Modal styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 400px;
    text-align: center;
    border-radius: 10px;
}

.modal-content.modal-large {
    max-width: 600px;
    text-align: left;
    padding: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #5e3023;
    color: white;
    border-radius: 10px 10px 0 0;
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 10px 10px;
}

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

.modal-header .close {
    color: white;
}

.close:hover,
.close:focus {
    color: black;
}

.modal-header .close:hover,
.modal-header .close:focus {
    color: #ccc;
}

/* Modal Form Styles */
.modal-form .form-group {
    margin-bottom: 15px;
}

.modal-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.modal-form .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.modal-form .input-group {
    display: flex;
    gap: 10px;
}

.modal-form .input-group .form-control {
    flex: 1;
}

.selected-targets {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.selected-targets h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

.selected-targets ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.selected-targets li {
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
}

.selected-targets li:last-child {
    border-bottom: none;
}

.status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background-color: #e9ecef;
    border-radius: 20px;
    font-size: 14px;
}

.status-item .remove-status {
    cursor: pointer;
    color: #dc3545;
    font-weight: bold;
}

#qrcode {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#shareLink {
    word-break: break-all;
    margin-top: 10px;
}

.damage-input {
    width: 60px;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

/* HP column minimum width */
#combatTable td:nth-child(3) {
    min-width: 120px;
}

/* Type badge styling */
.type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-top: 2px;
}

.type-badge.pc {
    background-color: #e3f2fd;
    color: #1565c0;
}

.type-badge.monster {
    background-color: #ffebee;
    color: #c62828;
}

/* Multi-select controls */
.multi-select-controls {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.selection-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.selection-info span {
    font-weight: 500;
    color: #5e3023;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

/* Checkbox styling */
input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

#combatTable th:first-child,
#combatTable td:first-child {
    width: 40px;
    text-align: center;
}

tr.selected {
    background-color: #e3f2fd;
}

tr.selected.current-turn-row {
    background-color: #fff9c4;
}

tr.selected.unconscious {
    background-color: #ffcdd2;
}

/* Roll result display */
.roll-result {
    display: inline-block;
    padding: 2px 8px;
    background-color: #28a745;
    color: white;
    border-radius: 3px;
    font-size: 12px;
    margin-right: 10px;
    font-weight: bold;
}

/* Session total and auto-save styles */
.session-total {
    background-color: #5e3023;
    color: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.session-total h3 {
    margin: 0;
}

.encounter-item.auto-save {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

.encounter-item.auto-save strong {
    color: #856404;
}

/* Pack/Group styles */
.pack-preview {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.pack-preview h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

.pack-row {
    background-color: #e8f5e9;
}

.pack-expand-btn {
    background: none;
    border: none;
    color: #5e72e4;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
}

.pack-expand-btn:hover {
    color: #4c63d2;
}

.pack-member-row {
    background-color: #f0f9ff;
    font-size: 14px;
}

.pack-member-row td:first-child {
    padding-left: 60px;
}

.pack-hp-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pack-total-hp {
    font-weight: bold;
}

.pack-member-count {
    font-size: 12px;
    color: #666;
}

.damage-distribution {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}

.damage-mode-select {
    font-size: 12px;
    padding: 2px 5px;
}

.aoe-damage-indicator {
    font-size: 11px;
    color: #dc3545;
    font-style: italic;
}

/* Toast notification styles */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #28a745;
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    font-size: 16px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1100;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Death state styles */
tr.dead {
    background-color: #e0e0e0;
    opacity: 0.6;
}

tr.dead.current-turn-row {
    background-color: #d0d0d0;
}

.death-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
    margin-left: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.death-toggle-btn:hover {
    opacity: 1;
}

.death-indicator {
    font-size: 16px;
    margin-left: 5px;
}

/* Creature table in pack modal */
#packCreatureTableDiv {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
    background-color: white;
}

#packCreatureTableBody tr:hover {
    background-color: #e3f2fd;
}

#packCreatureTableBody tr {
    cursor: pointer;
}

/* Button flash animation */
@keyframes buttonFlash {
    0% { background-color: inherit; }
    50% { background-color: white; color: #333; }
    100% { background-color: inherit; }
}

.btn-flash {
    animation: buttonFlash 0.3s ease;
}

/* Drag and drop styles */
.drag-handle {
    cursor: grab;
    color: #999;
    font-size: 18px;
    padding: 0 8px;
    user-select: none;
    transition: color 0.2s;
}

.drag-handle:hover {
    color: #5e3023;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Prevent accidental dragging */
[draggable="false"] {
    -webkit-user-drag: none;
    user-drag: none;
}

#combatTable tbody tr.dragging {
    opacity: 0.5;
}

#combatTable tbody tr.drag-over {
    border-top: 3px solid #5e72e4;
}

.initiative-reorder-mode {
    background-color: #e3f2fd;
    border: 2px dashed #5e72e4;
}

.initiative-reorder-mode .drag-handle {
    color: #5e72e4;
}

/* Adjust table to accommodate drag handle */
#combatTable th:nth-child(2),
#combatTable td:nth-child(2) {
    width: 40px;
    text-align: center;
}

#combatTable th:nth-child(3),
#combatTable td:nth-child(3) {
    width: 80px;
}

/* Unified Effects Column Styles */
.effects-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 250px;
    max-width: 350px;
}

.active-effects {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.effect-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.effect-status {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.effect-action {
    background-color: #fff3e0;
    color: #e65100;
}

.effect-temp-hp {
    background-color: #e1f5fe;
    color: #0277bd;
}

.effect-private {
    font-style: italic;
}

.effect-name {
    flex-grow: 1;
}

.effect-remove-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.effect-remove-btn:hover {
    color: #f44336;
}

.add-effect-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.effect-control-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.effect-control-row.secondary {
    flex-wrap: wrap;
}

.effect-input {
    flex-grow: 1;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.effect-duration-type {
    padding: 4px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.effect-duration-value {
    width: 60px;
    padding: 4px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.effect-conc-label {
    display: flex;
    align-items: center;
    font-size: 12px;
    margin: 0;
    white-space: nowrap;
}

.effect-conc-label input {
    margin-right: 4px;
}

.effect-checkbox-label {
    font-size: 12px;
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.effect-checkbox-label input {
    margin: 0 2px 0 0;
}

/* Unified Dice/Effects Modal Styles */
.dice-expression-section,
.effects-config-section,
.damage-config-section,
.roll-config-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.dice-expression-section h3,
.effects-config-section h3,
.damage-config-section h3,
.roll-config-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #5e3023;
    font-size: 16px;
}

.effect-config {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.effect-config input[type="text"] {
    flex: 1;
}

.effect-config select {
    width: 150px;
}

.dice-preview {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: monospace;
    display: none;
}

.dice-preview.valid {
    display: block;
    border-color: #28a745;
    color: #28a745;
}

.dice-preview.invalid {
    display: block;
    border-color: #dc3545;
    color: #dc3545;
}

.roll-results-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.roll-result-item {
    padding: 10px;
    margin: 5px 0;
    background: white;
    border-radius: 3px;
    border-left: 4px solid #6c757d;
}

.roll-result-item.success {
    border-left-color: #28a745;
}

.roll-result-item.failure {
    border-left-color: #dc3545;
}

.roll-result-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.roll-result-details {
    font-size: 14px;
    color: #666;
}

.roll-result-effects {
    margin-top: 5px;
    font-size: 13px;
    color: #495057;
}

.roll-result-summary {
    font-size: 14px;
    color: #333;
    margin-bottom: 5px;
}

.pack-member-results {
    border-left: 3px solid #dee2e6;
    padding-left: 15px;
    margin-top: 10px;
}

.roll-result-member {
    padding: 2px 5px;
    margin: 2px 0;
    border-radius: 3px;
    font-size: 13px;
}

.roll-result-member.success {
    background-color: #d4edda;
    color: #155724;
}

.roll-result-member.failure {
    background-color: #f8d7da;
    color: #721c24;
}

/* Combat Log Styles */
.combat-log-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.combat-log-container h2 {
    margin-top: 0;
    color: #5e3023;
}

.combat-log-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.combat-log {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 10px;
    background-color: #f8f9fa;
}

.log-entry {
    padding: 5px 10px;
    margin: 2px 0;
    border-radius: 3px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.log-entry:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.log-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.log-round {
    font-weight: bold;
    color: #6c757d;
    font-size: 12px;
}

.log-time {
    color: #6c757d;
    font-size: 12px;
}

.log-text {
    flex-grow: 1;
}

.log-damage {
    background-color: #ffebee;
    border-left: 3px solid #f44336;
}

.log-healing {
    background-color: #e8f5e9;
    border-left: 3px solid #4caf50;
}

.log-effect {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.log-turn {
    background-color: #f3e5f5;
    border-left: 3px solid #9c27b0;
}

.log-death {
    background-color: #efebe9;
    border-left: 3px solid #795548;
}

.log-status {
    background-color: #fff8e1;
    border-left: 3px solid #ffc107;
}

.log-encounter {
    background-color: #e0f2f1;
    border-left: 3px solid #009688;
    font-weight: bold;
}