:root {
    --bg: #14161b;
    --panel: #1e2230;
    --panel-2: #262b3a;
    --text: #e9eef3;
    --muted: #a9b6c7;
    --accent: #4ec9b0;
    --blue: #569cd6;
    --warn: #e57373;
    --gold: #d7ba7d;
    --border: #334055;
    --ok: #5bb98c;
    --crit: #ffd166;

    /* Chat settings variables */
    --chat-normal-color: #e9eef3;
    --chat-quote-color: #4ec9b0;
    --chat-font-size: 14px;
    --chat-font-family: Inter, 'Segoe UI', Arial, sans-serif;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px;
    font-family: Inter, 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(900px 600px at 100% 0%, color-mix(in srgb, var(--bg) 70%, var(--panel)) 0%, var(--bg) 40%) fixed;
    transition: all 0.3s ease;
    line-height: 1.5;
}

h1 {
    margin: 0 0 12px;
    text-align: center;
    color: var(--accent);
    font-weight: 700;
}

/* Layout */
.app-wrapper {
    display: flex;
    gap: 16px;
    max-width: 2200px;
    margin: 0 auto;
    padding: 0 8px 0 8px;
}

/* Character List Sidebar */
.character-list {
    flex: 0 0 240px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    height: fit-content;
    margin-top: 60px;
    margin-right: 8px;
}

.character-list h3 {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 18px;
}

.character-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.character-item:hover {
    background: var(--panel-2);
}

.character-item.selected {
    border-color: var(--accent);
    background: var(--panel-2);
}

.character-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--panel-2);
    background-size: cover;
    background-position: center;
}

.character-info {
    flex: 1;
}

.character-name {
    font-weight: 600;
    color: var(--text);
    margin: 0;
    font-size: 14px;
}

.character-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0;
}

.character-actions {
    display: flex;
    gap: 4px;
}

