* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: transparent;
    border-radius: 20px;
    padding: 0;
    box-shadow: none;
    max-width: 800px;
    width: 100%;
    perspective: 1000px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.container.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: relative;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: white;
    border-radius: 20px;
    padding: 40px 40px 20px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.card-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
}

h1 {
    text-align: center;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.title-main {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: bold;
}

.title-sub {
    font-size: 1.4rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: normal;
}

.instructions {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.tile-area {
    position: relative;
    width: 100%;
    min-height: 300px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    margin-bottom: 15px;
    border: 2px dashed #ddd;
    overflow: hidden;
}

.current-word-display {
    text-align: center;
    font-size: 2em;
    font-weight: bold;
    letter-spacing: 5px;
    color: #333;
    margin-bottom: 25px;
    min-height: 1.2em;
    text-transform: uppercase;
    font-family: 'Courier New', Courier, monospace;
}

.tile {
    width: 60px;
    height: 60px;
    position: absolute;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8em;
    font-weight: bold;
    border-radius: 10px;
    text-transform: uppercase;
    cursor: move;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: left 0.5s ease, top 0.5s ease, transform 0.2s, box-shadow 0.2s;
    z-index: 1;
}

.tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.tile.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    transition: none;
}

.tile.correct {
    animation: bounce 0.6s ease;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

button {
    padding: 12px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.solve-btn {
    background: linear-gradient(135deg, #1b5e20 0%, #43a047 100%);
    color: white;
}

.shuffle-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.manual-btn {
    background: linear-gradient(135deg, #f57c00 0%, #ff9800 100%);
    color: white;
}

.exit-btn {
    background: linear-gradient(135deg, #455a64 0%, #607d8b 100%);
    color: white;
}

.manual-input-container {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

#manual-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 20px;
    font-size: 1.2em;
    border: 2px solid #ddd;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
    text-align: center;
    text-transform: uppercase;
    font-family: 'Ubuntu', sans-serif;
}

#manual-input:focus {
    border-color: #667eea;
}

.message {
    text-align: center;
    margin-top: 15px;
    font-size: 1.3em;
    font-weight: bold;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.message:not(:empty) {
    min-height: 40px;
    padding: 10px;
    margin-bottom: 10px;
}

.message.success {
    color: #11998e;
    background: #d4edda;
    border: 2px solid #c3e6cb;
    animation: fadeIn 0.5s ease;
}

.message.error {
    color: #f5576c;
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

/* Responsive design */
@media (max-width: 600px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .container {
        padding: 0;
        border-radius: 15px;
    }

    .card-front, .card-back {
        padding: 15px 15px 10px 15px;
        border-radius: 15px;
    }
    
    h1 {
        margin-bottom: 5px;
    }

    .title-main {
        font-size: 1.8rem;
    }

    .title-sub {
        font-size: 1.1rem;
    }

    .instructions {
        margin-bottom: 15px;
        font-size: 0.95em;
    }

    .tile-area {
        min-height: 220px;
        padding: 10px;
        margin-bottom: 10px;
    }

    .current-word-display {
        font-size: 1.4em;
        letter-spacing: 2px;
        margin-bottom: 15px;
    }
    
    .tile {
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    button {
        padding: 10px 20px;
        font-size: 1em;
        width: 100%;
    }

    .message {
        margin-top: 10px;
        font-size: 1.1em;
    }
}
