/* --- Global Styles & Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; 
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #1e1e24; 
    color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* --- Gallery View --- */
#gallery {
    padding: 30px 20px;
    max-width: 900px;
    margin: 0 auto;
}

#gallery h1 {
    text-align: center;
    margin-bottom: 30px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #4da8da;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 25px;
}

.card {
    background: #2b2b36;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:active {
    transform: scale(0.95);
    box-shadow: 0 2px 3px rgba(0,0,0,0.4);
}

.card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
    margin-bottom: 10px;
    image-rendering: pixelated;
}

.card p {
    font-weight: 600;
    font-size: 1rem;
}

.no-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #111;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #4da8da;
    border: 2px dashed #333;
}

/* --- Game Player View --- */
#game-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    padding: 20px;
}

#back-btn {
    align-self: flex-start;
    background: transparent;
    color: #4da8da;
    border: none;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 10px 0;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#back-btn:active {
    opacity: 0.7;
}

.iframe-wrapper {
    width: 100%;
    max-width: 512px; 
    aspect-ratio: 1 / 1;
    background: #000;
    border: 15px solid #111; 
    border-radius: 10px;
    border-bottom-width: 25px; 
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 5px 15px rgba(0,0,0,0.5);
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden; 
}

/* --- On-Screen Controls (D-Pad) --- */
.controls {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.ctrl-row {
    display: flex;
    justify-content: center;
    gap: 75px; /* Increased from 50px to fit the 65px down button */
    position: relative;
    margin-bottom: 75px; /* Added to account for the absolute positioned down button */
}

#down {
    position: absolute;
    top: 70px; /* Pushed down to clear the left and right buttons */
}

.ctrl {
    width: 65px;
    height: 65px;
    background: #333;
    color: #aaa;
    border: 2px solid #111;
    border-radius: 12px; 
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 0 #111, 0 8px 10px rgba(0,0,0,0.5);
    touch-action: none; 
}

.ctrl:active, .ctrl.active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #111, 0 2px 5px rgba(0,0,0,0.5);
    background: #444;
    color: #fff;
}