.char-btn {
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.char-btn:hover {
    background: var(--panel-2);
}

.char-btn.load {
    color: var(--accent);
    border-color: var(--accent);
}

.char-btn.delete {
    color: var(--warn);
    border-color: var(--warn);
}

/* Authentication */
.auth-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.auth-section h4 {
    margin: 0 0 12px;
    color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
}

.auth-input:focus {
    border-color: var(--accent);
    outline: none;
}

.auth-btn {
    padding: 10px;
    background: var(--accent);
    color: #0c1a18;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

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

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

.auth-toggle {
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}

.auth-toggle:hover {
    color: var(--accent);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #0c1a18;
}

.user-details {
    flex: 1;
}

.username {
    font-weight: bold;
    color: var(--text);
    margin: 0;
}

.user-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0;
}

.logout-btn {
    padding: 6px 12px;
    background: var(--warn);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

/* Main App */
.app {
    flex: 1;
    max-width: 1000px;
    min-width: 750px;
}

.main-content {
    min-height: calc(100vh - 140px);
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.top-left {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
}

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

.btn.warn {
    background: var(--warn);
}

.btn-save-server {
    background: var(--accent);
    color: #0c1a18;
}

.btn-add {
    margin-left: auto;
    background: var(--gold);
    color: #1b1b1b;
}

/* Drop zone */
.drop {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    color: var(--muted);
}

.drop.drag {
    border-color: var(--accent);
    color: #c3f7ec;
    background: #0c1518;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 12px 0 0 0;
    flex-wrap: wrap;
}

.tab {
    position: relative;
    padding: 10px 28px 10px 14px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    color: var(--muted);
    user-select: none;
    transition: 0.15s;
    max-width: 100%;
    white-space: nowrap;
}

.tab .title {
    pointer-events: none;
}

.tab .close {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-weight: 900;
    font-size: 14px;
}

.tab .close:hover {
    background: rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.tab .share-char {
    position: absolute;
    right: 28px;
    top: 6px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 12px;
}

.tab .share-char:hover {
    background: rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.tab.active {
    background: var(--accent);
    color: #0c1a18;
    font-weight: 700;
}

/* Panels */
.panels {
    border: 1px solid var(--border);
    border-radius: 0 12px 12px 12px;
    background: var(--panel);
    overflow: hidden;
}

.panel {
    display: none;
    padding: 16px;
}

.panel.active {
    display: block;
}

/* Grid Layout */
.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1.25fr 0.75fr;
}

.compact-row {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
}

/* Cards */
.card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.card h3 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #fff;
}

/* Form Elements */
label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #171b26;
    color: var(--text);
    outline: none;
}

/* Specific styles for attribute input fields */
.staerke, .geschick, .wahrnehmung, .willenskraft {
    width: 80px !important;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    min-width: 80px;
    max-width: 80px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: 10px;
}

.attr-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* Lists */
.list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

.list li {
    padding: 10px 10px;
    background: #151a24;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
}

.pill {
    font-size: 12px;
    color: var(--muted);
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.remove {
    color: var(--warn);
    cursor: pointer;
    user-select: none;
}

/* Attributes */
.attr-str {
    --attr-color: #e57373;
}

.attr-dex {
    --attr-color: #5bb98c;
}

.attr-per {
    --attr-color: #569cd6;
}

.attr-wil {
    --attr-color: #d7ba7d;
}

.attr-input {
    position: relative;
}

.attr-input::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: var(--attr-color);
    border-radius: 2px;
}

.attr-input input {
    padding-left: 16px;
}

.progress-bar {
    height: 4px;
    background: #334055;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-fill {
    height: 100%;
    background: var(--attr-color);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.attr-btn {
    background: var(--panel-2);
    border: 2px solid var(--attr-color);
    color: var(--attr-color);
    transition: all 0.2s ease;
    font-weight: 600;
}

.attr-btn:hover {
    background: var(--attr-color);
    color: #1a1f28;
    transform: translateY(-1px);
}

.attr-btn.active {
    background: var(--attr-color);
    color: #1a1f28;
    box-shadow: 0 0 12px var(--attr-color);
}

/* Effective values */
.eff-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.eff {
    background: #151a24;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.eff .label {
    font-size: 12px;
    color: var(--muted);
}

.eff .val {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    margin-top: 4px;
}

/* Dice */
.dice-wrap {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
    align-items: stretch;
}

.dice-left {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 0;
    min-height: 260px;
}

.btn-roll-big {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #0c1a18;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04) inset, 0 10px 24px rgba(0, 0, 0, 0.25);
    transition: all 0.15s ease;
}

.btn-roll-big:hover {
    filter: brightness(1.05);
    transform: scale(1.02);
}

.btn-roll-big:active {
    transform: translateY(1px) scale(0.98);
}

.dice-panel {
    background: #0f1519;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: grid;
    gap: 10px;
    align-items: center;
}

.dice-big {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 44px;
    font-weight: 900;
    line-height: 1;
    padding: 14px;
    text-align: center;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: #0b1116;
}

.dice-big.ok {
    border-color: var(--ok);
    color: var(--ok);
    animation: pulse-ok 0.6s ease;
}

.dice-big.bad {
    border-color: var(--warn);
    color: var(--warn);
    animation: pulse-bad 0.6s ease;
}

.dice-big.crit {
    border-color: var(--crit);
    color: #ffd166;
    animation: pulse-crit 0.8s ease;
}

.dice-big.crit-success {
    border-color: #ffd166;
    color: #ffd166;
    animation: pulse-crit-success 0.8s ease;
}

.dice-big.crit-fail {
    border-color: var(--warn);
    color: var(--warn);
    animation: pulse-crit-fail 0.8s ease;
}

.dice-big.neutral {
    border-color: var(--accent);
    color: var(--accent);
    animation: pulse-neutral 0.5s ease;
}

@keyframes pulse-ok {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px var(--ok); }
}

@keyframes pulse-bad {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px var(--warn); }
}

@keyframes pulse-crit {
    0%, 100% { transform: scale(1); }
    25%, 75% { transform: scale(1.1); }
    50% { transform: scale(1.15); box-shadow: 0 0 30px var(--crit); }
}

@keyframes pulse-crit-success {
    0%, 100% { transform: scale(1); }
    25%, 75% { transform: scale(1.1); }
    50% { transform: scale(1.15); box-shadow: 0 0 30px #ffd166; }
}

@keyframes pulse-crit-fail {
    0%, 100% { transform: scale(1); }
    25%, 75% { transform: scale(1.1); }
    50% { transform: scale(1.15); box-shadow: 0 0 30px var(--warn); }
}

@keyframes pulse-neutral {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); box-shadow: 0 0 15px rgba(78, 201, 176, 0.3); }
}

