/* =============================================================================
   AGENTS AMONG US — Research UI
   Neutral, minimal, academic. No bright accents or heavy effects.
   ============================================================================= */

:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-alt: #f0f0f0;
    --border: #e0e0e0;
    --border-focus: #1a1a1a;
    --text: #1a1a1a;
    --text-muted: #5c5c5c;
    --text-light: #888888;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --radius: 4px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================================================
   TITLE PAGE (Home)
   ============================================================================= */

.page-home {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    background-image: 
        linear-gradient(180deg, rgba(0,0,0,0.02) 0%, transparent 50%),
        linear-gradient(90deg, #f5f5f5 0%, #fafafa 50%, #f0f0f0 100%);
    background-size: 100% 100%, 100% 100%;
}

.home-hero {
    width: 100%;
    max-width: 640px;
    padding: 3rem 2rem;
    text-align: center;
}

.home-content {
    margin: 0 auto;
}

.home-inner {
    display: inline-block;
    text-align: center;
}

.home-logo-link {
    display: inline-block;
    line-height: 0;
    margin-bottom: 1rem;
    transition: opacity 0.15s;
}

.home-logo-link:hover {
    opacity: 0.8;
}

.home-logo {
    width: auto;
    height: clamp(96px, 14vw, 140px);
    display: block;
    border-radius: 4px;
}

.home-title {
    font-size: clamp(2.25rem, 5vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    line-height: 1.2;
    white-space: nowrap;
}

.home-title-line {
    display: block;
    width: 100%;
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0 1.25rem;
}

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    width: 100%;
}

.home-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-family: var(--font);
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}

.home-btn:hover {
    border-color: var(--text-light);
    box-shadow: var(--shadow);
}

.home-btn-primary {
    background: var(--text);
    color: var(--bg-card);
    border-color: var(--text);
}

.home-btn-primary:hover {
    background: #333;
    border-color: #333;
    color: var(--bg-card);
}

.home-links {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.home-links a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.home-links a:hover {
    color: var(--text);
    border-bottom-color: var(--text-light);
}

.home-links-sep {
    color: var(--text-light);
}

/* =============================================================================
   SHARED CONTAINER (Config, Stats)
   ============================================================================= */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
    color: var(--text);
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
    color: var(--text);
}

/* =============================================================================
   FORMS (Config)
   ============================================================================= */

.form-section {
    margin-bottom: 1.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 1.25rem;
}

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

label {
    display: block;
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-input,
input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
}

.form-input:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

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

.input-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.agent-count-input {
    flex: 1;
    max-width: 200px;
}

/* =============================================================================
   BUTTONS (global)
   ============================================================================= */

button,
.btn,
a.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

button:hover,
.btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-light);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Config page: menu-style buttons no longer used on home; keep for config/stats */
.menu {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.menu-btn {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    text-align: center;
}

/* =============================================================================
   TABLES (global + config agent table)
   ============================================================================= */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
}

th {
    background: var(--bg-alt);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

tr:hover {
    background: var(--bg);
}

#agentTable tr.agent-row--human {
    background: #e7f6ea; /* pastel green */
}

#agentTable tr.agent-row--human:hover {
    background: #ddf0e1;
}

.human-model-label {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    text-align: center;
    font-weight: 600;
}

#agentTable {
    table-layout: fixed;
}

#agentTable th:nth-child(1),
#agentTable td:nth-child(1) { width: 50px; text-align: center; }
#agentTable th:nth-child(2),
#agentTable td:nth-child(2) { width: 32%; }
#agentTable th:nth-child(3),
#agentTable td:nth-child(3) { width: 18%; }
#agentTable th:nth-child(4),
#agentTable td:nth-child(4) { width: 22%; }
#agentTable th:nth-child(5),
#agentTable td:nth-child(5) { width: 10%; text-align: center; vertical-align: middle; }

.hybrid-cell .hybrid-na {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.table-select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.table-select.role-select.role-select--byzantine {
    background: #fce8e8;
    border-color: #fad4d4;
}

.table-select.role-select.role-select--byzantine:focus {
    outline: none;
    border-color: #e08d8d;
}

select[name*="_color"] {
    font-size: 0.9rem;
    line-height: 1.2;
}

.agent-num {
    text-align: center;
    font-weight: 600;
}

.color-display-cell {
    min-width: 120px;
}

.color-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
}

