/* ==========================================================================
   TASKFUN - MODERN BRIGHT GLASSMORPHISM REDESIGN
   Premium Animated Web3 Experience
   ========================================================================== */

/* --- Container & Fundamentals --- */
.taskfun-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-bottom: 4rem;
    font-family: 'Outfit', sans-serif;
    color: #1f2937;
    /* Match main site text */
    position: relative;
    z-index: 10;
}

/* Add an ethereal glowing orb specific to the game area background */
.taskfun-container::before {
    content: '';
    position: absolute;
    top: 20%;
    right: 10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, transparent 70%);
    filter: blur(40px);
    z-index: -1;
    pointer-events: none;
    animation: float 8s ease-in-out infinite alternate;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-30px, 40px) scale(1.1);
    }
}

/* --- Hero Section --- */
.tf-hero {
    text-align: center;
    position: relative;
    padding: 3rem 0 1rem;
}

.tf-hero .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.1), rgba(99, 102, 241, 0.1));
    color: #ec4899;
    border: 1px solid rgba(236, 72, 153, 0.3);
    padding: 0.4rem 1.25rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.15);
    backdrop-filter: blur(10px);
}

.tf-hero h1 {
    font-size: 4rem;
    font-weight: 900;
    margin: 0;
    background: linear-gradient(135deg, #4f46e5 0%, #ec4899 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
    line-height: 1.1;
    filter: drop-shadow(0 10px 20px rgba(79, 70, 229, 0.15));
}

.tf-hero p {
    color: #4b5563;
    font-size: 1.25rem;
    margin-top: 1rem;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* --- Main Dashboard Area --- */
.tf-dashboard {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 2.5rem;
    align-items: start;
}

@media (max-width: 950px) {
    .tf-dashboard {
        grid-template-columns: 1fr;
    }
}

/* --- Control Panel (Premium Light Glassmorphism) --- */
.tf-controls {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 32px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 20px 40px -10px rgba(31, 38, 135, 0.1), inset 0 2px 0 rgba(255, 255, 255, 1);
    position: relative;
    overflow: hidden;
}

.tf-controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #ec4899, #10b981);
}

.tf-stat-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.tf-stat-box .label {
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tf-stat-box .value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -1px;
}

.tf-stat-box .value.text-green {
    color: #10b981;
}

/* --- Bet Input --- */
.tf-bet-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.tf-bet-group label {
    color: #374151;
    font-size: 0.95rem;
    font-weight: 700;
}

.tf-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.tf-input-wrapper .currency-icon {
    position: absolute;
    left: 1.25rem;
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.tf-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(229, 231, 235, 0.8);
    color: #111827;
    font-size: 1.5rem;
    font-weight: 800;
    padding: 1.25rem 1rem 1.25rem 3.5rem;
    border-radius: 20px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.tf-input:focus {
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Custom Buttons */
.tf-btn {
    width: 100%;
    padding: 1.25rem;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.tf-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
}

.tf-btn:hover::after {
    opacity: 1;
    transform: scale(1);
}

.tf-btn-play {
    background: #111827;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(17, 24, 39, 0.3);
}

.tf-btn-play:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px -5px rgba(17, 24, 39, 0.4);
    background: #000;
}

.tf-btn-play:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.tf-btn-cashout {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4);
    display: none;
}

.tf-btn-cashout:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 35px -5px rgba(16, 185, 129, 0.5);
}

/* --- Game Area (The Grid) --- */
.tf-game-area {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 40px;
    padding: 3rem 4rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    position: relative;
    display: flex;
    flex-direction: column-reverse;
    /* Rows build upwards */
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    backdrop-filter: blur(10px);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.05), inset 0 2px 0 rgba(255, 255, 255, 1);
}

/* Game Row */
.tf-row {
    display: flex;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.5;
    filter: saturate(0.2) opacity(0.8);
    pointer-events: none;
}

.tf-row.active {
    opacity: 1;
    filter: none;
    pointer-events: auto;
    transform: scale(1.08);
}

.tf-row.completed {
    opacity: 0.9;
    filter: none;
    transform: scale(0.98);
}

/* Multiplier Label next to Row */
.tf-multiplier-label {
    position: absolute;
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    font-weight: 900;
    color: #6366f1;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: rgba(255, 255, 255, 0.8);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.1);
}

