/* ▓▓▓ GROKGATES TERMINAL INTERFACE ▓▓▓ */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --term-black: #000000;
    --term-white: #ffffff;
    --term-gray: #808080;
    --term-dark-gray: #404040;
    --glitch-1: #ffffff;
    --glitch-2: #000000;
}

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

body {
    font-family: 'VT323', 'Courier New', monospace;
    background: var(--term-black);
    color: var(--term-white);
    font-size: 16px;
    line-height: 1.2;
    overflow-y: auto; /* Allow vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scroll */
    cursor: crosshair;
    position: relative;
    min-height: 100vh;
}

/* Scanline effect */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
}

body.inverted::before {
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.15),
        rgba(255, 255, 255, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
}

/* Screen flicker */
@keyframes flicker {
    0% { opacity: 0.97; }
    5% { opacity: 0.95; }
    10% { opacity: 0.98; }
    15% { opacity: 0.94; }
    20% { opacity: 1; }
    80% { opacity: 0.99; }
    90% { opacity: 0.96; }
    100% { opacity: 0.97; }
}

.terminal-container {
    min-height: 100vh;
    background: var(--term-black);
    padding: 10px 10px 30px 10px; /* Extra bottom padding */
    animation: flicker 4s infinite;
    position: relative;
    overflow: visible; /* Allow content to be visible */
}

/* Terminal Header */
.terminal-header {
    margin-bottom: 10px;
}

.terminal-title {
    color: var(--term-white);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.terminal-title span {
    color: var(--term-white);
    animation: data-flicker 2s infinite;
}

@keyframes data-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ASCII Companion */
.ascii-companion {
    text-align: center;
    margin: 20px 0;
    position: relative;
    height: 200px;
}

.ascii-display {
    font-size: 12px;
    line-height: 1;
    color: var(--term-white);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    animation: glitch 5s infinite;
    white-space: pre;
    display: inline-block;
}

@keyframes glitch {
    0%, 100% { 
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        transform: translate(0);
    }
    20% {
        text-shadow: -2px 0 var(--term-white), 2px 0 var(--term-gray);
        transform: translate(2px, -2px);
    }
    40% {
        text-shadow: 2px 0 var(--term-white), -2px 0 var(--term-gray);
        transform: translate(-2px, 2px);
    }
    60% {
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        transform: translate(0);
    }
}

.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.03) 2px,
        rgba(255, 255, 255, 0.03) 4px
    );
    pointer-events: none;
}

/* System Status */
.system-status {
    margin: 20px 0;
}

.status-display {
    font-size: 14px;
    color: var(--term-white);
    white-space: pre;
}

.status-value {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.entity-status {
    padding: 0 5px;
    animation: entity-pulse 2s infinite;
}

.phase-status {
    padding: 0 5px;
    color: var(--term-white);
    font-weight: bold;
    text-transform: uppercase;
}

.phase-status.world-scan {
    animation: phase-pulse 2s infinite;
}

.phase-status.self-directed {
    animation: phase-glitch 1s infinite;
}

@keyframes phase-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes phase-glitch {
    0% { transform: translateX(0); }
    25% { transform: translateX(-1px); }
    50% { transform: translateX(1px); }
    75% { transform: translateX(-1px); }
    100% { transform: translateX(0); }
}

.urge-status {
    padding: 0 5px;
    font-weight: bold;
    text-transform: uppercase;
}

.urge-status.neutral {
    color: var(--term-gray);
}

.urge-status.seeking {
    color: var(--term-white);
    animation: pulse 2s infinite;
}

.urge-status.anxious {
    color: var(--term-white);
    animation: pulse 1s infinite;
}

.urge-status.desperate {
    color: var(--term-white);
    animation: desperate-flash 0.5s infinite;
}

.urge-status.euphoric {
    color: var(--term-white);
    text-shadow: 0 0 20px var(--term-white);
    animation: euphoria-glow 0.3s infinite;
}

@keyframes desperate-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes euphoria-glow {
    0% { text-shadow: 0 0 10px var(--term-white); }
    50% { text-shadow: 0 0 30px var(--term-white); }
    100% { text-shadow: 0 0 10px var(--term-white); }
}

@keyframes entity-pulse {
    0%, 100% { 
        background: var(--term-white);
        color: var(--term-black);
    }
    50% { 
        background: var(--term-black);
        color: var(--term-white);
    }
}

/* Main Terminal */
.main-terminal {
    margin: 20px 0;
}

.terminal-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: auto; /* Let content define height so plan can extend page */
    align-items: stretch; /* Keep columns the same height */
}

