* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent touch highlighting on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #ffc857 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.floating-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.shape {
    position: absolute;
    opacity: 0.1;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #ff6b6b, transparent);
    border-radius: 50%;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, #4ecdc4, transparent);
    border-radius: 50%;
    top: 70%;
    right: 10%;
    animation-delay: 2s;
}

.shape-3 {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, #45b7d1, transparent);
    border-radius: 50%;
    top: 30%;
    right: 20%;
    animation-delay: 4s;
}

.shape-4 {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, #96ceb4, transparent);
    border-radius: 50%;
    bottom: 20%;
    left: 15%;
    animation-delay: 6s;
}

.shape-5 {
    width: 90px;
    height: 90px;
    background: radial-gradient(circle, #feca57, transparent);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    animation-delay: 8s;
}

.shape-6 {
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, #ff9ff3, transparent);
    border-radius: 50%;
    top: 80%;
    left: 40%;
    animation-delay: 10s;
}

.shape-7 {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle, #74b9ff, transparent);
    border-radius: 50%;
    top: 20%;
    left: 70%;
    animation-delay: 12s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.1;
    }

    25% {
        transform: translateY(-20px) rotate(90deg);
        opacity: 0.2;
    }

    50% {
        transform: translateY(0px) rotate(180deg);
        opacity: 0.1;
    }

    75% {
        transform: translateY(20px) rotate(270deg);
        opacity: 0.2;
    }
}