.tf-row.active .tf-multiplier-label {
    opacity: 1;
    right: -65px;
    transform: translateY(-50%) scale(1.1);
    color: #ec4899;
}

.tf-row.completed .tf-multiplier-label {
    opacity: 0.7;
    right: -60px;
}

/* Game Tile */
.tf-tile {
    width: 85px;
    height: 85px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(243, 244, 246, 0.9));
    border: 2px solid rgba(255, 255, 255, 1);
    border-radius: 24px;
    cursor: pointer;
    position: relative;
    perspective: 1000px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), inset 0 -4px 10px rgba(0, 0, 0, 0.02);
}

.tf-row.active .tf-tile {
    animation: gentle-float 3s ease-in-out infinite alternate;
}

.tf-row.active .tf-tile:nth-child(2) {
    animation-delay: 0.2s;
}

.tf-row.active .tf-tile:nth-child(3) {
    animation-delay: 0.4s;
}

.tf-row.active .tf-tile:nth-child(4) {
    animation-delay: 0.6s;
}

@keyframes gentle-float {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-4px);
    }
}

.tf-row.active .tf-tile:hover {
    transform: translateY(-8px) scale(1.05) !important;
    box-shadow: 0 20px 35px rgba(99, 102, 241, 0.15), inset 0 2px 0 rgba(255, 255, 255, 1);
    border-color: #c7d2fe;
}

.tf-tile-inner {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tf-tile.revealed .tf-tile-inner {
    transform: rotateY(180deg);
}

.tf-tile-front,
.tf-tile-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
}

.tf-tile-front {
    background: transparent;
    /* Clean front, relying on the parents border & background */
}

.tf-tile-back {
    transform: rotateY(180deg);
}

/* Tile Revealed States */
.tf-tile.safe .tf-tile-back {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    border: 2px solid #059669;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.5);
    color: white;
}

.tf-tile.safe .tf-tile-back::after {
    content: '💎';
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    animation: bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tf-tile.death .tf-tile-back {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    border: 2px solid #b91c1c;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4), inset 0 2px 10px rgba(255, 255, 255, 0.4);
    color: white;
}

.tf-tile.death .tf-tile-back::after {
    content: '💣';
    /* Using a bomb for a more modern risk feel, or keep skull 💀 */
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    animation: explode-pulse 1s infinite;
}

@keyframes bounce-in {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes explode-pulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
    }

    50% {
        transform: scale(1.15) rotate(5deg);
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
    }
}

/* Animations for Game Over / Win */
@keyframes shake-death {

    0%,
    100% {
        transform: translateX(0) scale(1.1);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-8px) scale(1.1);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(8px) scale(1.1);
    }
}

.game-over-shake {
    animation: shake-death 0.5s cubic-bezier(.36, .07, .19, .97) both;
    z-index: 10;
}

/* Status Notifications Overlay */
.tf-status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.4);
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 40px;
}

.tf-status-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.tf-status-message {
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 3rem;
    border-radius: 32px;
    text-align: center;
    transform: scale(0.8) translateY(20px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.15), 0 0 0 8px rgba(255, 255, 255, 0.4);
    min-width: 350px;
}

.tf-status-overlay.show .tf-status-message {
    transform: scale(1) translateY(0);
}

