@import url('https://fonts.googleapis.com/css2?family=Cal+Sans:wght@400;600;700&display=swap');

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

body {
    font-family: 'Cal Sans', sans-serif;
    background: white;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #2c3e50;
}

header p {
    font-size: 1.1rem;
    color: #7f8c8d;
}

.game-area {
    display: grid;
    gap: 30px;
    animation: fadeIn 1s ease-out 0.3s both;
}

.game-screen {
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto auto auto;
    gap: 30px;
    animation: fadeIn 1s ease-out;
    align-items: start;
}

.hangman-display {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 0;
    position: sticky;
    top: 20px;
}

#gallows {
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
    width: 240px;
    height: 300px;
}

#gallows:hover {
    transform: scale(1.02);
}

.word-display {
    grid-column: 2;
    grid-row: 1;
    text-align: center;
    margin-bottom: 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.word-letters {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.letter-box {
    width: 55px;
    height: 65px;
    border: 3px solid #3498db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 600;
    background: white;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.letter-box.revealed {
    background: #e8f6f3;
    border-color: #27ae60;
    transform: scale(1.1);
    color: #27ae60;
}

.alphabet {
    margin-bottom: 0;
}

.game-controls {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.letter-buttons {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    max-width: 100%;
    margin: 0;
}

.letter-btn {
    padding: 14px 8px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.letter-btn:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
}

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

.letter-btn.disabled {
    background: #ecf0f1;
    color: #95a5a6;
    border-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.letter-btn.wrong {
    background: #e74c3c;
    color: white;
    border-color: #c0392b;
}

.letter-btn.correct {
    background: #27ae60;
    color: white;
    border-color: #229954;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: center;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.wrong-letters, .attempts {
    font-weight: 600;
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#wrongLetters {
    color: #e74c3c;
    margin-left: 10px;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

#attemptsLeft {
    color: #3498db;
    font-size: 1.2rem;
}

.game-status {
    grid-column: 1 / -1;
    grid-row: 3;
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.game-message {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-message.win {
    color: #27ae60;
    animation: bounce 0.6s ease;
}

.game-message.lose {
    color: #e74c3c;
    animation: shake 0.6s ease;
}

.new-game-btn {
    padding: 15px 30px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.new-game-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.new-game-btn:active {
    transform: translateY(0);
}

.start-game-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}

.start-game-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.start-game-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1c5985);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.start-game-btn:hover:before {
    left: 100%;
}

.start-game-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.3);
}

.start-game-btn:disabled {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(149, 165, 166, 0.2);
}

.start-game-btn:disabled:hover {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
    transform: none;
    box-shadow: 0 2px 8px rgba(149, 165, 166, 0.2);
}

.start-game-btn:disabled:before {
    display: none;
}

.word-input-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    animation: fadeIn 0.8s ease-out;
}

.input-container {
    text-align: center;
    background: #f8f9fa;
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-width: 500px;
    width: 100%;
}

.input-container h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
}

.input-container p {
    color: #e74c3c;
    font-weight: 600;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

#customWordInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #3498db;
    border-radius: 8px;
    font-size: 1.2rem;
    font-family: inherit;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

#customWordInput:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#hintInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #95a5a6;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

#hintInput:focus {
    outline: none;
    border-color: #7f8c8d;
    box-shadow: 0 0 0 3px rgba(149, 165, 166, 0.2);
}

.hint-section {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.hint-btn {
    padding: 8px 16px;
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    margin-bottom: 10px;
}

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

.hint-display {
    background: #fff3cd;
    border: 2px solid #ffeaa7;
    border-radius: 8px;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #856404;
    animation: fadeIn 0.5s ease-out;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideIn {
    from {
        transform: scale(0.8) translateY(-10px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
    }
    40%, 43% {
        transform: translateY(-10px);
    }
    70% {
        transform: translateY(-5px);
    }
    90% {
        transform: translateY(-2px);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Responsive for iPad */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        max-width: 900px;
        padding: 30px;
    }
    
    .game-screen {
        grid-template-columns: 1fr 1.8fr;
        gap: 25px;
    }
    
    #gallows {
        width: 220px;
        height: 280px;
    }
    
    .letter-buttons {
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
    }
    
    .letter-btn {
        padding: 12px 6px;
        font-size: 1.1rem;
    }
    
    .letter-box {
        width: 50px;
        height: 60px;
        font-size: 2rem;
    }
}

/* Responsive for tablets in portrait */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .game-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 20px;
    }
    
    .hangman-display {
        grid-column: 1;
        grid-row: 1;
        position: static;
        margin-bottom: 20px;
    }
    
    .word-display {
        grid-column: 1;
        grid-row: 2;
    }
    
    .game-controls {
        grid-column: 1;
        grid-row: 3;
    }
    
    .game-status {
        grid-column: 1;
        grid-row: 4;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .letter-buttons {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
    }
    
    .letter-btn {
        padding: 10px 6px;
        font-size: 1rem;
    }
    
    .letter-box {
        width: 40px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .game-info {
        grid-template-columns: 1fr;
        gap: 15px;
        text-align: center;
    }
    
    .hint-section {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    #gallows {
        width: 180px;
        height: 225px;
    }
    
    .input-container {
        padding: 30px 20px;
        margin: 0 15px;
    }
    
    .input-container h2 {
        font-size: 1.5rem;
    }
}

/* Large desktop optimization */
@media (min-width: 1200px) {
    .container {
        max-width: 1000px;
        padding: 40px;
    }
    
    .game-screen {
        grid-template-columns: 1fr 2.5fr;
        gap: 40px;
    }
    
    #gallows {
        width: 280px;
        height: 350px;
    }
    
    .letter-buttons {
        grid-template-columns: repeat(9, 1fr);
        gap: 12px;
    }
    
    .letter-btn {
        padding: 16px 10px;
        font-size: 1.3rem;
    }
    
    .letter-box {
        width: 60px;
        height: 70px;
        font-size: 2.4rem;
    }
    
    .word-display {
        padding: 30px;
    }
    
    .game-info {
        padding: 30px;
    }
    
    header h1 {
        font-size: 3.5rem;
    }
}