* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light Theme */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.2);
}

.dark-theme {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #b8b8b8;
    --accent: #4a90e2;
    --accent-hover: #357abd;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Settings Button */
.settings-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s ease;
}

.settings-btn:hover {
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    box-shadow: -5px 0 20px var(--shadow);
    z-index: 999;
    transition: right 0.3s ease;
    padding: 30px;
}

.settings-panel.active {
    right: 0;
}

.settings-content h2 {
    margin-bottom: 30px;
    color: var(--text-primary);
}

.setting-item {
    margin-bottom: 25px;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
}

.theme-toggle {
    display: flex;
    gap: 10px;
}

.theme-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--accent);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.theme-btn.active {
    background: var(--accent);
    color: white;
}

.theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow);
}

.close-settings {
    width: 100%;
    padding: 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.close-settings:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Main Menu */
.main-menu {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 40px 20px;
}

.ad-banner {
    width: 100%;
    height: 100px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 2px dashed var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    text-align: center;
}

.main-title {
    font-size: 4rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.game-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px var(--shadow);
    border: 2px solid transparent;
}

.game-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 10px 30px var(--shadow-hover);
    border-color: var(--accent);
}

.game-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-card h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.game-card p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Game Container */
.game-container {
    display: none;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.game-container.active {
    display: block;
}

.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
}

.back-btn:hover {
    background: var(--accent-hover);
    transform: translateX(-5px);
}

.ad-sidebar {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    height: 600px;
    z-index: 50;
}

