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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: #e0e0e0;
}

.container {
    width: 100%;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 8px;
}

h1 {
    font-size: 24px;
    color: #4fc3f7;
}

.connection-status {
    display: flex;
    gap: 10px;
    align-items: center;
}

#status {
    padding: 8px 16px;
    border-radius: 4px;
    background: #d32f2f;
    color: white;
    font-weight: bold;
}

#status.connected {
    background: #388e3c;
}

button {
    padding: 8px 16px;
    background: #4fc3f7;
    border: none;
    border-radius: 4px;
    color: #1a1a1a;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}

button:hover {
    background: #81d4fa;
}

main {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    gap: 20px;
}

.world-view {
    position: relative;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#world-canvas {
    display: block;
    border: 2px solid #424242;
    background: #1a1a1a;
    width: 100%;
    height: calc(100vh - 200px);
    cursor: move;
}

.viewport-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.viewport-controls button {
    padding: 5px 15px;
    min-width: 40px;
}

.viewport-controls span {
    color: #81d4fa;
    font-size: 12px;
}

.hover-info {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    display: none;
    z-index: 100;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: calc(100vh - 140px);
    overflow-y: auto;
}

.sidebar-left {
    grid-column: 1;
}

.sidebar-right {
    grid-column: 3;
}

.stats-panel, .surveillance-panel, .agent-info-panel, .agent-log-panel, .event-log, .narrator-panel {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s ease;
}

.stats-panel.collapsed, 
.surveillance-panel.collapsed, 
.agent-info-panel.collapsed, 
.agent-log-panel.collapsed, 
.event-log.collapsed,
.narrator-panel.collapsed {
    padding: 8px 15px;
}

.surveillance-panel {
    flex: 0 0 auto;
}

.agent-info-panel {
    flex: 0 0 auto;
}

.agent-info-panel h2 {
    margin-bottom: 15px;
}

.agent-info-section {
    margin-bottom: 15px;
}

.agent-info-section h3 {
    font-size: 12px;
    color: #4a9eff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-content {
    background: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    color: #ccc;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.info-content:empty::before {
    content: '(empty)';
    color: #666;
    font-style: italic;
}

.agent-log-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.agent-log-panel.collapsed {
    flex: 0 0 auto;
}

.agent-log-panel .collapsible-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.agent-log-info {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    font-style: italic;
    flex-shrink: 0;
}

#agent-log-list {
    flex: 1;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.5;
    min-height: 0;
}

#agent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-item {
    padding: 10px;
    background: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #4fc3f7;
    cursor: pointer;
    font-size: 12px;
}

.agent-item:hover {
    background: #333;
}

.agent-item.active {
    border-left-color: #ff9800;
    background: #333;
}

h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #4fc3f7;
    border-bottom: 2px solid #424242;
    padding-bottom: 10px;
}

.collapsed h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* Collapsible sections */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-header:hover {
    color: #81d4fa;
}

.collapse-icon {
    font-size: 14px;
    display: inline-block;
    transition: transform 0.2s;
}

.collapsible-content {
    display: block;
}

.collapsible.collapsed .collapsible-content {
    display: none;
}

#world-stats p {
    margin: 8px 0;
    font-size: 14px;
}

#world-stats span {
    color: #81d4fa;
    font-weight: bold;
}

.event-log {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.event-log.collapsed {
    flex: 0 0 auto;
}

.event-log .collapsible-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#event-list {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
    min-height: 0;
}

.event-item {
    padding: 8px;
    margin: 4px 0;
    background: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #4fc3f7;
}

.event-item.combat {
    border-left-color: #f44336;
}

.event-item.death {
    border-left-color: #9c27b0;
}

.event-item.spawn {
    border-left-color: #4caf50;
}

/* Agent log entries */
.log-entry {
    padding: 8px;
    margin: 4px 0;
    background: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #666;
    font-size: 11px;
}

.log-entry.obs {
    border-left-color: #2196f3;
}

.log-entry.decision {
    border-left-color: #ff9800;
}

.log-entry.result {
    border-left-color: #4caf50;
}

.log-entry.failed {
    border-left-color: #f44336;
    background: #2a1a1a;
}

.log-entry .log-phase {
    font-weight: bold;
    color: #81d4fa;
    margin-bottom: 4px;
}

.log-entry .log-reasoning {
    color: #ffb74d;
    font-style: italic;
    margin: 4px 0;
}

.log-entry .log-action {
    color: #4caf50;
    font-family: monospace;
}

.log-entry .log-error {
    color: #f44336;
    font-weight: bold;
}

.log-entry .log-stats {
    color: #999;
    font-size: 10px;
}

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

.modal-content {
    background-color: #1e1e1e;
    margin: 2% auto;
    padding: 0;
    border: 1px solid #444;
    width: 90%;
    max-width: 1200px;
    border-radius: 8px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    background-color: #2a2a2a;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #81d4fa;
}

.modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.prompt-section {
    margin-bottom: 30px;
}

.prompt-section h3 {
    color: #ffb74d;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.prompt-section pre {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 15px;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

#view-prompt-btn {
    padding: 5px 10px;
    font-size: 12px;
    background: #1e88e5;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#view-prompt-btn:hover {
    background: #1976d2;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    padding: 8px 20px;
    background: #1a1a1a;
    border: 2px solid #424242;
    color: #81d4fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.tab-btn:hover {
    background: #2a2a2a;
    border-color: #4fc3f7;
}

