/* Game View */
.game-view {
    background: rgba(52, 73, 94, 0.85);
    backdrop-filter: blur(5px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.game-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

.game-info {
    color: white;
    font-weight: bold;
    font-size: 1rem;
}

.game-header-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    margin: 0 0.2rem;
    transition: all 0.2s;
    font-weight: bold;
}

.game-header-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.game-header-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.95);
}

.game-board {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0.5rem;
    position: relative;
    min-height: 400px;
    width: 100%;
    overflow: visible;
}

.maze-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    padding: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 2px 10px rgba(255,255,255,0.5);
    width: fit-content;
    max-width: 100%;
    height: fit-content;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    position: relative;
    margin: 0.5rem auto;
}

.maze-grid {
    display: grid;
    gap: 0;
    background: #f8f9fa;
    padding: 3px;
    border-radius: 8px;
    position: relative;
    will-change: contents;
    transform: translateZ(0);
    border: 3px solid #34495e;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    width: fit-content;
    height: fit-content;
    margin: auto;
}

.cell {
    min-width: 30px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    position: relative;
    border-radius: 2px;
    transition: transform 0.15s ease-out, opacity 0.2s;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0); /* Force hardware acceleration */
}

.cell.wall {
    background: #34495e;
    border: 2px solid #2c3e50;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.cell.wall::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(255,255,255,0.1) 8px,
        rgba(255,255,255,0.1) 16px
    );
}

.cell.path {
    background: #ffffff;
    border: 1px solid #e8e8e8;
}

.cell.corn {
    background: #fff9c4;
    border: 2px solid #f1c40f;
    animation: cornRotate 2s infinite;
}

@keyframes cornRotate {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.1); }
}

.cell.door {
    background: #8b4513;
    color: white;
    border: 2px solid #654321;
    font-weight: bold;
    animation: doorShake 0.5s infinite;
    position: relative;
}

@keyframes doorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.cell.door.open {
    background: #ecf0f1;
    border: 1px solid #d5dbdb;
    animation: doorOpen 0.5s ease-out;
}

@keyframes doorOpen {
    0% {
        transform: scale(1);
        opacity: 1;
        background: #8b4513;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
        background: #ecf0f1;
    }
}

.cell.trap {
    background: #e74c3c;
    border: 2px solid #c0392b;
    animation: trapPulse 1s infinite;
}

@keyframes trapPulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.05);
        box-shadow: 0 0 15px 5px rgba(231, 76, 60, 0.5);
    }
}

.cell.exit {
    background: #2ecc71;
    border: 3px solid #27ae60;
    animation: exitGlow 1.5s infinite;
}

@keyframes exitGlow {
    0%, 100% { 
        box-shadow: 0 0 10px #2ecc71;
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 20px #2ecc71, 0 0 30px #2ecc71;
        transform: scale(1.05);
    }
}

.cell.player {
    background: #f1c40f;
    border-radius: 50%;
    z-index: 10;
    border: 3px solid #f39c12;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.8);
    transition: transform 0.15s ease-out;
    position: relative;
    will-change: transform;
}

.cell.player::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    pointer-events: none;
}

.cell.player.moving {
    animation: playerMove 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes playerMove {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.15) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.cell.player.collecting {
    animation: collectAnimation 0.5s ease-out;
}

@keyframes collectAnimation {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.controls {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 100;
    flex-shrink: 0;
    min-height: fit-content;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.3rem;
    max-width: 200px;
}

.dpad-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.dpad-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.dpad-btn:active::before {
    width: 200%;
    height: 200%;
}

.dpad-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.9);
}

.dpad-btn.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.dpad-btn.empty:active {
    transform: none;
}

/* Particle effects */
.particle {
    position: absolute;
    pointer-events: none;
    font-size: 1.5rem;
    z-index: 1000;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* Mobile optimizations for game */
@media (max-width: 480px) {
    .game-header {
        padding: 0.5rem;
        flex-wrap: wrap;
        min-height: auto;
    }

    .game-info {
        font-size: 0.75rem;
        width: 100%;
        text-align: center;
        margin-top: 0.2rem;
        order: 3;
    }

    .game-header-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
        margin: 0.1rem;
    }

    .game-board {
        padding: 0.2rem;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .maze-container {
        padding: 0.2rem;
        border-radius: 8px;
        margin: 0.2rem;
    }

    .maze-grid {
        padding: 1px;
        border-width: 2px;
    }

    .cell {
        min-width: 18px;
        min-height: 18px;
        font-size: 0.9rem;
    }

    .controls {
        padding: 0.4rem;
        flex-shrink: 0;
    }

    .dpad {
        gap: 0.2rem;
        padding: 0.4rem;
        max-width: 160px;
    }

    .dpad-btn {
        padding: 0.5rem;
        font-size: 1rem;
        border-radius: 6px;
    }

    .cell.player {
        border-width: 2px;
    }

    .cell.exit {
        border-width: 2px;
    }
}

@media (max-width: 360px) {
    .game-header {
        padding: 0.4rem;
    }

    .game-info {
        font-size: 0.7rem;
    }

    .game-header-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .game-board {
        padding: 0.15rem;
    }

    .maze-container {
        padding: 0.15rem;
        margin: 0.15rem;
    }

    .cell {
        min-width: 15px;
        min-height: 15px;
        font-size: 0.8rem;
    }

    .controls {
        padding: 0.3rem;
    }

    .dpad {
        max-width: 140px;
        gap: 0.15rem;
        padding: 0.3rem;
    }

    .dpad-btn {
        padding: 0.4rem;
        font-size: 0.9rem;
    }
}

/* Landscape orientation optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .game-header {
        padding: 0.4rem;
    }

    .game-info {
        font-size: 0.8rem;
    }

    .game-board {
        padding: 0.2rem;
    }

    .maze-container {
        max-height: calc(100vh - 120px);
        padding: 0.2rem;
    }

    .controls {
        padding: 0.3rem;
    }

    .dpad {
        gap: 0.2rem;
        padding: 0.3rem;
    }

    .dpad-btn {
        padding: 0.5rem;
        font-size: 1rem;
    }
}