.main-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1400px;
    width: 100%;
    padding: 30px;
    backdrop-filter: blur(10px);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.header {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #a29bfe, #6c5ce7, #ff9ff3, #ee5a6f);
    background-size: 300% 300%;
    animation: gradientMove 8s ease infinite;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.game-title {
    font-size: 2.5em;
    font-weight: 700;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    letter-spacing: 2px;
    animation: pulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.score,
.timer,
.level {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 20px;
    border-radius: 15px;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.score:hover,
.timer:hover,
.level:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.score i,
.timer i,
.level i {
    color: #6c5ce7;
    margin-right: 8px;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn:hover:before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover {
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
    color: white;
}

.btn-secondary {
    background: linear-gradient(45deg, #ff6b6b, #ee5a6f);
    color: white;
}

.btn-hint {
    background: linear-gradient(45deg, #feca57, #f39c12);
    color: white;
}

.btn-check {
    background: linear-gradient(45deg, #00b894, #00a085);
    color: white;
}

.btn-clear {
    background: linear-gradient(45deg, #74b9ff, #0984e3);
    color: white;
}

.btn-music {
    background: linear-gradient(45deg, #96ceb4, #88b0a3);
    color: white;
}

.btn-home {
    background: linear-gradient(45deg, #ff9ff3, #ee5a6f);
    color: white;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
}

.image-section {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-display {
    width: 100%;
    height: 300px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.placeholder-image {
    text-align: center;
    color: #999;
}

.placeholder-image i {
    font-size: 4em;
    margin-bottom: 20px;
    color: #ddd;
}

.placeholder-image p {
    font-size: 1.2em;
    font-weight: 600;
}

.image-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 15px;
    animation: imageAppear 0.5s ease;
}

@keyframes imageAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.word-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.target-word {
    text-align: center;
}

.target-word h3 {
    font-size: 1.5em;
    font-weight: 700;
    color: #2d3436;
    margin-bottom: 15px;
}

.word-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.word-slot {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    border: 3px dashed #6c5ce7;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    font-weight: 700;
    color: #6c5ce7;
    background: rgba(108, 92, 231, 0.1);
    transition: all 0.3s ease;
    touch-action: none;
}

.word-slot.filled {
    border-color: #00b894;
    background: rgba(0, 184, 148, 0.1);
    color: #00b894;
    animation: slotFilled 0.3s ease;
}

@keyframes slotFilled {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.word-slot.drag-over {
    border-color: #feca57;
    background: rgba(254, 202, 87, 0.2);
    transform: scale(1.05);
}

.letters-pool {
    text-align: center;
}

.letters-pool h3 {
    font-size: 1.3em;
    font-weight: 700;
    color: #2d3436;
    margin-bottom: 15px;
}

.letters-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 80px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    border: 2px dashed #ddd;
}

.letter-tile {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff9ff3, #ee5a6f);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.5em;
    font-weight: 700;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.letter-tile:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.letter-tile.dragging {
    cursor: grabbing;
    opacity: 0.5;
    transform: rotate(5deg);
}

.letter-tile.used {
    opacity: 0.3;
    cursor: not-allowed;
    transform: scale(0.8);
}

/* Touch-specific improvements */
.letter-tile {
    /* Better touch targets */
    touch-action: none;
}

.touch-ghost {
    border-radius: 10px !important;
    transition: none !important;
}

/* Visual feedback for touch dragging */
.word-slot.drag-over {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(116, 185, 255, 0.6);
}

/* Touch-specific highlighting for functional drag and drop */
.word-slot.touch-highlight {
    background: rgba(74, 222, 128, 0.4) !important;
    border: 4px solid #4ade80 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.6) !important;
    animation: pulse 0.6s infinite alternate;
}

/* CRÍTICO: Clon táctil que NO interfiere con detección */
.touch-clone {
    position: fixed !important;
    z-index: 9999 !important;
    pointer-events: none !important;
    opacity: 0.8 !important;
    transform: scale(1.2) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
    transition: none !important;
    will-change: transform, left, top;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}


@keyframes pulse {
    from {
        box-shadow: 0 0 15px rgba(74, 222, 128, 0.6);
    }

    to {
        box-shadow: 0 0 25px rgba(74, 222, 128, 0.8);
    }
}

/* Prevent scrolling while dragging */
body.dragging-active {
    overflow: hidden;
    position: fixed;
}

.letter-tile.hint {
    animation: hintPulse 1s ease infinite;
}

@keyframes hintPulse {

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

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(254, 202, 87, 0.6);
    }
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.feedback-area {
    text-align: center;
    margin-top: 30px;
}

.feedback-message {
    background: linear-gradient(45deg, #a29bfe, #6c5ce7, #ff9ff3, #ee5a6f);
    background-size: 300% 300%;
    animation: gradientMove 6s ease infinite;
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    font-size: 1.4em;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: inline-block;
    animation: slideInUp 0.5s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-section {
    margin-top: 20px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6c5ce7, #a29bfe, #ff9ff3);
    border-radius: 15px;
    transition: width 0.5s ease;
    width: 0%;
    box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

.progress-text {
    font-size: 1.1em;
    font-weight: 600;
    color: #2d3436;
}

.confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    animation: confettiFall 3s ease-in-out;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Game Footer */
.game-footer {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    animation: slideInUp 0.6s ease;
}

.game-footer .creator-credit {
    text-align: center;
    margin: 0;
    padding: 0;
    border: none;
}

.game-footer .made-by {
    font-size: 0.8em;
    color: #666;
    margin-bottom: 3px;
    font-weight: 500;
}

.game-footer .creator-name {
    color: #6c5ce7;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.game-footer .creator-name:hover {
    color: #a29bfe;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.game-footer .visit-site {
    font-size: 0.7em;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.game-footer .visit-site:hover {
    color: #6c5ce7;
}

.game-footer .creator-link {
    color: #6c5ce7;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
}

.game-footer .creator-link:hover {
    color: #a29bfe;
    border-bottom-color: #a29bfe;
}

.game-footer .visit-site i {
    color: #feca57;
    font-size: 0.8em;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-area {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .image-display {
        height: 250px;
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 20px;
    }

    .game-title {
        font-size: 2em;
        flex-direction: column;
        gap: 10px;
    }

    .score-board {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .game-controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 200px;
        justify-content: center;
    }

    .image-display {
        height: 200px;
    }

    .word-slot {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }

    .letter-tile {
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 15px;
    }

    .game-title {
        font-size: 1.5em;
    }

    .feedback-message {
        font-size: 1.1em;
        padding: 15px 20px;
    }

    .image-display {
        height: 180px;
    }

    .word-slot {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .letter-tile {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============ SISTEMA OPTIMIZADO PARA PIZARRAS DIGITALES Y TVs TÁCTILES ============ */

/* Optimización para pantallas táctiles grandes */
body {
    /* Prevenir scroll accidental en pizarras */
    overscroll-behavior: none;
    touch-action: manipulation;
}

/* Tiles optimizadas para pizarras digitales */
.letter-tile {
    /* Tamaño más grande para pantallas táctiles */
    min-width: 70px !important;
    min-height: 70px !important;

    /* Feedback táctil mejorado */
    cursor: grab !important;
    transition: all 0.2s ease !important;

    /* Mejor detección táctil */
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
}

/* Estado dragging para pizarras */
.letter-tile.dragging {
    cursor: grabbing !important;
    transform: scale(1.2) !important;
    z-index: 9999 !important;
    opacity: 0.6 !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5) !important;
    border: 3px solid #fff !important;
}

/* Slots optimizados para pizarras digitales */
.word-slot {
    /* Tamaño más grande para pantallas táctiles */
    min-width: 80px !important;
    min-height: 80px !important;

    /* Zona de detección más grande */
    border-width: 5px !important;

    /* Mejor respuesta táctil */
    touch-action: none !important;
    -webkit-touch-callout: none !important;
}

/* Highlight visible para pizarras grandes */
.word-slot.touch-highlight {
    background: rgba(74, 222, 128, 0.4) !important;
    border: 5px solid #4ade80 !important;
    transform: scale(1.15) !important;
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.8) !important;
    animation: digitalBoardPulse 0.8s infinite alternate !important;
}

/* Animación especial para pizarras digitales */
@keyframes digitalBoardPulse {
    from {
        box-shadow: 0 0 30px rgba(74, 222, 128, 0.8);
        transform: scale(1.15);
    }

    to {
        box-shadow: 0 0 50px rgba(74, 222, 128, 1);
        transform: scale(1.20);
    }
}

/* Animación pulse para highlighting táctil */
@keyframes touchPulse {
    from {
        box-shadow: 0 0 15px rgba(74, 222, 128, 0.6);
        transform: scale(1.05);
    }

    to {
        box-shadow: 0 0 25px rgba(74, 222, 128, 0.8);
        transform: scale(1.08);
    }
}

/* Mejoras en dragging state */
.letter-tile.dragging {
    cursor: grabbing !important;
    transform: scale(1.1) rotate(3deg) !important;
    z-index: 1000 !important;
    opacity: 0.7 !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
}

/* Estados mejorados para slots */
.word-slot.drag-over {
    background: rgba(74, 222, 128, 0.3) !important;
    border: 4px solid #4ade80 !important;
    transform: scale(1.05) !important;
    animation: dragOverPulse 0.4s ease !important;
}

@keyframes dragOverPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1.05);
    }
}

/* Mejoras para slots filled */
.word-slot.filled {
    border: 4px solid #4ade80 !important;
    background: rgba(74, 222, 128, 0.2) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.4) !important;
    animation: slotFilledSuccess 0.5s ease !important;
}

@keyframes slotFilledSuccess {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1.05);
    }
}

/* Animación bounce para éxito */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0) scale(1.05);
    }

    50% {
        transform: translateY(-15px) scale(1.1);
    }
}

/* Animación fall para confetti */
@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Mejoras en responsive para móviles */
@media (max-width: 768px) {
    .letter-tile {
        width: 60px !important;
        height: 60px !important;
        font-size: 28px !important;
        margin: 5px !important;
    }

    .word-slot {
        width: 65px !important;
        height: 65px !important;
        font-size: 30px !important;
        margin: 3px !important;
    }

    .touch-clone {
        transform: scale(1.1) !important;
    }
}

@media (max-width: 480px) {
    .letter-tile {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
        margin: 3px !important;
    }

    .word-slot {
        width: 55px !important;
        height: 55px !important;
        font-size: 26px !important;
        margin: 2px !important;
    }

    .touch-clone {
        transform: scale(1.0) !important;
    }
}

/* Optimización para touch en dispositivos móviles */
@media (hover: none) and (pointer: coarse) {
    .letter-tile:hover {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    }

    .letter-tile:active {
        transform: scale(1.05) !important;
    }

    .word-slot {
        min-height: 60px;
        min-width: 60px;
    }
}

/* Prevenir selección de texto durante el arrastre */
body.dragging-active,
body.dragging-active * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* Mejora de rendimiento para el clon táctil */
.touch-clone,
.letter-tile.dragging {
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}

/* Feedback visual mejorado para errores */
.word-slot.incorrect {
    background: rgba(255, 107, 107, 0.3) !important;
    border: 4px solid #ff6b6b !important;
    animation: shake 0.5s ease !important;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0) scale(1.05);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-3px) scale(1.05);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(3px) scale(1.05);
    }
}