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

body {
    font-family: 'Cal Sans', 'Noto Sans', sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 50%, #9b59b6 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 1px, transparent 1px),
        radial-gradient(circle at 40% 40%, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 50px 50px, 80px 80px, 60px 60px;
    z-index: -2;
}

body::after {
    content: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 12px;
    color: rgba(255,255,255,0.05);
    letter-spacing: 20px;
    line-height: 40px;
    word-spacing: 10px;
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: -1;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floatingLetters 20s linear infinite;
}

@keyframes floatingLetters {
    0% {
        transform: rotate(-15deg) translateY(0px);
    }
    50% {
        transform: rotate(-15deg) translateY(-10px);
    }
    100% {
        transform: rotate(-15deg) translateY(0px);
    }
}

/* Floating letter elements */
.floating-letters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.floating-letter {
    position: absolute;
    color: rgba(255,255,255,0.1);
    font-size: 24px;
    font-weight: bold;
    animation: float 15s linear infinite;
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

.container {
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.score-board {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    color: white;
    font-weight: 500;
}

.game-area {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: slideUp 0.6s ease-out;
}

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

.question-card {
    margin-bottom: 2rem;
}

.label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.word-display {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: 0.1em;
}

.letters-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.letter {
    background: #667eea;
    color: white;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: bounce 0.6s ease-out;
    user-select: none;
}

.letter:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.letter.used {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(0.9);
}

@keyframes bounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes letterSelect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        background: #28a745;
    }
    100% {
        transform: scale(0.9);
    }
}

.answer-area {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

#answerInput {
    flex: 1;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
    cursor: pointer;
    width: 100%;
}

#answerInput:focus {
    outline: none;
    border-color: #667eea;
}

#answerInput::placeholder {
    color: #999;
}

.hint {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1rem;
}

.hint-text {
    color: #856404;
    font-weight: 500;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.control-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.result-modal, .game-over-modal {
    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;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.result-score, .final-score {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 12px;
    margin: 1rem 0;
    font-weight: 600;
    color: #667eea;
}

.next-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    header h1 {
        font-size: 2rem;
        margin-bottom: 0.3rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .score-board {
        margin-bottom: 1rem;
        font-size: 0.9rem;
    }
    
    .game-area {
        padding: 1.5rem;
        border-radius: 15px;
    }
    
    .word-display {
        font-size: 1.5rem;
        padding: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .letters-container {
        gap: 0.8rem;
        margin-bottom: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .letter {
        width: 90px;
        height: 90px;
        font-size: 1.6rem;
        border-radius: 15px;
        /* Better touch targets */
        min-width: 44px;
        min-height: 44px;
        /* Improve touch feedback */
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
        touch-action: manipulation;
    }
    
    .letter:active {
        transform: scale(0.95);
        background: #5a6fd8;
    }
    
    #answerInput {
        font-size: 1.2rem;
        padding: 1.2rem;
        border-radius: 15px;
        /* Prevent zoom on focus for iOS */
        font-size: 16px;
    }
    
    .controls {
        gap: 1rem;
        flex-direction: row;
        justify-content: center;
    }
    
    .control-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        border-radius: 12px;
        min-width: 120px;
        /* Better touch targets */
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .control-btn:active {
        transform: scale(0.95);
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: 15px;
    }
    
    .next-btn {
        padding: 1.2rem 2rem;
        font-size: 1.1rem;
        border-radius: 15px;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .next-btn:active {
        transform: scale(0.95);
    }
    
    .hint {
        padding: 0.8rem;
        border-radius: 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .game-area {
        padding: 1.5rem;
    }
    
    .letters-container {
        gap: 0.5rem;
    }
    
    .letter {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }
    
    .answer-area {
        flex-direction: column;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .control-btn {
        flex: 1;
        min-width: 100px;
    }
    
    .letter {
        width: 85px;
        height: 85px;
        font-size: 1.5rem;
    }
    
    .letters-container {
        gap: 0.6rem;
    }
    
    .game-area {
        padding: 1.2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .control-btn {
        width: 100%;
        min-width: auto;
    }
}

/* Add touch-friendly hover states for mobile */
@media (hover: none) and (pointer: coarse) {
    .letter:hover {
        transform: none;
        box-shadow: none;
    }
    
    .control-btn:hover {
        background: #6c757d;
        transform: none;
    }
    
    .next-btn:hover {
        background: #28a745;
        transform: none;
    }
}

/* Improve accessibility and touch targets */
.letter, .control-btn, .next-btn, #answerInput {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#answerInput {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Prevent text selection on touch */
.question-card, .modal-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}