* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    direction: rtl;
    background: #f5f7fa;
    color: #2c3e50;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Modal Styles - Clean Institutional Design */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #ffffff;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 12px;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #2c3e50;
    font-size: 15px;
    transition: border-color 0.2s;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.modal-content button {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.modal-content button:hover {
    background: #2980b9;
}

.modal-content button:active {
    background: #21618c;
}

.modal-content a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s;
}

.modal-content a:hover {
    color: #2980b9;
    text-decoration: underline;
}

.close {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 24px;
    font-weight: 300;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #2c3e50;
}

/* Header - Clean Institutional Design */
.header {
    background: #ffffff;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    position: relative;
    border-bottom: 2px solid #e0e0e0;
}

.user-info {
    display: flex;
    gap: 15px;
    font-size: 14px;
    font-weight: 500;
    align-items: center;
    color: #2c3e50;
    flex-wrap: wrap;
}

.user-info span {
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.user-info span:hover {
    background: #e9ecef;
}

.header-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.header-buttons button {
    padding: 8px 16px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.header-buttons button:hover {
    background: #2980b9;
}

.header-buttons button:active {
    background: #21618c;
}

.header-buttons button:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Map Container */
#mapContainer {
    position: relative;
    width: 100%;
    height: calc(100vh - 70px);
    background: #f5f7fa;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Game UI Panels */
#gameUI {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.panel {
    background: #ffffff;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    max-height: 300px;
    overflow-y: auto;
}

.panel h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.chat-panel {
    max-height: 250px;
}

#chatMessages {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 5px;
}

.chat-message {
    padding: 8px 12px;
    margin: 6px 0;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 14px;
    border-left: 3px solid #3498db;
    transition: background-color 0.2s;
}

.chat-message:hover {
    background: #e9ecef;
}

.chat-message strong {
    color: #2c3e50;
    font-weight: 600;
}

#chatInput {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 8px;
}

#chatInput:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.controls button {
    padding: 10px 15px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
    flex: 1;
    min-width: 60px;
}

.controls button:hover {
    background: #2980b9;
}

.controls button:active {
    background: #21618c;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.stat-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.stat-item .stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #3498db;
}

.stat-item .stat-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 4px;
}

/* Questions Panel */
.question-item {
    padding: 12px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    transition: background-color 0.2s;
}

.question-item:hover {
    background: #e9ecef;
}

.question-item h4 {
    color: #2c3e50;
    font-size: 15px;
    margin-bottom: 6px;
    font-weight: 600;
}

.question-item p {
    color: #7f8c8d;
    font-size: 13px;
    margin-bottom: 8px;
}

.question-item button {
    padding: 6px 12px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.question-item button:hover {
    background: #2980b9;
}

/* Leaderboard */
.leaderboard-item {
    padding: 10px;
    margin: 6px 0;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid #3498db;
    transition: background-color 0.2s;
}

.leaderboard-item:hover {
    background: #e9ecef;
}

.leaderboard-item.rank-1 {
    border-left-color: #f39c12;
    background: #fffbf0;
}

.leaderboard-item.rank-2 {
    border-left-color: #95a5a6;
    background: #f8f9fa;
}

.leaderboard-item.rank-3 {
    border-left-color: #e67e22;
    background: #fff5f0;
}

/* BI Cards */
.bi-card {
    padding: 15px;
    margin: 10px 0;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s;
}

.bi-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.bi-card h4 {
    color: #2c3e50;
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.bi-card p {
    color: #7f8c8d;
    font-size: 14px;
    line-height: 1.5;
}

/* Avatar Selection */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.avatar-item {
    padding: 10px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.avatar-item:hover {
    border-color: #3498db;
    background: #e3f2fd;
}

.avatar-item.selected {
    border-color: #3498db;
    background: #e3f2fd;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.avatar-item img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Admin Panel */
.admin-modal {
    max-width: 800px;
    width: 95%;
}

.admin-section {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.admin-section h3 {
    color: #2c3e50;
    font-size: 18px;
    margin-bottom: 12px;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.admin-table tr:hover {
    background: #f8f9fa;
}

/* Notifications */
.notification-item {
    padding: 12px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    transition: background-color 0.2s;
}

.notification-item:hover {
    background: #e9ecef;
}

.notification-item.unread {
    background: #e3f2fd;
    border-left-color: #3498db;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 6px;
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 5px;
}

/* Pressure Indicator */
.pressure-indicator {
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.pressure-indicator.low {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.pressure-indicator.medium {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.pressure-indicator.high {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
}

button:not(:disabled):active {
    transform: translateY(0);
}

/* Smooth transitions */
* {
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .user-info {
        flex-direction: column;
        gap: 8px;
        font-size: 13px;
        width: 100%;
    }
    
    .user-info span {
        width: 100%;
        text-align: center;
    }
    
    .header-buttons {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .header-buttons button {
        padding: 8px 12px;
        font-size: 13px;
        flex: 1;
        min-width: 100px;
    }
    
    #gameUI {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .panel {
        min-width: 250px;
        max-height: 200px;
    }
    
    .controls {
        flex-direction: row;
    }
    
    .controls > div {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .admin-modal {
        max-width: 95%;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-buttons button {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .modal-content {
        padding: 15px;
    }
    
    .modal-content h2 {
        font-size: 18px;
    }
    
    .panel h3 {
        font-size: 16px;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Keyboard controls hint */
.keyboard-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    color: #2c3e50;
}

/* Improved button styles */
.btn-primary {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-success:hover {
    background: #229954;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error messages */
.message {
    padding: 12px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}
