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

html, body {
    height: 100%;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #e0e0e0;
    background: #0f0f1a;
}

body {
    display: flex;
}

/* Sidebar */

.sidebar {
    width: 200px;
    min-height: 100vh;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid #2d2d4e;
}

.sidebar-header {
    padding: 20px 16px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #a0a8d0;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #2d2d4e;
}

.nav-links {
    list-style: none;
    padding: 8px 0;
}

.nav-links li a {
    display: block;
    padding: 10px 16px;
    color: #8890b0;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav-links li a:hover {
    background: #252540;
    color: #c0c8e8;
}

.nav-links li a.active {
    background: #252550;
    color: #a8b4ff;
    border-left: 3px solid #6677dd;
    padding-left: 13px;
}

/* Content area */

.content {
    flex: 1;
    min-height: 100vh;
    background: #12121e;
    padding: 28px 32px;
    overflow-y: auto;
}

/* Placeholder */

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-top: 8px;
}

.placeholder h1 {
    font-size: 22px;
    font-weight: 600;
    color: #c0c8e8;
}

.placeholder-text {
    color: #6070a0;
    font-size: 15px;
}

/* Floating error panel */

.error-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 360px;
    background: #2a1a1a;
    border: 1px solid #7a3030;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.error-panel.hidden {
    display: none;
}

.error-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #3a1f1f;
    border-bottom: 1px solid #7a3030;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    color: #e06060;
}

.error-panel-close {
    background: none;
    border: none;
    color: #e06060;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

.error-panel-close:hover {
    color: #ff8080;
}

.error-panel-body {
    padding: 12px 14px;
    color: #d0a0a0;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Page header */

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

.page-actions {
    display: flex;
    gap: 8px;
    /* Push to the right edge of the header regardless of justify-content. */
    margin-left: auto;
}

.export-dropdown {
    position: relative;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    background: #1a1a2e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    min-width: 120px;
    padding: 4px 0;
    margin-top: 2px;
}

.export-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #c0c8e8;
    /* Match the Export button's padding/font so each row is the same height. */
    padding: 0.4rem 0.8rem;
    font: inherit;
    cursor: pointer;
}

.export-option:hover {
    background: #252540;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #c0c8e8;
}

/* Filters bar */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 14px 16px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: #8890b0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.filter-input {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 5px 10px;
    width: 180px;
    outline: none;
    transition: border-color 0.15s;
}

.filter-input:focus {
    border-color: #6677dd;
}

.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #c0c8e8;
    cursor: pointer;
    font-size: 13px;
}

.radio-label input[type="radio"] {
    accent-color: #6677dd;
    cursor: pointer;
}

/* Data table */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    padding: 9px 12px;
    background: #1a1a2e;
    border-bottom: 2px solid #2d2d4e;
    color: #8890b0;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    white-space: nowrap;
}

.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table thead th.sortable:hover {
    color: #c0c8e8;
    background: #252540;
}

.data-table thead th.sorted-asc,
.data-table thead th.sorted-desc {
    color: #a8b4ff;
}

.data-table tbody tr {
    border-bottom: 1px solid #1e1e32;
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: #181828;
}

.data-table td {
    padding: 9px 12px;
    color: #c8d0e8;
    vertical-align: middle;
}

.col-id {
    color: #6677dd;
    font-weight: 600;
    width: 70px;
    white-space: nowrap;
}

.col-export {
    width: 70px;
    text-align: center;
}

td.col-id .action-icon {
    color: #6677dd;
    font-weight: 400;
    margin-left: 4px;
}

td.col-id .action-icon:hover {
    color: #a8b4ff;
}

.col-map {
    font-family: monospace;
    font-size: 12px;
    color: #a0c8a0;
}

.col-datetime {
    color: #8090b0;
    font-size: 12px;
    white-space: nowrap;
}

.col-player {
    white-space: nowrap;
}

.col-email {
    white-space: nowrap;
    color: #8090b0;
    font-size: 12px;
}

.player-email {
    color: #c0c8e8;
}

.col-empty {
    color: #3a3a60;
}

.player-name {
    color: #c0c8e8;
    margin-right: 4px;
}

.player-id {
    color: #5060a0;
    font-size: 12px;
}

/* No results */

.no-results {
    padding: 40px 0;
    text-align: center;
    color: #4a5080;
    font-size: 15px;
}

