@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
    --primary-color: #4CAF50;
    /* Green */
    --secondary-color: #FFC107;
    /* Amber */
    --danger-color: #F44336;
    /* Red */
    --success-color: #8BC34A;
    /* Light Green */
    --background-color: #2c3e50;
    /* Dark Blue */
    --text-color: #ecf0f1;
    /* Light Grey */
    --input-bg: #34495e;
    /* Darker Blue */
    --input-border: #7f8c8d;
    /* Grey */
    --button-hover: #45a049;
}

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    color: var(--text-color);
    overflow-x: hidden;
    background: linear-gradient(-45deg, #0f0c29, #1a1a4e, #0d3b5e, #1b4332, #16213e, #0f3460);
    background-size: 400% 400%;
    animation: gradientShift 18s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.game-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    text-align: center;
    width: 100%;
    max-width: 500px;
    position: relative;
    margin: 20px 10px;
}

.card-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -10px;
}

.help-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--secondary-color);
    background: transparent;
    color: var(--secondary-color);
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.help-btn:hover {
    background: var(--secondary-color);
    color: #2c3e50;
    transform: scale(1.1);
}

.rules-list {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0 0 5px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.95em;
    color: var(--text-color);
    line-height: 1.5;
}

h1 {
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 2.2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-container {
    display: inline-block;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: var(--secondary-color);
    font-size: 0.9em;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 22px;
    letter-spacing: 0.5px;
}

.input-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#guessInput {
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-color);
    font-size: 1.1em;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

#guessInput::placeholder {
    color: #bdc3c7;
}

#guessInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
    transform: translateY(-2px);
}

#guessInput.input-error {
    border-color: var(--danger-color);
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.5);
}

#submitGuess {
    padding: 15px 25px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#submitGuess:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
}

#submitGuess:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.feedback-message {
    font-size: 1.3em;
    font-weight: 600;
    min-height: 30px;
    /* Reserve space */
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* --- Animations --- */

/* Incorrect Guess: Shake Animation */
.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
    color: var(--danger-color);
    opacity: 1;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Correct Guess: Bounce and Confetti */
.bounce {
    animation: bounce 0.8s ease-out;
    color: var(--success-color);
    opacity: 1;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

/* Confetti effect (CSS only for simplicity, JS for more complex) */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--primary-color);
    opacity: 0;
    animation: fall 3s linear infinite;
}

.confetti:nth-child(2n) {
    background-color: var(--secondary-color);
}

.confetti:nth-child(3n) {
    background-color: var(--success-color);
}

.confetti:nth-child(4n) {
    background-color: #03A9F4;
    /* Light Blue */
}

@keyframes fall {
    0% {
        transform: translate(var(--x), var(--y)) rotateZ(0deg);
        opacity: 1;
    }

    100% {
        transform: translate(var(--x-end), var(--y-end)) rotateZ(720deg);
        opacity: 0;
    }
}

/* Responsiveness */
@media (max-width: 600px) {
    .game-container {
        padding: 20px 15px;
        width: 90%;
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 20px;
    }

    .input-wrapper {
        flex-direction: column;
    }

    #guessInput,
    #submitGuess {
        width: 100%;
        box-sizing: border-box;
        /* Maintain padding within width */
    }

    #submitGuess {
        margin-top: 10px;
    }
}

/* --- Hint System UI --- */
.lives-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.lives-title {
    color: var(--text-color);
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 8px;
}

.lives-title span {
    font-weight: 400;
    color: #bdc3c7;
}

.lives-hearts {
    font-size: 1.4em;
    letter-spacing: 1px;
}

.actions-wrapper {
    margin-top: 15px;
    margin-bottom: 15px;
}

.hint-btn {
    padding: 10px 20px;
    background-color: #e67e22;
    /* Orange */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.hint-btn:hover:not(:disabled) {
    background-color: #d35400;
    transform: translateY(-2px);
}

.hint-btn:disabled {
    background-color: var(--input-border);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.hints-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.hint-card {
    background-color: var(--input-bg);
    padding: 12px 15px;
    border-left: 4px solid #e67e22;
    border-radius: 5px;
    animation: fadeIn 0.5s ease-in-out;
    font-size: 1em;
    color: #ffc107;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {

    .hint-btn,
    .reset-btn {
        width: 100%;
    }
}

.actions-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.reset-btn {
    padding: 10px 20px;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background-color: #7f8c8d;
    transform: translateY(-2px);
}

/* --- Victory Stats Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.10);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: modalFadeIn 0.5s ease;
}

.modal-content {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 1px solid rgba(76, 175, 80, 0.4);
    border-radius: 20px;
    padding: 40px 35px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(76, 175, 80, 0.15);
    animation: modalSlideUp 0.5s ease;
}

.modal-content h2 {
    color: var(--secondary-color);
    margin: 0 0 8px 0;
    font-size: 2em;
}

.modal-subtitle {
    color: var(--success-color);
    font-size: 1.1em;
    margin: 0 0 25px 0;
    font-weight: 400;
}

.modal-close-btn {
    margin-top: 25px;
    padding: 12px 40px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.modal-close-btn:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* --- Countdown Timer --- */
.countdown-text {
    margin-top: 15px;
    font-size: 0.95em;
    color: #03A9F4;
    font-weight: 600;
    letter-spacing: 0.3px;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-fade-out {
    animation: modalFadeOut 0.4s ease forwards;
}

.modal-fade-out .modal-content {
    animation: modalSlideDown 0.4s ease forwards;
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes modalSlideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
}

/* --- Title Badge --- */
.title-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0 20px 0;
    padding: 15px 20px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: 15px;
    animation: titleReveal 0.6s ease-out;
}

.title-emoji {
    font-size: 2.5em;
    animation: titleBounce 0.8s ease-out;
}

.title-name {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--secondary-color);
    margin-top: 5px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.title-desc {
    font-size: 0.85em;
    color: #bdc3c7;
    margin-top: 4px;
    font-style: italic;
}

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

@keyframes titleBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* --- Suspicious Modal --- */
.suspicious-modal {
    border-color: rgba(255, 193, 7, 0.5) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 193, 7, 0.15) !important;
}

.suspicious-modal h2 {
    color: var(--secondary-color);
}

/* --- Honesty Modal --- */
.honesty-modal {
    border-color: rgba(76, 175, 80, 0.5) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(76, 175, 80, 0.2) !important;
}

.honesty-modal h2 {
    color: var(--primary-color);
}