.dice-breakdown {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.history {
    margin-top: 8px;
    background: #0b1116;
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 10px;
    height: 200px;
    overflow-y: auto;
}

.history h4 {
    margin: 0 0 6px;
    font-size: 13px;
    color: #cbd5e1;
    position: sticky;
    top: 0;
    background: #0b1116;
    z-index: 1;
}

.history ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
    min-height: 0;
}

.history li {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: #b7c2d2;
    line-height: 1.3;
    flex-shrink: 0;
}

.history::-webkit-scrollbar {
    width: 8px;
}

.history::-webkit-scrollbar-track {
    background: #1a1f28;
    border-radius: 4px;
}

.history::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.history::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Images */
.img-wrap {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.img-preview {
    width: 120px;
    height: 120px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #0b1116;
    cursor: pointer;
}

.img-name {
    font-size: 12px;
    color: var(--muted);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
}

.modal.open {
    display: flex;
}

.modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    border: 2px solid #fff;
}

.modal .close-x {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #0008;
    color: #fff;
    border: none;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.tiny {
    font-size: 12px;
    color: var(--muted);
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.alert {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert .close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    margin-left: 10px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.alert .close:hover {
    opacity: 1;
}

/* Helper classes */
.hidden {
    display: none !important;
}

.justify-content-center {
    justify-content: center;
}

.file-loader-label {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

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

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

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

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

.w-100 {
    width: 100%;
}

.w-240 {
    width: 240px;
}

.h-240 {
    height: 240px;
}

.w-150 {
    width: 150px;
}

.h-150 {
    height: 150px;
}

.w-80 {
    width: 80px;
}

.font-12 {
    font-size: 12px;
}

.font-11 {
    font-size: 11px;
}

.font-10 {
    font-size: 10px;
}

.padding-6-8 {
    padding: 6px 8px;
}

.opacity-05 {
    opacity: 0.5;
}

.padding-20 {
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .app-wrapper {
        flex-direction: column;
        padding: 0 12px;
    }

    .app {
        flex: none;
        max-width: none;
    }

    .chat-container {
        margin-left: 0;
        margin-top: 20px;
        flex: none;
        max-height: 300px;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
    }

    .compact-row {
        grid-template-columns: 1fr;
    }

    .card[style*="grid-row"] {
        grid-row: auto;
    }
}

/* New Character Layout */
.character-layout {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 20px;
}

.character-profile {
    display: flex;
    flex-direction: column;
}

.attributes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.attr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.attr-item label {
    margin-bottom: 6px;
    font-weight: bold;
    color: var(--accent);
}

.gameplay-section {
    min-height: 500px;
}

.save-section {
    margin-top: 16px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}

.image-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 16px;
    height: calc(100% - 32px);
    justify-content: space-between;
}

.image-section h4 {
    margin-bottom: 12px;
    text-align: center;
    color: var(--accent);
    font-size: 16px;
}

/* Adjust image size for own column */
.image-section .img-preview {
    max-width: 320px;
    max-height: 320px;
}

.image-bottom {
    padding-bottom: 16px;
    margin-top: 16px;
}

/* Scrollable states container */
.zustaende-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: #0b1116;
    margin-top: 12px;
}

.zustaende-container::-webkit-scrollbar {
    width: 8px;
}

.zustaende-container::-webkit-scrollbar-track {
    background: #171b26;
    border-radius: 4px;
}

.zustaende-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.zustaende-container::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Better stat alignment with padding */
.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 8px;
    justify-items: center;
}

/* Center align attribute items */
.attr-str, .attr-dex, .attr-per, .attr-wil {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

.attr-str label, .attr-dex label, .attr-per label, .attr-wil label {
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--accent);
    text-align: center;
    font-size: 14px;
}

/* Add padding between character name and basis attribute title */
.card h3:nth-of-type(2) {
    margin-top: 24px;
    text-align: center;
    color: var(--accent);
    font-size: 18px;
}

/* Add padding between stats and modifiers */
.card h3 + .row {
    margin-top: 16px;
}

.card .card {
    margin-top: 16px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    min-width: 300px;
    max-width: none;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    height: calc(100vh - 140px);
    margin-top: 60px;
    margin-left: 8px;
    margin-right: 8px;
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
}

/* Chat Tabs */
.chat-tabs {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    background: var(--panel-2);
    border-radius: 12px 12px 0 0;
}

.chat-tab-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-room-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 0;
}

