/* sql.css - SQL Query Master game styles */
body {
    background-color: #f8fafc;
    margin: 0;
    font-family: 'Inter', sans-serif;
}

.sql-container {
    max-width: 1000px;
    margin: 15px auto;
    padding: 10px 20px;
    text-align: center;
}

.sql-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.btn-back {
    text-decoration: none;
    color: #0ea5e9;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.btn-back:hover {
    color: #0284c7;
}

.btn-help {
    background: none;
    border: none;
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.btn-help:hover {
    color: #475569;
}

.sql-title-area {
    margin-bottom: 10px;
}

.sql-title {
    font-size: 1.8rem;
    color: #1e293b;
    font-weight: 800;
    margin: 0;
}

.sql-title span {
    color: #0ea5e9;
    font-weight: 300;
    display: block;
    font-size: 1.1rem;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Stats panel */
.sql-stats {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 12px 20px;
    margin-bottom: 15px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-item .value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1e293b;
}

.stat-item .value.text-blue {
    color: #0ea5e9;
}

.stat-item .value.text-red {
    color: #ef4444;
}

/* Arena Grid Layout */
.sql-arena {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

/* Glass panel global */
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
}

.panel-subtitle {
    margin: 0 0 10px 0;
    color: #1e293b;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
}

/* Table Viewer (Left) */
.table-panel {
    display: flex;
    flex-direction: column;
    height: 400px;
    box-sizing: border-box;
}

.db-viewer {
    flex-grow: 1;
    background: #0f172a;
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
    text-align: left;
}

.db-viewer::-webkit-scrollbar {
    width: 6px;
}
.db-viewer::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.db-table-title {
    color: #38bdf8;
    font-weight: bold;
    margin-bottom: 5px;
    border-bottom: 1px dashed #334155;
    padding-bottom: 5px;
}

.db-table-header {
    display: flex;
    color: #cbd5e1;
    font-weight: bold;
    border-bottom: 1px solid #334155;
    padding: 5px 0;
}

.db-table-row {
    display: flex;
    padding: 4px 0;
    border-bottom: 1px solid #1e293b;
}

.db-col {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 10px;
}

.db-col.num {
    color: #fca5a5;
}

.db-col.str {
    color: #a7f3d0;
}

/* Query panel (Right) */
.query-panel {
    display: flex;
    flex-direction: column;
    height: 400px;
    box-sizing: border-box;
    text-align: left;
}

.query-card-header {
    margin-bottom: 8px;
}

.query-card-badge {
    background: #0ea5e9;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.query-card-body h3 {
    margin: 4px 0 10px;
    color: #1e293b;
    font-size: 1.1rem;
    font-weight: 800;
}

.sql-code-block {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 10px;
    border-left: 4px solid #0ea5e9;
    white-space: pre-wrap;
}

.sql-keyword { color: #c678dd; font-weight: bold; }
.sql-func { color: #61afef; }
.sql-string { color: #98c379; }
.sql-number { color: #d19a66; }
.sql-comment { color: #7f848e; font-style: italic; }

.question-box {
    background: #f0f9ff;
    border: 1px dashed #7dd3fc;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.question-badge {
    background: #0ea5e9;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
}

.question-text {
    margin: 0;
    font-weight: 700;
    color: #0369a1;
    font-size: 0.85rem;
}

/* Choices Grid */
.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    flex-grow: 1;
}

.choice-btn {
    background: white;
    border: 2px solid #e2e8f0;
    color: #1e293b;
    font-size: 0.85rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.choice-btn:hover {
    border-color: #0ea5e9;
    background: #f0f9ff;
    transform: translateY(-1px);
}

.choice-btn.correct {
    background: #ecfdf5 !important;
    border-color: #10b981 !important;
    color: #047857 !important;
}

.choice-btn.wrong {
    background: #fef2f2 !important;
    border-color: #ef4444 !important;
    color: #b91c1c !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* Modal Styling & Result Overrides */
.result-rank-box {
    color: #0369a1;
    background: #e0f2fe;
    border-color: #38bdf8;
    font-size: 1.4rem;
    font-weight: 800;
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    border: 2px dashed #38bdf8;
    text-align: center;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.glass-panel-modal {
    background: rgba(255, 255, 255, 0.96);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: slideUp 0.4s ease-out;
    max-height: 90vh;
    position: relative;
}

.modal-close-x {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 26px;
    font-weight: 700;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-x:hover {
    color: #ef4444;
}

.modal-scroll-body {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 15px;
}

.modal-scroll-body::-webkit-scrollbar { width: 6px; }
.modal-scroll-body::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); border-radius: 4px; }
.modal-scroll-body::-webkit-scrollbar-thumb { background: rgba(14, 165, 233, 0.3); border-radius: 4px; }
.modal-scroll-body::-webkit-scrollbar-thumb:hover { background: rgba(14, 165, 233, 0.6); }

.btn-restart {
    background: #0ea5e9;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-restart:hover {
    background: #0284c7;
}

.btn-share {
    background: #e2e8f0;
    color: #334155;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-share:hover {
    background: #cbd5e1;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 800px) {
    .sql-arena {
        grid-template-columns: 1fr;
    }
    .table-panel, .query-panel {
        height: auto;
        min-height: 350px;
    }
}
