/* ========================================
   AMG ARCADE - Common Game Styles
   ======================================== */

:root {
    --neon-pink: #ff00ff;
    --neon-cyan: #00ffff;
    --neon-green: #39ff14;
    --neon-yellow: #ffff00;
    --neon-orange: #ff6600;
    --neon-red: #ff0040;
    --neon-blue: #4d4dff;
    
    --bg-dark: #0a0a0f;
    --bg-cabinet: #1a1a2e;
    --bg-screen: #0f0f1a;
    
    --text-primary: #ffffff;
    --text-secondary: #aaaacc;
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'VT323', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    background-image: 
        radial-gradient(ellipse at center, #1a1a3e 0%, var(--bg-dark) 70%);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    max-width: 100%;
    width: 100%;
}

/* Game Header - Fixed layout that handles long titles */
.game-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 500px;
    padding: 0.5rem;
}

.back-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    color: var(--neon-cyan);
    text-decoration: none;
    padding: 0.4rem 0.6rem;
    border: 2px solid var(--neon-cyan);
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.back-btn:hover {
    background: var(--neon-cyan);
    color: var(--bg-dark);
    box-shadow: 0 0 15px var(--neon-cyan);
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.7rem, 3.5vw, 1.2rem);
    text-shadow: 0 0 10px currentColor;
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}

.score-display .label {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.4rem;
    color: var(--text-secondary);
}

.score-display .score {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
}

/* Game Canvas Wrapper */
.game-wrapper {
    position: relative;
    background: var(--bg-screen);
    border: 4px solid #333;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.5),
        inset 0 0 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-width: 100%;
    touch-action: none;
}

.game-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.1) 80%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 10;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
}

/* Game Overlays */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.game-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    text-align: center;
    padding: 1.5rem;
    max-width: 100%;
}

.overlay-content h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1rem, 5vw, 1.8rem);
    color: var(--neon-pink);
    text-shadow: 0 0 20px var(--neon-pink);
    margin-bottom: 1.2rem;
    animation: glow-pulse 1.5s ease-in-out infinite alternate;
    line-height: 1.4;
}

@keyframes glow-pulse {
    from { text-shadow: 0 0 10px currentColor; }
    to { text-shadow: 0 0 30px currentColor, 0 0 50px currentColor; }
}

.overlay-content p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    line-height: 1.5;
}

.overlay-content .high-score {
    color: var(--neon-yellow);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    margin-top: 0.8rem;
}

.start-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    padding: 0.8rem 1.5rem;
    margin-top: 1.2rem;
    background: transparent;
    border: 3px solid var(--neon-green);
    color: var(--neon-green);
    cursor: pointer;
    transition: all 0.3s ease;
    animation: button-pulse 2s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
}

@keyframes button-pulse {
    0%, 100% { box-shadow: 0 0 10px var(--neon-green); }
    50% { box-shadow: 0 0 25px var(--neon-green); }
}

.start-btn:hover,
.start-btn:active {
    background: var(--neon-green);
    color: var(--bg-dark);
    box-shadow: 0 0 30px var(--neon-green);
    transform: scale(1.05);
}

/* Mobile Controls - Always visible on touch devices */
.game-controls {
    display: none;
    margin-top: 0.5rem;
}

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

.control-row {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    width: 65px;
    height: 65px;
    background: linear-gradient(180deg, #444, #222);
    border: 3px solid #555;
    border-radius: 12px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 4px 0 #111,
        0 6px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

.control-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #111;
    background: linear-gradient(180deg, #555, #333);
}

/* Game Footer */
.game-footer {
    width: 100%;
    max-width: 500px;
    padding: 0.5rem;
}

.stats {
    display: flex;
    justify-content: space-around;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    color: var(--text-secondary);
    gap: 0.5rem;
}

.stats span {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    flex: 1;
    text-align: center;
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */

/* Show controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .game-controls {
        display: block;
    }
}

/* Small screens */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .game-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .game-header {
        padding: 0.25rem;
        gap: 0.35rem;
    }
    
    .back-btn {
        font-size: 0.4rem;
        padding: 0.3rem 0.5rem;
    }
    
    .game-title {
        font-size: clamp(0.55rem, 3vw, 0.9rem);
    }
    
    .score-display .label {
        font-size: 0.35rem;
    }
    
    .score-display .score {
        font-size: 0.8rem;
    }
    
    .game-wrapper {
        border-width: 3px;
        border-radius: 6px;
    }
    
    .control-btn {
        width: 58px;
        height: 58px;
        font-size: 1.3rem;
    }
    
    .stats {
        font-size: 0.45rem;
    }
    
    .stats span {
        padding: 0.35rem 0.5rem;
    }
    
    .overlay-content {
        padding: 1rem;
    }
    
    .overlay-content h2 {
        font-size: clamp(0.9rem, 4.5vw, 1.4rem);
        margin-bottom: 1rem;
    }
    
    .overlay-content p {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .start-btn {
        font-size: 0.6rem;
        padding: 0.7rem 1.2rem;
    }
    
    .game-controls {
        display: block;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .game-title {
        font-size: 0.5rem;
    }
    
    .back-btn {
        font-size: 0.35rem;
        padding: 0.25rem 0.4rem;
    }
    
    .control-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }
    
    .control-row {
        gap: 0.35rem;
    }
    
    .mobile-controls {
        gap: 0.35rem;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        justify-content: flex-start;
    }
    
    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .game-header {
        width: 100%;
        max-width: none;
    }
    
    .game-wrapper {
        max-height: 70vh;
    }
    
    .game-wrapper canvas {
        max-height: 60vh;
        width: auto;
    }
    
    .game-controls {
        display: block;
    }
    
    .mobile-controls {
        flex-direction: row;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
    }
    
    .game-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-dark);
        max-width: none;
    }
}

/* Tablet and larger touch devices */
@media (min-width: 481px) and (hover: none) {
    .game-controls {
        display: block;
    }
    
    .control-btn {
        width: 70px;
        height: 70px;
        font-size: 1.6rem;
    }
}