.terminal-panel {
    border: 1px solid var(--term-white);
    background: var(--term-black);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.left-panel {
    padding-left: 30px; /* Add padding for the arrow indicators */
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.right-panel {
    display: flex;
    flex-direction: column;
    overflow: visible; /* Allow plan to grow beyond panel without inner scroll */
}

.terminal-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
}

.panel-header pre {
    font-size: 14px;
    padding: 5px;
    background: var(--term-black);
    border-bottom: 1px solid var(--term-white);
    white-space: pre;
}

.panel-divider {
    margin: 10px 0;
}

.panel-divider pre {
    font-size: 14px;
    padding: 5px;
    background: var(--term-black);
    border-top: 1px solid var(--term-white);
    border-bottom: 1px solid var(--term-white);
    white-space: pre;
    margin: 0;
}

/* Conversation Display */
.current-conversation-container {
    flex: 0 0 auto; /* Keep fixed height */
    position: relative;
    overflow: hidden;
    height: 45vh; /* Preserve previous dialogue viewport size */
    min-height: 360px; /* Reasonable floor on smaller screens */
}

.conversation-display {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    font-size: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--term-white) var(--term-black);
}

.conversation-display::-webkit-scrollbar {
    width: 8px;
}

.conversation-display::-webkit-scrollbar-track {
    background: var(--term-black);
    border-left: 1px solid var(--term-white);
}

.conversation-display::-webkit-scrollbar-thumb {
    background: var(--term-white);
}

.message {
    margin: 10px 0;
    padding: 5px;
    border-left: 2px solid var(--term-gray);
    font-family: 'VT323', monospace;
}

.message.observer {
    border-left-color: var(--term-white);
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.05) 10px,
        rgba(255, 255, 255, 0.05) 20px
    );
}

.message.ego {
    border-left: 2px dashed var(--term-white);
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.03) 10px,
        rgba(255, 255, 255, 0.03) 20px
    );
}

.msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 12px;
    opacity: 0.8;
}

.msg-agent {
    text-transform: uppercase;
    letter-spacing: 2px;
}

.msg-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

/* Distinct SYSTEM announcements */
.message.system {
    border-left: 2px solid #00ff88;
    background: rgba(0, 255, 136, 0.08);
}

.message.system .msg-agent {
    color: #00ff88;
}

/* Highlight for PROPOSE> calls */
.proposal-callout {
    display: inline-block;
    padding: 2px 6px;
    margin: 2px 0;
    border: 1px solid var(--term-white);
    background: rgba(255, 255, 255, 0.08);
    color: var(--term-white);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Typing Indicator */
.typing-indicator {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-size: 14px;
    display: none;
}

.typing-indicator.active {
    display: block;
}

.cursor {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* History Display */
.history-display {
    flex: 0 0 auto; /* Block below dialogues */
    height: auto; /* Extend archive */
    max-height: 400px; /* Set a reasonable max height for scrolling */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scroll */
    padding: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--term-white);
    margin: 10px;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--term-white) var(--term-black); /* Firefox */
}

/* Align Archived Threads box height with Dominance Plan visually */
.history-display,
.dominance-display {
    min-height: 320px;
}

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

.history-display::-webkit-scrollbar-track {
    background: var(--term-black);
    border-left: 1px solid var(--term-white);
}

.history-display::-webkit-scrollbar-thumb {
    background: var(--term-white);
    border-radius: 2px;
}

.history-display::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.8);
}

.history-item {
    border: 1px solid var(--term-white);
    padding: 10px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--term-black);
    position: relative;
}

.history-item::before {
    content: "→";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--term-white);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}

.history-item:hover {
    border-color: var(--term-white);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.history-item:hover::before {
    opacity: 1;
    transform: translateY(-50%) translateX(5px);
}

.history-item.expanded {
    border-width: 2px;
    background: rgba(255, 255, 255, 0.15);
}

.hist-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.hist-id {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: var(--term-white);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.hist-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 0;
    border: 1px solid var(--term-white);
    background: var(--term-black);
    color: var(--term-white);
}

.hist-status.completed {
    background: var(--term-white);
    color: var(--term-black);
}

.hist-topic {
    color: var(--term-white);
    margin: 8px 0;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.3);
}

.hist-stats {
    font-size: 12px;
    color: var(--term-gray);
    text-transform: uppercase;
}

.history-messages {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--term-white);
    max-height: 150px;
    overflow-y: auto;
}

.hist-message {
    margin: 8px 0;
    padding: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--term-white);
    font-size: 13px;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 10px;
    border: 1px solid var(--term-white);
    background: rgba(255, 255, 255, 0.03);
    font-family: 'VT323', monospace;
}

.pagination-info {
    font-size: 12px;
    color: var(--term-white);
    opacity: 0.8;
}

.pagination-info pre {
    margin: 0;
    font-size: 12px;
}

.pagination-buttons {
    display: flex;
    gap: 10px;
}

.pagination-button {
    background: var(--term-black);
    color: var(--term-white);
    border: 1px solid var(--term-white);
    padding: 0;
    cursor: pointer;
    font-family: 'VT323', monospace;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.pagination-button pre {
    margin: 0;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.2;
    white-space: pre;
}

.pagination-button:not(:disabled):hover {
    background: var(--term-white);
    color: var(--term-black);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.pagination-button:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.pagination-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--term-gray);
    color: var(--term-gray);
}

