/* =========================================
   1. CONTENEDOR GENÉRICO DE JUEGO
   ========================================= */
.game-container {
    background: rgba(255, 248, 225, 0.65);
    border: 2px solid rgba(141, 110, 99, 0.5);
    border-radius: 16px;
    padding: 30px;
    box-shadow:
        0 15px 35px rgba(0, 0, 0, 0.2),
        inset 0 0 30px rgba(255, 255, 255, 0.4);
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    z-index: 20;
    transition: box-shadow 0.3s ease;
}

.game-container:hover {
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.25),
        inset 0 0 30px rgba(255, 255, 255, 0.5);
}

/* =========================================
   2. SISTEMA DE PISTAS (HINTS)
   ========================================= */
.hint-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.hint-box {
    background: linear-gradient(to bottom, #4e342e, #3e2723);
    border: 2px solid #8d6e63;
    border-radius: 8px;
    padding: 15px 20px;
    color: #d7ccc8;
    min-width: 250px;
    flex: 1;
    max-width: 450px;
    display: flex;
    flex-direction: row;
    /* Escritorio: En línea */
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.hint-box.disabled {
    opacity: 0.8;
    background: #2d201c;
    border-color: #4e342e;
    cursor: not-allowed;
}

.hint-box.enabled {
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.hint-box.active,
.hint-box.revealed {
    background: #ffecb3;
    color: #3e2723;
    border-color: #ffb300;
}

.hint-title {
    font-family: 'Pirata One', cursive;
    font-size: 1.4rem;
    letter-spacing: 1px;
    white-space: nowrap;
}

.hint-lock {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #ffb300;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 179, 0, 0.3);
    white-space: nowrap;
}

/* Pistas Reveladas (Texto) */
.revealed-hints-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.revealed-hint-line {
    background: rgba(255, 253, 231, 0.95);
    padding: 12px 20px;
    margin: 8px 0;
    border-radius: 6px;
    border-left: 5px solid #ffb300;
    font-weight: 500;
    color: #3e2723;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.5s ease;
    width: fit-content;
    min-width: 60%;
    max-width: 90%;
    text-align: center;
}

/* =========================================
   3. INPUT Y BÚSQUEDA (SEARCH WRAP)
   ========================================= */
.searchWrap {
    position: relative;
    max-width: 600px;
    margin: 0 auto 30px;
    z-index: 50;
}

.input-group {
    display: flex;
    gap: 10px;
    border-radius: 50px;
}

#guessInput {
    flex: 1;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-family: 'Roboto', sans-serif;
    color: #3e2723;
    background-color: #fffbf0;
    border: 2px solid #8d6e63;
    border-radius: 50px;
    outline: none;
    transition: border-color 0.3s;
}

#guessInput:focus {
    border-color: #8d6e63;
    box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.2);
}

#guessBtn {
    background: linear-gradient(to bottom, #3e2723, #2d201c);
    color: #ffca28;
    border: 2px solid #000000;
    padding: 12px 12px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Pirata One', cursive;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

#guessBtn:active {
    transform: translateY(2px);
}

#guessBtn svg {
    stroke: #ffca28;
}

/* =========================================
   4. AUTOCOMPLETE
   ========================================= */
#autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #4e342e;
    border: none;
    border-radius: 8px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    text-align: left !important;
}

#autocomplete::-webkit-scrollbar {
    width: 8px;
}

#autocomplete::-webkit-scrollbar-track {
    background: #3e2723;
}

#autocomplete::-webkit-scrollbar-thumb {
    background: #8d6e63;
    border-radius: 4px;
}

.ac-item {
    padding: 10px 15px;
    border-bottom: 1px solid #5d4037;
    color: #d7ccc8;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: block;
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.highlighted {
    background: #5d4037;
}

/* Flexbox para la fila interna */
.ac-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100%;
}

.ac-avatar {
    display: block;
    width: 50px !important;
    height: 50px !important;
    object-fit: cover;
    object-position: top center;
    border-radius: 4px;
    border: 1px solid #8d6e63;
    flex: 0 0 50px !important;
    margin-right: 15px !important;
}

.ac-texts {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    min-width: 0;
    line-height: 1.2;
}

.ac-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffecb3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.ac-alias {
    font-size: 0.9rem;
    color: #a1887f;
    font-style: italic;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.ac-item:hover .ac-name,
.ac-item.highlighted .ac-name {
    color: #ffca28;
}

.ac-item:hover .ac-alias,
.ac-item.highlighted .ac-alias {
    color: #d7ccc8;
}

.ac-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.ac-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 202, 40, 0.25);
    border-top-color: #ffca28;
    border-radius: 50%;
    animation: ac-spin 0.7s linear infinite;
}

@keyframes ac-spin {
    to {
        transform: rotate(360deg);
    }
}

.ac-no-results {
    padding: 14px 20px;
    color: #a1887f;
    font-style: italic;
    text-align: center;
    font-size: 0.95rem;
}

.ac-load-more {
    padding: 10px 20px;
    text-align: center;
    font-size: 0.9rem;
    color: #bcaaa4;
    cursor: pointer;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.15s, color 0.15s;
}

.ac-load-more:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #efebe9;
}

.ac-loading-more {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* =========================================
   5. MENSAJE DE VICTORIA
   ========================================= */
#winMsg {
    margin: 10px;
    margin-top: 20px;
    animation: bounceIn 0.8s;
}

