/* Main layout settings */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-image 1s ease-in-out;
    position: relative;
    min-height: 100vh;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    /* Dark dimming overlay */
    z-index: -1;
    /* Keep it behind main content */
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 90vh;
    padding: 0px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    /* Ensure content stays above the body overlay */
}

.puzzle-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 90%;
    margin: 20px 0;
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .puzzle-wrapper {
        max-width: 80%;
    }
}

/* Header and Footer */
header {
    text-align: center;
    background-color: rgba(40, 40, 40, 0.95);
    color: white;
    padding: 10px 0 0 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.title-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 5px;
}

.title-container h1 {
    margin: 10px 0;
}

.header-mascot {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

footer {
    text-align: center;
    background-color: #333;
    color: white;
    padding: 10px 0;
    width: 100%;
    box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.1);
}

/* Navigation */
.main-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.main-nav a {
    color: #fff;
    font-size: 18px;
    text-decoration: underline;
    margin: 5px 10px !important;
    /* overrides inline styles safely */
}

/* Provide specificity for colored links */
.main-nav a.trophy-room-link {
    color: #4CAF50 !important;
    text-decoration: none;
}

.main-nav a.global-leaderboard-link {
    color: gold !important;
    text-decoration: none;
}

@media (min-width: 768px) {
    .main-nav a {
        font-size: 20px;
    }

    #settingsLink {
        display: none !important;
    }
}

/* Desktop Profile Menu */
.desktop-profile-container {
    position: absolute;
    top: 15px;
    right: 20px;
    display: block;
    /* Hidden on mobile via media query later */
    z-index: 1000;
}

.profile-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
    border: 2px solid #555;
    background-color: #282828;
}

.profile-badge:hover {
    transform: scale(1.05);
    border-color: #fff;
}

.profile-dropdown {
    display: none;
    position: absolute;
    top: 55px;
    right: 0;
    background-color: rgba(30, 30, 30, 0.98);
    border: 1px solid #555;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    min-width: 150px;
    overflow: hidden;
}

.profile-dropdown.active {
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    color: white !important;
    padding: 12px 15px;
    text-decoration: none !important;
    display: block;
    margin: 0 !important;
    border-bottom: 1px solid #444;
    transition: background-color 0.2s;
    text-align: left;
}

.dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-item:last-child {
    border-bottom: none;
}

/* Mobile Menu Toggle (Hamburger) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    margin: 0 auto 10px auto;
}

.mobile-menu-toggle span {
    display: block;
    width: 30px;
    height: 3px;
    background-color: #fff;
    border-radius: 3px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile navigation overlay */
@media (max-width: 767px) {
    .desktop-profile-container {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        position: absolute;
        top: 25px;
        left: 20px;
        margin: 0;
    }

    .main-nav {
        display: none;
        /* Hide by default on mobile */
        flex-direction: column;
        background-color: rgba(30, 30, 30, 0.98);
        border: 1px solid #555;
        border-radius: 12px;
        padding: 15px;
        position: absolute;
        width: 80%;
        left: 10%;
        top: 90px;
        z-index: 1000;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    }

    .main-nav.active {
        display: flex;
        /* Show when active class added via JS */
    }

    .main-nav a {
        display: block;
        margin: 0 !important;
        padding: 12px 0;
        border-bottom: 1px solid #444;
        width: 100%;
        box-sizing: border-box;
    }

    .main-nav a:last-child {
        border-bottom: none;
    }

    /* Hamburger animation */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
}