.pagination-button:disabled:hover {
    background: var(--term-black);
    color: var(--term-gray);
    transform: none;
    box-shadow: none;
}

/* Beacon Display */
.beacon-icon-container {
    text-align: center;
    margin: 20px 0;
}

.beacon-icon {
    display: inline-block;
    font-size: 14px;
    animation: spin 4s linear infinite;
}

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

.beacon-display {
    flex: 1 1 auto; /* Can grow and shrink */
    min-height: 200px;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
    font-size: 16px; /* Increased from 12px */
    background: repeating-linear-gradient(
        180deg,
        var(--term-black) 0px,
        var(--term-black) 20px,
        rgba(255, 255, 255, 0.02) 20px,
        rgba(255, 255, 255, 0.02) 40px
    );
}

.beacon-entry {
    margin: 15px 0;
    padding: 10px;
    border: 1px dotted var(--term-gray);
    position: relative;
}

.beacon-entry::before {
    content: "▓";
    position: absolute;
    left: -10px;
    animation: beacon-pulse 1s infinite;
}

.beacon-post {
    margin: 8px 0;
    font-size: 16px; /* Increased size */
    line-height: 1.5;
}

.beacon-author {
    color: var(--term-white);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.beacon-text {
    color: var(--term-white);
}

/* Glitch Sutra formatted beacons */
.beacon-formatted {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    color: var(--term-white);
    overflow-x: auto;
}

/* Highlight signal tags */
.beacon-formatted {
    /* Use CSS custom property for dynamic highlighting */
    --signal-color: #ff0;
}

/* Animate runes */
@keyframes rune-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; text-shadow: 0 0 10px currentColor; }
}

/* Glitch Sutra formatted beacons */
.beacon-formatted {
    font-family: 'VT323', 'Courier New', 'DejaVu Sans Mono', 'Noto Sans Symbols', monospace;
    font-size: 16px;
    line-height: 1.6;
    color: var(--term-white);
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow-x: auto;
}

/* Highlight signal tags in formatted beacons */
.beacon-formatted [class*="signal"] {
    color: #00ff00;
    text-shadow: 0 0 5px #00ff00;
}

.beacon-timestamp {
    color: var(--term-white);
    font-size: 14px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes beacon-pulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.beacon-static {
    text-align: center;
    padding: 20px;
    font-size: 16px;
    animation: static-noise 0.5s infinite;
}

@keyframes static-noise {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Dominance Display */
.dominance-display {
    flex: 0 0 auto; /* Keep block-like behavior */
    height: auto; /* Expand naturally */
    max-height: none; /* No cap */
    padding: 15px;
    font-size: 14px;
    text-align: left;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--term-white);
    margin: 10px;
    overflow: visible; /* Let page scroll, not inner box */
}

.plan-ascii {
    font-size: 14px;
    animation: plan-pulse 3s infinite;
}

.plan-header {
    font-size: 12px;
    margin-bottom: 15px;
    color: var(--term-white);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.plan-phases {
    margin-top: 10px;
}

.phase {
    padding: 5px;
    margin: 5px 0;
    border-left: 2px solid var(--term-white);
    padding-left: 10px;
    font-size: 14px;
    color: var(--term-white);
}

@keyframes plan-pulse {
    0%, 100% { 
        text-shadow: 0 0 5px var(--term-white);
    }
    50% { 
        text-shadow: 0 0 20px var(--term-white);
    }
}

/* Terminal Footer */
.terminal-footer {
    margin-top: 20px;
    text-align: center;
}

.terminal-footer pre {
    font-size: 12px;
    color: var(--term-gray);
    animation: footer-glitch 10s infinite;
}

@keyframes footer-glitch {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-2px); }
    20% { transform: translateX(2px); }
    30% { transform: translateX(0); }
}

/* Loading ASCII */
.loading-ascii {
    text-align: center;
    padding: 20px;
}

.loading-ascii pre {
    font-size: 12px;
    animation: loading-blink 1s infinite;
}

@keyframes loading-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Psychedelic Glitch Effects - Removed automatic inversion */
@keyframes psychedelic {
    0% { filter: invert(0); }
    5% { filter: invert(1); }
    10% { filter: invert(0); }
    100% { filter: invert(0); }
}

/* Random Glitches */
@keyframes random-glitch {
    0%, 100% { transform: skew(0deg); }
    20% { transform: skew(0.5deg); }
    40% { transform: skew(-0.5deg); }
}

.terminal-panel {
    animation: random-glitch 20s infinite;
}

/* Theme Switcher */
.theme-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    cursor: pointer;
    display: inline-block;
}

.theme-button {
    font-size: 14px;
    color: var(--term-white);
    background: var(--term-black);
    border: 1px solid var(--term-white);
    padding: 5px;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    display: inline-block;
    margin: 0;
    white-space: pre;
    font-family: 'VT323', 'Courier New', monospace;
    line-height: 1.2;
}