.ad-sidebar .ad-placeholder {
    height: 100%;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* Game Screen */
.game-screen {
    display: none;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.game-screen.active {
    display: block;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.game-header h2 {
    font-size: 2.5rem;
    color: var(--text-primary);
}

.score-display {
    display: flex;
    gap: 20px;
}

.score-item {
    background: var(--bg-secondary);
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 3px 10px var(--shadow);
    font-weight: 600;
}

.score-item span:first-child {
    color: var(--text-secondary);
    margin-right: 10px;
}

.game-board {
    background: var(--bg-tertiary);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 20px var(--shadow);
    margin-bottom: 20px;
}

.game-controls {
    text-align: center;
    margin: 20px 0;
}

.game-btn {
    padding: 15px 30px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    margin: 0 10px;
}

.game-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

.game-instructions {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 15px;
    font-style: italic;
}

/* 2048 Game Styles */
#board2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 520px;
    height: 520px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 40px var(--shadow), inset 0 0 20px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

#board2048::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
    pointer-events: none;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tile {
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--text-primary);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tile:hover::before {
    opacity: 1;
}

.tile.new {
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tile.merged {
    animation: merge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.tile.slide {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popIn {
    0% { 
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% { 
        transform: scale(1.15) rotate(90deg);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes merge {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    50% { 
        transform: scale(1.4) rotate(5deg);
        box-shadow: 0 8px 20px rgba(52, 152, 219, 0.5);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
}

.tile-2 { 
    background: linear-gradient(135deg, #eee4da, #ddd4c8); 
    color: #776e65; 
    box-shadow: 0 4px 12px rgba(238, 228, 218, 0.4);
}
.tile-4 { 
    background: linear-gradient(135deg, #ede0c8, #dcd0b8); 
    color: #776e65; 
    box-shadow: 0 4px 12px rgba(237, 224, 200, 0.4);
}
.tile-8 { 
    background: linear-gradient(135deg, #f2b179, #e2a169); 
    color: #f9f6f2; 
    box-shadow: 0 4px 12px rgba(242, 177, 121, 0.5);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.tile-16 { 
    background: linear-gradient(135deg, #f59563, #e58553); 
    color: #f9f6f2; 
    box-shadow: 0 4px 12px rgba(245, 149, 99, 0.5);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.tile-32 { 
    background: linear-gradient(135deg, #f67c5f, #e66c4f); 
    color: #f9f6f2; 
    box-shadow: 0 4px 12px rgba(246, 124, 95, 0.5);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.tile-64 { 
    background: linear-gradient(135deg, #f65e3b, #e64e2b); 
    color: #f9f6f2; 
    box-shadow: 0 4px 12px rgba(246, 94, 59, 0.5);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.tile-128 { 
    background: linear-gradient(135deg, #edcf72, #ddbf62); 
    color: #f9f6f2; 
    box-shadow: 0 4px 16px rgba(237, 207, 114, 0.6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.8rem;
}
.tile-256 { 
    background: linear-gradient(135deg, #edcc61, #ddbc51); 
    color: #f9f6f2; 
    box-shadow: 0 4px 16px rgba(237, 204, 97, 0.6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.8rem;
}
.tile-512 { 
    background: linear-gradient(135deg, #edc850, #ddb840); 
    color: #f9f6f2; 
    box-shadow: 0 4px 16px rgba(237, 200, 80, 0.6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.8rem;
}
.tile-1024 { 
    background: linear-gradient(135deg, #edc53f, #ddb52f); 
    color: #f9f6f2; 
    box-shadow: 0 4px 20px rgba(237, 197, 63, 0.7);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.6rem;
    animation: glow 2s ease-in-out infinite;
}
.tile-2048 { 
    background: linear-gradient(135deg, #edc22e, #ddb21e); 
    color: #f9f6f2; 
    box-shadow: 0 4px 20px rgba(237, 194, 46, 0.7);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.6rem;
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 4px 20px rgba(237, 194, 46, 0.7); }
    50% { box-shadow: 0 4px 30px rgba(237, 194, 46, 1); }
}

.dark-theme .tile-2 { 
    background: linear-gradient(135deg, #3d3d3d, #2d2d2d); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(61, 61, 61, 0.4);
}
.dark-theme .tile-4 { 
    background: linear-gradient(135deg, #4a4a4a, #3a3a3a); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(74, 74, 74, 0.4);
}
.dark-theme .tile-8 { 
    background: linear-gradient(135deg, #5a5a5a, #4a4a4a); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(90, 90, 90, 0.5);
}
.dark-theme .tile-16 { 
    background: linear-gradient(135deg, #6a6a6a, #5a5a5a); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(106, 106, 106, 0.5);
}
.dark-theme .tile-32 { 
    background: linear-gradient(135deg, #7a7a7a, #6a6a6a); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(122, 122, 122, 0.5);
}
.dark-theme .tile-64 { 
    background: linear-gradient(135deg, #8a8a8a, #7a7a7a); 
    color: #eaeaea; 
    box-shadow: 0 4px 12px rgba(138, 138, 138, 0.5);
}
.dark-theme .tile-128 { 
    background: linear-gradient(135deg, #9a9a9a, #8a8a8a); 
    color: #eaeaea; 
    box-shadow: 0 4px 16px rgba(154, 154, 154, 0.6);
    font-size: 1.8rem;
}
.dark-theme .tile-256 { 
    background: linear-gradient(135deg, #aaaaaa, #9a9a9a); 
    color: #1a1a2e; 
    box-shadow: 0 4px 16px rgba(170, 170, 170, 0.6);
    font-size: 1.8rem;
}
.dark-theme .tile-512 { 
    background: linear-gradient(135deg, #bababa, #aaaaaa); 
    color: #1a1a2e; 
    box-shadow: 0 4px 16px rgba(186, 186, 186, 0.6);
    font-size: 1.8rem;
}
.dark-theme .tile-1024 { 
    background: linear-gradient(135deg, #cacaca, #bababa); 
    color: #1a1a2e; 
    box-shadow: 0 4px 20px rgba(202, 202, 202, 0.7);
    font-size: 1.6rem;
    animation: glowDark 2s ease-in-out infinite;
}
.dark-theme .tile-2048 { 
    background: linear-gradient(135deg, #dadada, #cacaca); 
    color: #1a1a2e; 
    box-shadow: 0 4px 20px rgba(218, 218, 218, 0.7);
    font-size: 1.6rem;
    animation: glowDark 2s ease-in-out infinite;
}

@keyframes glowDark {
    0%, 100% { box-shadow: 0 4px 20px rgba(218, 218, 218, 0.7); }
    50% { box-shadow: 0 4px 30px rgba(218, 218, 218, 1); }
}

/* Dinosaur Game Styles */
#dinoCanvas {
    display: block;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: 0 5px 20px var(--shadow);
    border: 3px solid var(--accent);
}

/* Poker Game Styles */
.poker-table {
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 40px;
    margin: 20px 0;
    position: relative;
    min-height: 500px;
    box-shadow: 0 5px 20px var(--shadow);
}

.opponent {
    position: absolute;
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 3px 10px var(--shadow);
    min-width: 150px;
}

#opponent1 {
    top: 20px;
    left: 20px;
}

#opponent2 {
    top: 20px;
    right: 20px;
}

.opponent-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    font-size: 14px;
}

.opponent-name {
    font-weight: bold;
    color: var(--text-primary);
}

.opponent-chips {
    color: var(--success);
    font-weight: 600;
}

.opponent-cards {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.card {
    width: 60px;
    height: 84px;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border: 2px solid var(--accent);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 12px var(--shadow), inset 0 0 10px rgba(0, 0, 0, 0.05);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px var(--shadow-hover);
}

.card:hover::before {
    opacity: 1;
}

.card.red {
    color: #e74c3c;
}

.card.black {
    color: #2c3e50;
}

.card .card-rank {
    font-size: 18px;
    line-height: 1;
}

.card .card-suit {
    font-size: 24px;
    line-height: 1;
    margin-top: 2px;
}

.card.hidden {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #764ba2;
    position: relative;
    overflow: hidden;
}

.card.hidden::after {
    content: '?';
    position: absolute;
    font-size: 32px;
    opacity: 0.3;
}

.card.hidden:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

.card.new {
    animation: cardFlip 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cardFlip {
    0% {
        transform: rotateY(90deg) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: rotateY(45deg) scale(1.1);
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.community-cards {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 100px 0;
    flex-wrap: wrap;
}

.player-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.player-cards {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.player-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.poker-btn {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.poker-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.poker-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#betAmount {
    padding: 12px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    width: 100px;
}

/* Snake Game Styles */
#snakeCanvas {
    display: block;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: 0 5px 20px var(--shadow);
    border: 3px solid var(--accent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-title {
        font-size: 2.5rem;
    }
    
    .game-grid {
        grid-template-columns: 1fr;
    }
    
    .ad-sidebar {
        display: none;
    }
    
    #board2048 {
        width: 100%;
        max-width: 400px;
        height: 400px;
    }
    
    #dinoCanvas, #snakeCanvas {
        width: 100%;
        max-width: 100%;
    }
    
    .settings-panel {
        width: 100%;
        right: -100%;
    }
}

/* Game Over Overlay */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.game-over-overlay.active {
    display: flex;
}

.game-over-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px var(--shadow);
}

.game-over-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.game-over-content p {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--text-secondary);
}