/* Prompt Container */
.prompt-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    margin-bottom: 10px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.prompt-container .number-card {
    width: 90%;
    aspect-ratio: 1 / 1;
    margin: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    will-change: transform;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.prompt-card {
    transition: background-color 0.3s ease;
}

@media (min-width: 768px) {
    .prompt-container {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        max-width: 500px;
    }

    .prompt-container .number-card {
        font-size: 28px;
    }
}

/* Puzzle Container */
.puzzle-container {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.puzzle-container .number-card {
    width: 62px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    color: black;
    border: 1px solid #ccc;
    font-size: 24px;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.puzzle-container .number-card.correct-value {
    background-color: yellow;
    color: black;
}

.puzzle-container .number-card.correct-position {
    background-color: green;
    color: white;
}

.puzzle-container .number-card[draggable="true"] {
    cursor: move;
}

.number-card.swapping {
    transform: scale(1.1);
    z-index: 10;
}

.target-indicator {
    position: absolute;
    left: -30px;
    font-size: 24px;
    color: #dc3545;
}

@media (min-width: 768px) {
    .puzzle-container {
        max-width: 500px;
    }

    .puzzle-container .number-card {
        width: 80px;
        height: 80px;
        font-size: 28px;
    }

    .target-indicator {
        font-size: 36px;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

@media (min-width: 768px) {
    .modal-content {
        width: 70%;
    }
}

/* Scoreboard */
.scoreboard-button {
    margin-left: 10px;
    color: white;
}

#scoreboardModal .modal-content {
    max-width: 500px;
}

#scoreRows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-row {
    display: flex;
    justify-content: space-between;
}

.score-row.header {
    font-weight: bold;
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.score-row span {
    flex: 1;
    text-align: center;
}

/* Sound Control */
.sound-control {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.sound-control label {
    margin-right: 10px;
}

.sound-control input[type="checkbox"] {
    appearance: none;
    width: 40px;
    height: 20px;
    background-color: #ccc;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background-color 0.3s;
}

.sound-control input[type="checkbox"]:checked {
    background-color: #4CAF50;
}

.sound-control input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 1px;
    left: 1px;
    background-color: white;
    transition: transform 0.3s;
}

.sound-control input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

.toggle-label {
    margin-left: 5px;
}

/* Dashboard */
.container_dashboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    margin: 0;
    background-color: rgba(40, 40, 40, 0.95);
    color: white;
    width: 100%;
    box-sizing: border-box;
}

.container_dashboard:not(.dashboard_header) {
    border-bottom: 1px solid #222;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 15px;
}

.item_dashboard {
    height: 20px;
    margin: 0 10px 0 0;
}

.item_dashboard span {
    margin-left: 2px;
}

.dashboard_header {
    background-color: transparent;
    padding: 10px 15px 5px 15px;
}

/* Congratulations Modal */
.congratulations-content {
    text-align: center;
    position: relative;
    padding-top: 50px;
}

.fireworks-container {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
}

.fireworks {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: absolute;
    animation: fireworks 1s ease-out infinite;
}

.fireworks.left {
    left: 20px;
}

.fireworks.right {
    right: 20px;
}

@keyframes fireworks {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

#finalScoreCard {
    margin: 20px auto;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 8px;
    max-width: 300px;
}

/* How to Play Content */
.how-to-play-content {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

.how-to-play-content h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.how-to-play-content h3 {
    color: #2980b9;
    margin-top: 20px;
}

.how-to-play-content ul,
.how-to-play-content ol {
    padding-left: 20px;
}

.how-to-play-content li {
    margin-bottom: 10px;
}

.how-to-play-content strong {
    color: #e74c3c;
}

.number-card.immovable {
    cursor: not-allowed;
}

/* DNF Status Styling */
.score-row .dnf {
    color: #ff4444;
    font-weight: bold;
}

.dnf-warning {
    text-align: center;
    padding: 20px;
}

.dnf-warning button {
    margin-top: 15px;
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dnf-warning button:hover {
    background-color: #45a049;
}

/* Add this to your existing modal styles section for consistency */
#dnfModal .modal-content {
    max-width: 400px;
    text-align: center;
}

/* Settings Modal */
.settings-content {
    max-width: 400px;
    background-color: rgba(30, 30, 30, 0.95);
    color: white;
    border: 1px solid #555;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item label {
    font-size: 18px;
    font-weight: bold;
}

.setting-item .toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.setting-item .text-status {
    width: 30px;
    text-align: right;
    font-family: monospace;
    font-size: 16px;
}

/* Make the DNF warning responsive */
@media (max-width: 768px) {
    .dnf-warning {
        padding: 15px;
    }

    .dnf-warning button {
        width: 100%;
        max-width: 200px;
    }
}

/* Player Name Modal Styles */
.player-name-form {
    padding: 20px;
    text-align: center;
}

.input-group {
    margin: 20px 0;
}

#playerNameInput {
    width: 100%;
    max-width: 300px;
    padding: 8px;
    font-size: 16px;
    border: 2px solid #ccc;
    border-radius: 4px;
    margin-bottom: 8px;
}

.input-help {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.primary-button,
.secondary-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.primary-button {
    background-color: #4CAF50;
    color: white;
}

.primary-button:hover {
    background-color: #45a049;
}

.secondary-button {
    background-color: #f0f0f0;
    color: #333;
}

.secondary-button:hover {
    background-color: #e0e0e0;
}

.error-message {
    color: #ff4444;
    margin-top: 10px;
    min-height: 20px;
}

@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }

    .button-group button {
        width: 100%;
        margin: 5px 0;
    }
}

.player-name-container {
    padding: 8px 15px;
    margin: 0;
    background-color: rgba(50, 50, 50, 0.95);
    color: white;
    font-weight: bold;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}

#playerNameDisplay {
    margin-left: 5px;
    color: #4CAF50;
}

/*====================*/
/* Add to your master.css */
.completion-content {
    text-align: center;
    padding: 2rem;
}

.completion-content h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.next-puzzle-timer {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.countdown-timer {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    font-family: monospace;
    margin-top: 0.5rem;
}

.best-scores-summary {
    margin: 2rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.total-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.scores-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 0.5rem;
    background-color: #e9ecef;
    border-radius: 4px;
    font-weight: bold;
}

.score-item {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 0.5rem;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.score-item.completed {
    border-left: 4px solid #28a745;
}

.score-item.dnf {
    border-left: 4px solid #dc3545;
}

.completion-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

@media (max-width: 480px) {
    .completion-buttons {
        flex-direction: column;
    }

    .score-item {
        font-size: 0.9rem;
    }

    .countdown-timer {
        font-size: 1.5rem;
    }

    .total-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}


/* aboutPage.css */
.about-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
}

.about-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.replay-button {
    padding: 12px 24px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.replay-button:hover {
    background-color: #45a049;
}

.about-content section {
    margin-bottom: 40px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.feature-grid,
.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.feature-card,
.tip-card {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4CAF50;
}

.feature-card h3,
.tip-card h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.game-story p {
    line-height: 1.6;
    color: #444;
    margin-bottom: 15px;
}

.game-features ul {
    list-style-type: none;
    padding: 0;
}

.game-features li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.game-features li:last-child {
    border-bottom: none;
}

@media (max-width: 768px) {
    .about-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .feature-grid,
    .tips-grid {
        grid-template-columns: 1fr;
    }
}

/* Sensei Notification System */
#sensei-container {
    position: fixed;
    bottom: -200px;
    right: 20px;
    display: flex;
    align-items: flex-end;
    z-index: 9999;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#sensei-container.visible {
    transform: translateY(-220px);
}

#sensei-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 3px solid #d4af37;
    object-fit: cover;
    background-color: #1a1a2e;
}

#sensei-bubble {
    position: relative;
    background: #fff;
    border-radius: .4em;
    padding: 15px 20px;
    margin-right: 15px;
    margin-bottom: 40px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: 'Georgia', serif;
    font-size: 16px;
    color: #333;
    max-width: 250px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    transition-delay: 0.3s;
}

#sensei-container.visible #sensei-bubble {
    opacity: 1;
    transform: scale(1);
}

