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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    margin-top: 5px;
    margin-bottom: 8px;
    font-weight: 500;
}

.subtitle-small {
    font-size: 0.9em;
    opacity: 0.8;
    font-style: italic;
    margin-top: 0;
    margin-bottom: 15px;
    display: block;
}

.difficulty-badge {
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.difficulty-easy {
    background: #d4edda;
    color: #155724;
}

.difficulty-medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty-hard {
    background: #f8d7da;
    color: #721c24;
}

.points-badge {
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    background: #667eea;
    color: white;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 30px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-weight: 600;
    margin-right: 8px;
}

.stat-item span:last-child {
    font-size: 1.5em;
    font-weight: bold;
}

main {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    padding: 30px;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.challenge-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.challenge-section h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.challenge-section p {
    font-size: 1.1em;
    line-height: 1.6;
    color: #555;
    margin-bottom: 20px;
}

.table-preview {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #dee2e6;
}

.table-preview h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.2em;
}

#table-display {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

table th {
    background: #667eea;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
}

table tr:hover {
    background: #f8f9fa;
}

table tr:last-child td {
    border-bottom: none;
}

.editor-section {
    background: #1e1e1e;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: white;
    font-weight: 600;
}

#sql-editor {
    width: 100%;
    min-height: 150px;
    background: #2d2d2d;
    color: #d4d4d4;
    border: 2px solid #3e3e3e;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    resize: vertical;
    margin-bottom: 15px;
    line-height: 1.6;
}

#sql-editor:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.result-section {
    min-height: 100px;
}

#query-result {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    min-height: 80px;
}

#feedback {
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
    display: none;
}

#feedback.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
    display: block;
}

#feedback.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
    display: block;
}

#feedback.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 2px solid #bee5eb;
    display: block;
}

.levels-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    height: fit-content;
}

.levels-panel h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.level-item {
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: all 0.3s ease;
}

.level-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.level-item.current {
    background: #667eea;
    color: white;
    border-color: #5568d3;
}

.level-item.completed {
    background: #d4edda;
    border-color: #c3e6cb;
}

.level-item.locked {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.level-number {
    font-weight: bold;
    margin-right: 8px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

#modal-title {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

#modal-message {
    font-size: 1.2em;
    margin-bottom: 25px;
    color: #555;
    line-height: 1.6;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    .levels-panel {
        order: -1;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .stats {
        flex-direction: column;
        gap: 15px;
    }

    .stat-item {
        padding: 10px 20px;
    }
}

