/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Roboto:wght@400;700&display=swap');

/* CSS Variables for easy theme management */
:root {
    --primary-color: #ffea00;
    --secondary-color: #ff7700;
    --background-color: #0a0a14; /* A deep, dark blue for the background */
    --card-background: rgba(22, 33, 62, 0.85); /* Slightly more opaque for readability */
    --grid-color: rgba(255, 251, 0, 0.1); /* Color for the grid lines */
    --text-color: #e0e0e0;
    --font-pixel: 'Press Start 2P', cursive;
    --font-sans: 'Roboto', sans-serif;
}

/* General Reset and Body Styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative; /* Needed for the pseudo-element background */
}

/* ========================================= */
/* === ANIMATED GRID BACKGROUND (NEW!) === */
/* ========================================= */
@keyframes moveGrid {
    0% { background-position: 0 0; }
    100% { background-position: 100px 100px; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Place it behind all content */

    /* The grid lines, created with repeating gradients */
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px; /* Size of the grid cells */
    
    /* The animation that moves the grid */
    animation: moveGrid 4s linear infinite;

    /* Vignette effect to focus the view on the center */
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%);
    mask-image: radial-gradient(ellipse at center, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1; /* Ensure content is above the background */
}

/* ========================================= */
/* === HEADER & GLITCH EFFECT === */
/* ========================================= */
header {
    background: transparent;
    padding: 60px 0;
    text-align: center;
    border-bottom: 4px solid var(--primary-color);
}

header h1 {
    font-family: var(--font-pixel);
    color: var(--primary-color);
    font-size: 3rem;
    margin-bottom: 10px;
    position: relative;
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color); /* Stronger glow */
}

/* Glitch Animation (unchanged) */
@keyframes glitch-top { 2%, 64% { transform: translate(2px, -2px); } 4%, 60% { transform: translate(-2px, 2px); } 62% { transform: translate(13px, -1px) skew(-13deg); } }
@keyframes glitch-bottom { 2%, 64% { transform: translate(-2px, 0); } 4%, 60% { transform: translate(-2px, 0); } 62% { transform: translate(-22px, 5px) skew(21deg); } }
header h1::before, header h1::after { content: 'ZentrixFun'; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: transparent; overflow: hidden; }
header h1::before { color: var(--secondary-color); animation: glitch-top 3s linear infinite; clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%); }
header h1::after { color: var(--primary-color); animation: glitch-bottom 2.5s linear infinite; clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%); }

/* ========================================= */
/* === MAIN CONTENT & ENHANCED CARDS === */
/* ========================================= */

/* Main Header */
.main-header {
    text-align: center;
    margin: 60px 0;
    position: relative;
}

.floating-icons {
    position: relative;
    height: 80px;
    margin-bottom: 30px;
}

.floating-icon {
    position: absolute;
    font-size: 2rem;
    animation: float 3s ease-in-out infinite;
    opacity: 0.8;
}

