* {
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}
h1 {
    color: #00ff88;
    margin-bottom: 5px;
}
.subtitle {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
}
.status-bar {
    background: #16213e;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #ff4444;
}
.status-bar.connected {
    border-left-color: #00ff88;
}
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4444;
}
.status-bar.connected .status-dot {
    background: #00ff88;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 1000px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.panel {
    background: #16213e;
    border-radius: 8px;
    border: 1px solid #333;
    overflow: hidden;
}
.panel-header {
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-header h2 {
    margin: 0;
    font-size: 14px;
    color: #00ff88;
    text-transform: uppercase;
}
.panel-body {
    padding: 15px;
}

/* Device selector */
.device-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.device-tab {
    background: #0f3460;
    border: 1px solid #1a5f7a;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.device-tab:hover {
    background: #1a5f7a;
}
.device-tab.active {
    background: #00ff88;
    color: #000;
    border-color: #00ff88;
}
.device-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
    text-transform: uppercase;
}
.device-badge.turtle {
    background: #1a5f7a;
    color: #7dd3fc;
}
.device-badge.computer {
    background: #5f1a7a;
    color: #d37dfc;
}
.device-tab.active .device-badge {
    background: rgba(0,0,0,0.2);
    color: #000;
}
.device-tab.disconnected {
    background: #2a1a1a;
    border-color: #5a3030;
    opacity: 0.8;
}
.device-tab.disconnected:hover {
    background: #3a2020;
}
.device-tab.disconnected.active {
    background: #4a2020;
    border-color: #ff6666;
    color: #ff9999;
}
.device-badge.disconnected {
    background: #5a3030;
    color: #ff6666;
}
.dismiss-btn {
    background: none;
    border: none;
    color: #ff6666;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    font-size: 14px;
    line-height: 1;
    opacity: 0.6;
}
.dismiss-btn:hover {
    opacity: 1;
}
.device-tab.unauthorized {
    opacity: 0.7;
}
.device-badge.pending {
    background: #5a4a10;
    color: #ffcc00;
}
.auth-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    font-size: 12px;
    opacity: 0.7;
}
.auth-btn:hover {
    opacity: 1;
}

/* Stats */
.stats-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.stat {
    background: #0f3460;
    padding: 8px 12px;
    border-radius: 6px;
}
.stat.clickable:hover, .stat[onclick]:hover {
    background: #1a5f7a;
}
.stat-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
}
.stat-value {
    font-size: 14px;
    color: #00ff88;
    font-weight: bold;
}
.stat-seen-container {
    position: relative;
}
.stat-seen-container .stat-value {
    transition: opacity 0.2s;
}
.stat-seen-container .resync-btn {
    position: absolute;
    top: 0;
    left: 0;
    background: transparent;
    border: none;
    color: #ff6b6b;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s;
}
.stat:hover .stat-seen-container .stat-value {
    opacity: 0;
}
.stat:hover .stat-seen-container .resync-btn {
    opacity: 1;
}

/* World View */
.world-view {
    display: flex;
    gap: 15px;
}
.canvas-container {
    background: #0a1628;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.canvas-container canvas {
    display: block;
}

/* Controls */
.controls-container {
    flex: 1;
    min-width: 200px;
}
.control-group {
    margin-bottom: 15px;
}
.control-group-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.control-grid.movement {
    grid-template-columns: repeat(3, 50px);
}
button {
    background: #0f3460;
    border: 1px solid #1a5f7a;
    color: #fff;
    padding: 10px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}
button:hover {
    background: #1a5f7a;
}
button:active {
    background: #00ff88;
    color: #000;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
button.success {
    background: #00ff88;
    color: #000;
}
button.failure {
    background: #ff4444;
    color: #fff;
}
.spacer {
    visibility: hidden;
}

/* Action Log */
.action-log {
    background: #0a1628;
    border-radius: 6px;
    padding: 10px;
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}
.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid #1a1a2e;
}
.log-entry:last-child {
    border-bottom: none;
}
.log-entry.success {
    color: #00ff88;
}
.log-entry.error {
    color: #ff6b6b;
}
.log-entry.buffered {
    color: #7dd3fc;
}
.log-entry.cancelled {
    color: #666;
    text-decoration: line-through;
}
.log-entry .log-time {
    color: #444;
    margin-right: 8px;
}

/* Terminal */
.terminal-container {
    background: #000;
    border-radius: 6px;
    border: 2px solid #333;
}
.terminal {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.2;
    background: #191919;
    padding: 6px;
    white-space: pre;
    overflow: hidden;
    /* CC terminal is 51x19 characters */
    width: calc(51ch + 12px);
    height: calc(19 * 1.2em + 12px);
}
.terminal-line {
    height: 1.2em;
}
.terminal.focused {
    outline: 2px solid #00ff88;
}
.terminal-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(19 * 1.2em + 12px);
    color: #666;
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

/* Cursor */
.cursor {
    animation: blink 1s step-end infinite;
}
.cursor.no-blink {
    animation: none;
}
@keyframes blink {
    50% { opacity: 0; }
}

/* Predicted (unconfirmed) characters - mosh-style local echo */
.predicted {
    opacity: 0.5;
    font-style: italic;
}