.chat-room-tabs::-webkit-scrollbar {
    height: 6px;
}

.chat-room-tabs::-webkit-scrollbar-track {
    background: var(--panel);
    border-radius: 3px;
}

.chat-room-tabs::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-room-tab {
    padding: 6px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: fit-content;
}

.chat-room-tab:hover {
    background: var(--panel-2);
    transform: translateY(-1px);
}

.chat-room-tab.active {
    background: var(--accent);
    color: #0c1a18;
    border-color: var(--accent);
    font-weight: bold;
}

.chat-room-tab .close-tab {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.7;
    padding: 0 2px;
}

.chat-room-tab .close-tab:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Chat Content Wrapper */
.chat-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
}

.chat-header h4 {
    margin: 0;
    color: var(--accent);
    font-size: 16px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 200px;
    max-height: none;
    background: #0f1519;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #1a1f28;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-placeholder {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

.message {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    animation: slideInMessage 0.2s ease;
}

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

.message.own {
    background: transparent;
    color: var(--text);
    margin-left: 20%;
    border-color: var(--accent);
    border-width: 2px;
}

.message.system {
    background: var(--muted);
    color: #fff;
    font-style: italic;
    text-align: center;
    margin: 4px 0;
}

.message-header {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.btn-message-edit,
.btn-message-delete {
    padding: 2px 4px;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.btn-message-edit:hover {
    background: var(--blue);
}

.btn-message-delete:hover {
    background: var(--warn);
}

/* Message Modal Styles */
.message-preview {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    font-style: italic;
    color: var(--muted);
    max-height: 100px;
    overflow-y: auto;
}

.message-preview-content {
    font-size: 14px;
    line-height: 1.4;
}

#editMessageText {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 320px;
}

#editMessageModal .modal-content {
    max-width: 800px;
    width: 90vw;
}

#editMessageText:focus {
    outline: none;
    border-color: var(--accent);
}

.char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.btn.danger {
    background: var(--warn);
    color: #fff;
}

.btn.danger:hover {
    background: #c65656;
}

.message.own .message-header {
    color: var(--muted);
}

.message-content {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Chat Input */
.chat-input-section {
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--panel);
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chatInput {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
    resize: none;
}

#chatInput:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(78, 201, 176, 0.2);
}

#chatInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#sendBtn, #shareCharBtn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #0c1a18;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

#sendBtn:hover, #shareCharBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#sendBtn:disabled, #shareCharBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#shareCharBtn {
    background: var(--blue);
}

/* Member Sidebar */
.member-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 200px;
    background: var(--panel-2);
    border-left: 2px solid var(--border);
    padding: 12px;
    border-radius: 0 12px 12px 0;
    z-index: 100;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
}

.member-sidebar:not(.hidden) {
    transform: translateX(0);
}

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

.member-sidebar h5 {
    margin: 0;
    color: var(--accent);
    font-size: 14px;
}

.member-header .btn {
    padding: 4px 8px;
    font-size: 12px;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: var(--panel);
    border-radius: 6px;
    border: 1px solid var(--border);
}

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

