/* Custom keyframe animations */
@keyframes tada {
    from {
        transform: scale3d(1, 1, 1);
    }
    10%, 20% {
        transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg);
    }
    30%, 50%, 70%, 90% {
        transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);
    }
    40%, 60%, 80% {
        transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);
    }
    to {
        transform: scale3d(1, 1, 1);
    }
}
.animate-tada {
    animation: tada 1s;
}
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { 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); }
}
@keyframes open-lid-left {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(90deg); }
}
@keyframes open-lid-right {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(-90deg); }
}
@keyframes fade-in-text {
    0% { opacity: 0; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}
.animate-pop { animation: pop 0.2s ease-in-out; }
.animate-shake { animation: shake 0.5s ease-in-out; }

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-pop-in {
    animation: pop-in 0.3s ease-out forwards;
}

@keyframes pop-counter {
    0% { transform: scale(1) translateY(-50%); }
    50% { transform: scale(1.2) translateY(-50%); }
    100% { transform: scale(1) translateY(-50%); }
}

.plays-counter.animate-counter-pop {
    animation: pop-counter 0.5s ease-in-out;
}

.keyboard-key.grow {
    animation: pop 0.2s ease-in-out;
}

@keyframes dissolve {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

.animate-dissolve .letter {
    animation: dissolve 0.5s ease-in-out;
    animation-fill-mode: forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}
.animate-fadeInOut {
    animation: fadeInOut 2s ease-in-out;
}
.notification-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    padding: 20px;
    border-radius: 10px;
    z-index: 1000;
}
.floating-controls {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.floating-controls.hidden {
    display: none;
}

.keyboard-container {
    background-color: rgba(240, 240, 240, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: 15px;
    width: 600px;
}

.word-entry-area {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 0.5rem;
}

.current-row-container {
    position: relative;
    display: flex;
    justify-content: center;
}

.plays-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #800080;
    color: white;
    border-radius: 50%;
    width: 4rem;
    height: 4rem;
    position: absolute;
    left: 100%;
    margin-left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 640px) {
    .keyboard-container {
        width: 100vw;
        border-radius: 15px 15px 0 0;
        padding: 5px;
    }
    .floating-controls {
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
    }
    .scroll-top-button {
        display: none !important;
    }
    .word-entry-area {
        justify-content: space-between;
        padding: 0 10px;
    }
    .plays-counter {
        position: relative;
        left: auto;
        margin-left: 0.5rem;
        top: auto;
        transform: none;
        width: 3.5rem;
        height: 3.5rem;
    }
    .current-row-container {
        flex-grow: 1;
    }
}

.keyboard-key {
    border: 1px solid #ccc;
    box-shadow: 0 2px 2px rgba(0,0,0,0.2);
    transition: background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.keyboard-key:hover {
    transform: translateY(-2px);
}

.text-dark-blue {
    color: #1e40af !important;
}

.text-light-blue {
    color: #93c5fd !important;
}

.text-light-gray {
    color: #D1D5DB !important;
}


.key-enter {
    background-color: #4caf50 !important;
    color: white !important;
}

.key-enter:hover {
    background-color: #45a049 !important;
}

.key-delete {
    background-color: #f44336 !important;
    color: white !important;
}

.key-delete:hover {
    background-color: #e53935 !important;
}

.keyboard-container .border-2 {
    border-color: #800080;
    color: #800080;
}

main .border-2 {
    border-color: #d1d5db;
}

main .current-row .border-2 {
    border-color: #000 !important;
}

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

.animate-openPresent {
    animation: openPresent 0.5s ease-out;
}

@keyframes dissolve-out {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.9); }
}

.animate-dissolve-out {
    animation: dissolve-out 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 0.75; }
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeOut {
    from { opacity: 0.75; }
    to { opacity: 0; }
}

.animate-fadeOut {
    animation: fadeOut 0.5s ease-in forwards;
}

.keyword-placeholder {
    color: purple;
}

.how-to-play-button {
    transition: transform 0.3s;
}

.how-to-play-button:hover {
    transform: scale(1.05);
}

.how-to-play-button .lg-visible {
    display: none;
}

@media (min-width: 640px) {
    .how-to-play-button .sm-hidden {
        display: none;
    }
    .how-to-play-button .lg-visible {
        display: inline;
    }
}


.how-to-play-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
}

.how-to-play-content {
    overflow-y: auto;
    padding-right: 1rem;
    flex-grow: 1;
}

@media (max-width: 640px) {
    .how-to-play-content {
        font-size: 0.875rem;
    }
}

.sound-toggle-button {
    background-color: #800080;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: background-color 0.3s;
}

.sound-toggle-button:hover {
    background-color: #990099;
}

.music-toggle-container {
    position: relative;
}

.volume-slider-container {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out;
    z-index: 10;
}

.volume-slider-container.visible {
    opacity: 1;
    visibility: visible;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 8px;
    background: #ddd;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
    border-radius: 5px;
}

.volume-slider:hover {
    opacity: 1;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: #800080;
    cursor: pointer;
    border-radius: 50%;
}

.volume-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: #800080;
    cursor: pointer;
    border-radius: 50%;
}

.loading-spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #800080;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 2s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes explosion {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animate-explosion {
    animation: explosion 0.5s ease-out;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100px) rotateZ(360deg);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f00;
    animation: confetti-fall 2s linear infinite;
}

.confetti:nth-child(2) {
    background-color: #0f0;
    left: 20%;
    animation-delay: 0.2s;
}

.confetti:nth-child(3) {
    background-color: #00f;
    left: 40%;
    animation-delay: 0.4s;
}

.confetti:nth-child(4) {
    background-color: #ff0;
    left: 60%;
    animation-delay: 0.6s;
}

.confetti:nth-child(5) {
    background-color: #f0f;
    left: 80%;
    animation-delay: 0.8s;
}

.leaderboard-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
}

.leaderboard-content {
    overflow-y: auto;
    padding-right: 1rem;
    flex-grow: 1;
}

.leaderboard-sidebar {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    right: -300px;
    width: 300px;
    height: 500px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: right 0.5s ease-in-out;
    z-index: 101;
    border-radius: 15px;
}

.leaderboard-sidebar.open {
    right: 0;
}

@keyframes pulse-rainbow {
    0% {
        color: #ff0000;
        transform: scale(1);
    }
    16% {
        color: #ff7f00;
    }
    33% {
        color: #ffff00;
    }
    50% {
        color: #00ff00;
        transform: scale(1.05);
    }
    66% {
        color: #0000ff;
    }
    83% {
        color: #4b0082;
    }
    100% {
        color: #9400d3;
        transform: scale(1);
    }
}

.new-score-permanent-rainbow {
    animation: pulse-rainbow 2s infinite;
}

@keyframes new-score-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

@keyframes vanish {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.animate-vanish {
    animation: vanish 0.5s ease-out forwards;
}

.leaderboard-list {
    position: relative;
}

.leaderboard-item {
    transition: all 0.5s ease-in-out;
}

.leaderboard-item.new-score-pop {
    animation: new-score-pop 0.5s ease-out forwards;
}

@keyframes dissolve-out {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

.leaderboard-item.dissolve-out {
    animation: dissolve-out 0.5s forwards;
}

@keyframes slide-down {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.leaderboard-item.slide-down {
    animation: slide-down 0.5s;
}

@keyframes explode-in {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.leaderboard-item.explode-in {
    animation: explode-in 0.5s;
}

.invisible {
    visibility: hidden;
}