.tf-status-title {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.tf-status-title.win {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tf-status-title.lose {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tf-status-desc {
    color: #4b5563;
    font-size: 1.25rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.tf-status-desc strong {
    font-size: 1.5rem;
    color: #111827 !important;
    background: #dcfce7;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
}

.tf-dp-award {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #f3e8ff, #e0e7ff);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #4f46e5;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.1);
    margin-top: 1rem;
}

/* --- Provably Fair Section --- */
.tf-provably-fair {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 2rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.tf-pf-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #111827;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tf-pf-header svg {
    width: 20px;
    height: 20px;
    color: #6366f1;
}

.tf-hash-display {
    background: rgba(243, 244, 246, 0.8);
    padding: 1.25rem;
    border-radius: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: #4b5563;
    font-size: 0.9rem;
    word-break: break-all;
    border: 1px solid rgba(209, 213, 219, 0.8);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    line-height: 1.6;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .tf-game-area {
        padding: 2rem 1.5rem;
        border-radius: 32px;
    }

    .tf-row {
        gap: 1rem;
    }

    .tf-tile {
        width: 60px;
        height: 60px;
    }

    .tf-tile-front,
    .tf-tile-back {
        font-size: 1.5rem;
    }

    .tf-multiplier-label {
        font-size: 0.85rem;
        right: -45px;
    }

    .tf-controls {
        padding: 1.5rem;
    }

    .tf-hero h1 {
        font-size: 2.5rem;
    }
}

/* TaskFun integration with backend-driven UI */
.tf-grid {
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    gap: 1.5rem;
    align-items: center;
}

.tf-row {
    align-items: center;
    justify-content: center;
}

.tf-row-meta {
    width: 96px;
    flex: 0 0 96px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    margin-right: 0.75rem;
}

.tf-row-name {
    font-size: 0.95rem;
    color: #111827;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.tf-row.active .tf-row-name {
    color: #ec4899;
}

.tf-tile-disabled {
    pointer-events: none;
    opacity: 0.78;
}

.tf-tile-clickable {
    border-color: rgba(16, 185, 129, 0.68);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14), 0 14px 30px rgba(16, 185, 129, 0.2);
}

.tf-row.active .tf-tile-clickable {
    animation: tf-pulse-tile 1.2s ease-in-out infinite;
}

@keyframes tf-pulse-tile {
    0% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12), 0 14px 30px rgba(16, 185, 129, 0.2);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.2), 0 16px 34px rgba(16, 185, 129, 0.28);
    }

    100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12), 0 14px 30px rgba(16, 185, 129, 0.2);
    }
}

.tf-inline-note {
    min-height: 1.25rem;
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 600;
    margin-top: 0.25rem;
}

.tf-inline-note.success {
    color: #059669;
}

.tf-inline-note.error {
    color: #dc2626;
}

.tf-input-seed {
    padding: 1rem 1.25rem;
    font-size: 1rem;
}

#tf-setup-panel[hidden],
#tf-live-panel[hidden] {
    display: none !important;
}

#tf-live-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.taskfun-playing .tf-hero {
    display: none;
}

.taskfun-playing .tf-provably-fair {
    display: none;
}

.taskfun-playing .tf-controls {
    position: sticky;
    top: 0.75rem;
    z-index: 20;
}

.tf-taskfun-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.tf-board-card {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.tf-board-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #111827;
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 0.85rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.tf-board-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: 260px;
    overflow: auto;
}

.tf-board-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.6rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 0.55rem 0.7rem;
    color: #334155;
    font-size: 0.86rem;
}

.tf-board-rank {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 800;
    color: #111827;
    background: rgba(226, 232, 240, 0.9);
}

.tf-board-main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.tf-board-main strong {
    color: #0f172a;
    font-size: 0.86rem;
}

.tf-board-meta {
    color: #64748b;
    font-size: 0.75rem;
}

.tf-board-value {
    font-weight: 800;
    color: #0f172a;
}

.tf-board-value.win {
    color: #059669;
}

.tf-board-value.loss {
    color: #dc2626;
}

.tf-board-empty {
    color: #64748b;
    font-size: 0.88rem;
    padding: 0.4rem 0.1rem;
}

.tf-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tf-status-pill.win {
    color: #065f46;
    background: rgba(16, 185, 129, 0.14);
}

.tf-status-pill.dead {
    color: #991b1b;
    background: rgba(239, 68, 68, 0.14);
}

.tf-verify-modal {
    width: min(860px, 94vw);
    max-height: 85vh;
    overflow: auto;
}

.tf-verify-block {
    margin-top: 0.85rem;
    padding: 0.85rem;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.85);
    border: 1px solid rgba(209, 213, 219, 0.8);
    color: #334155;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    line-height: 1.5;
}

.tf-verify-block ol {
    margin: 0.4rem 0 0 1rem;
    padding: 0;
}

.tf-verify-rows {
    max-height: 320px;
    overflow: auto;
}

.tf-verify-line {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.82rem;
    padding: 0.32rem 0;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.45);
}

.tf-verify-line.ok {
    color: #0f766e;
}

.tf-verify-line.bad {
    color: #b91c1c;
}

@media (max-width: 950px) {
    .tf-taskfun-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tf-row-meta {
        width: 68px;
        flex-basis: 68px;
        margin-right: 0.5rem;
    }

    .tf-row-name {
        font-size: 0.78rem;
    }

    .tf-board-row {
        grid-template-columns: auto 1fr;
    }
}
