@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

button, input {
    font-family: 'Cairo';
}

body {
    font-family: 'Cairo', Tahoma, Geneva, Verdana, sans-serif;
    background: lightblue;
    min-height: 100vh;
    color: #2c3e50;
    direction: rtl;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 2.5rem;
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.score-board > div {
    background: lightblue;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.1rem;
}

.game-controls {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.input-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

#elementInput {
    flex: 1;
    max-width: 300px;
    padding: 12px 20px;
    border: 2px solid #bdc3c7;
    border-radius: 25px;
    font-size: 16px;
    text-align: center;
    transition: all 0.3s ease;
}

#elementInput:focus {
    outline: none;
    border-color: #34495e;
    box-shadow: 0 0 0 3px rgba(52, 73, 94, 0.1);
    transform: scale(1.02);
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#submitBtn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.feedback {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s ease;
}

.feedback.success {
    background: #d5f4e6;
    color: #27ae60;
    border: 1px solid #2ecc71;
}

.feedback.error {
    background: #fadbd8;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.instructions {
    text-align: center;
    background: #ecf0f1;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #bdc3c7;
}

.instructions h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.instructions p {
    margin-bottom: 8px;
    color: #34495e;
    line-height: 1.5;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 2px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    direction: ltr; /* قلب اتجاه الجدول لجعل الهيدروجين في الشمال */
}

.element {
    aspect-ratio: 1;
    min-width: 50px;
    min-height: 50px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ecf0f1;
    position: relative;
}

.element:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.element.discovered {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border-color: #27ae60;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.atomic-number {
    font-size: 0.7rem;
    font-weight: bold;
    position: absolute;
    top: 2px;
    right: 2px;
    display: none; /* إخفاء العدد الذري */
}

.element-symbol {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.element-name {
    font-size: 0.6rem;
    text-align: center;
    margin-top: 2px;
    display: none; /* إخفاء اسم العنصر عند الاكتشاف */
}

.game-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.current-element {
    text-align: center;
}

.current-element h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

.element-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.element-info .atomic-number {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    position: static;
}

.element-details {
    text-align: center;
}

.element-details .element-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 5px;
}

.element-details .element-symbol {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.controls button {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
}

.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.celebration-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.celebration-content h2 {
    color: #27ae60;
    margin-bottom: 20px;
    font-size: 2.5rem;
}

.celebration-content p {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #2c3e50;
}

.celebration-content button {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    font-size: 1.1rem;
    padding: 15px 30px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .periodic-table {
        gap: 1px;
        padding: 15px;
    }
    
    .element {
        min-width: 45px;
        min-height: 45px;
    }
    
    .element-symbol {
        font-size: 1rem;
    }
}

@media (max-width: 992px) {
    .container {
        padding: 15px;
    }
    
    .periodic-table {
        gap: 1px;
        padding: 10px;
    }
    
    .element {
        min-width: 40px;
        min-height: 40px;
    }
    
    .element-symbol {
        font-size: 0.95rem;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .score-board {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .periodic-table {
        gap: 1px;
        padding: 8px;
        overflow-x: auto;
    }
    
    .element {
        min-width: 35px;
        min-height: 35px;
    }
    
    .element-symbol {
        font-size: 0.9rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .score-board {
        gap: 15px;
    }
    
    .score-board > div {
        padding: 8px 16px;
        font-size: 1rem;
    }
    
    .input-section {
        flex-direction: column;
        align-items: center;
    }
    
    #elementInput {
        max-width: 100%;
        margin-bottom: 10px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 10px;
    }
    
    .periodic-table {
        gap: 0.5px;
        padding: 5px;
    }
    
    .element {
        min-width: 30px;
        min-height: 30px;
    }
    
    .element-symbol {
        font-size: 0.8rem;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .score-board {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .score-board > div {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .controls button {
        width: 100%;
        max-width: 200px;
        margin-bottom: 10px;
    }
}

@media (max-width: 400px) {
    .element {
        min-width: 25px;
        min-height: 25px;
    }
    
    .element-symbol {
        font-size: 0.7rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
}

/* Element Categories Colors - Formal */
.element.alkali-metal.discovered {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

.element.alkaline-earth.discovered {
    background: linear-gradient(135deg, #d35400, #e67e22);
}

.element.transition-metal.discovered {
    background: linear-gradient(135deg, #2980b9, #3498db);
}

.element.post-transition.discovered {
    background: linear-gradient(135deg, #16a085, #1abc9c);
}

.element.metalloid.discovered {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.element.nonmetal.discovered {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
}

.element.halogen.discovered {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.element.noble-gas.discovered {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.element.lanthanide.discovered {
    background: linear-gradient(135deg, #34495e, #2c3e50);
}

.element.actinide.discovered {
    background: linear-gradient(135deg, #5d4e75, #8e44ad);
}