.member-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.member-role {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.member-role.admin {
    background: var(--warn);
    color: #fff;
}

.member-role.moderator {
    background: var(--blue);
    color: #fff;
}

.member-role.member {
    background: var(--muted);
    color: var(--bg);
}

.btn-kick {
    padding: 4px 6px;
    background: var(--warn);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-kick:hover {
    opacity: 1;
}


.member-role {
    background: var(--accent);
    color: #0c1a18;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.member-role.admin {
    background: var(--warn);
}

.member-role.moderator {
    background: var(--blue);
}

/* Modal Styles for Chat */
.modal .modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    min-width: 300px;
    max-width: 500px;
}

.modal .modal-content h3 {
    margin: 0 0 16px;
    color: var(--accent);
}

.modal .modal-content input,
.modal .modal-content textarea {
    width: 100%;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
}

.modal .modal-content label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.available-rooms {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.room-item {
    padding: 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.room-item:hover {
    background: var(--panel);
    transform: translateY(-1px);
}

.room-name {
    font-weight: bold;
    color: var(--text);
    margin-bottom: 4px;
}

.room-description {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.room-meta {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
}

.room-lock {
    color: var(--warn);
}

/* Chat Settings Modal */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-weight: bold;
    color: var(--accent);
    font-size: 14px;
    margin: 0;
}

.setting-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.setting-group input[type="range"] {
    width: 100%;
    margin: 0;
}

.setting-group select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
}

.preview-group {
    grid-column: 1 / -1;
}

.message-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: transparent;
    min-height: 60px;
}

.message-preview .message-content {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

#fontSizeValue {
    font-size: 12px;
    color: var(--muted);
    margin-left: 8px;
}

/* Chat Settings Styling Variables */

.message-content {
    color: var(--chat-normal-color);
    font-size: var(--chat-font-size);
    font-family: var(--chat-font-family);
}

.message-content .quote-text {
    color: var(--chat-quote-color, #4ec9b0);
    font-weight: 500;
}

/* Dice Roll Messages */
.message.dice {
    background: linear-gradient(135deg, rgba(78, 201, 176, 0.1) 0%, rgba(86, 156, 214, 0.1) 100%);
    border-color: var(--accent);
    border-width: 2px;
}

.dice-roll-content {
    font-family: var(--chat-font-family, 'Courier New'), monospace;
    font-size: var(--chat-font-size, 14px);
    font-weight: 600;
}

.dice-character-name {
    color: var(--accent);
    font-weight: bold;
}

.dice-attribute {
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 2px;
}

.dice-attribute.str {
    color: #e57373;
    background: rgba(229, 115, 115, 0.2);
}

.dice-attribute.ges {
    color: #5bb98c;
    background: rgba(91, 185, 140, 0.2);
}

.dice-attribute.wah {
    color: #569cd6;
    background: rgba(86, 156, 214, 0.2);
}

.dice-attribute.wil {
    color: #d7ba7d;
    background: rgba(215, 186, 125, 0.2);
}

.dice-result {
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

.dice-result.critical-success {
    color: #ffd166;
    background: rgba(255, 209, 102, 0.2);
}

.dice-result.critical-fail {
    color: #e57373;
    background: rgba(229, 115, 115, 0.2);
}

.dice-result.normal.str {
    color: #e57373;
}

.dice-result.normal.ges {
    color: #5bb98c;
}

.dice-result.normal.wah {
    color: #569cd6;
}

.dice-result.normal.wil {
    color: #d7ba7d;
}

/* Character Share Messages */
.message.character-share {
    background: linear-gradient(135deg, rgba(78, 201, 176, 0.15) 0%, rgba(215, 186, 125, 0.15) 100%);
    border-color: var(--accent);
    border-width: 2px;
}

.character-share-content {
    font-family: Inter, 'Segoe UI', Arial, sans-serif;
}

.share-message {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}

.character-preview {
    background: rgba(30, 34, 48, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.character-info strong {
    color: var(--text);
    font-size: 16px;
    display: block;
    margin-bottom: 6px;
}

.attributes-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attr-preview {
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.attr-preview.str {
    color: #e57373;
    background: rgba(229, 115, 115, 0.2);
}

.attr-preview.ges {
    color: #5bb98c;
    background: rgba(91, 185, 140, 0.2);
}

.attr-preview.wah {
    color: #569cd6;
    background: rgba(86, 156, 214, 0.2);
}

.attr-preview.wil {
    color: #d7ba7d;
    background: rgba(215, 186, 125, 0.2);
}

.btn-import {
    background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    white-space: nowrap;
}

.btn-import:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 201, 176, 0.3);
}

@media (max-width: 800px) {
    .grid,
    .compact-row {
        grid-template-columns: 1fr;
    }

    .dice-wrap {
        grid-template-columns: 1fr;
    }

    .img-preview {
        width: 150px !important;
        height: 150px !important;
    }

    /* Stack character layout vertically on mobile */
    .character-layout {
        grid-template-columns: 1fr;
    }

    .attributes-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}