:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --card-bg: #1e1e1e;
    --accent-color: #bb86fc;
    --secondary-color: #03dac6;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    --font-family: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    padding: 0.5rem;
    overflow-x: hidden;
}

.game-container {
    max-width: 100%;
    margin: 0 auto;
}

header {
    margin-bottom: 1rem;
    text-align: center;
    position: relative;
}

.back-btn {
    position: absolute;
    top: 0;
    left: 0;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.5rem;
}

.back-btn:hover {
    color: var(--secondary-color);
}

h1 {
    font-size: 2rem;
    margin: 0.5rem 0;
    color: var(--accent-color);
}

.header-info {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.score-box {
    background-color: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #333;
    min-width: 100px;
}

.score-box span:first-child {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.25rem;
}

.score-box span:last-child {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.game-layout {
    display: grid;
    grid-template-columns: 250px 1fr 350px;
    gap: 1rem;
    height: calc(100vh - 200px);
    min-height: 600px;
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.left-panel {
    max-height: 100%;
}

.right-panel {
    max-height: 100%;
}

.inventory-panel,
.toolbar-panel,
.block-selector-panel,
.mission-panel,
.code-preview-panel,
.execution-panel {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #333;
}

h3 {
    color: var(--accent-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.inventory-item {
    background-color: #0d1117;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.inventory-item:hover {
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.inventory-item.empty {
    opacity: 0.3;
    cursor: not-allowed;
}

.inventory-item .count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--accent-color);
    color: #000;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.tool-btn {
    background-color: #0d1117;
    color: var(--text-color);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.tool-btn:hover {
    border-color: var(--accent-color);
    background-color: rgba(187, 134, 252, 0.1);
}

.tool-btn.active {
    border-color: var(--accent-color);
    background-color: rgba(187, 134, 252, 0.2);
    color: var(--accent-color);
}

.block-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.block-item {
    background-color: #0d1117;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.block-item:hover {
    border-color: var(--accent-color);
    transform: translateX(5px);
}

.block-item.selected {
    border-color: var(--accent-color);
    background-color: rgba(187, 134, 252, 0.2);
}

.block-item .block-icon {
    font-size: 1.5rem;
    width: 30px;
    text-align: center;
}

.block-item .block-name {
    flex: 1;
    font-size: 0.9rem;
}

.world-panel {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.world-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.world-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background-color: #0d1117;
    color: var(--text-color);
    border: 1px solid #555;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
}

.control-btn:hover {
    border-color: var(--accent-color);
    background-color: rgba(187, 134, 252, 0.1);
}

.world-container {
    flex: 1;
    position: relative;
    background-color: #0a0a0a;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #333;
}

#world-canvas {
    width: 100%;
    height: 100%;
    position: relative;
}

#world-canvas canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: crosshair;
}

.world-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

.mission-content {
    background-color: #0d1117;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 150px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.mission-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background-color: #0d1117;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #333;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--secondary-color));
    transition: width 0.3s;
    width: 0%;
}

.code-preview {
    background-color: #0d1117;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.code-preview pre {
    margin: 0;
    color: var(--text-color);
}

.code-preview .keyword {
    color: #c792ea;
}

.code-preview .string {
    color: #c3e88d;
}

.code-preview .number {
    color: #f78c6c;
}

.code-preview .comment {
    color: #546e7a;
    font-style: italic;
}

.execution-output {
    background-color: #0d1117;
    border-radius: 8px;
    padding: 1rem;
    min-height: 150px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.execution-output .placeholder {
    color: #666;
    font-style: italic;
}

.execution-output .success {
    color: var(--success-color);
}

.execution-output .error {
    color: var(--error-color);
}

.execution-output .output {
    color: var(--secondary-color);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.primary-btn,
.secondary-btn {
    padding: 0.75rem 2rem;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn {
    background-color: var(--accent-color);
    color: #000;
}

.primary-btn:hover {
    background-color: #a970ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(187, 134, 252, 0.4);
}

.secondary-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid #555;
}

.secondary-btn:hover {
    background-color: #2a2a2a;
}

.hidden {
    display: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    border: 2px solid var(--accent-color);
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.modal-content button {
    margin-top: 1.5rem;
    padding: 0.75rem 2rem;
    background-color: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.modal-content button:hover {
    background-color: #a970ff;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--success-color);
    color: #000;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    z-index: 2000;
    animation: slideIn 0.3s;
}

.toast.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 1400px) {
    .game-layout {
        grid-template-columns: 200px 1fr 300px;
    }
}

@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .left-panel,
    .right-panel {
        max-height: 400px;
    }
}