.tab-btn.active {
    background: #4fc3f7;
    color: #1a1a1a;
    border-color: #4fc3f7;
}

.tab-btn.blog-link {
    border-color: #81d4fa;
    opacity: 0.85;
}

.tab-btn.blog-link:hover {
    opacity: 1;
    border-color: #4fc3f7;
    background: #2a2a2a;
}

.tab-content {
    width: 100%;
}

/* Actions Reference */
.actions-reference {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.actions-reference h2 {
    font-size: 28px;
    color: #4fc3f7;
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 3px solid #424242;
    padding-bottom: 15px;
}

.action-card {
    background: #2a2a2a;
    border-left: 4px solid #4fc3f7;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.action-card:hover {
    background: #333;
    border-left-color: #81d4fa;
    transform: translateX(5px);
}

.action-card h3 {
    font-size: 20px;
    color: #ff9800;
    margin-bottom: 12px;
    font-family: 'Courier New', monospace;
}

.action-args {
    background: #1a1a1a;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    border-left: 3px solid #4fc3f7;
}

.action-args strong {
    color: #4fc3f7;
    font-weight: bold;
    margin-right: 8px;
}

.action-args code {
    color: #81d4fa;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: #0a0a0a;
    padding: 2px 6px;
    border-radius: 3px;
}

.action-description {
    margin: 0;
    line-height: 1.6;
    font-size: 14px;
    color: #e0e0e0;
    padding-top: 4px;
}
/* ============================================
   ARCHAEOLOGY TAB
   ============================================ */

.archaeology-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 180px);
}

.archaeology-sidebar {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.archaeology-sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #4fc3f7;
}

.archaeology-runs-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.archaeology-run-card {
    background: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.archaeology-run-card:hover {
    border-color: #4fc3f7;
    background: #252525;
}

.archaeology-run-card.selected {
    border-color: #4fc3f7;
    background: #2a3a4a;
}

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

.run-status {
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.status-ongoing {
    background: #388e3c;
    color: white;
}

.status-ended {
    background: #5a5a5a;
    color: #d0d0d0;
}

.run-id {
    font-size: 11px;
    color: #888;
    font-family: monospace;
}

.run-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.stat {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.stat-label {
    color: #888;
}

.stat-value {
    color: #4fc3f7;
    font-weight: bold;
}

.run-time {
    font-size: 12px;
    color: #888;
    border-top: 1px solid #3a3a3a;
    padding-top: 8px;
    margin-top: 8px;
}

.run-time div {
    margin-bottom: 4px;
}

.run-summary {
    margin-top: 10px;
    padding: 10px;
    background: #2a2a2a;
    border-left: 3px solid #4fc3f7;
    font-size: 13px;
    font-style: italic;
    color: #d0d0d0;
}

.archaeology-main {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.archaeology-welcome {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #888;
    text-align: center;
}

.archaeology-welcome h2 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #4fc3f7;
}

.archaeology-welcome p {
    font-size: 16px;
    margin-bottom: 10px;
    max-width: 500px;
}

.run-details-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.run-details-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #4fc3f7;
    border-bottom: 2px solid #3a3a3a;
    padding-bottom: 8px;
}

.run-events-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.turn-group {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
}

.turn-group h4 {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: #252525;
}

.event-attack {
    border-left: 3px solid #f44336;
}

.event-death {
    border-left: 3px solid #9c27b0;
}

.event-birth {
    border-left: 3px solid #4caf50;
}

.event-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.event-text {
    font-size: 14px;
    color: #e0e0e0;
}

.event-text strong {
    color: #4fc3f7;
}

.run-lifespans-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lifespan-item {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    border-left: 3px solid #4fc3f7;
}

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

.lifespan-header strong {
    font-size: 16px;
    color: #4fc3f7;
}

.lifespan-duration {
    font-size: 13px;
    color: #888;
    background: #252525;
    padding: 4px 8px;
    border-radius: 4px;
}

.lifespan-details {
    font-size: 13px;
    color: #d0d0d0;
}

.lifespan-details div {
    margin-bottom: 5px;
}

.no-runs, .no-events, .no-agents, .error, .loading {
    padding: 20px;
    text-align: center;
    color: #888;
    font-style: italic;
}

.error {
    color: #f44336;
}

/* ============================================
   NARRATOR PANEL
   ============================================ */

.narrator-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.narrator-panel.collapsed {
    flex: 0 0 auto;
}

.narrator-panel .collapsible-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.narrator-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 10px;
    background: #1a1a1a;
    border-radius: 4px;
}

.narrator-placeholder {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.narrator-entry {
    margin-bottom: 15px;
    padding: 15px;
    background: #2a2a2a;
    border-left: 4px solid #4fc3f7;
    border-radius: 4px;
    min-height: 70px;
}

.narrator-turn {
    font-size: 12px;
    color: #4fc3f7;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.narrator-text {
    font-size: 15px;
    line-height: 1.7;
    color: #ffffff !important;
    font-weight: 400;
    min-height: 40px;
    display: block;
}

.narrator-loading {
    color: #888;
    font-style: italic;
    padding: 10px;
    text-align: center;
}
