/* CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables - Consistent Dark Blue Theme */
:root {
    /* Background gradient */
    --gradient-1: #1a1a2e;
    --gradient-2: #16213e;
    --gradient-3: #0f3460;
    --gradient-4: #1a1a2e;

    /* Card */
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);

    /* Primary accent - Teal/Green (used for Yes button, success states) */
    --primary: #00b894;
    --primary-dark: #00a383;
    --primary-glow: rgba(0, 184, 148, 0.4);

    /* Secondary - Light gray (used for No button) */
    --secondary: #b2bec3;
    --secondary-dark: #a0adb3;

    /* Text colors */
    --text-dark: #2d3436;
    --text-light: #636e72;
    --text-muted: #b2bec3;

    /* Input */
    --input-border: #dfe6e9;
    --input-focus: #00b894;

    /* States */
    --error: #d63031;
    --success: #00b894;
}

/* Base Styles */
html, body {
    height: 100%;
    font-family: 'Nunito', sans-serif;
    color: var(--text-dark);
    overflow-x: hidden;
}

/* Animated Background */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(-45deg, var(--gradient-1), var(--gradient-2), var(--gradient-3), var(--gradient-4));
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    z-index: -1;
}

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

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Card */
.card {
    position: relative;
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--card-shadow);
    text-align: center;
    animation: cardEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Typography */
.heading {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.subheading {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.6;
}

.message {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 32px;
}

.highlight {
    color: var(--primary);
    font-weight: 700;
}

/* Input Styles */
.input-group {
    margin-bottom: 20px;
}

.input-field {
    width: 100%;
    padding: 16px 20px;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
}

.input-field:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field.error {
    border-color: var(--error);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.error-text {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: left;
}

.input-label {
    display: block;
    text-align: left;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.input-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: left;
    margin-top: 4px;
}

/* Button Styles */
.btn {
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-yes {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
    font-size: 1.1rem;
    padding: 16px 40px;
}

.btn-yes:hover {
    background: var(--primary-dark);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-no {
    background: var(--secondary);
    color: var(--text-dark);
    position: absolute;
    transition: all 0.15s ease-out;
    font-size: 1.1rem;
    padding: 16px 40px;
}

.btn-no:hover {
    background: var(--secondary-dark);
}

.btn-back {
    position: absolute;
    top: 16px;
    left: 16px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
}

.btn-no.escaping {
    animation: spinEscape 0.3s ease-out;
}

@keyframes spinEscape {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Button Container */
.btn-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

.question-container {
    position: relative;
    min-height: 200px;
}

.buttons-area {
    position: relative;
    height: 180px;
    margin-top: 20px;
    touch-action: none; /* Prevents scroll while chasing button */
}

.btn-yes-wrapper {
    display: flex;
    justify-content: center;
}

/* Escape hint */
.escape-hint {
    color: var(--primary);
    font-size: 0.95rem;
    margin-top: 60px;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: 600;
}

.escape-hint.visible {
    opacity: 1;
    animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Form Styles */
.form-section {
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: var(--text-light);
    font-size: 0.85rem;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--input-border);
}

.form-divider span {
    padding: 0 12px;
}

/* Loading State */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success Screen */
.success-screen {
    animation: cardEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-gif {
    width: 100%;
    max-width: 300px;
    border-radius: 16px;
    margin-bottom: 24px;
}

.success-heading {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--primary);
}

.success-message {
    font-size: 1.1rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 520px) {
    .container {
        padding: 12px;
    }

    .card {
        padding: 24px 16px;
        padding-top: 50px;
        border-radius: 20px;
    }

    .heading {
        font-size: 1.5rem;
    }

    .subheading {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .message {
        font-size: 1rem;
        margin-bottom: 24px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 0.95rem;
    }

    .btn-yes, .btn-no {
        padding: 12px 28px;
        font-size: 1rem;
    }

    .buttons-area {
        height: 200px;
    }

    .btn-back {
        top: 12px;
        left: 12px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .input-field {
        padding: 14px 16px;
        font-size: 1rem;
    }

    .input-group {
        margin-bottom: 16px;
    }

    .escape-hint {
        margin-top: 40px;
        font-size: 0.9rem;
    }

    .form-section .heading {
        font-size: 1.4rem;
    }

    .success-gif {
        max-width: 250px;
    }

    .success-heading {
        font-size: 1.5rem;
    }

    .success-message {
        font-size: 1rem;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .card {
        padding: 20px 14px;
        padding-top: 48px;
    }

    .heading {
        font-size: 1.3rem;
    }

    .message {
        font-size: 0.95rem;
    }

    .btn-yes, .btn-no {
        padding: 10px 24px;
        font-size: 0.95rem;
    }

    .buttons-area {
        height: 180px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .background {
        animation: none;
        background-position: 0% 50%;
    }
}

/* Focus styles for accessibility */
.btn:focus-visible,
.input-field:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
        min-width: 48px;
    }

    .btn-yes, .btn-no {
        min-height: 48px;
    }

    .input-field {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn-back {
        min-height: 44px;
        min-width: 44px;
    }
}
