* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    background: #1a1a2e;
    width: 100%;
    height: 100%;
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.menu-content {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    animation: slideUp 0.5s ease-out;
}

.menu-content.wide {
    max-width: 95%;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Menu Stats */
.menu-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
}

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

.stat-icon {
    font-size: 2rem;
}

.stat-label {
    color: #e0e0e0;
    font-size: 0.9rem;
}

.stat-value {
    color: #ffd700;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Background Selector */
.background-selector {
    margin: 2rem 0 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.background-selector h4 {
    color: #ffd700;
    margin-bottom: 0.8rem;
}

.bg-options {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.bg-option {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.bg-option:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.bg-option.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.game-title {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    }

    to {
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 40px rgba(102, 126, 234, 0.6);
    }
}

.game-subtitle {
    font-size: 1.2rem;
    color: #e0e0e0;
    margin-bottom: 2rem;
}

.game-over-title {
    font-size: 2.5rem;
    color: #ff6b6b;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

.game-over-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 15px;
    margin: 1rem 0;
}

.final-score,
.final-level,
.final-coins,
.high-score {
    font-size: 1.3rem;
    color: #fff;
    margin: 0.8rem 0;
}

.final-score span,
.final-level span,
.final-coins span,
.high-score span {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.8rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-left: 10px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Buttons */
.game-btn {
    padding: 1rem 2.5rem;
    margin: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.game-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.game-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.game-btn.secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.game-btn.secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.game-btn:active {
    transform: translateY(0);
}

.game-btn.ai-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.game-btn.ai-btn:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
    transform: translateY(-2px);
}

.menu-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

/* Instructions */
.instructions {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
}

.instructions h3 {
    color: #ffd700;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.instructions p {
    color: #e0e0e0;
    margin: 0.5rem 0;
    font-size: 1rem;
}

/* Character Selection */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
    max-width: 100%;
}

.character-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.character-card:hover {
    transform: translateY(-10px);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.character-card.selected {
    border-color: #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.character-preview {
    width: 150px;
    height: 150px;
    margin: 0 auto 1rem;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-card h3 {
    color: #fff;
    margin: 1rem 0 0.5rem;
    font-size: 1.3rem;
}

.character-ability {
    color: #ffd700;
    font-size: 1rem;
    margin: 0.5rem 0 1rem;
    font-weight: bold;
}

.character-card .game-btn {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
}

.hud-top {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    pointer-events: none;
}

.hud-bottom {
    position: absolute;
    top: 20px;
    right: 20px;
    pointer-events: all;
}

#hud.hidden {
    display: none;
}

.hud-item {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hud-label {
    color: #ffd700;
    font-weight: bold;
    margin-right: 8px;
    font-size: 0.9rem;
}

.hud-value {
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
}

.hud-value.combo {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Pause Button */
.pause-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-btn:hover {
    background: rgba(102, 126, 234, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
}

.pause-btn:active {
    transform: scale(0.95);
}

/* Power-up Display */
.power-up-display {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.3));
    border-color: #ffd700;
    animation: powerupGlow 1s ease-in-out infinite;
}

@keyframes powerupGlow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
    }
}

.powerup-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}

.powerup-timer {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Touch Hint */
.ai-indicator {
    background: rgba(16, 185, 129, 0.9);
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    animation: pulse 1.5s infinite;
    margin-top: 10px;
}

.touch-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    z-index: 5;
    animation: bounce 2s ease-in-out infinite;
    pointer-events: none;
}

.touch-hint.hidden {
    display: none;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }

    .game-subtitle {
        font-size: 1rem;
    }

    .game-btn {
        padding: 0.8rem 2rem;
        font-size: 1rem;
    }

    .instructions h3 {
        font-size: 1.1rem;
    }

    .instructions p {
        font-size: 0.9rem;
    }

    .character-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .character-preview {
        width: 120px;
        height: 120px;
    }

    .hud-top {
        padding: 10px 5px;
        gap: 5px;
    }

    .hud-item {
        padding: 6px 10px;
    }

    .hud-label {
        font-size: 0.7rem;
    }

    .hud-value {
        font-size: 0.85rem;
    }

    .pause-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* Landscape mode for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .menu-content {
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .game-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .instructions {
        margin-top: 1rem;
        padding: 1rem;
    }
}

/* Shop Styles */
.game-btn.shop {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.game-btn.shop:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.shop-coins {
    font-size: 1.5rem;
    color: #ffd700;
    margin-bottom: 1.5rem;
}

.shop-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.shop-tab {
    padding: 0.8rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.shop-tab:hover {
    background: rgba(255, 255, 255, 0.2);
}

.shop-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #ffd700;
}

.shop-content {
    max-height: 300px;
    overflow-y: auto;
}

.shop-content.hidden {
    display: none;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.shop-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

.shop-item:hover {
    transform: translateY(-5px);
    border-color: rgba(102, 126, 234, 0.6);
}

.shop-item.owned {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.shop-preview {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.shop-item h4 {
    color: #fff;
    margin: 0.5rem 0;
}

.shop-desc {
    color: #aaa;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.shop-price {
    color: #ffd700;
    font-weight: bold;
    margin: 0.5rem 0;
}

.shop-item .game-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.shop-item .game-btn.owned-btn {
    background: #4ade80;
    cursor: default;
}

/* Leaderboard Styles */
.game-btn.leaderboard {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.game-btn.leaderboard:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.leaderboard-submit {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.leaderboard-submit input {
    padding: 0.8rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    outline: none;
    width: 150px;
}

.leaderboard-submit input:focus {
    border-color: #8b5cf6;
}

.submit-status {
    color: #4ade80;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.leaderboard-list {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    margin: 1rem 0;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffd700;
    width: 40px;
}

.leaderboard-entry:nth-child(1) .leaderboard-rank {
    color: #ffd700;
}

.leaderboard-entry:nth-child(2) .leaderboard-rank {
    color: #c0c0c0;
}

.leaderboard-entry:nth-child(3) .leaderboard-rank {
    color: #cd7f32;
}

.leaderboard-name {
    flex: 1;
    color: #fff;
    font-weight: bold;
}

.leaderboard-score {
    color: #4ade80;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Locked world style */
.bg-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Orientation Lock */
#orientation-lock {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #2d3436;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
}

.lock-content {
    color: white;
}

.phone-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: rotate-phone 2s infinite ease-in-out;
}

@keyframes rotate-phone {
    0% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(-90deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

@media screen and (orientation: portrait) and (max-width: 900px) {
    #orientation-lock {
        display: flex;
    }

    #game-container {
        display: none;
    }
}