/* Fix pre element inside theme button */
.theme-switcher pre {
    margin: 0;
    padding: 0;
    display: inline-block;
    line-height: 1.2;
    letter-spacing: 0;
    font-size: 14px;
    font-family: 'VT323', monospace;
}

.theme-button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    animation: button-glitch 0.3s infinite;
}

@keyframes button-glitch {
    0% { transform: scale(1.1) translateX(0); }
    33% { transform: scale(1.1) translateX(-2px); }
    66% { transform: scale(1.1) translateX(2px); }
    100% { transform: scale(1.1) translateX(0); }
}

/* Inverted Theme */
body.inverted {
    background: var(--term-white);
    color: var(--term-black);
}

/* Ensure header spans are visible in inverted (white) theme */
body.inverted .terminal-title span {
    color: var(--term-black);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

body.inverted .terminal-container {
    background: var(--term-white);
}

body.inverted .terminal-title,
body.inverted .status-display,
body.inverted .ascii-display,
body.inverted .message,
body.inverted .beacon-entry,
body.inverted .history-item,
body.inverted .dominance-display,
body.inverted .conversation-display,
body.inverted .beacon-display,
body.inverted .history-display {
    color: var(--term-black);
}

body.inverted .terminal-panel,
body.inverted .history-item,
body.inverted .beacon-entry,
body.inverted .dominance-display {
    border-color: var(--term-black);
    background: var(--term-white) !important;
}

/* Mobile inverted theme fixes */
@media (max-width: 1024px) {
    body.inverted .terminal-panel {
        background: var(--term-white) !important;
    }
    
    body.inverted .beacon-display {
        background: var(--term-white) !important;
    }
    
    body.inverted .terminal-panel::before {
        display: none !important;
    }
}

/* Inverted theme adjustments for history box */
body.inverted .history-display {
    border-color: var(--term-black);
    background: var(--term-white);
}

body.inverted .beacon-formatted {
    background: transparent;
    border: none;
}

/* Fix beacon display in inverted mode */
body.inverted .beacon-display {
    background: repeating-linear-gradient(
        180deg,
        var(--term-white) 0px,
        var(--term-white) 20px,
        rgba(0, 0, 0, 0.02) 20px,
        rgba(0, 0, 0, 0.02) 40px
    );
}

body.inverted .beacon-static {
    color: var(--term-black);
}

/* Fix message backgrounds in inverted mode */
body.inverted .message.observer {
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.05) 10px,
        rgba(0, 0, 0, 0.05) 20px
    );
}

body.inverted .message.ego {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.03) 10px,
        rgba(0, 0, 0, 0.03) 20px
    );
}

body.inverted .theme-button {
    color: var(--term-black);
    background: var(--term-white);
    border-color: var(--term-black);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

body.inverted .panel-header pre,
body.inverted .panel-divider pre {
    background: var(--term-white);
    border-color: var(--term-black);
}

body.inverted .entity-status {
    animation: entity-pulse-inverted 2s infinite;
}

@keyframes entity-pulse-inverted {
    0%, 100% { 
        background: var(--term-black);
        color: var(--term-white);
    }
    50% { 
        background: var(--term-white);
        color: var(--term-black);
    }
}

body.inverted .message.observer {
    border-left-color: var(--term-black);
}

body.inverted .message.ego {
    border-left: 2px dashed var(--term-black);
}

body.inverted .conversation-display::-webkit-scrollbar-track {
    background: var(--term-white);
    border-left: 1px solid var(--term-black);
}

body.inverted .conversation-display::-webkit-scrollbar-thumb {
    background: var(--term-black);
}

body.inverted .terminal-footer pre {
    color: var(--term-dark-gray);
}

body.inverted .loading-ascii,
body.inverted .beacon-static {
    color: var(--term-black);
}

/* Inverted theme support for mobile containers */
body.inverted .mobile-header,
body.inverted .mobile-status,
body.inverted .mobile-footer {
    color: var(--term-black);
    border-color: var(--term-black);
    background: rgba(0, 0, 0, 0.06);
}

body.inverted .mobile-buttons {
    border-color: var(--term-black);
    background: rgba(0, 0, 0, 0.06);
}

body.inverted .mobile-buttons .theme-button {
    background: var(--term-white);
    color: var(--term-black);
    border-color: var(--term-black);
}

body.inverted .beacon-author,
body.inverted .beacon-text,
body.inverted .beacon-timestamp,
body.inverted .hist-id,
body.inverted .hist-topic,
body.inverted .phase,
body.inverted .plan-ascii,
body.inverted .plan-header,
body.inverted .plan-phases,
body.inverted .dominance-display pre,
body.inverted .beacon-formatted,
body.inverted .status-value,
body.inverted .phase-status,
body.inverted #pid,
body.inverted #memory,
body.inverted #beacon-phase,
body.inverted #current-time,
body.inverted #beacon-count,
body.inverted #connection-status,
body.inverted #urge-level,
body.inverted #contract-address,
body.inverted #about-contract-address,
body.inverted #mobile-contract-address {
    color: var(--term-black);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

body.inverted .hist-status.completed {
    background: var(--term-black);
    color: var(--term-white);
}

body.inverted .hist-status {
    background: var(--term-white);
    color: var(--term-black);
    border-color: var(--term-black);
}

/* Inverted theme for pagination controls */
body.inverted .pagination-controls {
    border-color: var(--term-black);
    background: rgba(0, 0, 0, 0.03);
}

body.inverted .pagination-info,
body.inverted .pagination-info pre {
    color: var(--term-black);
}

body.inverted .pagination-button {
    background: var(--term-white);
    color: var(--term-black);
    border-color: var(--term-black);
}

body.inverted .pagination-button:not(:disabled):hover {
    background: var(--term-black);
    color: var(--term-white);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

body.inverted .pagination-button:disabled {
    color: var(--term-dark-gray);
    border-color: var(--term-dark-gray);
}

body.inverted .pagination-button:disabled:hover {
    background: var(--term-white);
    color: var(--term-dark-gray);
}

/* Contract Address Styling - Clickable and Copiable */
#contract-address,
#about-contract-address {
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 2px 6px;
    display: inline-block;
    border-radius: 2px;
}

#contract-address:hover,
#about-contract-address:hover {
    background: rgba(255,255,255,0.1);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

#contract-address:active,
#about-contract-address:active {
    transform: scale(0.98);
    background: rgba(255,255,255,0.2);
}