.win-content {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    border: 3px solid #ffb300;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.jolly-roger img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: #fff;
    object-fit: cover;
    object-position: top center;
}

#winMsg h2 {
    font-family: 'Pirata One', cursive;
    color: #ffca28;
    font-size: 2rem;
    margin: 0 0 10px 0;
}

#winMsg p {
    margin: 0;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* =========================================
   6. MENSAJES DE ERROR
   ========================================= */
.error-message {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
    animation: fadeIn 0.3s ease;
}

.error-message.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* =========================================
   7. ANIMACIONES COMUNES
   ========================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}


/* =========================================
   9. ACTION BUTTONS (Surrender, etc)
   ========================================= */

.btn-surrender {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    /* Slightly larger matching height of standard inputs usually */
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #c62828, #b71c1c);
    color: #fff;
    border: 2px solid #8d0000;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    flex-shrink: 0;

    /* Position */
    margin-left: 10px;
}


.btn-surrender:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-surrender svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

/* =========================================
   8. RESPONSIVE COMÚN (MÓVIL)
   ========================================= */
@media (max-width: 600px) {
    .game-container {
        padding: 15px 10px;
    }

    /* Input y Botón apilados */
    .searchWrap {
        max-width: 100%;
        position: relative;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    #guessInput {
        width: 100%;
        font-size: 1.2rem;
    }

    #guessBtn {
        width: 100%;
        justify-content: center;
        padding: 12px 0;
        font-size: 1.4rem;
    }

    /* Autocomplete posicionado bajo el input */
    #autocomplete {
        top: 60px;
        z-index: 200;
        width: 100%;
    }

    /* Pistas apiladas verticalmente */
    .hint-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }

    .hint-box {
        width: 100%;
        min-width: unset;
        flex-direction: row;
        justify-content: space-between;
        padding: 15px 10px;
        gap: 8px;
        height: auto;
    }

    .hint-title {
        white-space: normal;
        text-align: left;
    }

    .hint-lock {
        flex-shrink: 0;
    }

    .revealed-hint-line {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Win modal apilado */
    .win-content {
        flex-direction: column;
        text-align: center;
    }
}

/* =========================================
   9. SECCIÓN DE INFORMACIÓN / TUTORIAL
   ========================================= */
.info-game {
    background: linear-gradient(135deg, #3e2723, #281b18);
    border: 3px solid #ffb300;
    border-radius: 12px;
    padding: 30px;
    margin: 10px;
    margin-top: 40px;
    margin-bottom: 40px;
    color: #d7ccc8;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.info-game h3 {
    font-family: 'Pirata One', cursive;
    font-size: 2rem;
    color: #ffca28;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 202, 40, 0.3);
    padding-bottom: 10px;
}

.info-game p {
    line-height: 1.6;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.color-legend {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.color-legend li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.color-legend strong {
    display: block;
    color: #ffecb3;
    margin-bottom: 4px;
}

.color-legend span {
    font-size: 0.9rem;
    color: #bcaaa4;
}

.color-legend .color-box {
    width: 30px;
    height: 30px;
    margin-top: 2px;
}

.game-legend-container .color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.color-box {
    display: inline-block;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-top: 2px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.color-box.green {
    background: linear-gradient(145deg, rgba(46, 139, 87, 0.9), rgba(34, 102, 68, 0.9));
}

.color-box.yellow {
    background: linear-gradient(145deg, rgba(230, 126, 34, 0.85), rgba(211, 84, 0, 0.85));
}

.color-box.gray {
    background: linear-gradient(145deg, #757575, #505050);
}

.color-box.red {
    background: linear-gradient(145deg, #da1616, #8d1616);
}


/* =========================================
   SEARCH ACTIONS (Common for Personaje/Fruta)
   ========================================= */
.search-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Ajustes Responsive para la barra de búsqueda */
@media (max-width: 600px) {
    .input-group {
        display: flex;
        flex-direction: column;
        /* Force column layout on mobile */
        gap: 10px;
        background: transparent;
        border-radius: 0;
    }

    /* FILA 1: Input ocupa todo el ancho */
    #guessInput {
        width: 100%;
        border-radius: 50px;
        margin: 0;
        /* Clear previous margins */
        text-align: center;
    }

    /* FILA 2: Contenedor de botones acciones */
    .search-actions {
        display: flex;
        width: 100%;
        gap: 10px;
        /* Default flex row behaviour is good here */
    }

    /* FILA 2: Botón Adivinar (~83% visual) */
    #guessBtn {
        flex: 5;
        border-radius: 50px;
        justify-content: center;
        padding: 20px 20px;
        width: auto;
        /* Reset fixed width */
        margin: 0;
    }

    #guessBtn span {
        display: inline;
        font-size: 1rem;
    }

    /* FILA 2: Botón Rendirse (~17% visual) */
    .btn-surrender {
        flex: 1;
        margin: 0;
        width: auto;
        height: auto;
        aspect-ratio: auto;
        /* Remove explicit circle aspect */
        border-radius: 50px;
        padding: 0;
        align-self: stretch;
        /* Match height of guessBtn */
    }

    .btn-surrender svg {
        width: 24px;
        height: 24px;
    }
}

/* Disabled Level Buttons */
.btn-level.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #3e2723 !important;
    pointer-events: none;
    box-shadow: none;
    transform: none;
    color: #9e9e9e;
    border-color: #5d4037;
}
