@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Teko:wght@400;600;700&family=Outfit:wght@400;700;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    background: #050f05;
    overflow-x: hidden;
    overflow-y: auto;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    min-height: 100vh;
    width: 100vw;
}

#gameCanvas {
    display: block;
    position: fixed;
    top: 60px; /* Safe space for header/score */
    left: 0;
    width: 100vw;
    height: calc(100vh - 160px); /* 60px top + 100px bottom ad space */
    z-index: 5;
    background: #0d5c1d;
    transition: left 0.3s ease, width 0.3s ease;
}

body.pmg-sidebar-open #gameCanvas {
    left: 280px;
    width: calc(100vw - 280px);
}

#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* UI covers full screen to handle modals, but elements are placed relatively */
    z-index: 1000;
    pointer-events: none;
    transition: left 0.3s ease, width 0.3s ease;
}

body.pmg-sidebar-open #ui-layer {
    left: 280px;
    width: calc(100vw - 280px);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(5, 10, 5, 0.9);
    backdrop-filter: blur(12px);
    z-index: 100;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto; /* Standard for HTML */
    padding-bottom: 50px; /* Shift content up slightly to avoid middle-side toggle button */
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
}

.game-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(36px, 10vw, 72px);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 8px;
    margin-bottom: 5px;
    text-align: center;
}

.title-green { 
    color: #00ff44; 
    text-shadow: 0 0 20px rgba(0, 255, 68, 0.5), 0 0 40px rgba(0, 255, 68, 0.2); 
}
.title-white { 
    color: #fff; 
    text-shadow: 0 4px 10px rgba(0,0,0,0.3); 
}

.subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 10px;
    text-transform: uppercase;
    margin-bottom: 40px;
    font-family: 'Orbitron';
}

.pmg-btn {
    background: linear-gradient(135deg, #00ff44, #00aa22);
    color: #000;
    border: none;
    padding: 18px 50px;
    font-size: 1.2rem;
    font-family: 'Orbitron', monospace;
    font-weight: 800;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 25px rgba(0, 255, 68, 0.3);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 10px 0;
    pointer-events: auto;
    z-index: 110;
}

.pmg-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0, 255, 68, 0.4);
}

.pmg-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.pmg-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #00ff44;
    color: #00ff44;
}

#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 60px;
    padding: 0 30px 0 100px; /* Leave space for back button on the left */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #000;
    border-bottom: 2px solid rgba(0, 255, 68, 0.4);
    z-index: 1001;
    pointer-events: all;
    transition: left 0.3s ease, width 0.3s ease;
}

body.pmg-sidebar-open #hud {
    left: 280px;
    width: calc(100vw - 280px);
}

.hud-team {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hud-score {
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    font-weight: 900;
    text-shadow: 0 0 10px currentColor;
}

.hud-name {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    font-weight: 700;
}

.hud-timer {
    font-family: 'Orbitron', monospace;
    font-size: 24px;
    color: #ffcc00;
    background: rgba(255, 204, 0, 0.1);
    padding: 5px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 204, 0, 0.2);
}

.team-color-indicator {
    width: 6px;
    height: 30px;
    border-radius: 3px;
}

#power-bar-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    display: none;
    z-index: 50;
}

#power-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00ff44, #ffcc00, #ff0044);
    box-shadow: 0 0 15px rgba(0, 255, 68, 0.5);
}

.formation-selector {
    display: flex;
    gap: 12px;
    margin: 20px 0;
}

.formation-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 14px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.formation-btn:hover, .formation-btn.active {
    border-color: #00ff44;
    background: rgba(0, 255, 68, 0.1);
    color: #00ff44;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 68, 0.2);
}

.back-btn {
    position: fixed;
    top: 12px; 
    left: 15px;
    z-index: 1002;
    color: white;
    text-decoration: none;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 350px;
    margin: 25px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 15px;
    border-radius: 18px;
    text-align: center;
}

.stat-val {
    font-family: 'Orbitron';
    font-size: 24px;
    font-weight: 900;
    color: #00ff44;
}

.stat-lab {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 5px;
}

#match-events {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    z-index: 100;
}

.event-pop {
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin: 10px 0;
    animation: pmgEventPop 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes pmgEventPop {
    0% { opacity: 0; transform: scale(0.5) translateY(40px); filter: blur(10px); }
    20% { opacity: 1; transform: scale(1.1) translateY(0); filter: blur(0); }
    80% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.9) translateY(-60px); filter: blur(5px); }
}

@media (max-width: 600px) {
    .hud-timer { font-size: 18px; padding: 4px 10px; }
    .hud-score { font-size: 24px; }
    .stats-container { grid-template-columns: 1fr 1fr; }
}