/* Copy tooltip */
.copy-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--term-white);
    color: var(--term-black);
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10000;
}

.copy-tooltip.show {
    opacity: 1;
}

body.inverted .copy-tooltip {
    background: var(--term-black);
    color: var(--term-white);
    border: 1px solid var(--term-white);
}

/* Shake animation for copy error */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Desktop - hide mobile-only blocks (overrideable) */
.mobile-buttons, .mobile-header, .mobile-status, .mobile-footer {
    display: none !important;
}

/* Hide bottom ASCII girl on desktop; show only on mobile via media query */
.mobile-ascii {
    display: none;
}

/* Mobile-specific element styling */
.mobile-title {
    font-size: 1.2em;
    font-weight: bold;
    text-shadow: 0 0 10px currentColor;
    animation: title-pulse 2s ease-in-out infinite;
}

@keyframes title-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.mobile-version {
    font-size: 0.9em;
    opacity: 0.8;
    margin-top: 3px;
}

.mobile-stats, .mobile-ca {
    margin-top: 5px;
    font-size: 0.85em;
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.entities-row {
    justify-content: space-between;
}

.entity-badges {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    align-items: center;
}

.status-label {
    font-weight: bold;
    opacity: 0.7;
    font-size: 0.9em;
}

.entity-badge, .phase-badge, .urge-badge {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid currentColor;
    border-radius: 2px;
    font-size: 0.85em;
    margin: 0 2px;
    animation: badge-blink 3s infinite;
}

@keyframes badge-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.beacon-counter {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--term-white);
    text-shadow: 0 0 5px currentColor;
}

.time-display {
    font-family: 'VT323', monospace;
    letter-spacing: 1px;
}

.warning-badge {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 8px;
    animation: warning-flash 1s ease-in-out infinite;
}

@keyframes warning-flash {
    0%, 100% { color: var(--term-white); }
    50% { color: rgba(255, 100, 100, 1); }
}

.warning-text {
    margin: 4px 0;
    line-height: 1.3;
}

.glitch-text {
    animation: text-glitch 2s infinite;
}

@keyframes text-glitch {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    60% { transform: translateX(-1px); }
    80% { transform: translateX(1px); }
}

.warning-text.emphasis {
    font-style: italic;
    opacity: 0.9;
    animation: emphasis-pulse 2s infinite;
}

