body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-image: url('images/background.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
}

div.block {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

h1, h2 {
    font-size: 2em;
    margin: 0;
}

#cardContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    margin-top: 80px;
    margin-bottom: 80px;
}

.card {
    width: 100px;
    height: 150px;
    margin-right: -30px;
    background-image: url('images/back.jpg');
    background-size: cover;
    cursor: pointer;
    transition: transform 0.6s ease;
    position: relative;
    z-index: 1;
}

.card.selected {
    margin-right: 30px;
}

.card img {
    width: 100px;
    height: 150px;
    display: block;
}

.cardName {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    font-size: 1.5em;
    text-align: center;
    width: 100%;
}

.card:hover {
    z-index: 2;
    transform: scale(1.1);
}

.card img.reversed {
    transform: rotate(180deg); /* 將逆位卡片旋轉 180 度 */
    transition: transform 0.6s ease; /* 添加平滑的翻轉效果 */
}

.shuffling {
    animation: rotateShuffle 0.5s linear infinite;
}

@keyframes rotateShuffle {
    0% { transform: rotate(0deg) translate(0, 0); }
    25% { transform: rotate(20deg) translate(5px, -10px); }
    50% { transform: rotate(-15deg) translate(-10px, 5px); }
    75% { transform: rotate(10deg) translate(10px, -5px); }
    100% { transform: rotate(0deg) translate(0, 0); }
}

#shuffleBtn {
    position: fixed;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
}

#selectedCards {
    margin-top: 20px;
    font-size: 1.2em;
    color: #333;
    text-align: center;
}

#userQuestion {
    position: fixed;
    top: 60px;
    left: 40px;
    padding: 10px;
    font-size: 1em;
    width: 400px;
    max-width: 400px;
    box-sizing: border-box;
    opacity: 0.8;
}

#responseContainer {
    position: fixed;
    top: 20%;
    right: 5%;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    width: 25%;
    max-width: 400px;
    box-sizing: border-box;
    text-align: center;
    display: none; /* Initially hidden */
    overflow-y: auto; /* Enable vertical scrolling */
    max-height: 40%;
}

@media only screen and (max-width: 768px) {
    .card {
        width: 80px;
        height: 120px;
        margin-right: -20px;
    }

    .card.selected {
        margin-right: 10px;
    }

    .card img {
        width: 80px;
        height: 120px;
    }

    .cardName {
        margin-top: 15px;
    }

    h1, h2 {
        font-size: 1.5em;
    }

    #shuffleBtn {
        bottom: 10%;
        padding: 8px 16px;
        font-size: 0.9em;
    }

    #userQuestion {
        width: 90%;
        font-size: 0.9em;
    }

    #responseContainer {
        width: 80%;
        max-width: 300px;
        right: 10%;
    }
}


#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    z-index: 1000; /* Ensure it is above other elements */
    width: 300px;
    text-align: center;
}


#loading .progress {
    width: 100%;
}

#loading h5 {
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #555;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

#loading .progress-bar {
    animation: progress-animation 5s infinite; /* Slower animation */
}

@keyframes progress-animation {
    0% { width: 0%; }
    100% { width: 100%; }
}


/* Button container styles */
.button-container {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
}

/* Anchor styles */
.button-container a {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    background-color: #6600ff;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Hover effect */
.button-container a:hover {
    background-color: #5501a5;
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

/* Active effect */
.button-container a:active {
    transform: translateY(0);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Add a glowing effect */
.button-container a::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: rgba(42, 4, 140, 0.5);
    border-radius: 5px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.button-container a:hover::before {
    opacity: 1;
}