#sensei-bubble:after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-left-color: #fff;
    border-right: 0;
    border-bottom: 0;
    margin-top: -5px;
    margin-right: -10px;
}

/* Pre-Game Tutorial Modal specific styles */
.tutorial-modal-content {
    background: #1a1a2e;
    color: white;
    max-width: 600px;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tutorial-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.tutorial-sensei-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid #d4af37;
    object-fit: cover;
    background-color: #1a1a2e;
}

.tutorial-bubble {
    background: #fff;
    color: #333;
    padding: 15px 20px;
    border-radius: 12px;
    position: relative;
    font-size: 16px;
    line-height: 1.5;
    flex-grow: 1;
    font-family: 'Georgia', serif;
}

.tutorial-bubble::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -20px;
    transform: translateY(-50%);
    border-width: 10px 20px 10px 0;
    border-style: solid;
    border-color: transparent #fff transparent transparent;
}

.tutorial-body {
    width: 100%;
    text-align: center;
}

/* Animations for the tutorial */
.tutorial-animation-container {
    background: #282828;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

.mini-puzzle-container {
    background: #282828;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.mini-puzzle-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
}

.tut-block {
    width: 60px;
    height: 60px;
    background: white;
    color: black;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 8px;
    position: relative;
}

.anim-slide-source {
    animation: tutSlideRight 4s infinite ease-in-out;
}

.anim-slide-target {
    animation: tutSlideReceive 4s infinite ease-in-out;
}

.anim-slide-source::after {
    content: "2";
    animation: tutSlideSourceNum 4s infinite step-end;
}

.anim-slide-target::after {
    content: "4";
    animation: tutSlideTargetNum 4s infinite step-end;
}

@keyframes tutSlideSourceNum {

    0%,
    45% {
        content: "2";
    }

    46%,
    100% {
        content: "0";
    }
}

@keyframes tutSlideTargetNum {

    0%,
    45% {
        content: "4";
    }

    46%,
    100% {
        content: "6";
    }
}

@keyframes tutSlideRight {

    0%,
    20% {
        transform: translateX(0);
        opacity: 1;
    }

    40%,
    45% {
        transform: translateX(75px);
        opacity: 1;
    }

    46%,
    75% {
        transform: translateX(0);
        opacity: 1;
    }

    80%,
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes tutSlideReceive {

    0%,
    35% {
        transform: scale(1);
        background: white;
        color: black;
    }

    40%,
    45% {
        transform: scale(1.1);
        background: #f1f2f6;
        color: black;
    }

    46%,
    75% {
        transform: scale(1);
        background: #4CAF50;
        color: white;
    }

    80%,
    100% {
        transform: scale(1);
        background: white;
        color: black;
    }
}

/* Direction Matters Animations */
.anim-dir-source-right {
    animation: tutSlideRightNew 10s infinite;
}

.anim-dir-target-right {
    animation: tutDirTargetRight 10s infinite;
}

.anim-dir-source-left {
    animation: tutSlideLeftNew 10s infinite;
}

.anim-dir-target-left {
    animation: tutDirTargetLeft 10s infinite;
}

.anim-dir-source-right::after {
    content: "3";
    animation: tutDirSourceRightNum 10s infinite step-end;
}

.anim-dir-target-right::after {
    content: "9";
    animation: tutDirTargetRightNum 10s infinite step-end;
}

.anim-dir-source-left::after {
    content: "3";
    animation: tutDirSourceLeftNum 10s infinite step-end;
}

.anim-dir-target-left::after {
    content: "9";
    animation: tutDirTargetLeftNum 10s infinite step-end;
}

@keyframes tutDirSourceRightNum {

    0%,
    4% {
        content: "3";
    }

    5%,
    95% {
        content: "1";
    }

    95.01%,
    100% {
        content: "3";
    }
}

@keyframes tutDirTargetRightNum {

    0%,
    4% {
        content: "9";
    }

    5%,
    95% {
        content: "2";
    }

    95.01%,
    100% {
        content: "9";
    }
}

@keyframes tutDirSourceLeftNum {

    0%,
    54% {
        content: "3";
    }

    55%,
    95% {
        content: "1";
    }

    95.01%,
    100% {
        content: "3";
    }
}

@keyframes tutDirTargetLeftNum {

    0%,
    54% {
        content: "9";
    }

    55%,
    95% {
        content: "2";
    }

    95.01%,
    100% {
        content: "9";
    }
}

@keyframes tutSlideRightNew {

    0%,
    2% {
        transform: translateX(0);
        z-index: 10;
    }

    5% {
        transform: translateX(60px);
        z-index: 10;
    }

    8%,
    100% {
        transform: translateX(0);
        z-index: 10;
    }
}

@keyframes tutDirTargetRight {

    0%,
    4% {
        transform: scale(1);
        background: white;
        color: black;
    }

    5% {
        transform: scale(1.1);
        background: #f1f2f6;
        color: black;
    }

    8%,
    100% {
        transform: scale(1);
        background: white;
        color: black;
    }
}

@keyframes tutSlideLeftNew {

    0%,
    52% {
        transform: translateX(0);
        z-index: 10;
    }

    55% {
        transform: translateX(-60px);
        z-index: 10;
    }

    58%,
    100% {
        transform: translateX(0);
        z-index: 10;
    }
}

@keyframes tutDirTargetLeft {

    0%,
    54% {
        transform: scale(1);
        background: white;
        color: black;
    }

    55% {
        transform: scale(1.1);
        background: #f1f2f6;
        color: black;
    }

    58%,
    100% {
        transform: scale(1);
        background: white;
        color: black;
    }
}

/* Mixed Colors Animations */
.anim-mixed-source-right {
    animation: tutMixedSlideRight 10s infinite;
    background: white;
    color: black;
}

.anim-mixed-target-right {
    animation: tutMixedTargetRight 10s infinite;
    background: #9b59b6;
    color: white;
}

.anim-mixed-source-left {
    animation: tutMixedSlideLeft 10s infinite;
    background: #9b59b6;
    color: white;
}

.anim-mixed-target-left {
    animation: tutMixedTargetLeft 10s infinite;
    background: white;
    color: black;
}

.anim-mixed-source-right::after {
    content: "2";
    animation: tutMixedSourceRightNum 10s infinite step-end;
}

.anim-mixed-target-right::after {
    content: "4";
    animation: tutMixedTargetRightNum 10s infinite step-end;
}

.anim-mixed-source-left::after {
    content: "4";
    animation: tutMixedSourceLeftNum 10s infinite step-end;
}

.anim-mixed-target-left::after {
    content: "2";
    animation: tutMixedTargetLeftNum 10s infinite step-end;
}

@keyframes tutMixedSourceRightNum {

    0%,
    4% {
        content: "2";
    }

    5%,
    95% {
        content: "0";
    }

    95.01%,
    100% {
        content: "2";
    }
}

@keyframes tutMixedTargetRightNum {

    0%,
    4% {
        content: "4";
    }

    5%,
    95% {
        content: "6";
    }

    95.01%,
    100% {
        content: "4";
    }
}

@keyframes tutMixedSourceLeftNum {

    0%,
    54% {
        content: "4";
    }

    55%,
    95% {
        content: "0";
    }

    95.01%,
    100% {
        content: "4";
    }
}

@keyframes tutMixedTargetLeftNum {

    0%,
    54% {
        content: "2";
    }

    55%,
    95% {
        content: "8";
    }

    95.01%,
    100% {
        content: "2";
    }
}

@keyframes tutMixedSlideRight {

    0%,
    2% {
        transform: translateX(0);
        z-index: 10;
        background: white;
        color: black;
    }

    5% {
        transform: translateX(60px);
        z-index: 10;
        background: white;
        color: black;
    }

    8%,
    95% {
        transform: translateX(0);
        z-index: 10;
        background: #666;
        color: rgba(255, 255, 255, 0.5);
    }

    95.01%,
    100% {
        transform: translateX(0);
        z-index: 10;
        background: white;
        color: black;
    }
}

@keyframes tutMixedTargetRight {

    0%,
    4% {
        transform: scale(1);
        background: #9b59b6;
        color: white;
    }

    5% {
        transform: scale(1.1);
        background: #e0b0ff;
        color: white;
    }

    8%,
    95% {
        transform: scale(1);
        background: #4CAF50;
        color: white;
    }

    95.01%,
    100% {
        transform: scale(1);
        background: #9b59b6;
        color: white;
    }
}

@keyframes tutMixedSlideLeft {

    0%,
    52% {
        transform: translateX(0);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }

    55% {
        transform: translateX(-60px);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }

    58%,
    95% {
        transform: translateX(0);
        z-index: 10;
        background: #666;
        color: rgba(255, 255, 255, 0.5);
    }

    95.01%,
    100% {
        transform: translateX(0);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }
}

@keyframes tutMixedTargetLeft {

    0%,
    54% {
        transform: scale(1);
        background: white;
        color: black;
    }

    55% {
        transform: scale(1.1);
        background: #f1f2f6;
        color: black;
    }

    58%,
    95% {
        transform: scale(1);
        background: #4CAF50;
        color: white;
    }

    95.01%,
    100% {
        transform: scale(1);
        background: white;
        color: black;
    }
}

/* Zeros & Special Tiles Swap Animations */
.anim-zero-source-right {
    animation: tutZeroSlideRight 10s infinite;
    background: #9b59b6;
    color: white;
}

.anim-zero-target-right {
    animation: tutZeroTargetRight 10s infinite;
    background: white;
    color: black;
}

.anim-zero-source-left {
    animation: tutZeroSlideLeft 10s infinite;
    background: white;
    color: black;
}

.anim-zero-target-left {
    animation: tutZeroTargetLeft 10s infinite;
    background: #9b59b6;
    color: white;
}

.anim-zero-source-right::after {
    content: "8";
    animation: tutZeroSourceRightNum 10s infinite step-end;
}

.anim-zero-target-right::after {
    content: "0";
    animation: tutZeroTargetRightNum 10s infinite step-end;
}

.anim-zero-source-left::after {
    content: "0";
    animation: tutZeroSourceLeftNum 10s infinite step-end;
}

.anim-zero-target-left::after {
    content: "8";
    animation: tutZeroTargetLeftNum 10s infinite step-end;
}

@keyframes tutZeroSourceRightNum {

    0%,
    4% {
        content: "8";
    }

    5%,
    95% {
        content: "0";
    }

    95.01%,
    100% {
        content: "8";
    }
}

@keyframes tutZeroTargetRightNum {

    0%,
    4% {
        content: "0";
    }

    5%,
    95% {
        content: "8";
    }

    95.01%,
    100% {
        content: "0";
    }
}

@keyframes tutZeroSourceLeftNum {

    0%,
    54% {
        content: "0";
    }

    55%,
    95% {
        content: "8";
    }

    95.01%,
    100% {
        content: "0";
    }
}

@keyframes tutZeroTargetLeftNum {

    0%,
    54% {
        content: "8";
    }

    55%,
    95% {
        content: "0";
    }

    95.01%,
    100% {
        content: "8";
    }
}

/* Slide Right (Purple 8 -> White 0 becomes White 0, Purple 8) */
@keyframes tutZeroSlideRight {

    0%,
    2% {
        transform: translateX(0);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }

    5% {
        transform: translateX(60px);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }

    8%,
    95% {
        transform: translateX(0);
        z-index: 10;
        background: white;
        color: black;
    }

    95.01%,
    100% {
        transform: translateX(0);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }
}

@keyframes tutZeroTargetRight {

    0%,
    4% {
        transform: scale(1);
        background: white;
        color: black;
    }

    5% {
        transform: scale(1.1);
        background: #f1f2f6;
        color: black;
    }

    8%,
    95% {
        transform: scale(1);
        background: #9b59b6;
        color: white;
    }

    95.01%,
    100% {
        transform: scale(1);
        background: white;
        color: black;
    }
}

/* Slide Left (White 0 <- Purple 8 becomes Purple 8, White 0) */
@keyframes tutZeroSlideLeft {

    0%,
    52% {
        transform: translateX(0);
        z-index: 10;
        background: white;
        color: black;
    }

    55% {
        transform: translateX(-60px);
        z-index: 10;
        background: white;
        color: black;
    }

    58%,
    95% {
        transform: translateX(0);
        z-index: 10;
        background: #9b59b6;
        color: white;
    }

    95.01%,
    100% {
        transform: translateX(0);
        z-index: 10;
        background: white;
        color: black;
    }
}

@keyframes tutZeroTargetLeft {

    0%,
    54% {
        transform: scale(1);
        background: #9b59b6;
        color: white;
    }

    55% {
        transform: scale(1.1);
        background: #e0b0ff;
        color: white;
    }

    58%,
    95% {
        transform: scale(1);
        background: white;
        color: black;
    }

    95.01%,
    100% {
        transform: scale(1);
        background: #9b59b6;
        color: white;
    }
}

/* Grid Pulse Animation */
.anim-grid-target {
    animation: tutGridTarget 4s infinite;
}

@keyframes tutGridTarget {

    0%,
    20% {
        opacity: 0.3;
        transform: scale(1);
        box-shadow: none;
    }

    40%,
    80% {
        opacity: 1;
        transform: scale(1.05);
        box-shadow: 0 0 15px #e74c3c;
        z-index: 10;
        border-color: #e74c3c;
    }

    100% {
        opacity: 0.3;
        transform: scale(1);
        box-shadow: none;
    }
}

/* Color explanation animations */
.anim-color-green {
    animation: colorGreen 3s infinite;
}

.anim-color-yellow {
    animation: colorYellow 3s infinite;
}

.anim-color-red {
    animation: colorRed 3s infinite;
}

@keyframes colorGreen {

    0%,
    30% {
        background: white;
        color: black;
    }

    50%,
    100% {
        background: #4CAF50;
        color: white;
    }
}

@keyframes colorYellow {

    0%,
    30% {
        background: white;
        color: black;
    }

    50%,
    100% {
        background: gold;
        color: black;
    }
}

@keyframes colorRed {

    0%,
    30% {
        background: white;
        color: black;
    }

    50%,
    100% {
        background: #e74c3c;
        color: white;
    }
}