/* Pagination */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-info {
    color: #5060a0;
    font-size: 12px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 4px;
    color: #8890b0;
    cursor: pointer;
    font-size: 13px;
    min-width: 32px;
    padding: 4px 8px;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.page-btn:hover:not(:disabled) {
    background: #252540;
    border-color: #4a4a70;
    color: #c0c8e8;
}

.page-btn.active {
    background: #252550;
    border-color: #6677dd;
    color: #a8b4ff;
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.page-ellipsis {
    color: #4a5080;
    padding: 0 4px;
    font-size: 13px;
}

/* Game type badge */

.game-type-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.game-type-network {
    background: #1a2a4a;
    color: #6090d0;
    border: 1px solid #2a3a6a;
}

.game-type-local {
    background: #1a3a1a;
    color: #60a060;
    border: 1px solid #2a4a2a;
}

.game-type-tutorial {
    background: #2a2a1a;
    color: #a09060;
    border: 1px solid #3a3a2a;
}

.game-status-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.game-status-challenge {
    background: #2a2a1a;
    color: #a09060;
    border: 1px solid #3a3a2a;
}

.game-status-in_progress {
    background: #1a2a4a;
    color: #6090d0;
    border: 1px solid #2a3a6a;
}

.game-status-completed {
    background: #1a3a1a;
    color: #60a060;
    border: 1px solid #2a4a2a;
}

/* Game Info cell: status/type badges with a clickable tag list below. */
.game-info-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.game-info-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.game-tag {
    font-size: 11px;
    color: #8890b0;
    background: #20203a;
    border: 1px solid #2d2d4e;
    border-radius: 8px;
    padding: 1px 7px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.game-tag:hover {
    border-color: #6677dd;
    color: #c0c8e8;
}

.game-tag-active {
    background: #2a3a55;
    color: #e0e0e0;
    border-color: #6677dd;
}

/* Games table */

.timeout-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeout-value {
    white-space: nowrap;
}

.turn-timestamps-toggle {
    font-size: 12px;
    line-height: 1;
}

.turn-timestamps-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    background: #12121e;
    border: 1px solid #2d2d4e;
    border-radius: 4px;
}

.turn-timestamps-list[hidden] {
    display: none;
}

.turn-timestamp-entry {
    display: flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
    color: #8090b0;
    font-size: 12px;
}

.turn-number {
    color: #ffd266;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
}

.turn-timestamps-empty {
    color: #4a5080;
    font-size: 12px;
    font-style: italic;
}

.col-turns {
    text-align: right;
    width: 60px;
    color: #8090b0;
    font-size: 12px;
}

.col-opponents {
    min-width: 140px;
}

.opponent-entry {
    white-space: nowrap;
    line-height: 1.7;
}

.opponent-active .player-name {
    color: #ffd266;
    font-weight: 600;
}

.player-type {
    color: #6878b0;
    font-size: 12px;
    margin-right: 4px;
}

.alliance-id {
    color: #5060a0;
    font-size: 12px;
    margin-right: 4px;
}

.col-uuid {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 12px;
    color: #8090c0;
    white-space: nowrap;
}

/* Players table */

.col-counts {
    white-space: nowrap;
    text-align: right;
    width: 80px;
}

.count-total {
    color: #c0c8e8;
}

.count-separator {
    color: #3a3a60;
    margin: 0 2px;
}

.count-active {
    color: #6090d0;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}

.online-dot.online {
    background: #40c040;
    box-shadow: 0 0 4px #40c040;
}

.online-dot.offline {
    background: #604040;
}

/* Account type badge */

.account-type-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.account-type-human {
    background: #1a2a1a;
    color: #60a060;
    border: 1px solid #2a4a2a;
}

.account-type-ai {
    background: #1a1a3a;
    color: #6060c0;
    border: 1px solid #2a2a5a;
}

.account-type-support {
    background: #2a2a1a;
    color: #a09040;
    border: 1px solid #3a3a2a;
}

.account-type-dev {
    background: #2a1a2a;
    color: #a060a0;
    border: 1px solid #4a2a4a;
}

.account-type-admin {
    background: #3a1a1a;
    color: #d06060;
    border: 1px solid #5a2a2a;
}

.account-type-unknown {
    background: #1e1e2e;
    color: #505080;
    border: 1px solid #2a2a4a;
}

/* Online identities list */

.identities-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.identity-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
}

.identity-platform {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 2px;
    background: #1a2a3a;
    border: 1px solid #2a3a5a;
    color: #6090c0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.identity-id {
    color: #8090b0;
    font-family: monospace;
}

.identity-empty {
    color: #3a3a60;
    font-style: italic;
}

/* Action icons */

.col-type {
    white-space: nowrap;
    position: relative;
}

.action-icon {
    background: none;
    border: none;
    color: #4a5080;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    vertical-align: middle;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
    text-decoration: none;
    display: inline-block;
}

.action-icon:hover {
    color: #a8b4ff;
    background: #252540;
}

.action-icon-active {
    color: #a8b4ff;
    background: #252550;
}

.action-icon-danger {
    color: #604040;
}

.action-icon-danger:hover {
    color: #e06060;
    background: #3a1f1f;
}

/* Delete confirmation row */

.row-confirm-delete td {
    background: #1e1214;
    border-top: 1px solid #7a3030;
    border-bottom: 1px solid #7a3030;
}

.confirm-delete {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 0;
}

.confirm-delete-text {
    color: #d0a0a0;
    font-size: 13px;
}

.confirm-delete-text strong {
    color: #e0c0c0;
}

.btn-confirm-delete {
    background: #5a1a1a;
    border: 1px solid #8a3030;
    border-radius: 4px;
    color: #e06060;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    transition: background 0.1s, border-color 0.1s;
}

.btn-confirm-delete:hover {
    background: #7a2020;
    border-color: #c04040;
    color: #ff8080;
}

.btn-cancel-delete {
    background: #1a1a2e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #8890b0;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 12px;
    transition: background 0.1s, color 0.1s;
}

.btn-cancel-delete:hover {
    background: #252540;
    color: #c0c8e8;
}

/* Account type dropdown */

.type-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: #1a1a2e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    min-width: 110px;
    padding: 4px 0;
    margin-top: 2px;
}

.type-option {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #c0c8e8;
    cursor: pointer;
    font-size: 12px;
    padding: 6px 12px;
    text-align: left;
    transition: background 0.1s, color 0.1s;
}

.type-option:hover {
    background: #252550;
    color: #ffffff;
}

.type-option-current {
    color: #a8b4ff;
    font-weight: 600;
}

/* Create Arena page */

.create-arena-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
    padding: 18px 18px;
    max-width: 640px;
    margin-bottom: 16px;
}