.floating-icon:nth-child(1) { left: 20%; animation-delay: 0s; }
.floating-icon:nth-child(2) { left: 35%; animation-delay: 0.5s; }
.floating-icon:nth-child(3) { left: 50%; animation-delay: 1s; }
.floating-icon:nth-child(4) { left: 65%; animation-delay: 1.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.main-title {
    font-family: var(--font-pixel);
    color: var(--secondary-color);
    font-size: 2.5rem;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.title-text {
    position: relative;
    z-index: 2;
    text-shadow: 0 0 15px var(--secondary-color);
}

.title-underline {
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
    animation: underline-grow 1.5s ease-out;
}

@keyframes underline-grow {
    from { width: 0; }
    to { width: 100%; }
}

.main-subtitle {
    font-size: 1.3rem;
    color: var(--text-color);
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Enhanced Game Cards */
.game-list { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 30px; 
    margin: 40px 0;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.game-card {
    background: linear-gradient(135deg, var(--card-background), rgba(22, 33, 62, 0.95));
    padding: 35px 25px;
    border-radius: 20px;
    border: 2px solid rgba(238, 255, 0, 0.3);
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    position: relative;
    overflow: hidden;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.game-card:hover::before {
    left: 100%;
}

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 0%, rgba(255, 251, 0, 0.1), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.game-card:hover .card-glow {
    opacity: 1;
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    animation: icon-bounce 2s ease-in-out infinite;
}

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

.game-card h3 { 
    color: var(--primary-color); 
    margin-bottom: 15px; 
    font-size: 1.6rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 157, 0.5);
}

.game-card p { 
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}

.card-features {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.feature {
    background: rgba(255, 251, 0, 0.1);
    color: var(--primary-color);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid ;
    transition: all 0.3s ease;
}

.feature:hover {
    background: rgba(238, 255, 0, 0.292);
    transform: scale(1.05);
}

.game-card:hover {
    transform: translateY(-15px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 
        0 20px 40px rgba(238, 255, 0, 0.3),
        0 0 60px rgba(238, 255, 0, 0.292),
        inset 0 0 20px rgba(255, 251, 0, 0.1);
}

/* Enhanced Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary-color), #cc6900);
    color: #0a0a14;
    padding: 15px 25px;
    text-decoration: none;
    border-radius: 12px;
    font-weight: bold;
    margin-top: 20px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    box-shadow: 0 5px 15px rgba(221, 255, 0, 0.4);
    font-size: 1rem;
    min-width: 200px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover { 
    background: linear-gradient(135deg, var(--secondary-color), #cc00cc);
    color: #fff; 
    transform: translateY(-3px) scale(1.05); 
    box-shadow: 
        0 15px 30px rgba(255, 0, 255, 0.4),
        0 0 40px rgba(255, 0, 255, 0.3);
}

.btn:active { transform: translateY(-1px) scale(1.02); }

.btn-text {
    flex-grow: 1;
    text-align: center;
}

.btn-arrow {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.btn:hover .btn-arrow {
    transform: translateX(5px);
}

/* Main Footer */
.main-footer {
    margin-top: 80px;
    text-align: center;
}

.stats-container {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin-bottom: 50px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: rgba(255, 251, 0, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(238, 255, 0, 0.3);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    background: rgba(238, 255, 0, 0.292);
    box-shadow: 0 10px 25px rgba(238, 255, 0, 0.3);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    font-family: var(--font-pixel);
    text-shadow: 0 0 10px var(--primary-color);
}

.stat-label {
    color: var(--text-color);
    font-size: 0.9rem;
    margin-top: 5px;
    opacity: 0.8;
}

.cta-section {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.1), rgba(255, 251, 0, 0.1));
    padding: 40px;
    border-radius: 20px;
    border: 1px solid rgba(255, 0, 255, 0.3);
}

.cta-section h3 {
    color: var(--secondary-color);
    font-size: 1.8rem;
    margin-bottom: 15px;
    font-family: var(--font-pixel);
}

.cta-section p {
    color: var(--text-color);
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.coming-soon-text {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.pulse-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

/* ========================================= */
/* === RESPONSIVE DESIGN & ANIMATIONS === */
/* ========================================= */

/* Responsive Design */
@media (max-width: 768px) {
    /* Header responsive styling */
    header {
        padding: 40px 0;
    }
    
    header h1 {
        font-size: 2.5rem;
        margin-bottom: 8px;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .game-list {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 20px 0;
    }
    
    .game-card {
        padding: 25px 20px;
        min-height: 350px;
    }
    
    .main-title {
        font-size: 2rem;
    }
    
    .stats-container {
        gap: 30px;
    }
    
    .floating-icons {
        height: 60px;
    }
    
    .floating-icon {
        font-size: 1.5rem;
    }
    
    .btn {
        min-width: 180px;
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    /* Header responsive styling for very small screens */
    header {
        padding: 30px 0;
    }
    
    header h1 {
        font-size: 2rem;
        margin-bottom: 6px;
    }
    
    header p {
        font-size: 0.9rem;
        padding: 0 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    .game-card {
        padding: 20px 15px;
    }
    
    .card-features {
        flex-direction: column;
        align-items: center;
    }
    
    .stats-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .main-header {
        margin: 40px 0;
    }
    
    .floating-icons {
        height: 50px;
        margin-bottom: 20px;
    }
    
    .floating-icon {
        font-size: 1.2rem;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    header {
        padding: 25px 0;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    header p {
        font-size: 0.85rem;
        padding: 0 15px;
    }
    
    .stick-base {
        width: 200px;
        height: 200px;
    }
    
    .stick-base::before {
        width: 180px;
        height: 180px;
    }
    
    .d-pad {
        width: 140px;
        height: 140px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .control-up {
        top: 12px;
    }
    
    .control-down {
        bottom: 12px;
    }
    
    .control-left {
        left: 12px;
    }
    
    .control-right {
        right: 12px;
    }
}

/* Additional Animations */
.game-card {
    animation: card-fade-in 0.6s ease-out;
}

.game-card:nth-child(1) { animation-delay: 0.1s; }
.game-card:nth-child(2) { animation-delay: 0.2s; }
.game-card:nth-child(3) { animation-delay: 0.3s; }
.game-card:nth-child(4) { animation-delay: 0.4s; }
.game-card:nth-child(5) { animation-delay: 0.5s; }
.game-card:nth-child(6) { animation-delay: 0.6s; }
.game-card:nth-child(7) { animation-delay: 0.7s; }
.game-card:nth-child(8) { animation-delay: 0.8s; }
.game-card:nth-child(9) { animation-delay: 0.9s; }

@keyframes card-fade-in {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hover Effects Enhancement */
.game-card:hover .card-icon {
    animation: icon-spin 0.6s ease-out;
}

@keyframes icon-spin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Loading Animation for Stats */
.stat-item {
    animation: stat-slide-up 0.8s ease-out;
}

.stat-item:nth-child(1) { animation-delay: 0.2s; }
.stat-item:nth-child(2) { animation-delay: 0.4s; }
.stat-item:nth-child(3) { animation-delay: 0.6s; }

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

/* ========================================= */
/* === BUTTONS & INTERACTIVE ELEMENTS === */
/* ========================================= */
.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: #0a0a14;
    padding: 12px 25px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    margin-top: 20px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    box-shadow: 0 0 5px var(--primary-color), 0 0 10px rgba(238, 255, 0, 0.3);
    font-size: 1rem;
}
.btn:hover { background-color: var(--secondary-color); color: #fff; transform: scale(1.05); box-shadow: 0 0 15px var(--secondary-color), 0 0 30px rgba(255, 0, 255, 0.5); }
.btn:active { transform: scale(0.98); }

/* Footer */
footer { text-align: center; padding: 20px; margin-top: 50px; background-color: #000; font-size: 0.9rem; border-top: 2px solid var(--secondary-color); position: relative; z-index: 1; }

.glow-copyright {
    font-weight: bold;
    animation: glowCycle 2s infinite ease-in-out;
}

@keyframes glowCycle {
    0% { color: #ffea00; text-shadow: 0 0 8px #ffea00, 0 0 16px rgba(255,234,0,0.6); }
    25% { color: #ff6b6b; text-shadow: 0 0 8px #ff6b6b, 0 0 16px rgba(255,107,107,0.6); }
    50% { color: #70a1ff; text-shadow: 0 0 8px #70a1ff, 0 0 16px rgba(112,161,255,0.6); }
    75% { color: #2ed573; text-shadow: 0 0 8px #2ed573, 0 0 16px rgba(46,213,115,0.6); }
    100% { color: #ffea00; text-shadow: 0 0 8px #ffea00, 0 0 16px rgba(255,234,0,0.6); }
}

/* ========================================= */
/* === GAME PAGE SPECIFIC STYLES === */
/* ========================================= */
.game-container {
    background: var(--card-background);
    padding: 40px;
    margin-top: 30px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid var(--primary-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.game-container h1 { font-family: var(--font-pixel); color: var(--primary-color); margin-bottom: 20px; text-shadow: 0 0 5px var(--primary-color); }
.game-container p { margin-bottom: 20px; max-width: 600px; margin-left: auto; margin-right: auto; }

.back-link { display: inline-block; margin-top: 30px; color: var(--secondary-color); text-decoration: none; font-weight: bold; transition: color 0.3s, text-shadow 0.3s; }
.back-link:hover { text-decoration: none; color: var(--primary-color); text-shadow: 0 0 10px var(--primary-color); }

input[type="text"], input[type="number"] { padding: 12px; border-radius: 8px; border: 2px solid var(--primary-color); background: rgba(13, 13, 26, 0.7); color: var(--text-color); font-size: 1.1rem; margin: 10px; text-align: center; transition: box-shadow 0.3s; }
input[type="text"]:focus, input[type="number"]:focus { outline: none; box-shadow: 0 0 10px var(--primary-color); }

#message, #result-message { font-size: 1.2rem; font-weight: bold; min-height: 30px; margin-top: 20px; }

/* Rock Paper Scissors Specific */
.choices button { font-size: 2.5rem; margin: 0 15px; padding: 10px; cursor: pointer; background: none; border: 3px solid var(--primary-color); border-radius: 50%; width: 90px; height: 90px; transition: all 0.3s ease; color: var(--text-color); }
.choices button:hover { background-color: rgba(238, 255, 0, 0.292); border-color: var(--secondary-color); transform: scale(1.1); box-shadow: 0 0 15px var(--secondary-color); }
.score-board, .results { margin-top: 20px; font-size: 1.2rem; }

/* Memory Game Specific */
.memory-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 15px; 
    justify-content: center; 
    margin: 20px auto;
    perspective: 1000px;
    max-width: 500px;
}

.card { 
    width: 100%; 
    height: 80px; 
    position: relative; 
    transform-style: preserve-3d; 
    transition: transform 0.6s; 
    cursor: pointer;
    aspect-ratio: 1;
}

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

.card-face { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    backface-visibility: hidden; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: 2rem; 
    border-radius: 10px; 
    border: 2px solid var(--primary-color);
    user-select: none;
}

.card-back { 
    background-color: var(--primary-color); 
    color: var(--background-color); 
    font-family: var(--font-pixel); 
    box-shadow: 0 0 10px var(--primary-color);
    font-size: 1.5rem;
}

.card-front { 
    background-color: var(--card-background); 
    transform: rotateY(180deg);
    color: var(--text-color);
}

/* Matched cards styling */
.card.matched {
    pointer-events: none;
}

.card.matched .card-front {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: white;
    border-color: #00ff88;
    box-shadow: 0 0 15px #00ff88;
}

/* Memory Game Mobile Optimizations */
.game-info {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 251, 0, 0.1);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(238, 255, 0, 0.3);
    min-width: 100px;
}

.info-label {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    font-family: var(--font-pixel);
}

.mobile-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn-hint {
    background: linear-gradient(135deg, #00ff88, #00cc6a) !important;
    color: #0a0a14 !important;
}

.btn-hint:hover {
    background: linear-gradient(135deg, #00cc6a, #00994d) !important;
    transform: translateY(-3px) scale(1.05) !important;
}

.btn-hint.disabled {
    background: linear-gradient(135deg, #666, #444) !important;
    color: #999 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.btn-hint.disabled:hover {
    background: linear-gradient(135deg, #666, #444) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Responsive Memory Grid */
@media (max-width: 768px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        max-width: 400px;
    }
    
    .card {
        height: 70px;
    }
    
    .card-face {
        font-size: 1.5rem;
    }
    
    .card-back {
        font-size: 1.2rem;
    }
    
    .game-info {
        flex-direction: column;
        align-items: center;
    }
    
    .info-item {
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        max-width: 320px;
    }
    
    .card {
        height: 60px;
    }
    
    .card-face {
        font-size: 1.2rem;
    }
    
    .card-back {
        font-size: 1rem;
    }
    
    .mobile-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        min-width: 200px;
    }
}

@media (max-width: 320px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        max-width: 280px;
    }
    
    .card {
        height: 50px;
    }
    
    .card-face {
        font-size: 1rem;
    }
    
    .card-back {
        font-size: 0.9rem;
    }
}

/* Snake Game Specific */
.snake-game-info { display: flex; justify-content: space-around; margin: 20px 0; font-size: 1.2rem; flex-wrap: wrap; }
.snake-game-info p { margin: 10px; }
#gameCanvas { border: 3px solid var(--primary-color); border-radius: 10px; margin: 20px auto; display: block; box-shadow: 0 0 20px var(--primary-color); background-color: var(--background-color); }
.game-controls { text-align: center; margin: 20px 0; }
.instructions { margin: 30px 0; text-align: center; }
.instructions h3 { color: var(--primary-color); margin-bottom: 15px; }
.instructions ul { list-style: none; padding: 0; }
.instructions li { margin: 8px 0; padding: 5px 0; }

/* Mobile Snake Controls */
.mobile-snake-controls {
    display: none; /* Hidden by default on desktop */
    justify-content: center;
    margin: 30px 0;
    gap: 20px;
}

.control-stick-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.stick-base {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 280px;
    height: 280px;
}

.stick-base::before {
    content: '';
    position: absolute;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle at 30% 30%, #4a5568, #2d3748);
    border-radius: 50%;
    border: 4px solid #718096;
    box-shadow: 
        inset 0 0 30px rgba(0,0,0,0.4),
        0 8px 25px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.1);
    z-index: 1;
}

.d-pad {
    position: relative;
    width: 200px;
    height: 200px;
    z-index: 2;
}

.control-up {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #48bb78, #38a169) !important;
    border: 3px solid #2f855a !important;
    box-shadow: 
        0 4px 15px rgba(72, 187, 120, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3) !important;
}

.control-down {
    position: absolute;
    bottom: 10px;
    left: 51%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4299e1, #3182ce) !important;
    border: 3px solid #2b6cb0 !important;
    box-shadow: 
        0 4px 15px rgba(66, 153, 225, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3) !important;
    }
    
.control-left {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(135deg, #f56565, #e53e3e) !important;
        border: 3px solid #c53030 !important;
        box-shadow: 
        0 4px 15px rgba(245, 101, 101, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3) !important;
}

.control-right {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #ed8936, #dd6b20) !important;
    border: 3px solid #c05621 !important;
    box-shadow: 
        0 4px 15px rgba(237, 137, 54, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3) !important;
}

.control-up:hover {
    background: linear-gradient(135deg, #038948, #03512a) !important;
}

.control-down:hover {
    background: linear-gradient(135deg, #2980b9, #1f4e79) !important;
}

.control-left:hover {
    background: linear-gradient(135deg, #c752ee, #a430d6) !important;
}

.control-right:hover {
    background: linear-gradient(135deg, #c0392b, #7b241c) !important;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    color: var(--background-color);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.control-btn:hover {
    /* transform: scale(1.1); */
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.control-btn:active {
    /* transform: scale(0.95); */
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.control-btn.holding {
    /* transform: scale(0.95); */
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    animation: hold-pulse 0.2s ease-in-out infinite;
}

@keyframes hold-pulse {
    0%, 100% { 
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }
    50% { 
        box-shadow: 0 2px 15px rgba(0,0,0,0.6);
    }
}

/* Prevent unwanted mobile behaviors */
.game-container {
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
}

#gameCanvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Responsive design untuk mobile */
@media (max-width: 768px) {
    .mobile-snake-controls {
        display: flex; /* Show on mobile */
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 350px;
        height: auto;
    }
    
    .game-controls {
        margin-bottom: 10px;
    }
    
    .control-btn {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    .snake-game-info {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .snake-game-info p {
        margin: 5px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .mobile-snake-controls {
        gap: 15px;
        margin: 20px 0;
    }
    
    .stick-base {
        width: 240px;
        height: 240px;
    }
    
    .stick-base::before {
        width: 220px;
        height: 220px;
    }
    
    .d-pad {
        width: 160px;
        height: 160px;
    }
    
    .control-up {
        top: 15px;
    }
    
    .control-down {
        bottom: 15px;
    }
    
    .control-left {
        left: 15px;
    }
    
    .control-right {
        right: 15px;
    }
    
    #gameCanvas {
        max-width: 300px;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* Tic Tac Toe Specific */
.game-info { display: flex; justify-content: space-around; margin: 20px 0; font-size: 1.2rem; }
.board-container { display: flex; justify-content: center; margin: 30px 0; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 300px; height: 300px; }
.cell { background-color: var(--card-background); border: 3px solid var(--primary-color); border-radius: 10px; display: flex; justify-content: center; align-items: center; font-size: 3rem; font-weight: bold; cursor: pointer; transition: all 0.3s ease; color: var(--text-color); }
.cell:hover { background-color: rgba(238, 255, 0, 0.292); border-color: var(--secondary-color); transform: scale(1.05); }
.cell.X { color: var(--primary-color); text-shadow: 0 0 10px var(--primary-color); }
.cell.O { color: var(--secondary-color); text-shadow: 0 0 10px var(--secondary-color); }

/* Winner History Styles */
.game-history { 
    margin-top: 20px; 
    padding: 16px; 
    border: 2px solid rgba(238, 255, 0, 0.3); 
    border-radius: 12px; 
    background: rgba(22, 33, 62, 0.5);
}
.history-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 10px; 
    margin-bottom: 12px; 
}
.history-header h3 { 
    color: var(--primary-color); 
    text-shadow: 0 0 8px var(--primary-color); 
}
.history-stats { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
}
.stat { 
    background: rgba(238, 255, 0, 0.1); 
    border: 1px solid rgba(238, 255, 0, 0.3); 
    padding: 6px 10px; 
    border-radius: 999px; 
    font-size: 0.9rem; 
}
.stat-x { color: var(--primary-color); }
.stat-o { color: var(--secondary-color); }
.stat-draw { color: #9ae6b4; }
.winner-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}
.winner-item { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    background: rgba(0, 0, 0, 0.25); 
    border: 1px solid rgba(238, 255, 0, 0.2); 
    border-radius: 10px; 
    padding: 10px 12px; 
}
.winner-left { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}
.badge { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    width: 28px; 
    height: 28px; 
    border-radius: 50%; 
    font-weight: bold; 
    color: #0a0a14; 
    box-shadow: 0 0 10px rgba(238, 255, 0, 0.3);
}
.badge-x { background: var(--primary-color); }
.badge-o { background: var(--secondary-color); }
.badge-draw { background: #38a169; color: #0a0a14; }
.winner-meta { 
    font-size: 0.9rem; 
    opacity: 0.85; 
}

/* Color Match Specific */
.color-display { text-align: center; margin: 30px 0; }
.target-color { width: 200px; height: 100px; margin: 0 auto; border-radius: 15px; display: flex; justify-content: center; align-items: center; font-family: var(--font-pixel); font-size: 1.2rem; font-weight: bold; cursor: pointer; transition: all 0.3s ease; background-color: #333; }
.target-color:hover { transform: scale(1.05); }
.color-options { display: flex; justify-content: center; flex-wrap: wrap; margin: 30px 0; }
.color-option:hover { transform: scale(1.1); box-shadow: 0 0 15px var(--primary-color); }

/* 2048 Puzzle Specific */
.puzzle-container { display: flex; justify-content: center; margin: 30px 0; }
.puzzle-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 320px; height: 320px; background: rgba(255, 251, 0, 0.1); padding: 20px; border-radius: 15px; border: 2px solid var(--primary-color); }
.puzzle-tile { background: var(--card-background); border: 2px solid var(--primary-color); border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; font-weight: bold; color: var(--text-color); transition: all 0.3s ease; min-height: 60px; }
.puzzle-tile:empty { background: transparent; border-color: transparent; }
.tile-2 { background: linear-gradient(135deg, #ff6b6b, #ee5a52); color: white; }
.tile-4 { background: linear-gradient(135deg, #ffa726, #ff9800); color: white; }
.tile-8 { background: linear-gradient(135deg, #ffd54f, #ffc107); color: #333; }
.tile-16 { background: linear-gradient(135deg, #66bb6a, #4caf50); color: white; }
.tile-32 { background: linear-gradient(135deg, #42a5f5, #2196f3); color: white; }
.tile-64 { background: linear-gradient(135deg, #ab47bc, #9c27b0); color: white; }
.tile-128 { background: linear-gradient(135deg, #ff7043, #ff5722); color: white; font-size: 1.2rem; }
.tile-256 { background: linear-gradient(135deg, #26a69a, #009688); color: white; font-size: 1.2rem; }
.tile-512 { background: linear-gradient(135deg, #d4e157, #cddc39); color: #333; font-size: 1.2rem; }
.tile-1024 { background: linear-gradient(135deg, #ffab91, #ff8a65); color: white; font-size: 1rem; }
.tile-2048 { background: linear-gradient(135deg, #f06292, #e91e63); color: white; font-size: 1rem; animation: tile-2048-glow 2s ease-in-out infinite; }

@keyframes tile-2048-glow {
    0%, 100% { box-shadow: 0 0 20px var(--primary-color); }
    50% { box-shadow: 0 0 40px var(--primary-color), 0 0 60px var(--secondary-color); }
}

@keyframes tile-appear {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Flappy Bird Specific */
.game-info { display: flex; justify-content: space-around; margin: 20px 0; font-size: 1.2rem; flex-wrap: wrap; }
.game-info p { margin: 10px; }

/* Breakout Specific */
#gameCanvas { border: 3px solid var(--primary-color); border-radius: 10px; margin: 20px auto; display: block; box-shadow: 0 0 20px var(--primary-color); background-color: var(--background-color); }

/* Mobile Breakout Controls */
.mobile-breakout-controls {
    display: none; /* Hidden by default on desktop */
    justify-content: center;
    margin: 20px 0;
    gap: 15px;
}

.control-stick-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.stick-base {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 200px;
    height: 120px;
}

.stick-base::before {
    content: '';
    position: absolute;
    width: 180px;
    height: 100px;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 50px;
    border: 3px solid #95a5a6;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.3),
        0 5px 15px rgba(0,0,0,0.3);
    z-index: 1;
}

.control-left {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: linear-gradient(135deg, #f86bff, #e452ee) !important;
    border: 2px solid #d330d6 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

.control-right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
    border: 2px solid #d63031 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

.control-launch {
    background: linear-gradient(135deg, #449e41, #539534) !important;
    color: white !important;
    font-size: 20px !important;
    border: 2px solid #215b15 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

.control-launch:hover {
    background: linear-gradient(135deg, #52ee6f, #30d654) !important;
}

.control-left:hover {
    background: linear-gradient(135deg, #ba52ee, #aa30d6) !important;
}

.control-right:hover {
    background: linear-gradient(135deg, #c0392b, #7b241c) !important;
}

/* Responsive design untuk breakout mobile */
@media (max-width: 768px) {
    .mobile-breakout-controls {
        display: flex; /* Show on mobile */
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 600px;
        height: auto;
    }
    
    .game-info {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .game-info p {
        margin: 5px;
        font-size: 1rem;
    }
    
    .power-ups-info ul {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    #gameCanvas {
        max-width: 400px;
    }
    
    .mobile-breakout-controls {
        gap: 10px;
    }
    
    .stick-base {
        width: 160px;
        height: 100px;
    }
    
    .stick-base::before {
        width: 140px;
        height: 80px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
    
    .control-left {
        left: 15px;
    }
    
    .control-right {
        right: 15px;
    }
    
    .control-launch {
        font-size: 16px !important;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .power-ups-info h4 {
        font-size: 1.1rem;
    }
    
    .power-ups-info li {
        font-size: 0.9rem;
        margin: 5px 0;
    }
}

/* ========================================= */
/* === JUMP BUTTON STYLES === */
/* ========================================= */
.jump-btn {
    background: linear-gradient(135deg, #00ff88, #00cc6a) !important;
    color: #0a0a14 !important;
    font-weight: bold !important;
    font-size: 1.2rem !important;
    padding: 20px 30px !important;
    min-width: 150px !important;
    border: 3px solid #00ff88 !important;
    box-shadow: 
        0 0 20px rgba(0, 255, 136, 0.6),
        0 0 40px rgba(0, 255, 136, 0.4),
        inset 0 0 20px rgba(0, 255, 136, 0.2) !important;
    animation: jump-btn-pulse 2s ease-in-out infinite !important;
    margin: 10px !important;
}

.jump-btn:hover {
    background: linear-gradient(135deg, #00cc6a, #00994d) !important;
    transform: translateY(-5px) scale(1.1) !important;
    box-shadow: 
        0 0 30px rgba(0, 255, 136, 0.8),
        0 0 60px rgba(0, 255, 136, 0.6),
        inset 0 0 30px rgba(0, 255, 136, 0.3) !important;
}

.jump-btn:active {
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 
        0 0 15px rgba(0, 255, 136, 0.7),
        0 0 30px rgba(0, 255, 136, 0.5) !important;
}

@keyframes jump-btn-pulse {
    0%, 100% { 
        box-shadow: 
            0 0 20px rgba(0, 255, 136, 0.6),
            0 0 40px rgba(0, 255, 136, 0.4),
            inset 0 0 20px rgba(0, 255, 136, 0.2);
    }
    50% { 
        box-shadow: 
            0 0 30px rgba(0, 255, 136, 0.8),
            0 0 60px rgba(0, 255, 136, 0.6),
            inset 0 0 30px rgba(0, 255, 136, 0.3);
    }
}

/* Mobile 2048 Controls */
.mobile-2048-controls {
    display: none; /* Hidden by default on desktop */
    justify-content: center;
    margin: 20px 0;
    gap: 10px;
}

/* Responsive design untuk 2048 puzzle mobile */
@media (max-width: 768px) {
    .mobile-2048-controls {
        display: flex; /* Show on mobile */
    }
    
    .puzzle-board {
        width: 100%;
        max-width: 350px;
        height: auto;
        aspect-ratio: 1;
    }
    
    .puzzle-tile {
        min-height: 50px;
        font-size: 1.2rem;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 0.9rem;
    }
    
    .game-info {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .game-info p {
        margin: 5px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .puzzle-board {
        max-width: 300px;
        padding: 15px;
        gap: 6px;
    }
    
    .puzzle-tile {
        min-height: 45px;
        font-size: 1rem;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 0.9rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 0.8rem;
    }
    
    .mobile-2048-controls {
        gap: 8px;
    }
    
    .control-row {
        gap: 8px;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* Prevent unwanted mobile behaviors untuk 2048 puzzle */
.puzzle-board {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Prevent unwanted mobile behaviors untuk breakout game */
#gameCanvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}