body {
    font-family: 'Baloo Thambi 2', cursive, 'Noto Sans TC', sans-serif;
    background-color: #4A00E0; /* Purple gradient start */
    background-image: linear-gradient(to right, #4A00E0, #8E2DE2); /* Purple gradient */
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.container {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(8px);
    width: 100%;
    max-width: 480px;
    text-align: center;
    margin: auto;
}

h1, h2 {
    color: #e0e0e0;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    margin-bottom: 15px;
}
h1 { font-size: 2.2em; font-weight: 700; }
h2 { font-size: 1.4em; margin-top: 20px; font-weight: 600; }

label {
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
    font-weight: 500;
    text-align: left;
    color: #d1c4e9; /* Light purple for labels */
    font-size: 0.9em;
}

input[type="text"],
input[type="password"] {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid rgba(224, 224, 224, 0.5);
    background-color: rgba(255,255,255,0.15);
    color: #e0e0e0;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1em;
}
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: #ede7f6; /* Lighter purple on focus */
    box-shadow: 0 0 0 0.2rem rgba(209, 196, 233, 0.25);
    outline: none;
}

button {
    background: linear-gradient(45deg, #c0392b, #e74c3c); /* Red-Orange gradient */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    margin: 10px 5px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    letter-spacing: 0.5px;
}
button:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}
button:active { transform: translateY(0px) scale(1); }
button:disabled {
    background: #7f8c8d; /* Grey for disabled */
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.error-message { color: #ff8a80; } /* Light red */
.success-message { color: #b9f6ca; } /* Light green */
.info-message { color: #e0e0e0; margin-top: 10px; font-size: 0.95em; }

/* CAPTCHA Styles */
#captcha-container { margin-bottom: 15px; text-align: left; }
.captcha-line { display: flex; align-items: center; }
#captchaInput { width: 80px; padding: 8px; font-size: 0.9em; margin-right: 8px;}
.captcha-display { padding: 8px 12px; font-size: 1.1em; margin-right: 8px; background-color: rgba(0,0,0,0.2); border-radius: 4px;}
.captcha-refresh-btn { padding: 6px 10px; font-size: 1.1em; background: #d35400; } /* Darker orange */
.captcha-refresh-btn:hover { background-color: #a04000; }


/* Game Section Specific Styles */
#game-section, #leaderboard-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 500;
}
.game-info span {
    background-color: rgba(0,0,0,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    margin: 4px;
    min-width: 100px;
}

#gameBoard {
    display: grid;
    /* grid-template-columns and rows will be set by JS */
    gap: 3px;
    margin: 20px auto;
    padding: 8px;
    background-color: rgba(0,0,0,0.25);
    border-radius: 10px;
    width: fit-content; /* Adjusts to content */
    max-width: 90vw; /* Ensure it doesn't overflow small screens */
    border: 2px solid rgba(255,255,255,0.1);
}

.block {
    /* width and height will be set by JS */
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.15s ease-out, opacity 0.2s ease-out, background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.2), 0 2px 3px rgba(0,0,0,0.3);
}
.block.empty {
    background-color: transparent !important; /* Ensure empty blocks are visually empty */
    cursor: default;
    box-shadow: none;
}
.block:not(.empty):hover {
    transform: scale(1.1);
    opacity: 0.85;
}
.block.popping {
    animation: popAnimation 0.3s ease-out forwards;
}
@keyframes popAnimation {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(0.1); opacity: 0; }
}

/* Leaderboard Styles */
.leaderboard-filters button { background: #6a1b9a; margin-bottom: 10px; } /* Darker Purple */
.leaderboard-filters button:hover { background-color: #4a148c; }
#leaderboardTable { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85em; }
#leaderboardTable th, #leaderboardTable td { border: 1px solid rgba(255,255,255,0.2); padding: 7px; text-align: left; }
#leaderboardTable th { background-color: #8E2DE2; color: white; text-align: center; }
#leaderboardTable tbody tr:nth-child(even) { background-color: rgba(255,255,255,0.1); }
#leaderboardTable tbody tr:hover { background-color: rgba(255,255,255,0.2); }

@media (max-width: 400px) {
    .container { padding: 15px; }
    h1 { font-size: 1.8em; }
    .game-info span { padding: 6px 10px; font-size: 0.9em; min-width: 80px; }
    #gameBoard { gap: 2px; padding: 5px; }
    /* Block size will be handled by JS, ensuring it fits */
}