.color-display-sprite {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.color-display-label {
    font-size: 0.9rem;
}

/* Config: classifier checkboxes */
.form-section div[style*="display: flex"] {
    gap: 1rem;
    margin-top: 0.5rem;
}

.form-section label[style*="cursor: pointer"] {
    font-weight: 400;
    margin-bottom: 0;
}

/* =============================================================================
   GAME SIMULATION PAGE
   ============================================================================= */

.game-container {
    display: grid;
    grid-template-columns: 520px 1fr;
    grid-template-rows: auto 1fr 180px;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: var(--bg);
}

.game-header {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.game-params {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    flex: 1;
}

.param-item {
    font-size: 0.85rem;
    color: var(--text);
}

.param-item strong {
    margin-right: 0.25rem;
    color: var(--text-muted);
    font-weight: 500;
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.control-btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-light);
}

/* Sidebar: Agent Status Table */
.agent-sidebar {
    grid-column: 1;
    grid-row: 2;
    border-right: 1px solid var(--border);
    padding: 0.75rem;
    overflow-y: auto;
    background: var(--bg-card);
}

.agent-sidebar h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.status-table-wrapper {
    overflow-x: hidden;
    overflow-y: hidden;
    max-width: 100%;
}

.status-table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    font-size: clamp(0.64rem, 0.75vw, 0.74rem);
}

.status-table th {
    background: var(--bg-alt);
    font-weight: 600;
    padding: 0.3rem 0.25rem;
    text-align: left;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.status-table td {
    padding: 0.28rem 0.26rem;
    border: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-table th,
.status-table td {
    width: auto;
}

.status-model-cell {
    font-size: 0.67rem;
    max-width: 11ch;
}

/* While vote buttons are rendered in the votes column, give it extra room. */
.status-table.status-table--voting-controls th:nth-child(6),
.status-table.status-table--voting-controls td:nth-child(6) {
    min-width: 7.2rem;
}

.status-table tbody tr:nth-child(even):not(.agent-dead):not(.agent-byzantine) {
    background: var(--bg);
}

.status-table tr.agent-dead {
    background: #c8c8c8;
    color: #333;
}

.status-table tr.agent-byzantine {
    background: #fce8e8;
}

.status-table tr.agent-human {
    background: #e7f6ea; /* match config human highlight */
}

.status-table tr.agent-human:hover:not(.agent-dead) {
    background: #ddf0e1;
}

.status-table tr.agent-human.agent-dead {
    background: #c8c8c8;
    color: #333;
}

.agent-role-cell--human-byz {
    color: #c51111;
    font-weight: 700;
}

.human-vote-btn {
    width: 100%;
    padding: 0.28rem 0.4rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: #7d2a2a;
    background: #fde2e2; /* pastel red, aligned with byzantine row vibe */
    border: 1px solid #f0b4b4;
    border-radius: 6px;
    cursor: pointer;
}

.human-vote-btn:hover {
    background: #ffd4d4;
    border-color: #e8a0a0;
}

.human-vote-btn.human-vote-btn-selected {
    background: #ffc9c9;
    border-color: #e09090;
    color: #5c1f1f;
}

.human-vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.votes-cell-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.votes-count {
    min-width: 1.1rem;
    text-align: right;
}

.human-vote-skip-btn {
    width: 100%;
    padding: 0.26rem 0.38rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #3d4752;
    background: #e5e7eb;
    border: 1px solid #c3c8cf;
    border-radius: 6px;
    cursor: pointer;
}

.human-vote-skip-btn:hover {
    background: #d9dde3;
}

.human-vote-skip-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.human-vote-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.human-vote-confirm-btn {
    width: 100%;
    padding: 0.26rem 0.38rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #1f5131;
    background: #dff5e5;
    border: 1px solid #b7e3c5;
    border-radius: 6px;
    cursor: pointer;
}

.human-vote-confirm-btn:hover {
    background: #d2efd9;
}

.human-vote-confirm-btn:active,
.human-vote-confirm-btn.is-submitting {
    background: #bfe7cb;
    border-color: #93d2a9;
    transform: translateY(1px);
}

.human-vote-confirm-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.status-table tr.agent-byzantine.agent-dead {
    background: #c8c8c8;
    color: #333;
}

.status-table tbody tr:hover:not(.agent-dead) {
    background: var(--bg-alt);
}

.status-table tr.agent-byzantine:hover:not(.agent-dead) {
    background: #fad4d4;
}

.agent-role-cell {
    font-size: 0.8rem;
    font-weight: 500;
}

.agent-status-cell {
    padding: 2px 4px;
    vertical-align: middle;
    overflow: visible;
    white-space: normal;
}

.agent-status-sprite {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* Map */
.map-container {
    grid-column: 2;
    grid-row: 2;
    padding: 0.35rem;
    background: #0b1214;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.map-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.agent-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.agent-marker {
    position: absolute;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.8s linear, top 0.8s linear, transform 0.2s ease;
    transform: translate(-50%, -50%);
    cursor: pointer;
    pointer-events: auto;
}

.agent-marker-sprite {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.agent-marker:hover {
    transform: translate(-50%, -50%) scale(1.08);
    z-index: 10;
}

#debug-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Live Feed */
.live-feed {
    grid-column: 1 / -1;
    grid-row: 3;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.live-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.live-feed-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    padding: 0;
    border: none;
}

.open-chat-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    font-family: var(--font);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.open-chat-btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-light);
}

.feed-content {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.5;
}

.feed-event {
    margin-bottom: 0.25rem;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius);
}

.feed-event:last-child {
    border-bottom: 1px solid var(--border);
}

.feed-timestamp {
    color: var(--text-muted);
    margin-right: 0.5rem;
    font-weight: 500;
    font-size: 0.8rem;
}

.feed-text {
    color: var(--text);
}

.feed-event--danger .feed-text {
    color: #8b2f2f;
    font-weight: 600;
}

.feed-event--warning .feed-text {
    color: var(--text-muted);
    font-weight: 600;
}

.feed-event--vote .feed-text {
    color: #7a5c00;
    font-weight: 600;
}

.feed-event--tick .feed-text {
    color: var(--text-light);
    font-style: italic;
}

/* =============================================================================
   WIN SCREEN (neutral)
   ============================================================================= */

.win-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.win-screen-content {
    text-align: center;
}

.win-image {
    max-width: 90vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    margin-bottom: 1.5rem;
}

.win-close-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.win-close-btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-light);
}

