/* Arabic Letter Writing Practice Styles */

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.writing-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: white;
}

.writing-header {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.writing-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.writing-header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Letter Selection Grid */
.letter-selector {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.letter-selector h3 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: #333;
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.letter-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 2rem;
    font-family: 'Amiri', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    position: relative;
}

.letter-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.letter-button.completed {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.letter-button.current {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 5px 25px rgba(255, 152, 0, 0.6);
    }

    100% {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }
}

/* Writing Area */
.writing-area {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-width: 900px;
    margin: 0 auto;
}

.letter-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 15px;
    border: 2px solid #667eea;
}

.letter-details {
    flex: 1;
}

.letter-details h2 {
    font-size: 2.2rem;
    margin: 0 0 5px 0;
    color: #333;
    font-family: 'Amiri', serif;
}

.letter-details p {
    font-size: 1.3rem;
    color: #666;
    margin: 0 0 15px 0;
    font-style: italic;
}

.audio-btn,
.control-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.audio-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.audio-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.writing-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.clear-btn {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

.guide-btn {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.next-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Canvas Area */
.canvas-container {
    position: relative;
    text-align: center;
    margin-bottom: 25px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

#writingCanvas {
    border: 4px solid #667eea;
    border-radius: 15px;
    background: white;
    cursor: crosshair;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    width: 100%;
    height: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.canvas-instructions {
    margin-top: 10px;
    font-size: 1.1rem;
    color: #666;
    font-style: italic;
}

.writing-feedback {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 10px;
    border-left: 4px solid #2196F3;
    text-align: center;
}

.writing-feedback.success {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    border-left-color: #4CAF50;
}

.writing-feedback.error {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border-left-color: #f44336;
}

.writing-feedback.warning {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    border-left-color: #ff9800;
}

#feedbackText {
    font-weight: 500;
    font-size: 1.1rem;
}

.try-again-btn {
    background: #ff5722;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.try-again-btn:hover {
    background: #e64a19;
    transform: translateY(-1px);
}

.stroke-info {
    font-size: 0.9rem;
    color: #666;
    margin: 5px 0;
}

.stroke-info span:first-child {
    font-weight: bold;
    margin-right: 8px;
}

.control-btn.stroke-btn {
    background: #9c27b0;
    color: white;
}

.control-btn.stroke-btn:hover {
    background: #7b1fa2;
}

/* Game Statistics */
.game-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.stat-item {
    text-align: center;
    color: white;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .game-stats {
        flex-direction: column;
        gap: 8px;
    }

    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .stat-label {
        margin-bottom: 0;
    }
}

/* Progress Area */
.progress-area {
    margin-top: 30px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .writing-container {
        padding: 15px;
    }

    .writing-header h1 {
        font-size: 2rem;
    }

    .writing-area {
        padding: 20px;
    }

    .letter-info-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .writing-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .control-btn {
        font-size: 0.9rem;
        padding: 10px 15px;
    }

    .letter-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px;
    }

    .letter-button {
        padding: 15px;
        font-size: 1.5rem;
    }

    .letter-details h2 {
        font-size: 2rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .letter-button:hover {
        transform: none;
    }

    .letter-button:active {
        transform: scale(0.95);
    }

    #writingCanvas {
        cursor: default;
    }
}

/* Touchscreen Laptop Optimizations */
@media (pointer: coarse) {
    #writingCanvas {
        cursor: crosshair;
    }
}

/* Fine pointer devices (traditional mouse) */
@media (pointer: fine) {
    #writingCanvas {
        cursor: crosshair;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    #writingCanvas {
        image-rendering: pixelated;
        image-rendering: -moz-crisp-edges;
        image-rendering: crisp-edges;
    }
}