/* CC:Tweaked color palette */
.cc-0 { color: #F0F0F0; } /* white */
.cc-1 { color: #F2B233; } /* orange */
.cc-2 { color: #E57FD8; } /* magenta */
.cc-3 { color: #99B2F2; } /* lightBlue */
.cc-4 { color: #DEDE6C; } /* yellow */
.cc-5 { color: #7FCC19; } /* lime */
.cc-6 { color: #F2B2CC; } /* pink */
.cc-7 { color: #4C4C4C; } /* gray */
.cc-8 { color: #999999; } /* lightGray */
.cc-9 { color: #4C99B2; } /* cyan */
.cc-a { color: #B266E5; } /* purple */
.cc-b { color: #3366CC; } /* blue */
.cc-c { color: #7F664C; } /* brown */
.cc-d { color: #57A64E; } /* green */
.cc-e { color: #CC4C4C; } /* red */
.cc-f { color: #191919; } /* black */

.bg-0 { background-color: #F0F0F0; }
.bg-1 { background-color: #F2B233; }
.bg-2 { background-color: #E57FD8; }
.bg-3 { background-color: #99B2F2; }
.bg-4 { background-color: #DEDE6C; }
.bg-5 { background-color: #7FCC19; }
.bg-6 { background-color: #F2B2CC; }
.bg-7 { background-color: #4C4C4C; }
.bg-8 { background-color: #999999; }
.bg-9 { background-color: #4C99B2; }
.bg-a { background-color: #B266E5; }
.bg-b { background-color: #3366CC; }
.bg-c { background-color: #7F664C; }
.bg-d { background-color: #57A64E; }
.bg-e { background-color: #CC4C4C; }
.bg-f { background-color: #191919; }

.terminal-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.reboot-btn {
    background: transparent;
    border: 1px solid #444;
    color: #666;
    font-size: 10px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}
.reboot-btn:hover {
    background: #3d1a1a;
    color: #ff6b6b;
    border-color: #ff6b6b;
}

/* Inventory - compact */
.inventory-section {
    display: flex;
    align-items: center;
    gap: 10px;
}
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    flex: 1;
}
.inv-slot {
    aspect-ratio: 1;
    background: #0a1628;
    border: 1px solid #333;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    min-height: 24px;
    max-height: 28px;
    font-size: 8px;
}
.inv-slot:hover {
    border-color: #1a5f7a;
}
.inv-slot.selected {
    border-color: #00ff88;
    background: #0f3460;
    box-shadow: 0 0 4px #00ff88;
}
.inv-slot.has-item {
    background: #16213e;
}
.inv-slot .item-count {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-weight: bold;
    font-size: 9px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}
.inv-slot .item-icon {
    width: 16px;
    height: 16px;
}
.inv-slot .icon-minecraft-sm {
    transform: scale(1.25);
}
.inv-slot .slot-num {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 6px;
    color: #444;
}
.slot-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.slot-nav button {
    padding: 4px 8px;
    font-size: 11px;
}
.slot-indicator {
    text-align: center;
    font-size: 12px;
    color: #00ff88;
    font-weight: bold;
}

/* Block info section */
.block-info {
    background: #0a1628;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
}
.block-info .block-name {
    color: #00ff88;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.block-info .block-details {
    color: #888;
    font-size: 11px;
    margin-top: 4px;
}
.container-inventory .inventory-grid {
    grid-template-columns: repeat(9, 1fr);
}

/* Block tooltip */
.block-tooltip {
    position: fixed;
    background: #16213e;
    border: 1px solid #1a5f7a;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 11px;
    color: #fff;
    pointer-events: none;
    z-index: 1000;
    display: none;
    max-width: 250px;
}
.block-tooltip.visible {
    display: block;
}
.block-tooltip .tooltip-header {
    color: #666;
    font-size: 10px;
    margin-bottom: 6px;
}
.block-tooltip .tooltip-layer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}
.block-tooltip .tooltip-layer .layer-label {
    color: #666;
    font-size: 9px;
    width: 45px;
}
.block-tooltip .tooltip-layer .layer-name {
    color: #fff;
}
.block-tooltip .tooltip-layer.current .layer-name {
    color: #00ff88;
    font-weight: bold;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}
.empty-state code {
    background: #0f3460;
    padding: 8px 12px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 10px;
    color: #00ff88;
    font-size: 12px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0a1628;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

/* Add Turtle Button */
.add-turtle-btn {
    background: #0f3460;
    border: 2px dashed #444;
    color: #888;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.add-turtle-btn:hover {
    background: #16213e;
    border-color: #00ff88;
    color: #00ff88;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden {
    display: none;
}
.modal {
    background: #16213e;
    border-radius: 8px;
    border: 1px solid #333;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 {
    margin: 0;
    color: #00ff88;
}
.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover {
    color: #fff;
}
.modal-body {
    padding: 15px 20px;
    overflow-y: auto;
    flex: 1;
}
.turtle-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.turtle-list-item {
    background: #0f3460;
    border-radius: 6px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.turtle-list-item .turtle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.turtle-list-item .turtle-name {
    font-weight: bold;
}
.turtle-list-item .turtle-meta {
    font-size: 12px;
    color: #888;
}
.turtle-list-item button {
    background: #00ff88;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.turtle-list-item button:hover {
    background: #00cc6a;
}
.turtle-list-item button.pending {
    background: #ffc107;
}
.turtle-list-item button.authed {
    background: #444;
    color: #888;
    cursor: default;
}
.turtle-list-empty {
    text-align: center;
    color: #666;
    padding: 20px;
}