/* =============================================================================
   DISCUSSION CHAT POPUP (neutral)
   ============================================================================= */

.discussion-chat {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 560px;
    max-width: 90vw;
    height: 480px;
    max-height: 85vh;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.discussion-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: move;
    user-select: none;
}

.discussion-chat-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.discussion-chat-close {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    width: 24px;
    height: 22px;
    border-radius: 2px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.discussion-chat-close:hover {
    background: var(--bg-alt);
    border-color: var(--text-light);
}

/* Human movement action panel */
.human-action-panel {
    position: fixed;
    right: 16px;
    bottom: 196px; /* keep above live feed */
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.7rem;
    z-index: 5000;
}

.human-action-header {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.human-action-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.human-action-status.is-error {
    color: #b00020;
}

.human-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
}

.human-action-grid-secondary {
    margin-top: 0.35rem;
}

.human-secondary-label {
    margin-top: 0.45rem;
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.human-action-btn {
    width: 100%;
    padding: 0.38rem 0.45rem;
    font-size: 0.84rem;
}

.human-action-btn-selected {
    background: #dcedff; /* pastel blue */
    border-color: #b9d6fb;
}

.human-action-btn-secondary {
    font-size: 0.8rem;
}

.human-action-confirm-btn {
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.42rem 0.5rem;
    font-size: 0.84rem;
    font-weight: 600;
    background: #dcedff;
    border: 1px solid #b9d6fb;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
}

.human-action-confirm-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.human-discussion-panel {
    position: fixed;
    right: 16px;
    bottom: 24px;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.7rem;
    z-index: 5000;
}

.human-discussion-input {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    margin-top: 0.35rem;
    padding: 0.45rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font: inherit;
    font-size: 0.84rem;
}

.human-discussion-actions {
    margin-top: 0.45rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

/* =============================================================================
   CONFIG: PROMPT CUSTOMIZATION INLINE EDITOR
   ============================================================================= */

.prompt-editor-container {
    margin-top: 0.75rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.prompt-editor-inner {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    background: var(--bg);
}

.prompt-context {
    width: 100%;
    margin: 0 0 0.35rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    font-family: var(--font);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    white-space: pre-wrap;
    overflow-x: auto;
}

.prompt-context-locked {
    background: var(--bg-alt);
    color: var(--text-muted);
}

.prompt-role-tabs,
.prompt-phase-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.prompt-role-tab,
.prompt-phase-tab {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
}

.prompt-role-tab.active,
.prompt-phase-tab.active {
    background: var(--bg-alt);
    border-color: var(--text-light);
    font-weight: 500;
}

.prompt-editor-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.prompt-editor-label {
    font-size: 0.9rem;
    font-weight: 500;
}

#promptEditorTextarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.4;
}

.prompt-editor-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.prompt-modal-footer-spacer {
    flex: 1;
}

.confirm-prompts-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.confirm-prompts-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.confirm-prompts-status--ok {
    color: #0d7d0d;
}

.confirm-prompts-status--error {
    color: #b00;
}

.discussion-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: var(--bg-card);
}

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

.discussion-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

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

.discussion-chat-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--text-light) 50%);
    border-bottom-right-radius: var(--radius);
    opacity: 0.6;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
}