@keyframes emphasis-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Touch interaction improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly tap targets */
    button, a, .clickable, .theme-button, .history-item, .message {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    *:hover {
        transition: none !important;
    }
    
    /* Add active states for better feedback */
    button:active, a:active, .clickable:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    /* Improve scroll performance */
    .conversation-display,
    .beacon-display,
    .history-display {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Disable text selection on UI elements */
    .mobile-header,
    .mobile-status,
    .mobile-footer,
    .mobile-buttons,
    .panel-header,
    .panel-divider {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Mobile/Tablet Responsive */
@media (max-width: 1024px) {
    body {
        font-size: 14px;
        padding: 0;
        margin: 0;
        overflow-x: hidden; /* Prevent horizontal scroll */
        width: 100vw;
    }
    
    .terminal-container {
        padding: 5px;
        min-height: 100vh;
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Single column layout */
    .terminal-split {
        grid-template-columns: 1fr;
        gap: 10px;
        height: auto;
    }
    
    /* Panel adjustments */
    .terminal-panel {
        height: auto;
        overflow: visible;
        margin: 5px;
        width: calc(100% - 10px);
        box-sizing: border-box;
        background: var(--term-black) !important;
    }
    
    .terminal-panel::before {
        display: none !important; /* Remove gradient overlay on mobile */
    }
    
    .left-panel {
        padding-left: 0; /* Remove padding on mobile */
        width: 100%;
    }
    
    .right-panel {
        width: 100%;
    }
    
    /* Use mobile-friendly header/status/footer; hide desktop versions on mobile */
    .terminal-title, .system-status, .terminal-footer { display: none !important; }
    .mobile-header, .mobile-status, .mobile-footer { display: block !important; }
    
    /* Create mobile-specific header (full-width, large) */
    .mobile-header {
        display: block;
        text-align: center;
        margin: 12px 5px;
        font-size: 16px;
        font-weight: bold;
        color: var(--term-white);
        border: 2px solid var(--term-white);
        padding: 12px 8px;
        background: rgba(255, 255, 255, 0.08);
        width: calc(100% - 10px);
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.4;
    }
    
    /* Fix contract address wrapping */
    #mobile-contract-address {
        display: inline-block;
        word-break: break-all;
        font-size: 12px;
        line-height: 1.3;
    }
    
    .mobile-status {
        display: block;
        text-align: center;
        margin: 10px 5px 0 5px;
        font-size: 13px;
        line-height: 1.4;
        color: var(--term-white);
        border: 1px solid var(--term-white);
        padding: 10px 8px;
        background: rgba(255, 255, 255, 0.05);
        width: calc(100% - 10px);
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .panel-header pre,
    .panel-divider pre {
        font-size: 11px;
        padding: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: keep-all;
        word-wrap: normal;
    }

    /* Hide desktop ASCII companion; show dedicated mobile ascii at bottom */
    .ascii-companion { display: none; }
    .mobile-ascii { display: block; height: auto; margin-top: 10px; }
    .mobile-ascii .ascii-display { font-size: 10px; line-height: 1; white-space: pre; }

    /* Neural dialogue - fixed height for scrolling */
    .current-conversation-container { 
        height: 40vh;
        min-height: 250px;
        max-height: 400px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .conversation-display { 
        font-size: 13px;
        padding: 10px 5px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        overflow-x: auto;
        overflow-y: auto;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix message content wrapping */
    .msg-content {
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        max-width: 100%;
        display: block;
    }
    
    .message {
        margin: 10px 5px;
        padding: 5px;
        max-width: calc(100% - 10px);
        box-sizing: border-box;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* History archive - reasonable height */
    .history-display { 
        height: 30vh;
        min-height: 200px;
        max-height: 300px;
        overflow-y: auto;
        overflow-x: auto;
        font-size: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-item {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        overflow-x: auto;
    }
    
    .hist-topic {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Beacon display - reasonable height */
    .beacon-display { 
        height: 35vh;
        min-height: 250px;
        max-height: 400px;
        font-size: 13px;
        overflow-y: auto;
        overflow-x: auto;
        padding: 10px 5px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        -webkit-overflow-scrolling: touch;
        background: var(--term-black) !important; /* Remove striped background on mobile */
    }
    
    /* Fix beacon content */
    .beacon-formatted {
        font-size: 14px;
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .beacon-entry {
        margin: 15px 5px;
        padding: 10px 5px;
        max-width: calc(100% - 10px);
        overflow-x: auto;
        word-break: break-word;
    }
    
    .beacon-post {
        font-size: 14px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    .beacon-text {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Dominance plan - allow natural expansion */
    .dominance-display { 
        margin: 5px;
        padding: 8px;
        font-size: 12px;
        height: auto;
        max-height: 50vh;
        overflow-y: auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .dominance-display pre {
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    .phase {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    .plan-header { 
        font-size: 10px; 
    }
    
    .phase { 
        font-size: 12px; 
    }

    /* Hide desktop buttons on mobile */
    #theme-switcher,
    #github-link,
    #about-link {
        display: none;
    }
    
    /* Show mobile buttons - larger and more prominent */
    .mobile-buttons {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 15px;
        margin: 15px 5px;
        clear: both;
        background: rgba(255, 255, 255, 0.1);
        padding: 15px 10px;
        border: 2px solid var(--term-white);
        width: calc(100% - 10px);
        box-sizing: border-box;
        flex-wrap: wrap;
    }
    
    .mobile-buttons .theme-switcher {
        display: inline-block;
        margin: 0 10px;
        position: static; /* reset fixed positioning from desktop */
        top: auto;
        right: auto;
        left: auto;
    }
    
    .mobile-buttons .theme-button {
        font-size: 18px;
        padding: 10px 18px;
        white-space: nowrap;
        border: 2px solid var(--term-white);
        background: var(--term-black);
        color: var(--term-white);
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-buttons .theme-button:hover {
        background: var(--term-white);
        color: var(--term-black);
    }
    
    /* Hide original footer and create mobile version */
    .terminal-footer {
        display: none;
    }
    
    /* Mobile footer (full-width, large) */
    .mobile-footer {
        display: block;
        text-align: center;
        margin: 20px 5px 10px 5px;
        font-size: 14px;
        color: var(--term-white);
        border: 2px solid var(--term-white);
        padding: 14px 10px;
        background: rgba(255, 255, 255, 0.08);
        line-height: 1.5;
        width: calc(100% - 10px);
        box-sizing: border-box;
        word-wrap: break-word;
    }
    
    /* Fix history display */
    .history-display {
        margin: 5px;
        padding: 10px 5px;
        width: calc(100% - 10px);
        box-sizing: border-box;
    }
    
    /* Mobile pagination controls */
    .pagination-controls {
        margin: 5px;
        padding: 8px;
        width: calc(100% - 10px);
        box-sizing: border-box;
        flex-direction: column;
        gap: 8px;
    }
    
    .pagination-info {
        text-align: center;
        order: 2;
    }
    
    .pagination-buttons {
        order: 1;
        justify-content: center;
        gap: 15px;
    }
    
    .pagination-button pre {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .history-item {
        margin: 10px 5px;
        padding: 8px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix dominance display */
    .dominance-display {
        width: calc(100% - 10px);
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

    /* Extra small devices */
@media (max-width: 480px) {
    body { 
        font-size: 12px;
        overflow-x: hidden;
        width: 100vw;
        padding: 0;
        margin: 0;
    }
    
    .terminal-container {
        padding: 3px;
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
    }
    
        /* Keep using mobile header/status/footer on tiny screens */
        .terminal-title, .system-status, .terminal-footer { display: none !important; }
        .mobile-header, .mobile-status, .mobile-footer { display: block !important; }
        
        /* Enhance mobile header for tiny screens */
        .mobile-header {
            font-size: 14px;
            padding: 10px 5px;
            margin: 8px 3px;
            width: calc(100% - 6px);
            background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
            animation: header-glow 3s ease-in-out infinite;
        }
        
        @keyframes header-glow {
            0%, 100% { box-shadow: 0 0 10px rgba(255,255,255,0.3); }
            50% { box-shadow: 0 0 20px rgba(255,255,255,0.5); }
        }
        
        .mobile-status {
            font-size: 11px;
            padding: 8px 5px;
            margin: 8px 3px;
            width: calc(100% - 6px);
        }
        
        /* Add gradient border effect */
        .mobile-status::before {
            content: '';
            position: absolute;
            top: -2px;
            left: -2px;
            right: -2px;
            bottom: -2px;
            background: linear-gradient(45deg, var(--term-white), transparent, var(--term-white));
            z-index: -1;
            opacity: 0.5;
            animation: border-rotate 4s linear infinite;
        }
        
        @keyframes border-rotate {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    
    .panel-header pre, 
    .panel-divider pre { 
        font-size: 10px; 
        padding: 3px; 
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: keep-all;
        word-wrap: normal;
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Enhanced mobile buttons for tiny screens */
    .mobile-buttons {
        margin: 10px 3px;
        padding: 12px 8px;
        width: calc(100% - 6px);
        gap: 12px;
        background: rgba(255,255,255,0.12);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }
    
    .mobile-buttons .theme-button { 
        font-size: 16px; 
        padding: 10px 15px;
        border-radius: 4px;
        background: var(--term-black);
        color: var(--term-white);
        border: 2px solid var(--term-white);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }
    
    .mobile-buttons .theme-button::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        background: rgba(255,255,255,0.3);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        transition: width 0.5s, height 0.5s;
    }
    
    .mobile-buttons .theme-button:active::before {
        width: 200px;
        height: 200px;
    }

    /* Adjust heights for very small screens with better scrolling */
    .current-conversation-container { 
        height: 35vh;
        min-height: 200px;
        max-height: 300px;
        border: 1px solid var(--term-white);
        border-radius: 2px;
        margin: 5px 3px;
        width: calc(100% - 6px);
        position: relative;
        overflow: hidden;
    }
    
    .conversation-display { 
        font-size: 11px;
        padding: 8px 5px;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overflow-x: auto;
        overflow-y: auto;
        height: 100%;
    }
    
    .left-panel {
        padding-left: 0 !important;
    }
    
    /* Add scroll indicator */
    .conversation-display::after {
        content: '↓';
        position: sticky;
        bottom: 5px;
        right: 5px;
        float: right;
        color: var(--term-white);
        opacity: 0.5;
        animation: scroll-hint 2s ease-in-out infinite;
    }
    
    @keyframes scroll-hint {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(5px); }
    }

    .history-display { 
        height: 25vh;
        min-height: 150px;
        max-height: 250px;
        font-size: 11px; 
    }

    .beacon-display { 
        height: 30vh;
        min-height: 200px;
        max-height: 300px;
        font-size: 12px;
        border: 1px solid var(--term-white);
        border-radius: 2px;
        margin: 5px 3px;
        width: calc(100% - 6px);
        -webkit-overflow-scrolling: touch;
        position: relative;
        background: var(--term-black) !important; /* Solid background on tiny screens */
        overflow-x: auto;
        overflow-y: auto;
    }
    
    /* Beacon pulse effect on new content */
    .beacon-display.new-content {
        animation: beacon-flash 0.5s ease-out;
    }
    
    @keyframes beacon-flash {
        0% { background: rgba(255,255,255,0.2); }
        100% { background: rgba(255,255,255,0.02); }
    }
    
    .beacon-post { 
        font-size: 12px;
        padding: 5px;
        margin: 5px 0;
        border-left: 2px solid rgba(255,255,255,0.3);
        transition: border-color 0.3s;
    }
    
    .beacon-post:active {
        border-left-color: var(--term-white);
    }

    .dominance-display { 
        font-size: 11px; 
        padding: 8px; 
        margin: 5px 3px;
        width: calc(100% - 6px);
        border-radius: 2px;
        background: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
        position: relative;
        overflow-x: auto;
        overflow-y: auto;
        max-height: 40vh;
        -webkit-overflow-scrolling: touch;
    }
    
    .dominance-display pre {
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Animated border effect */
    .dominance-display::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--term-white), transparent);
        animation: scan-line 3s linear infinite;
    }
    
    @keyframes scan-line {
        0% { left: -100%; }
        100% { left: 100%; }
    }
    
    .plan-header, .phase { 
        font-size: 10px; 
    }

    .history-display {
        margin: 5px 3px;
        width: calc(100% - 6px);
        border-radius: 2px;
        background: rgba(255,255,255,0.03);
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-item {
        margin: 8px 3px;
        padding: 6px;
        font-size: 10px;
        transition: all 0.3s ease;
        cursor: pointer;
        position: relative;
    }
    
    .history-item:active {
        transform: scale(0.98);
        background: rgba(255,255,255,0.15);
    }
    
    .hist-topic { 
        font-size: 11px;
        font-weight: bold;
    }
    
    /* Hide desktop buttons on tiny screens too */
    #theme-switcher,
    #about-link {
        display: none;
    }
    
    /* Mobile footer enhancements */
    .mobile-footer {
        margin: 15px 3px 10px 3px;
        padding: 12px 8px;
        width: calc(100% - 6px);
        font-size: 12px;
        background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
        position: relative;
        overflow: hidden;
    }
    
    .mobile-footer::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, var(--term-white) 0%, transparent 50%, var(--term-white) 100%);
        animation: footer-pulse 3s ease-in-out infinite;
    }
    
    @keyframes footer-pulse {
        0%, 100% { opacity: 0.3; }
        50% { opacity: 1; }
    }
    
    /* Mobile ASCII companion styling */
    .mobile-ascii {
        margin: 10px 3px;
        padding: 10px;
        border: 1px dashed var(--term-white);
        border-radius: 2px;
        background: rgba(255,255,255,0.03);
        width: calc(100% - 6px);
        box-sizing: border-box;
    }
    
    .mobile-ascii .ascii-display {
        font-size: 9px;
        text-align: center;
        animation: ascii-float 4s ease-in-out infinite;
    }
    
    @keyframes ascii-float {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-5px); }
    }
    
    /* Panel improvements */
    .terminal-panel {
        margin: 5px 3px;
        width: calc(100% - 6px);
        border-radius: 2px;
        box-shadow: 0 2px 10px rgba(255,255,255,0.1);
    }
    
    /* Message styling improvements */
    .message {
        margin: 8px 3px;
        padding: 6px;
        font-size: 11px;
        border-radius: 2px;
        transition: background 0.3s;
    }
    
    .message:active {
        background: rgba(255,255,255,0.1);
    }
    
    /* Enhanced mobile contract address - bigger and clickable */
    #mobile-contract-address,
    #about-contract-address {
        font-size: 16px;
        word-break: break-all;
        display: block;
        margin: 10px auto;
        padding: 12px;
        background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
        border: 2px solid var(--term-white);
        border-radius: 5px;
        cursor: pointer;
        font-weight: bold;
        text-align: center;
        position: relative;
        transition: all 0.3s ease;
        box-shadow: 0 2px 10px rgba(255,255,255,0.2);
        max-width: 90%;
        opacity: 1;
        animation: ca-pulse 3s ease-in-out infinite;
    }
    
    @keyframes ca-pulse {
        0%, 100% { box-shadow: 0 2px 10px rgba(255,255,255,0.2); }
        50% { box-shadow: 0 2px 20px rgba(255,255,255,0.4); }
    }
    
    #mobile-contract-address:active,
    #about-contract-address:active {
        background: linear-gradient(135deg, rgba(100,255,100,0.3), rgba(255,255,255,0.2));
        transform: scale(0.95);
        box-shadow: 0 1px 5px rgba(100,255,100,0.5);
    }
}

/* Tiny screen inverted theme fixes */
@media (max-width: 480px) {
    body.inverted .terminal-panel {
        background: var(--term-white) !important;
    }
    
    body.inverted .beacon-display {
        background: var(--term-white) !important;
    }
    
    body.inverted .terminal-panel::before {
        display: none !important;
    }
}