.create-arena-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.create-arena-map-select {
    width: 360px;
    cursor: pointer;
}

.player-slot {
    position: relative;
    width: 360px;
}

.player-search-input {
    width: 100%;
}

.player-search-results {
    position: relative;
    margin-top: 4px;
}

.player-search-list {
    list-style: none;
    background: #12121e;
    border: 1px solid #2d2d4e;
    border-radius: 4px;
    max-height: 240px;
    overflow-y: auto;
}

.player-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: #c0c8e8;
    cursor: pointer;
    font-size: 13px;
    padding: 7px 12px;
    text-align: left;
    transition: background 0.1s;
}

.player-search-item:hover {
    background: #252540;
}

.player-search-empty {
    padding: 8px 12px;
    color: #4a5080;
    font-size: 12px;
    font-style: italic;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #252550;
    border: 1px solid #4a4a70;
    border-radius: 4px;
    color: #c0c8e8;
    font-size: 13px;
}

.create-arena-actions {
    margin-bottom: 20px;
}

.create-arena-submit {
    background: #2a2a50;
    border: 1px solid #4a4a70;
    border-radius: 4px;
    color: #a8b4ff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 24px;
    transition: background 0.15s, border-color 0.15s;
}

.create-arena-submit:hover {
    background: #3a3a60;
    border-color: #6677dd;
}

.create-arena-submit:disabled,
.create-arena-submit:disabled:hover {
    background: #1a1a2c;
    border-color: #2c2c40;
    color: #5a5a78;
    cursor: not-allowed;
    opacity: 0.7;
}

.create-arena-preview {
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
    padding: 16px 18px;
    max-width: 640px;
}

.create-arena-preview h3 {
    color: #c0c8e8;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.create-arena-preview ul {
    list-style: none;
    margin-bottom: 12px;
}

.create-arena-preview li {
    align-items: center;
    color: #c8d0e8;
    display: flex;
    font-size: 13px;
    gap: 8px;
    padding: 4px 0;
}

.create-arena-preview .filter-label {
    min-width: 70px;
}

.create-arena-json {
    background: #0c0c14;
    border: 1px solid #2d2d4e;
    border-radius: 4px;
    color: #b0bcd8;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 8px;
    max-height: 480px;
    overflow: auto;
    padding: 10px 12px;
    white-space: pre;
}

.create-arena-error {
    border-color: #6e2d36;
}

.create-arena-error h3 {
    color: #f0a0a8;
}

.create-arena-error details {
    color: #c8d0e8;
    font-size: 13px;
    margin-top: 12px;
}

.create-arena-error details summary {
    cursor: pointer;
    user-select: none;
}

/* Login page */

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #0f0f1a;
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 0 16px;
}

.login-card {
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 8px;
    padding: 32px 28px;
}

.login-header {
    font-size: 20px;
    font-weight: 600;
    color: #a0a8d0;
    letter-spacing: 0.05em;
    text-align: center;
    margin-bottom: 24px;
}

