/* ==========================================================================
   Card Game Tool - Zhween Brand Styling
   ========================================================================== */

/* ========================================
       Card Game Styles (Zhween Brand)
       ======================================== */
    
    /* Game Container */
    .game-container {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 1rem;
        position: relative;
        overflow: hidden;
    }

    /* Setup Panel */
    .setup-panel {
        background: var(--white);
        border-radius: var(--radius-2xl, 1rem);
        padding: 2rem;
        max-width: 600px;
        width: 100%;
        box-shadow: var(--shadow-xl);
        border: 1px solid rgba(21, 174, 191, 0.1);
        animation: fadeInUp 0.5s ease-out;
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .setup-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-primary);
        text-align: center;
        margin-bottom: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
    }

    .setup-title-icon {
        font-size: 1.75rem;
    }

    .setup-subtitle {
        text-align: center;
        color: var(--text-muted);
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .textarea-wrapper {
        position: relative;
        margin-bottom: 1.25rem;
    }

    .question-textarea {
        width: 100%;
        min-height: 160px;
        padding: 1rem;
        border: 2px solid var(--gray-300);
        border-radius: var(--radius-xl, 0.75rem);
        font-size: 0.9375rem;
        font-family: inherit;
        line-height: 1.6;
        resize: vertical;
        transition: 0.15s ease;
        background: var(--white);
    }

    .question-textarea:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(21, 174, 191, 0.12);
    }

    .question-textarea::placeholder {
        color: var(--text-muted);
        opacity: 0.7;
    }

    /* Options */
    .setup-options {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 1.5rem;
    }

    .checkbox-wrapper {
        display: flex;
        align-items: center;
        gap: 0.625rem;
        cursor: pointer;
        user-select: none;
    }

    .checkbox-wrapper input {
        display: none;
    }

    .custom-checkbox {
        width: 22px;
        height: 22px;
        border: 2px solid var(--gray-400);
        border-radius: var(--radius-md, 0.5rem);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: 0.15s ease;
        flex-shrink: 0;
    }

    .checkbox-wrapper input:checked + .custom-checkbox {
        background: var(--bg-gradient);
        border-color: var(--primary-color);
    }

    .custom-checkbox svg {
        width: 14px;
        height: 14px;
        stroke: var(--white);
        stroke-width: 3;
        opacity: 0;
        transform: scale(0.5);
        transition: 0.15s ease;
    }

    .checkbox-wrapper input:checked + .custom-checkbox svg {
        opacity: 1;
        transform: scale(1);
    }

    .checkbox-label {
        font-size: 0.9375rem;
        color: var(--text-secondary);
        font-weight: 500;
    }

    /* Buttons */
    .setup-buttons {
        display: flex;
        gap: 0.75rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.875rem 1.75rem;
        border: none;
        border-radius: var(--radius-full, 9999px);
        font-size: 0.9375rem;
        font-weight: 600;
        cursor: pointer;
        transition: 0.25s ease;
        font-family: inherit;
        text-decoration: none;
        min-height: 48px;
    }

    .btn-primary {
        background: var(--bg-gradient);
        color: var(--white);
        box-shadow: 0 4px 20px rgba(21, 174, 191, 0.35);
    }

    .btn-primary:hover {
        background: linear-gradient(135deg, #0e9bb2 0%, #15aebf 100%);
        transform: translateY(-2px);
        box-shadow: 0 8px 30px rgba(21, 174, 191, 0.4);
    }

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

    .btn-secondary {
        background: var(--gray-100);
        color: var(--text-secondary);
        border: 2px solid var(--gray-300);
    }

    .btn-secondary:hover {
        background: var(--gray-200);
        border-color: var(--gray-400);
    }

    .btn-icon {
        font-size: 1.125rem;
    }

    /* Question Count */
    .question-count {
        text-align: center;
        margin-top: 1rem;
        font-size: 0.875rem;
        color: var(--text-muted);
        font-weight: 500;
    }

    .question-count.has-questions {
        color: var(--success-color);
    }

    /* Error Message */
    .error-message {
        background: linear-gradient(135deg, #ffeaea 0%, #fff5f5 100%);
        color: var(--danger-color);
        padding: 0.875rem 1rem;
        border-radius: var(--radius-lg, 0.5rem);
        margin-top: 1rem;
        font-size: 0.875rem;
        text-align: center;
        border: 1px solid rgba(225, 112, 85, 0.2);
        display: none;
    }

    .error-message.show {
        display: block;
        animation: shake 0.5s ease-out;
    }

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

    /* Game Area */
    .game-area {
        width: 100%;
        min-height: calc(100vh - 2rem);
        min-height: calc(100dvh - 2rem);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 1rem;
        padding-bottom: 5rem;
        position: relative;
        box-sizing: border-box;
    }

    #gameContent {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
    }

    /* Reset Button */
    .reset-btn {
        position: fixed;
        bottom: 1.5rem;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.625rem 1.25rem;
        background: var(--white);
        color: var(--text-secondary);
        border: 2px solid var(--gray-300);
        border-radius: var(--radius-full, 9999px);
        font-size: 0.8125rem;
        font-weight: 600;
        cursor: pointer;
        transition: 0.15s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        z-index: 50;
        font-family: inherit;
        box-shadow: var(--shadow-sm);
    }

    .reset-btn:hover {
        background: var(--gray-100);
        border-color: var(--primary-color);
        color: var(--primary-color);
        box-shadow: var(--shadow-md);
    }

    /* Card Wrapper */
    .card-wrapper {
        perspective: 1200px;
        width: 100%;
        max-width: 580px;
        height: 420px;
        position: relative;
    }

    /* Card */
    .flip-card {
        width: 100%;
        height: 100%;
        position: relative;
        transform-style: preserve-3d;
        transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
    }

    .flip-card.flipped {
        transform: rotateY(180deg);
    }

    [dir="rtl"] .flip-card.flipped {
        transform: rotateY(-180deg);
    }

    .card-face {
        width: 100%;
        height: 100%;
        position: absolute;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        border-radius: var(--radius-2xl, 1rem);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem 1.5rem;
        text-align: center;
        overflow: hidden;
    }

    /* Front Face */
    .card-front {
        background: var(--bg-gradient);
        color: var(--white);
        box-shadow: var(--shadow-xl), 0 4px 20px rgba(21, 174, 191, 0.35);
    }

    .card-front::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        border-radius: var(--radius-2xl, 1rem);
        opacity: 0.6;
    }

    .card-number {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        font-size: 1.75rem;
        font-weight: 800;
        opacity: 0.85;
        z-index: 2;
    }

    [dir="rtl"] .card-number { 
        right: auto;
        left: 1.5rem; 
    }

    .card-front-icon {
        font-size: 5rem;
        margin-bottom: 1.5rem;
        position: relative;
        z-index: 1;
    }

    .card-front-text {
        font-size: 1.5rem;
        font-weight: 600;
        opacity: 0.95;
        position: relative;
        z-index: 1;
        line-height: 1.5;
    }

    .card-hint {
        position: absolute;
        bottom: 2rem;
        font-size: 1rem;
        opacity: 0.7;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Back Face */
    .card-back {
        background: var(--white);
        color: var(--text-primary);
        transform: rotateY(180deg);
        box-shadow: var(--shadow-xl);
        border: 2px solid var(--gray-200);
        overflow: hidden;
    }

    [dir="rtl"] .card-back {
        transform: rotateY(-180deg);
    }

    .card-back .card-number {
        color: var(--primary-color);
        font-size: 1.25rem;
        opacity: 0.8;
    }

    .question-text {
        font-size: 2rem;
        font-weight: 600;
        line-height: 1.5;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0.5rem 1rem;
        color: var(--text-primary);
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .question-text::-webkit-scrollbar {
        display: none;
    }

    /* Card Slide Out Animation */
    .flip-card.slide-out {
        animation: slideOut 0.4s cubic-bezier(0.6, 0, 0.8, 1) forwards;
        pointer-events: none;
    }

    @keyframes slideOut {
        0% {
            transform: translateX(0) rotate(0deg) scale(1);
            opacity: 1;
        }
        100% {
            transform: translateX(-150%) rotate(-12deg) scale(0.8);
            opacity: 0;
        }
    }

    [dir="rtl"] .flip-card.slide-out {
        animation: slideOutRtl 0.4s cubic-bezier(0.6, 0, 0.8, 1) forwards;
        pointer-events: none;
    }

    @keyframes slideOutRtl {
        0% {
            transform: translateX(0) rotate(0deg) scale(1);
            opacity: 1;
        }
        100% {
            transform: translateX(150%) rotate(12deg) scale(0.8);
            opacity: 0;
        }
    }
    
    /* Card Slide In Animation */
    .flip-card.slide-in {
        animation: slideIn 0.4s cubic-bezier(0.2, 0, 0.4, 1) forwards;
    }

    @keyframes slideIn {
        0% {
            transform: translateX(150%) rotate(12deg) scale(0.8);
            opacity: 0;
        }
        100% {
            transform: translateX(0) rotate(0deg) scale(1);
            opacity: 1;
        }
    }

    [dir="rtl"] .flip-card.slide-in {
        animation: slideInRtl 0.4s cubic-bezier(0.2, 0, 0.4, 1) forwards;
    }

    @keyframes slideInRtl {
        0% {
            transform: translateX(-150%) rotate(-12deg) scale(0.8);
            opacity: 0;
        }
        100% {
            transform: translateX(0) rotate(0deg) scale(1);
            opacity: 1;
        }
    }

    /* Back Card Hint */
    .card-back-hint {
        position: absolute;
        bottom: 1.5rem;
        color: var(--primary-color);
        opacity: 0;
        animation: fadeInHint 0.4s ease-out 0.5s forwards;
    }

    @keyframes fadeInHint {
        to {
            opacity: 0.8;
        }
    }

    /* Card clickable state after flip */
    .flip-card.flipped {
        cursor: pointer;
    }

    .flip-card.flipped:hover .card-back {
        box-shadow: var(--shadow-xl), 0 8px 40px rgba(21, 174, 191, 0.25);
    }

    /* Progress Dots */
    .progress-dots {
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 400px;
    }

    .progress-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: rgba(21, 174, 191, 0.2);
        transition: 0.15s ease;
    }

    .progress-dot.active {
        background: var(--primary-color);
        transform: scale(1.3);
        box-shadow: 0 0 8px rgba(21, 174, 191, 0.5);
    }

    .progress-dot.completed {
        background: var(--success-color);
    }

    /* Game Over Screen */
    .game-over {
        text-align: center;
        padding: 2rem;
        animation: fadeInUp 0.5s ease-out;
    }

    .game-over-icon {
        font-size: 5rem;
        margin-bottom: 1.5rem;
    }

    .game-over-title {
        font-size: 2.5rem;
        font-weight: 800;
        color: var(--primary-color);
        margin-bottom: 0.75rem;
    }

    .game-over-subtitle {
        font-size: 1.125rem;
        color: var(--text-muted);
        margin-bottom: 2rem;
    }

    .game-over-buttons {
        display: flex;
        gap: 1rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .btn-success {
        background: var(--success-color);
        color: var(--white);
        box-shadow: 0 4px 15px rgba(0, 184, 148, 0.35);
    }

    .btn-success:hover {
        background: #00a085;
        transform: translateY(-2px);
    }

    /* Responsive Styles */
    @media (max-width: 768px) {
        .setup-panel {
            padding: 1.5rem;
        }

        .setup-title {
            font-size: 1.25rem;
        }

        .question-textarea {
            min-height: 130px;
            font-size: 0.875rem;
        }

        .btn {
            padding: 0.75rem 1.25rem;
            font-size: 0.875rem;
            min-height: 44px;
        }

        .card-wrapper {
            height: 380px;
        }

        .card-face {
            padding: 2rem 1.5rem;
        }

        .card-front-icon {
            font-size: 4rem;
        }

        .card-front-text {
            font-size: 1.25rem;
        }

        .question-text {
            font-size: 1.5rem;
        }

        .card-number {
            font-size: 1.5rem;
            top: 1rem;
            right: 1rem;
        }

        [dir="rtl"] .card-number { 
            right: auto;
            left: 1rem; 
        }

        .game-over-title {
            font-size: 2rem;
        }

        .game-over-icon {
            font-size: 4rem;
        }
    }

    @media (max-width: 480px) {
        .setup-panel {
            padding: 1.25rem;
        }

        .setup-title {
            font-size: 1.125rem;
        }

        .setup-subtitle {
            font-size: 0.8125rem;
        }

        .card-wrapper {
            height: 340px;
        }

        .card-face {
            padding: 1.5rem 1rem;
        }

        .card-front-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
        }

        .card-front-text {
            font-size: 1rem;
        }

        .question-text {
            font-size: 1.25rem;
        }

        .card-number {
            font-size: 1.25rem;
        }
        
        .card-hint {
            bottom: 1rem;
            font-size: 0.875rem;
        }

        .reset-btn {
            position: fixed;
            bottom: 1rem;
            padding: 0.5rem 1rem;
            font-size: 0.75rem;
        }

        .game-over-title {
            font-size: 1.75rem;
        }

        .game-over-subtitle {
            font-size: 1rem;
        }

        .progress-dots {
            gap: 0.375rem;
        }

        .progress-dot {
            width: 8px;
            height: 8px;
        }
    }

    /* Card Hover Effect */
    .flip-card:not(.flipped):hover {
        transform: scale(1.02) translateY(-5px);
    }

    .flip-card:not(.flipped):hover .card-front {
        box-shadow: var(--shadow-xl), 0 8px 40px rgba(21, 174, 191, 0.45);
    }

    /* Pulse Animation for Hint */
    .card-hint {
        animation: pulseHint 2s ease-in-out infinite;
    }

    @keyframes pulseHint {
        0%, 100% { opacity: 0.7; transform: scale(1); }
        50% { opacity: 1; transform: scale(1.05); }
    }

    /* Question Mark Bounce */
    .card-front-icon {
        animation: bounceIcon 2s ease-in-out infinite;
    }

    @keyframes bounceIcon {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-10px); }
    }

    /* Confetti */
    .confetti {
        position: absolute;
        width: 10px;
        height: 10px;
        border-radius: 2px;
        top: -20px;
        z-index: 100;
        pointer-events: none;
        animation: confettiFall 3s ease-out forwards;
    }

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

    /* Button Press Effect */
    .btn:active,
    .reset-btn:active {
        transform: scale(0.95);
    }

    /* Card Back Question Reveal Animation */
    .flip-card.flipped .question-text {
        animation: revealText 0.5s ease-out 0.3s both;
    }

    @keyframes revealText {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Progress Dot Transition */
    .progress-dot {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .progress-dot.completed {
        animation: dotComplete 0.3s ease-out;
    }

    @keyframes dotComplete {
        0% { transform: scale(1); }
        50% { transform: scale(1.5); }
        100% { transform: scale(1); }
    }

    /* Game Over Icon Bounce */
    .game-over-icon {
        animation: celebrateBounce 0.6s ease-out;
    }

    @keyframes celebrateBounce {
        0% { transform: scale(0); opacity: 0; }
        50% { transform: scale(1.2); }
        100% { transform: scale(1); opacity: 1; }
    }

    /* Game Over Title Slide */
    .game-over-title {
        animation: slideInTitle 0.5s ease-out 0.2s both;
    }

    @keyframes slideInTitle {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }


    /* Accessibility */
    *:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    *:focus:not(:focus-visible) {
        outline: none;
    }

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

        .flip-card:not(.flipped):hover {
            transform: none;
        }

        .card-hint,
        .card-front-icon {
            animation: none;
        }
    }
