@media (prefers-color-scheme: dark) {
  body {
    background-color: #000;
    color: inherit;
  }
  * {
    color-scheme: dark;
  }
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #0F1527;
    font-family: Arial, sans-serif;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    color: white;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #0F1527;
}

#stars-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-title {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 30px;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 10px #88f, 0 0 20px #44f;
    z-index: 10;
}
#stats-bar {
    position: absolute;
    top: 70px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 15px;
    box-sizing: border-box;
    z-index: 10;
}
#selected-category {
    font-size: 16px;
    color: #aaccff;
    font-weight: bold;
    margin-bottom: 5px;
}
#words-hidden {
    font-size: 16px;
    color: #ffcc66;
    font-weight: bold;
}
#words-found {
    font-size: 16px;
    color: #99ff99;
    font-weight: bold;
}
#word-display {
    position: absolute;
    top: 150px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 22px;
    color: white;
    text-shadow: 0 0 5px #fff;
    z-index: 10;
}
/* Word complete animation */
#word-complete-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-size: 40px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    z-index: 25;
    opacity: 0;
    transition: opacity 0.5s, transform 0.5s;
    pointer-events: none;
    text-align: center;
}
#word-complete-animation.word-complete-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}
#word-complete-animation.word-complete-hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
}
.buttons-container {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 10;
}
.button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.button svg {
    width: 24px;
    height: 24px;
}
.button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}
#undo-btn {
    background-color: #33B8B8;
    box-shadow: 0 0 10px rgba(51, 153, 51, 0.5);
}
#hint-btn {
    background-color: #339933;
    box-shadow: 0 0 10px rgba(51, 153, 51, 0.5);
}
#hint-btn:disabled {
    background-color: #336633;
    box-shadow: none;
    opacity: 0.7;
    cursor: not-allowed;
}
#check-btn {
    background-color: #3355cc;
    box-shadow: 0 0 10px rgba(51, 85, 204, 0.5);
}
#check-btn:disabled {
    background-color: #334466;
    box-shadow: none;
    opacity: 0.7;
    cursor: not-allowed;
}
#clear-btn {
    background-color: #cc3355;
    box-shadow: 0 0 10px rgba(204, 51, 85, 0.5);
}
#restart-btn {
    background-color: #cc5500;
    box-shadow: 0 0 10px rgba(204, 85, 0, 0.5);
}
#settings-btn {
    background-color: #666699;
    box-shadow: 0 0 10px rgba(102, 102, 153, 0.5);
}
#copyright {
    position: absolute;
    bottom: 15px;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #888;
    z-index: 10;
}
#copyright a {
    color: #aaf;
    text-decoration: none;
}
#copyright a:hover {
    text-decoration: underline;
    color: #ccf;
}
.star {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 4px black;
    background: radial-gradient(circle at 30% 30%, #4488ff, #224488);
    box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 2;
}
.star.selected {
    transform: scale(1.3);
    box-shadow: 0 0 15px 5px #88ddff;
    background: radial-gradient(circle at 30% 30%, #55aaff, #3366cc);
    z-index: 3;
}
.star.used {
    background: radial-gradient(circle at 30% 30%, #ffd700, #ff9900);
    cursor: default;
}
/* New fade-out animation for used stars */
.star.fading {
    animation: fadeOut 2s forwards;
    pointer-events: none;
}
@keyframes fadeOut {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(0); }
}
.star.hint {
    animation: pulsate 1.5s infinite alternate;
    box-shadow: 0 0 15px 5px #88ff88;
    z-index: 3;
}
@keyframes pulsate {
    0% { transform: scale(1); box-shadow: 0 0 10px 2px #88ff88; }
    100% { transform: scale(1.2); box-shadow: 0 0 20px 5px #88ff88; }
}
.path-hint {
    position: absolute;
    height: 3px;
    background: linear-gradient(to right, rgba(80, 255, 80, 0.8), rgba(80, 255, 80, 0.3));
    transform-origin: 0% 50%;
    z-index: 1;
    pointer-events: none;
    animation: pathPulsate 1.5s infinite alternate;
}
@keyframes pathPulsate {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}
.line {
    position: absolute;
    height: 2px;
    background: linear-gradient(to right, rgba(255,255,255,0.8), rgba(255,255,255,0.3));
    transform-origin: 0% 50%;
    z-index: 1;
    pointer-events: none;
}
.line.permanent {
    opacity: 0.6;
}
/* Fade out animation for lines */
.line.fading {
    animation: fadeOutLine 2s forwards;
}
@keyframes fadeOutLine {
    0% { opacity: 0.6; }
    100% { opacity: 0; }
}
.bg-star {
    position: absolute;
    background-color: white;
    border-radius: 50%;
    pointer-events: none;
}
#message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 20;
    pointer-events: none;
}
.hint-panel {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    z-index: 11;
    display: none;
    transition: opacity 0.3s;
}
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.modal.open {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    width: 80%;
    max-width: 500px;
    background-color: #1a2033;
    border-radius: 10px;
    padding: 20px;
    color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: #4466cc #1a2033;
    -webkit-overflow-scrolling: touch; /* Para iOS scrolling suave */
    overscroll-behavior-y: contain; /* Prevenir rebote en dispositivos */
    touch-action: pan-y; /* Permitir desplazamiento vertical */
}
/* Estilizar scrollbar para Webkit (Chrome, Safari, etc.) */
.modal-content::-webkit-scrollbar {
    width: 8px;
}
.modal-content::-webkit-scrollbar-track {
    background: #1a2033;
    border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb {
    background-color: #4466cc;
    border-radius: 4px;
    border: 2px solid #1a2033;
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
}
.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
.modal-title {
    font-size: 20px;
    text-align: center;
    margin-bottom: 20px;
    color: #88f;
    font-weight: bold;
}
.modal-section {
    margin-bottom: 20px;
}
.modal-section-title {
    font-size: 16px;
    margin-bottom: 8px;
    color: #bbf;
}
.modal-section p {
    margin: 8px 0;
    line-height: 1.4;
    font-size: 14px;
}
.modal-section ul {
    margin: 8px 0;
    padding-left: 20px;
}
.modal-section li {
    margin: 5px 0;
    line-height: 1.3;
    font-size: 14px;
}
select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    background-color: #2a3045;
    color: white;
    border: 1px solid #4466cc;
    margin-bottom: 15px;
    font-size: 15px;
}
select option {
    background-color: #1a2033;
    color: white;
}
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}
.modal-button {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    background-color: #4466cc;
    color: white;
    cursor: pointer;
    font-weight: bold;
}
.how-to-play-btn {
    background-color: #33aa66;
}
.close-modal {
    background-color: #4466cc;
}
.confirm-restart {
    background-color: #cc3355;
}
.cancel-restart {
    background-color: #666;
}
.audio-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.audio-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #2a3045;
    border: 2px solid #4466cc;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}
.audio-button:hover {
    background-color: #3a4055;
}
.audio-button.muted {
    background-color: #333;
    border-color: #666;
    opacity: 0.5;
}
.audio-button .icon {
    font-size: 24px;
}
/* Estilos para la estrella fugaz */
.shooting-star {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    text-shadow: 0 0 4px #000;
}
.shooting-star-glow {
    font-size: 1.2em;
    color: #fffc66;
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ffaa00;
}
@keyframes pulsate-shooting-star {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.1); opacity: 1; }
}
.shooting-star-exit {
    animation: shoot-away 0.5s forwards;
}
@keyframes shoot-away {
    from { 
        transform: scale(1); 
        opacity: 1; 
    }
    to { 
        transform: translateY(-100px) scale(0.5); 
        opacity: 0; 
    }
}
/* Responsiveness for small screens */
@media (max-width: 600px) {
    .buttons-container {
        gap: 15px;
    }
    
    .button {
        width: 45px;
        height: 45px;
    }
    
    .button svg {
        width: 20px;
        height: 20px;
    }
}
/* Zonas seguras para no solapar UI */
.safe-zone-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 220px; /* Ajustar según la altura de los elementos superiores */
    z-index: -1;
    pointer-events: none;
}
.safe-zone-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px; /* Ajustar según la altura de los botones */
    z-index: -1;
    pointer-events: none;
}
/* Estilos para la ayuda compacta */
.help-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}
.quick-button-help {
    display: flex;
    align-items: center;
    background-color: rgba(68, 102, 204, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    margin: 5px 0;
    width: calc(50% - 10px);
    box-sizing: border-box;
}
.quick-button-help .btn-icon {
    margin-right: 10px;
    color: #88aaff;
}
.compact-rules {
    margin: 10px 0;
    padding-left: 20px;
}
.compact-rules li {
    margin: 5px 0;
    line-height: 1.2;
}
/* Estilos para la estrella fugaz */
.shooting-star {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    text-shadow: 0 0 4px #000;
}
.shooting-star-glow {
    font-size: 1.2em;
    color: #fffc66;
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ffaa00;
}
@keyframes pulsate-shooting-star {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.1); opacity: 1; }
}
.shooting-star-exit {
    animation: shoot-away 0.5s forwards;
}
@keyframes shoot-away {
    from { 
        transform: scale(1); 
        opacity: 1; 
    }
    to { 
        transform: translateY(-100px) scale(0.5); 
        opacity: 0; 
    }
}
/* Word complete animation con glow blanco */
#word-complete-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-size: 40px;
    font-weight: bold;
    color: #ffd700; /* Color amarillo dorado */
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7), /* Glow amarillo original */
                 0 0 15px rgba(255, 255, 255, 0.7), /* Glow blanco */
                 0 0 20px rgba(255, 255, 255, 0.8); /* Glow blanco más difuminado */
    z-index: 25;
    opacity: 0;
    transition: opacity 0.5s, transform 0.5s;
    pointer-events: none;
    text-align: center;
}
#word-complete-animation.word-complete-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
    animation: word-glow-pulse 1.5s ease-in-out;
}
#word-complete-animation.word-complete-hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
}