.login-error {
    background: #2a1a1a;
    border: 1px solid #7a3030;
    border-radius: 4px;
    color: #e06060;
    font-size: 13px;
    padding: 8px 12px;
    margin-bottom: 16px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #8890b0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.login-input {
    width: 100%;
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.login-input:focus {
    border-color: #6677dd;
}

.login-btn {
    width: 100%;
    background: #2a2a50;
    border: 1px solid #4a4a70;
    border-radius: 4px;
    color: #a8b4ff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 0;
    margin-top: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.login-btn:hover {
    background: #3a3a60;
    border-color: #6677dd;
}

/* Sidebar footer */

.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid #2d2d4e;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    color: #8890b0;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout {
    background: none;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #8890b0;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-logout:hover {
    background: #2a1a1a;
    border-color: #7a3030;
    color: #e06060;
}

/* ---------------- Create Game page ---------------- */

.cg-section { margin: 1.5rem 0; padding: 1rem; border: 1px solid #2c2c2c; border-radius: 6px; background: #181818; }
.cg-section-title { margin: 0 0 0.75rem 0; font-size: 1.1rem; }
.cg-section-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.cg-counter { font-weight: normal; opacity: 0.7; margin-left: 0.4rem; }

/* Shared config grid */
.cg-shared-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
.cg-description-field, .cg-tags-field { grid-column: 1 / -1; }

/* Tag chips */
.cg-tags-input-wrap { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; padding: 0.3rem; border: 1px solid #333; border-radius: 4px; background: #0f0f0f; }
.cg-tags-chips { display: contents; }
.cg-tag-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.5rem; background: #2a3a55; border-radius: 12px; font-size: 0.85rem; }
.cg-tag-chip-remove { background: none; border: none; cursor: pointer; color: #aaa; padding: 0; }
.cg-tag-chip-remove:hover { color: #fff; }
.cg-tags-input { flex: 1; min-width: 120px; border: none; background: transparent; padding: 0.2rem; color: #e0e0e0; caret-color: #e0e0e0; }
.cg-tags-input.cg-invalid { box-shadow: inset 0 0 0 2px #b33; }
.cg-tags-counter { font-size: 0.8rem; opacity: 0.7; margin-left: 0.4rem; }

/* Games filter bar: let the Tags chip box span the full row width. */
.filters .cg-tags-field { flex: 1 1 100%; }
.filters .cg-tags-field .cg-tags-input-wrap { flex: 1; }

/* Queue */
.cg-queue { min-height: 80px; padding: 0.75rem; background: #0f0f0f; border-radius: 4px; display: flex; flex-wrap: wrap; gap: 0.5rem; align-content: flex-start; }
.cg-queue:empty::before { content: attr(data-empty-message); opacity: 0.5; align-self: center; }
.cg-search-results { margin-bottom: 0.5rem; }
.cg-search-input { width: 280px; max-width: 100%; }

/* Player chip */
.cg-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; background: #1f3a5e; border-radius: 4px; cursor: grab; user-select: none; }
.cg-chip.sortable-ghost { opacity: 0.4; }
.cg-chip.sortable-chosen { cursor: grabbing; }
.cg-chip-remove { background: none; border: none; color: #ccc; cursor: pointer; padding: 0 0.2rem; }
.cg-chip-remove:hover { color: #fff; }

/* Matches */
.cg-matches { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 0.75rem; max-height: 60vh; overflow-y: auto; padding: 0.25rem; border: 1px solid #2c2c2c; border-radius: 4px; }
.cg-match-card { display: grid; grid-template-columns: 1fr 2.25rem 1fr; align-items: center; gap: 0.5rem; padding: 0.75rem; background: #1c1c1c; border: 1px solid #2c2c2c; border-radius: 4px; }
.cg-match-card-placeholder { background: #141414; border-style: dashed; opacity: 0.75; }
.cg-match-slot { display: flex; flex-direction: column; gap: 0.25rem; }
.cg-slot-label { font-size: 0.75rem; opacity: 0.6; }
.cg-slot-target { min-height: 36px; padding: 0.3rem; border: 1px dashed #444; border-radius: 4px; background: #0f0f0f; display: flex; align-items: center; }
.cg-slot-target.cg-slot-empty::before { content: "Drop player here"; opacity: 0.4; font-size: 0.85rem; }
.cg-slot-target.sortable-drag-over { border-color: #6a6; background: #143; }
.cg-match-controls { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.cg-icon-btn { background: #333; border: 1px solid #555; color: #eee; cursor: pointer; padding: 0.25rem 0.4rem; border-radius: 3px; font-size: 0.9rem; }
.cg-icon-btn:hover { background: #444; }

/* Actions */
.cg-btn { background: #2c3a5a; border: 1px solid #3a4a72; color: #eee; padding: 0.4rem 0.8rem; border-radius: 4px; cursor: pointer; }
.cg-btn:hover { background: #3a4a72; }
.cg-btn-danger { background: #4a2c2c; border-color: #6a3a3a; }
.cg-btn-danger:hover { background: #6a3a3a; }
.cg-auto-allocate { display: inline-flex; gap: 0.4rem; align-items: center; }
.cg-queue-actions, .cg-matches-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* Teams (optional Team A vs Team B cross-join builder) */
.cg-teams-section[hidden] { display: none; }
.cg-teams-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.cg-teams-both { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; }
.cg-teams-help { margin: 0 0 0.75rem 0; opacity: 0.6; font-size: 0.85rem; }
.cg-teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.cg-team-title { margin: 0 0 0.4rem 0; font-size: 0.95rem; }
.cg-team-side { font-weight: normal; opacity: 0.6; font-size: 0.8rem; margin-left: 0.4rem; }
.cg-team-zone { min-height: 100px; }

/* Sticky submit bar */
.cg-submit-bar { position: sticky; bottom: 0; padding: 0.75rem 1rem; background: #181818; border-top: 1px solid #2c2c2c; display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.cg-submit-status { opacity: 0.8; }

/* Paste panel */
.cg-paste-panel { position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 100vw; background: #181818; border-left: 1px solid #2c2c2c; padding: 1rem; z-index: 10; overflow-y: auto; }
.cg-paste-panel[hidden] { display: none; }
.cg-paste-panel textarea { width: 100%; min-height: 200px; }

/* Confirm modal */
.cg-confirm-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 20; }
.cg-confirm-modal[hidden] { display: none; }
.cg-confirm-box { background: #181818; padding: 1.5rem; border-radius: 6px; max-width: 600px; max-height: 80vh; overflow-y: auto; }

/* Toast */
.cg-toast { position: fixed; bottom: 4rem; left: 50%; transform: translateX(-50%); background: #2c3a5a; padding: 0.6rem 1rem; border-radius: 4px; z-index: 30; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

/* Paste panel detail styles */
.cg-paste-help { opacity: 0.7; font-size: 0.85rem; }
.cg-paste-actions { display: flex; gap: 0.5rem; margin: 0.5rem 0; flex-wrap: wrap; }
.cg-paste-summary { padding: 0.5rem 0; opacity: 0.8; }
.cg-paste-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.cg-chip-preview { cursor: default; }
.cg-ambig-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 0.5rem; align-items: center; padding: 0.3rem 0; border-bottom: 1px solid #2c2c2c; }
.cg-ambig-line { font-family: monospace; }
.cg-unresolved { list-style: none; padding: 0; }

/* Confirm modal detail styles */
.cg-confirm-shared { display: grid; grid-template-columns: 120px 1fr; gap: 0.3rem; margin-bottom: 0.75rem; }
.cg-confirm-shared dt { opacity: 0.6; }
.cg-confirm-shared dd { margin: 0; }
.cg-confirm-matches-wrap { max-height: 8rem; overflow-y: auto; margin-bottom: 0.75rem; border: 1px solid #2c2c2c; border-radius: 4px; }
.cg-confirm-matches { width: 100%; border-collapse: collapse; font-family: monospace; }
.cg-confirm-matches td { padding: 0.15rem 0.4rem; }
.cg-confirm-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.cg-btn-primary { background: #2a5a2a; border-color: #3a7a3a; }
.cg-btn-primary:hover { background: #3a7a3a; }

/* Result panel */
.cg-result h3 { color: #fff; }
.cg-result-green { border-left: 4px solid #4caf50; padding-left: 0.75rem; }
.cg-result-amber { border-left: 4px solid #ffb300; padding-left: 0.75rem; }
.cg-result-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.cg-result-table td { padding: 0.2rem 0.4rem; border-bottom: 1px solid #2c2c2c; }
.cg-result-table tr.cg-result-ok td { color: #cfc; }
.cg-result-table tr.cg-result-err td { color: #fcc; }
.cg-unresolved-reason { opacity: 0.6; font-size: 0.85rem; }

/* Bulk Create Accounts ------------------------------------------------ */

.bulk-create-help {
    color: #8890b0;
    font-size: 13px;
    margin-bottom: 16px;
    max-width: 720px;
    line-height: 1.5;
}

.bulk-create-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
    padding: 18px;
    max-width: 720px;
    margin-bottom: 16px;
}

.bulk-create-fields .filter-label {
    margin-top: 4px;
}

.bulk-create-fields .filter-label:first-child {
    margin-top: 0;
}

.bulk-email-textarea {
    width: 100%;
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 13px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
}

.bulk-email-textarea:focus {
    border-color: #6677dd;
}

.bulk-file-input {
    color: #c0c8e8;
    font-size: 13px;
}

.bulk-file-input::file-selector-button {
    background: #2a2a50;
    border: 1px solid #4a4a70;
    border-radius: 4px;
    color: #a8b4ff;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 12px;
    margin-right: 10px;
    transition: background 0.15s, border-color 0.15s;
}

.bulk-file-input::file-selector-button:hover {
    background: #3a3a60;
    border-color: #6677dd;
}

.bulk-create-actions {
    margin-bottom: 24px;
}

.bulk-create-submit {
    background: #2a2a50;
    border: 1px solid #4a4a70;
    border-radius: 4px;
    color: #a8b4ff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 24px;
    transition: background 0.15s, border-color 0.15s;
}

.bulk-create-submit:hover {
    background: #3a3a60;
    border-color: #6677dd;
}

.bulk-create-result h2 {
    color: #c0c8e8;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.bulk-create-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 13px;
}

.bulk-create-table thead th {
    padding: 9px 12px;
    background: #1a1a2e;
    border-bottom: 2px solid #2d2d4e;
    color: #8890b0;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
}

.bulk-create-table td {
    padding: 8px 12px;
    color: #c8d0e8;
    border-bottom: 1px solid #1e1e32;
    vertical-align: top;
}

.bulk-create-table tr.row-created {
    background: rgba(90, 180, 110, 0.06);
}

.bulk-create-table tr.row-created td {
    color: #c8e0c8;
}

.bulk-create-table tr.row-skipped_duplicate td {
    color: #8890b0;
}

.bulk-create-table tr.row-invalid_format,
.bulk-create-table tr.row-error {
    background: rgba(220, 90, 90, 0.08);
}

.bulk-create-table tr.row-invalid_format td,
.bulk-create-table tr.row-error td {
    color: #e0a0a0;
}

.badge-email-failed {
    display: inline-block;
    background: #4a3500;
    color: #f4c542;
    border: 1px solid #6a4d00;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bulk-create-error {
    border: 1px solid #5a2a2e;
    background: #2a1a1e;
    border-radius: 4px;
    padding: 14px 16px;
    margin-top: 16px;
    color: #e0a0a0;
    max-width: 720px;
}

.bulk-create-error h2 {
    color: #f0c0c0;
    font-size: 15px;
    margin-bottom: 6px;
}

.bulk-create-error pre {
    background: #1a0e10;
    border: 1px solid #4a2a2e;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 8px;
    overflow: auto;
    font-size: 12px;
    color: #d0a0a0;
    white-space: pre-wrap;
    word-break: break-word;
}

.bulk-create-error details summary {
    cursor: pointer;
    margin-top: 6px;
    color: #d0a0a0;
}

.result-summary {
    margin: 4px 0 12px;
    color: #c8d0e8;
}

/* Audit page */

.col-game-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
}

.col-details details summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.col-details details summary::-webkit-details-marker {
    display: none;
}

.audit-details-count {
    display: inline-block;
    min-width: 1.5em;
    text-align: center;
    color: #c8d0e8;
}

.audit-details-toggle {
    color: #5060a0;
    transition: transform 0.15s ease;
}

.col-details details[open] .audit-details-toggle {
    transform: rotate(90deg);
}

.audit-details-list {
    margin: 6px 0 0;
    padding-left: 16px;
    list-style: none;
    font-size: 12px;
    color: #c8d0e8;
    word-break: break-word;
}

.audit-details-key {
    color: #5060a0;
}

.audit-details-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ===================================================================== */
/* Tournaments                                                            */
/* ===================================================================== */

/* Generic buttons used across tournament views */

.button,
#tab-content button,
.tournament-header button,
.round-chips button,
.search-result button,
.roster-candidates button {
    display: inline-block;
    background: #2c3a5a;
    border: 1px solid #3a4a72;
    color: #e8ecf8;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.button:hover,
#tab-content button:hover,
.tournament-header button:hover,
.round-chips button:hover,
.search-result button:hover,
.roster-candidates button:hover {
    background: #3a4a72;
}

.button.primary,
.primary {
    background: #2a5a2a;
    border: 1px solid #3a7a3a;
    color: #d8f0d8;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.primary:hover,
.button.primary:hover {
    background: #3a7a3a;
}

/* Tournament list filters row (mirrors .filters) */

.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 14px 16px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
    margin-bottom: 16px;
}

.filters-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8890b0;
    font-size: 13px;
}

.filters-row input[type="text"] {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 5px 10px;
    outline: none;
}

.filters-row input[type="text"]:focus {
    border-color: #6677dd;
}

.filters-row fieldset.radio-group {
    border: none;
    display: flex;
    gap: 12px;
    align-items: center;
}

.filters-row fieldset.radio-group legend {
    font-size: 12px;
    font-weight: 600;
    color: #8890b0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    float: left;
    margin-right: 10px;
}

/* Pagination footer */

.pagination-footer {
    margin-top: 14px;
    color: #8890b0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.pagination-footer a {
    color: #a8b4ff;
    cursor: pointer;
    text-decoration: none;
}

.pagination-footer a:hover {
    text-decoration: underline;
}

/* Content links inside tournament tables (nicknames, tournament names, game
   ids). Scoped to the tournament containers so the Players/Games pages'
   .action-icon links are left untouched. Uses the house accent colour instead
   of the default browser blue, with underline reserved for hover. */
#tab-content .data-table td a,
#tournaments-table-target .data-table td a {
    color: #a8b4ff;
    text-decoration: none;
}

#tab-content .data-table td a:hover,
#tournaments-table-target .data-table td a:hover {
    color: #c4ccff;
    text-decoration: underline;
}

/* Generic status / candidate badge */

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #252540;
    color: #a0a8d0;
    border: 1px solid #3a3a60;
}

.status-draft { background: #2a2a1a; color: #a09060; border-color: #3a3a2a; }
.status-registration { background: #1a2a4a; color: #6090d0; border-color: #2a3a6a; }
.status-in_progress { background: #1a2a4a; color: #6090d0; border-color: #2a3a6a; }
.status-completed { background: #1a3a1a; color: #60a060; border-color: #2a4a2a; }
.status-cancelled { background: #2a1a1a; color: #c08080; border-color: #4a2a2a; }
.status-challenge { background: #2a2a1a; color: #a09060; border-color: #3a3a2a; }
.status-scheduled { background: #2a1a3a; color: #a080d0; border-color: #3a2a5a; }
.status-expired,
.status-deleted { background: #2a1a1a; color: #c08080; border-color: #4a2a2a; }

.cand-applied { background: #2a2a1a; color: #a09060; border-color: #3a3a2a; }
.cand-invited { background: #1a2a4a; color: #6090d0; border-color: #2a3a6a; }
.cand-accepted { background: #1a3a1a; color: #60a060; border-color: #2a4a2a; }
.cand-rejected { background: #2a1a1a; color: #c08080; border-color: #4a2a2a; }
.cand-declined { background: #251525; color: #b080b0; border-color: #4a2a4a; }

/* Tournament page header */

.tournament-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #2d2d4e;
}

.tournament-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #c0c8e8;
    margin-right: 4px;
}

.tournament-header .meta {
    flex-basis: 100%;
    color: #6070a0;
    font-size: 13px;
}

.tournament-header .actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.logo-thumb {
    height: 24px;
    width: auto;
    vertical-align: middle;
    border-radius: 3px;
}

/* Tabs */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #2d2d4e;
    margin-bottom: 20px;
}

.tabs .tab {
    padding: 8px 16px;
    color: #8890b0;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
}

.tabs .tab:hover {
    color: #c0c8e8;
}

.tabs .tab.active {
    color: #a8b4ff;
    border-bottom-color: #6677dd;
}

/* Overview tab */

.overview-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 640px;
    margin-bottom: 20px;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-row label {
    font-size: 12px;
    font-weight: 600;
    color: #8890b0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-row input,
.field-row textarea,
.field-row select {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    font-family: inherit;
}

.field-row textarea {
    min-height: 70px;
    resize: vertical;
}

.field-row input:focus,
.field-row textarea:focus,
.field-row select:focus {
    border-color: #6677dd;
}

.status-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #2d2d4e;
}

/* Roster tab */

.roster-add,
.roster-bulk,
.roster-candidates,
.roster-participants {
    margin-bottom: 24px;
}

.roster-add h3,
.roster-bulk h3,
.roster-candidates h3,
.roster-participants h3 {
    font-size: 14px;
    color: #c0c8e8;
    margin-bottom: 10px;
}

.roster-add input[type="text"],
.roster-bulk textarea {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 6px 10px;
    outline: none;
    width: 100%;
    max-width: 420px;
    font-family: inherit;
}

.roster-bulk textarea {
    min-height: 80px;
    display: block;
    margin-bottom: 8px;
    resize: vertical;
}

.roster-add input[type="text"]:focus,
.roster-bulk textarea:focus {
    border-color: #6677dd;
}

.search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 10px;
    max-width: 420px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-top: none;
}

.search-result:first-child {
    border-top: 1px solid #2d2d4e;
    border-radius: 4px 4px 0 0;
}

.search-no-results {
    padding: 6px 10px;
    color: #6070a0;
    font-size: 13px;
    max-width: 420px;
}

.bulk-result {
    margin-top: 10px;
    color: #c8d0e8;
    font-size: 13px;
}

.bulk-result h4 {
    margin: 8px 0 4px;
    color: #a0a8d0;
    font-size: 13px;
}

/* Rounds tab */

.round-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #2d2d4e;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 14px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    color: #c0c8e8;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.chip:hover {
    background: #252540;
}

.chip.active {
    border-color: #6677dd;
    background: #252550;
    color: #a8b4ff;
}

.chip small {
    color: #6070a0;
}

.chip-live small { color: #6090d0; }
.chip-done small { color: #60a060; }
.chip-planned small { color: #a09060; }

.chip-add {
    border-style: dashed;
    color: #8890b0;
}

.chip-add:disabled,
.chip-add[disabled] {
    cursor: not-allowed;
    opacity: 0.45;
}

.round-header {
    margin-bottom: 12px;
}

.round-header h3 {
    font-size: 16px;
    color: #c0c8e8;
}

.round-meta {
    color: #6070a0;
    font-size: 12px;
    margin-top: 2px;
}

.round-locked-note {
    color: #6070a0;
    font-size: 12px;
    font-style: italic;
    margin-top: 4px;
}

.round-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.manual-match {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #2d2d4e;
}

.manual-match h4 {
    font-size: 14px;
    color: #c0c8e8;
    margin-bottom: 4px;
}

.manual-match p {
    color: #6070a0;
    font-size: 12px;
    margin-bottom: 10px;
}

.manual-match label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
    color: #8890b0;
    font-size: 13px;
}

.manual-match input {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 6px 8px;
    outline: none;
    width: 120px;
}

.manual-match input:focus {
    border-color: #6677dd;
}

/* Per-round score override */
.round-scores {
    margin-top: 20px;
}

.round-scores h4 {
    font-size: 14px;
    color: #c0c8e8;
    margin-bottom: 4px;
}

.round-scores p {
    color: #6070a0;
    font-size: 12px;
    margin-bottom: 10px;
}

.round-scores input[type="number"] {
    width: 64px;
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 4px 6px;
    outline: none;
}

.round-scores input[type="number"]:focus {
    border-color: #6677dd;
}

/* Proposed pairings (review-before-create) */
.proposed-pairings h4 {
    font-size: 14px;
    color: #c0c8e8;
    margin-bottom: 8px;
}

.proposed-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Add-round form: responsive grid of label-above-control fields. */
.round-add-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 16px;
    align-items: end;
    max-width: 960px;
    margin-bottom: 8px;
    padding: 16px;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
}

.round-add-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #8890b0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.round-add-form input,
.round-add-form select {
    background: #12121e;
    border: 1px solid #3a3a60;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    padding: 6px 8px;
    outline: none;
    font-family: inherit;
    width: 100%;
}

.round-add-form input:focus,
.round-add-form select:focus {
    border-color: #6677dd;
}

.round-add-form button[type="submit"] {
    grid-column: 1 / -1;
    justify-self: start;
}

.empty {
    color: #6070a0;
    font-size: 14px;
    padding: 16px 0;
}

/* Error / alert panel (HTMX-swapped) */

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
}

.alert-error {
    background: #2a1a1a;
    border: 1px solid #7a3030;
    color: #e0b0b0;
}

.alert-error button {
    background: none;
    border: none;
    color: #c08080;
    cursor: pointer;
    float: right;
    font-size: 16px;
    line-height: 1;
}

/* Public read-only page (standalone document, body.public) */

body.public {
    display: block;
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.public-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2d2d4e;
}

.public-header h1 {
    font-size: 26px;
    color: #c0c8e8;
    margin: 8px 0;
}

.public-header .banner {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 12px;
}

.public-header .description {
    color: #8890b0;
    margin-top: 8px;
}

.public-standings,
.public-rounds {
    margin-bottom: 32px;
}

.public-standings h2,
.public-rounds h2 {
    font-size: 18px;
    color: #a0a8d0;
    margin: 18px 0 10px;
}

.public-standings table,
.public-rounds table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
}

.public-standings th,
.public-rounds th {
    text-align: left;
    padding: 8px 10px;
    background: #1a1a2e;
    color: #8890b0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #2d2d4e;
}

.public-standings td,
.public-rounds td {
    padding: 7px 10px;
    border-bottom: 1px solid #1e1e30;
    color: #d0d4e8;
}

/* ---------------------------------------------------------------- */
/* Server AI page                                                    */
/* ---------------------------------------------------------------- */

.sai-owner-results {
    margin-top: 0.4rem;
}

.sai-owner-chosen {
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #9fb4d8;
}

.sai-owner-chosen[hidden] {
    display: none;
}

.sai-owner-clear {
    background: none;
    border: 1px solid #3a4a72;
    color: #9fb4d8;
    border-radius: 4px;
    padding: 0.1rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.sai-owner-clear:hover {
    background: #2c3a5a;
    color: #e8ecf8;
}

.sai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.sai-key-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sai-key-active {
    background: #1a2a1a;
    color: #60a060;
    border: 1px solid #2a4a2a;
}

.sai-key-revoked {
    background: #2a1a1a;
    color: #b06a6a;
    border: 1px solid #4a2a2a;
}

.sai-key-reveal {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    background: #14251a;
    border: 1px solid #2a5a2a;
    border-radius: 6px;
}

.sai-key-reveal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.sai-key-reveal-head h3 {
    margin: 0;
    font-size: 1rem;
    color: #d8f0d8;
}

.sai-key-reveal-close {
    background: none;
    border: none;
    color: #8aa08a;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}

.sai-key-reveal-close:hover {
    color: #e8ecf8;
}

.sai-key-reveal-subject {
    margin: 0.25rem 0 0.6rem 0;
    font-size: 0.85rem;
    opacity: 0.75;
}

.sai-key-reveal-value {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sai-key-reveal-value .filter-input {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
}

.sai-key-reveal-note {
    margin: 0.6rem 0 0 0;
    font-size: 0.8rem;
    opacity: 0.7;
}
