.how-to-play-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.how-to-play-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.how-to-play-modal-content {
    background: linear-gradient(135deg, rgba(18, 18, 18, 0.95), rgba(15, 15, 15, 0.98));
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 40px;
    max-width: 1200px;
    width: 90%;
    height: 85vh;
    overflow: hidden;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    transform: scale(0.8) translateY(30px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: grid;
    grid-template-areas: 
        "header"
        "content";
    grid-template-rows: auto 1fr;
    gap: 20px;
}

.how-to-play-modal-overlay.visible .how-to-play-modal-content {
    transform: scale(1) translateY(0);
}

.how-to-play-modal-header {
    grid-area: header;
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.how-to-play-modal-header h2 {
    color: #ffffff;
    font-size: 32px;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

.how-to-play-modal-body {
    grid-area: content;
    position: relative;
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    grid-template-areas: "nav-left page-content nav-right";
    align-items: center;
    min-height: 0; /* Allow grid item to shrink */
    gap: 10px;
}
/* Modal page container styles */
.modal-page {
    grid-area: page-content;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-page.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}
/* Carousel navigation arrows */
.carousel-arrow {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 20px;
    color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    user-select: none;
    justify-self: center;
    position: relative;
}
.carousel-arrow:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
    color: rgba(255, 255, 255, 1);
}
.carousel-arrow:active {
    transform: scale(0.95);
}
.carousel-arrow.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}
.carousel-arrow.left {
    grid-area: nav-left;
}
.carousel-arrow.right {
    grid-area: nav-right;
}
/* Page indicators - removed */
/* Page content wrapper for consistent layout */
.page-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
}
/* Visual content (GIF) container */
.page-visual {
    width: 100%;
    max-width: 1000px; /* Increased from 800px for 4/3 bigger GIFs */
    display: flex;
    justify-content: center;
    align-items: center;
}
.page-gif {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    object-fit: cover;
    max-height: 710px; /* 4/3 bigger than 533px */
}
/* Text content container */
.page-text-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: auto;
}
.game-intro {
    margin: 0 0 40px 0;
    padding: 0;
    background: none;
    border: none;
}
.story-setup {
    color: #e8f0fe;
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 25px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(204, 0, 0, 0.15), rgba(160, 0, 0, 0.08));
    border: 1px solid rgba(204, 0, 0, 0.3);
    border-radius: 16px;
    border-left: 5px solid #cc0000;
    position: relative;
    overflow: hidden;
}
.story-setup::before {
    content: "🎬";
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 24px;
    opacity: 0.6;
}
.story-setup .story-text {
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.story-title {
    display: inline-block;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(204, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    transform: rotate(-1deg);
    transition: transform 0.3s ease;
}
.story-title:hover {
    transform: rotate(0deg) scale(1.02);
}
.instructions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.instruction-item:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.instruction-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, #cc0000, #a00000);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.instruction-item:hover::before {
    opacity: 1;
}

.instruction-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, #cc0000, #a00000);
    color: white;
    font-size: 20px;
    font-weight: bold;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(204, 0, 0, 0.3);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.instruction-text {
    color: #e8f0fe;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.5;
    flex: 1;
    margin-top: 8px;
}
/* Modal actions/footer */
.how-to-play-modal-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.how-to-play-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 200px;
    justify-content: center;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.how-to-play-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.how-to-play-button.primary {
    background: linear-gradient(135deg, #cc0000, #a00000);
    color: white;
    box-shadow: 0 4px 20px rgba(204, 0, 0, 0.3);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.how-to-play-button.primary:hover {
    background: linear-gradient(135deg, #e60000, #cc0000);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(204, 0, 0, 0.4);
}

.how-to-play-button.primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 20px rgba(204, 0, 0, 0.3);
}

/* Loading state */
.how-to-play-button.loading {
    position: relative;
    color: transparent;
}

.how-to-play-button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: buttonSpin 1s linear infinite;
}

/* Animations */
@keyframes buttonSpin {
    to {
        transform: rotate(360deg);
    }
}

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

/* Tablet styles */
@media (max-width: 768px) {
    .how-to-play-modal-content {
        width: 95%;
        padding: 35px 25px;
        max-height: 85vh;
        max-width: 95%;
    }
    
    /* Tablet-specific adjustments */
    .page-gif {
        max-height: 350px; /* Increased from 250px for better visibility */
    }
    
    .carousel-arrow {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .how-to-play-modal-body {
        grid-template-columns: 70px 1fr 70px;
        gap: 5px;
    }
    
    .page-visual {
        max-width: 90%;
    }
    
    .story-setup {
        padding: 25px;
        font-size: 16px;
    }
    
    .story-title {
        font-size: 15px;
        padding: 6px 12px;
        margin: 12px 0;
    }
    .how-to-play-modal-header h2 {
        font-size: 28px;
    }

    .game-intro {
        font-size: 15px;
        padding: 16px;
    }

    .instruction-item {
        padding: 16px;
        gap: 16px;
    }

    .instruction-number {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 18px;
    }

    .instruction-text {
        font-size: 16px;
        margin-top: 6px;
    }

    .how-to-play-button {
        width: 100%;
        max-width: 300px;
        padding: 14px 28px;
        font-size: 16px;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    .how-to-play-modal-content {
        padding: 30px 20px;
        width: 95%;
        max-height: 90vh;
        max-width: 95%;
    }
    
    /* Mobile-specific adjustments */
    .page-content-wrapper {
        gap: 20px;
    }
    
    .page-gif {
        max-height: 280px; /* Increased from 200px */
        border-radius: 8px;
    }
    
    .carousel-arrow {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .how-to-play-modal-body {
        grid-template-columns: 60px 1fr 60px;
        gap: 0px;
    }
    
    .page-visual {
        max-width: 95%;
    }
    
    .page-indicators {
        bottom: 15px;
        gap: 10px;
    }
    
    .page-indicator {
        width: 10px;
        height: 10px;
    }
    
    .story-setup {
        padding: 20px;
        font-size: 15px;
        margin-bottom: 20px;
    }
    
    .story-title {
        font-size: 14px;
        padding: 5px 10px;
        margin: 10px 0;
        transform: rotate(0deg);
    }
    .how-to-play-modal-header {
        margin-bottom: 25px;
        padding-bottom: 15px;
    }

    .how-to-play-modal-header h2 {
        font-size: 24px;
    }

    .game-intro {
        font-size: 14px;
        padding: 14px;
        margin-bottom: 25px;
    }

    .instructions-list {
        gap: 15px;
    }

    .instruction-item {
        padding: 14px;
        gap: 14px;
        flex-direction: row;
        align-items: flex-start;
    }

    .instruction-number {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 16px;
    }

    .instruction-text {
        font-size: 15px;
        margin-top: 4px;
    }

    .how-to-play-button {
        font-size: 16px;
        padding: 12px 24px;
        min-width: 180px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .how-to-play-modal-content {
        border-color: #ffffff;
        background: rgba(0, 0, 0, 0.95);
    }

    .how-to-play-button.primary {
        background: #cc0000;
        border: 2px solid #ffffff;
    }

    .instruction-item {
        border-color: #ffffff;
        background: rgba(255, 255, 255, 0.1);
    }

    .game-intro {
        border-color: #ffffff;
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .how-to-play-modal-overlay {
        transition: opacity 0.2s ease;
    }

    .how-to-play-modal-content {
        transition: transform 0.2s ease;
    }

    .how-to-play-button {
        transition: background-color 0.2s ease;
    }

    .instruction-item {
        transition: background-color 0.2s ease;
    }

    .how-to-play-button.loading::after {
        animation: none;
        border: 2px solid #ffffff;
        border-radius: 2px;
    }
}

/* Focus management for accessibility */
.how-to-play-modal-content:focus-within {
    outline: none;
}

.instruction-item:focus-within {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .how-to-play-modal-overlay {
        position: static;
        background: none;
        backdrop-filter: none;
    }

    .how-to-play-modal-content {
        background: white;
        color: black;
        border: 1px solid #000;
        box-shadow: none;
        backdrop-filter: none;
        transform: none;
    }

    .how-to-play-modal-header h2 {
        color: #000;
        text-shadow: none;
    }

    .instruction-number {
        background: #000;
        color: white;
        box-shadow: none;
    }

    .instruction-text,
    .game-intro {
        color: #000;
    }

    .how-to-play-button {
        display: none;
    }
}