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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#game-container {
    width: 100%;
    max-width: 480px;
    margin: 20px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

#game-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.game-title {
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.stats-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.stat-label {
    font-size: 0.85em;
    opacity: 0.8;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.4em;
    font-weight: 600;
}

#timer-display.warning .stat-value {
    color: #ff6b6b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

#game-content {
    padding: 30px 25px;
}

#hint-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.hint-label {
    font-size: 0.9em;
    color: #64748b;
    margin-bottom: 8px;
    font-weight: 500;
}

#hint-display {
    font-size: 1.1em;
    color: #334155;
    line-height: 1.4;
    font-weight: 500;
}

#word-display {
    min-height: 70px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2em;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: 3px;
    background: #ffffff;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    padding: 10px;
    flex-wrap: wrap;
    gap: 5px;
}

#word-display.drop-zone {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: scale(1.02);
}

.word-letter {
    display: inline-block;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.word-letter:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #f87171;
    transform: scale(1.05);
}

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

.removal-hint {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

#word-display:hover .removal-hint {
    opacity: 1;
}

#letters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f1f5f9;
    border-radius: 12px;
}

.letter-tile {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8em;
    font-weight: 600;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
    position: relative;
}

.letter-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.letter-tile:active {
    transform: translateY(0);
}

.letter-tile.used {
    opacity: 0.4;
    transform: scale(0.9);
    pointer-events: none;
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

.letter-tile.dragging {
    opacity: 0.7;
    transform: scale(1.1) rotate(5deg);
}

#submit-word-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.2em;
    font-weight: 600;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

#submit-word-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

#submit-word-btn:active {
    transform: translateY(0);
}

#message-area {
    text-align: center;
    font-size: 1em;
    font-weight: 500;
    min-height: 30px;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 10px;
    border-radius: 8px;
}

#message-area.show {
    opacity: 1;
}

/* Rating Popup Styles */
#rating-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#rating-popup.show {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    color: #334155;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#rating-popup.show .popup-content {
    transform: scale(1);
}

.popup-title {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 15px;
    color: #1e293b;
}

.correct-word {
    font-size: 1.5em;
    color: #059669;
    margin-bottom: 20px;
    font-weight: 600;
}

.rating-section {
    margin: 25px 0;
}

.rating-label {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #64748b;
    font-weight: 500;
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.star {
    font-size: 2.5em;
    color: #e2e8f0;
    transition: all 0.3s ease;
}

.star.filled {
    color: #fbbf24;
}

.performance-info {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.time-info, .score-info {
    font-size: 1em;
    margin: 5px 0;
    color: #64748b;
}

.score-info {
    color: #059669;
    font-weight: 600;
}

.popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
}

.popup-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.continue-btn {
    background: #3b82f6;
    color: white;
}

.continue-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.quit-btn {
    background: #e5e7eb;
    color: #374151;
}

.quit-btn:hover {
    background: #d1d5db;
    transform: translateY(-1px);
}

/* Game Over Screen */
#game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    color: white;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#game-over.show {
    opacity: 1;
    visibility: visible;
}

.game-over-title {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 20px;
}

.final-score {
    font-size: 1.8em;
    margin-bottom: 30px;
    color: #fbbf24;
    font-weight: 600;
}

.restart-btn {
    padding: 16px 32px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restart-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 480px) {
    #game-container {
        margin: 10px;
        border-radius: 12px;
    }

    #game-content {
        padding: 20px 15px;
    }

    .letter-tile {
        width: 60px;
        height: 60px;
        font-size: 1.6em;
    }

    #letters-grid {
        gap: 10px;
        padding: 15px;
    }

    #word-display {
        font-size: 1.8em;
        letter-spacing: 2px;
    }

    .popup-content {
        padding: 25px;
        margin: 20px;
    }

    .stats-container {
        gap: 20px;
    }
}