:root {
    --bg: #1a1b26;
    --bg-secondary: #24283b;
    --bg-tertiary: #2a2f42;
    --text: #c0caf5;
    --text-muted: #787c99;
    --accent: #7aa2f7;
    --accent-hover: #5d8ff2;
    --danger: #f7768e;
    --success: #9ece6a;
    --warning: #e0af68;
    --border: #3b4261;
    --radius: 8px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* Layout */
.app {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-center {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.header-user {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.game-switcher {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.game-switcher:focus {
    outline: none;
    border-color: var(--accent);
}

.game-description {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.game-name {
    font-weight: 600;
    color: var(--text);
}

.game-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-planning { background: rgba(224, 175, 104, 0.15); color: var(--warning); }
.status-active { background: rgba(158, 206, 106, 0.15); color: var(--success); }
.status-paused { background: rgba(200, 200, 200, 0.15); color: var(--text-muted); }
.status-completed { background: rgba(247, 118, 142, 0.15); color: var(--danger); }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem 0 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    border-radius: 0 0 var(--radius) var(--radius);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(36, 40, 59, 0.98);
    backdrop-filter: blur(8px);
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(122, 162, 247, 0.05);
}

.tab-panel {
    padding: 0.5rem 0;
}

/* Header actions */
.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tab-header h2 {
    font-size: 1.25rem;
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.btn-danger {
    background: rgba(247, 118, 142, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

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

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.modal[style*="display: flex"],
.modal[style*="display: block"] {
    pointer-events: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
}

.modal-header .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.modal-close:hover {
    color: var(--danger);
    background: rgba(247, 118, 142, 0.1);
}

/* Abbrechen-Buttons im Modal-Footer sollen normale .btn-Buttons bleiben,
   nicht wie das X-Schließen gestylt werden. */
.modal-footer .modal-close,
.modal-footer .btn.modal-close {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    color: var(--text);
}
.modal-footer .modal-close:hover,
.modal-footer .btn.modal-close:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-tertiary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.25rem;
    border-top: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group small {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-checkbox label {
    margin-bottom: 0;
    cursor: pointer;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.2);
}

textarea {
    resize: vertical;
}

/* Setup page */
.setup-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.setup-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
}

.setup-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.setup-message {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Rulebooks */
.rulebook-card {
    margin-bottom: 1.25rem;
}

.rulebook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.rulebook-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.rulebook-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.rulebook-actions {
    display: flex;
    gap: 0.5rem;
}

.rulebook-tables {
    margin-top: 0.5rem;
}

.table-category {
    margin-bottom: 1rem;
}

.table-category h4 {
    color: var(--warning);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.table-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    transition: all 0.2s;
}

.table-item:hover {
    border-color: var(--accent);
}

.table-item.hidden {
    opacity: 0.4;
}

.table-link {
    flex: 1;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-link:hover {
    color: var(--accent);
}

.table-abbr {
    background: rgba(122, 162, 247, 0.15);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.table-page {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.table-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.table-item:hover .table-actions {
    opacity: 1;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

.icon-btn:hover {
    color: var(--accent);
    background: rgba(122, 162, 247, 0.1);
}

/* NSC layout */
.nsc-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 220px);
    min-height: 500px;
}

.npc-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.npc-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.npc-list-header h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.search-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    width: 100%;
    font-size: 0.85rem;
}

.npc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.npc-list-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(59, 66, 97, 0.3);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.npc-list-item:hover {
    background: var(--bg-tertiary);
}

.npc-list-item.active {
    background: rgba(122, 162, 247, 0.1);
    border-left: 3px solid var(--accent);
}

.npc-portrait,
.npc-portrait-small {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.npc-portrait {
    width: 40px;
    height: 40px;
}

.npc-portrait-small {
    width: 48px;
    height: 48px;
}

.npc-portrait-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.npc-list-item-info {
    flex: 1;
    min-width: 0;
}

.npc-list-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.npc-list-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.npc-delete-btn {
    flex-shrink: 0;
    opacity: 0.6;
    padding: 0.15rem 0.4rem;
    line-height: 1.2;
}

.npc-delete-btn:hover {
    opacity: 1;
}

/* Chat */
.npc-chat-area {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-placeholder,
.detail-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.placeholder-content {
    text-align: center;
    padding: 2rem;
}

.placeholder-content svg {
    margin-bottom: 1rem;
    opacity: 0.4;
}

.placeholder-content h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.placeholder-content p {
    font-size: 0.9rem;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.npc-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.npc-info h3 {
    font-size: 1.1rem;
}

.npc-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message.system {
    align-self: center;
    max-width: 80%;
    align-items: center;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.system .message-bubble {
    background: rgba(158, 206, 106, 0.1);
    border: 1px solid rgba(158, 206, 106, 0.2);
    color: var(--success);
    font-size: 0.8rem;
}

.message-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 1rem;
}

.npc-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.recipient-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.recipient-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.recipient-tag.default-selected {
    background: rgba(122, 162, 247, 0.1);
    border-color: var(--accent);
}

.recipient-tag:hover {
    border-color: var(--accent);
}

.recipient-tag .tag-remove {
    font-weight: 700;
    cursor: pointer;
    opacity: 0.6;
}

.recipient-tag .tag-remove:hover {
    opacity: 1;
    color: var(--danger);
}

.add-recipient-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
}

.add-recipient-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.recipient-dropdown {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
}

.recipient-option {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recipient-option:hover {
    background: var(--bg-tertiary);
}

.recipient-option.selected {
    color: var(--accent);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    max-height: 120px;
    resize: vertical;
}

/* SC layout */
.sc-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

.sc-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: calc(100vh - 220px);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.sc-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sc-list-header h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.sc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.sc-list-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(59, 66, 97, 0.3);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sc-list-item:hover {
    background: var(--bg-tertiary);
}

.sc-list-item.active {
    background: rgba(122, 162, 247, 0.1);
    border-left: 3px solid var(--accent);
}

.sc-list-item-info {
    flex: 1;
    min-width: 0;
}

.sc-list-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.sc-list-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portrait {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.sc-detail {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-height: 500px;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

.character-form .form-tabs {
    background: var(--bg-tertiary);
    margin-bottom: 1.5rem;
    position: static;
}

.form-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.form-tab {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.form-tab:hover {
    color: var(--text);
}

.form-tab.active {
    background: var(--accent);
    color: #fff;
}

.form-tab-panel {
    display: none;
}

.form-tab-panel.active {
    display: block;
}

.character-header {
    display: grid;
    gap: 1rem;
}

.portrait-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.portrait-upload img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.stat-entry {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem;
    text-align: center;
}

.stat-entry label {
    display: block;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-entry input {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.4rem 0.25rem;
}

/* Skills */
.skills-categories {
    display: grid;
    gap: 1.5rem;
}

.skill-category h4,
.equip-section h4 {
    color: var(--accent);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.skill-list,
.equip-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.skill-entry,
.equip-entry {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.skill-entry input,
.equip-entry input {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

.skill-category h4,
.equip-section h4 {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.equipment-sections {
    display: grid;
    gap: 1.5rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.form-actions > div {
    display: flex;
    gap: 0.5rem;
}

/* Game tab */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    height: calc(100vh - 220px);
    min-height: 500px;
}

.game-log-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.game-state-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-size: 1rem;
}

.current-round {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.round-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.round-number {
    font-weight: 700;
    color: var(--accent);
}

.round-title {
    flex: 1;
}

.round-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
}

.round-status.active {
    background: rgba(122, 162, 247, 0.15);
    color: var(--accent);
}

.round-status.ended {
    background: rgba(158, 206, 106, 0.15);
    color: var(--success);
}

.round-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

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

.round-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(59, 66, 97, 0.3);
    cursor: pointer;
    transition: background 0.2s;
}

.round-item:hover {
    background: var(--bg-tertiary);
}

.round-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.round-item-number {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.85rem;
}

.round-item-title {
    font-size: 0.9rem;
}

.round-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.round-item-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.round-detail {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.action-log {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.action-entry {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.action-index {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.85rem;
    min-width: 24px;
}

.action-content {
    flex: 1;
}

.action-actor {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.action-type-tag {
    display: inline-block;
    font-size: 0.7rem;
    background: rgba(122, 162, 247, 0.15);
    color: var(--accent);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.action-description {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.action-mechanics {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.action-result {
    font-size: 0.85rem;
    color: var(--success);
}

.add-action-form {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.add-action-form h4 {
    margin-bottom: 1rem;
    color: var(--accent);
}

/* State panel */
.state-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.state-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
}

.state-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(122, 162, 247, 0.05);
}

.state-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.75rem;
}

.state-entry {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.state-entry:hover {
    border-color: var(--accent);
}

.state-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.state-entry-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.state-faction {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.state-faction.pc {
    background: rgba(122, 162, 247, 0.15);
    color: var(--accent);
}

.state-faction.npc {
    background: rgba(224, 175, 104, 0.15);
    color: var(--warning);
}

.state-values {
    display: grid;
    gap: 0.35rem;
}

.state-value-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.state-value-label {
    color: var(--text-muted);
}

.hp-bar,
.pp-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    margin-top: 0.25rem;
    overflow: hidden;
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger), var(--warning));
    border-radius: 3px;
    transition: width 0.3s;
}

.pp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 3px;
    transition: width 0.3s;
}

.status-effects {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.status-effect-tag {
    font-size: 0.7rem;
    background: rgba(224, 175, 104, 0.2);
    color: var(--warning);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

#status-effects-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.status-effect-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-effect-row input {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Responsive */
@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    
    .game-state-panel {
        min-height: 300px;
    }
}

@media (max-width: 900px) {
    .nsc-layout,
    .sc-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    
    .npc-sidebar,
    .sc-sidebar {
        height: 300px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0.5rem;
    }
}