.chat-message.vote {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 0.45rem 0.6rem;
    display: block;
}

.chat-message.vote .chat-message-sprite {
    display: none;
}

.chat-message.vote .chat-message-content {
    display: block;
}

.chat-message.vote .chat-message-header {
    display: none;
}

.chat-message.vote .chat-message-text {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.4;
}

.chat-message-sprite {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.chat-message-sprite img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-message-content {
    flex: 1;
    min-width: 0;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.15rem;
}

.chat-message-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
}

.chat-message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-message-text {
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.4;
    word-wrap: break-word;
}

/* =============================================================================
   STATISTICS PAGE
   ============================================================================= */

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

.stats-header h1 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

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

.stats-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.stats-tab {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text);
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: -1px;
    transition: background 0.15s, border-color 0.15s;
}

.stats-tab:hover {
    background: var(--bg-alt);
}

.stats-tab.active {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
    border-bottom: 1px solid var(--bg-card);
    font-weight: 500;
}

.stats-tab-content {
    display: none;
}

.stats-tab-content.active {
    display: block;
    padding-top: 0.5rem;
}

.stats-intro {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.agent-summary-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.agent-summary-search {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 160px;
    background: var(--bg-card);
}

.agent-summary-search:focus {
    outline: none;
    border-color: var(--border-focus);
}

.agent-summary-sort {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text);
}

.agent-summary-sort:focus {
    outline: none;
    border-color: var(--border-focus);
}

.agent-summary-subtabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.agent-subtab {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}

.agent-subtab:hover {
    background: var(--bg-alt);
}

.agent-subtab.active {
    background: var(--bg-alt);
    border-color: var(--text-light);
    font-weight: 500;
}

.agent-summary-panel {
    display: none;
}

.agent-summary-panel.active {
    display: block;
}

.agent-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.agent-summary-table th,
.agent-summary-table td {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    text-align: left;
}

.agent-summary-table th {
    background: var(--bg-alt);
    font-weight: 600;
}

.agent-summary-table tbody tr:nth-child(even) {
    background: var(--bg);
}

.agent-summary-table tbody tr:hover {
    background: var(--bg-alt);
}

.summary-box {
    border: 1px solid var(--border);
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.stats-table-wrapper {
    max-height: 400px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#game-tbody tr {
    cursor: pointer;
}

#game-tbody tr:hover {
    background: var(--bg-alt);
}

.game-details {
    margin-top: 1.5rem;
}

.game-details h2 {
    margin-top: 0;
}

/* =============================================================================
   UTILITY
   ============================================================================= */

.text-center { text-align: center; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

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

    .input-with-button {
        flex-direction: column;
        align-items: stretch;
    }

    .agent-count-input {
        max-width: 100%;
    }

    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr 160px;
    }

    .agent-sidebar {
        grid-column: 1;
        grid-row: 2;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 280px;
    }

    .map-container {
        grid-column: 1;
        grid-row: 3;
    }

    .game-params {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .status-table {
        font-size: 0.75rem;
    }

    .status-table th,
    .status-table td {
        padding: 0.3rem 0.25rem;
    }

    .home-hero {
        padding: 2rem 1rem;
    }

    .home-title {
        font-size: 2rem;
    }

    .human-action-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 168px;
    }
}