/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --retro-yellow: #ffff00;
    --retro-cyan: #00ffff;
    --retro-pink: #ff00ff;
    --retro-green: #00ff00;
    --retro-orange: #ff8800;
    --retro-red: #ff0000;
    --retro-blue: #0000ff;
    --space-black: #000000;
    --cabinet-wood: #8b4513;
    --cabinet-dark: #2a1810;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: var(--space-black);
    color: var(--retro-cyan);
    overflow: hidden;
    line-height: 1.8;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Animated Space Background */
.space-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.stars, .stars2, .stars3 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.stars {
    background-image:
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 60px 70px, white, transparent),
        radial-gradient(1px 1px at 50px 50px, white, transparent),
        radial-gradient(1px 1px at 130px 80px, white, transparent),
        radial-gradient(2px 2px at 90px 10px, white, transparent);
    background-size: 200px 200px;
    background-repeat: repeat;
    animation: stars-float-1 60s linear infinite;
}

.stars2 {
    background-image:
        radial-gradient(1px 1px at 40px 60px, var(--retro-cyan), transparent),
        radial-gradient(1px 1px at 100px 100px, var(--retro-cyan), transparent),
        radial-gradient(1px 1px at 150px 30px, var(--retro-pink), transparent);
    background-size: 250px 250px;
    background-repeat: repeat;
    animation: stars-float-2 90s linear infinite;
}

.stars3 {
    background-image:
        radial-gradient(1px 1px at 75px 125px, var(--retro-yellow), transparent),
        radial-gradient(1px 1px at 180px 80px, white, transparent);
    background-size: 300px 300px;
    background-repeat: repeat;
    animation: stars-float-3 120s linear infinite;
}

@keyframes stars-float-1 {
    from { transform: translateY(0); }
    to { transform: translateY(-200px); }
}

@keyframes stars-float-2 {
    from { transform: translateY(0); }
    to { transform: translateY(-250px); }
}

@keyframes stars-float-3 {
    from { transform: translateY(0); }
    to { transform: translateY(-300px); }
}

/* Retro Game Sprites */
.sprite {
    position: fixed;
    width: 40px;
    height: 40px;
    z-index: 0;
    animation-duration: 20s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.pacman {
    background: radial-gradient(circle at 100%, transparent 50%, var(--retro-yellow) 50%);
    border-radius: 50%;
    top: 20%;
    left: -50px;
    animation-name: float-right;
}

.ghost {
    background: var(--retro-pink);
    border-radius: 50% 50% 0 0;
    position: relative;
}

.ghost::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 100%;
    height: 10px;
    background:
        linear-gradient(45deg, transparent 33%, var(--retro-pink) 33%, var(--retro-pink) 66%, transparent 66%);
}

.ghost1 {
    background: var(--retro-pink);
    top: 40%;
    left: -50px;
    animation-name: float-right;
    animation-delay: 2s;
}

.ghost2 {
    background: var(--retro-cyan);
    top: 60%;
    right: -50px;
    animation-name: float-left;
    animation-delay: 4s;
}

.invader {
    background-image:
        linear-gradient(transparent 20%, var(--retro-green) 20%, var(--retro-green) 30%, transparent 30%),
        linear-gradient(90deg, transparent 30%, var(--retro-green) 30%, var(--retro-green) 70%, transparent 70%),
        linear-gradient(transparent 40%, var(--retro-green) 40%, var(--retro-green) 60%, transparent 60%);
    top: 30%;
    animation-name: float-down;
}

.invader1 {
    right: 10%;
    animation-delay: 1s;
}

.invader2 {
    left: 15%;
    animation-delay: 6s;
}

.galaga {
    background:
        radial-gradient(circle at 50% 30%, var(--retro-yellow) 30%, transparent 30%),
        linear-gradient(var(--retro-orange) 50%, transparent 50%);
    top: 10%;
    right: -50px;
    animation-name: float-diagonal;
    animation-delay: 3s;
}

.ship {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 40px solid var(--retro-cyan);
    top: 70%;
    left: -50px;
    animation-name: float-right;
    animation-delay: 5s;
}

@keyframes float-right {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 100px)); }
}

@keyframes float-left {
    from { transform: translateX(0); }
    to { transform: translateX(calc(-100vw - 100px)); }
}

@keyframes float-down {
    0% { transform: translateY(0) translateX(0); }
    50% { transform: translateY(50vh) translateX(50px); }
    100% { transform: translateY(100vh) translateX(0); }
}

@keyframes float-diagonal {
    from {
        transform: translate(0, 0);
    }
    to {
        transform: translate(calc(-100vw - 100px), 80vh);
    }
}

/* Arcade Cabinet */
.arcade-cabinet {
    position: relative;
    width: 600px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Cabinet Top */
.cabinet-top {
    width: 500px;
    height: 80px;
    background: linear-gradient(145deg, #aa5522, var(--cabinet-wood));
    border: 4px solid var(--cabinet-dark);
    border-bottom: none;
    border-radius: 100px 100px 0 0;
    box-shadow:
        0 -10px 30px rgba(0, 0, 0, 0.8),
        inset 0 -20px 30px rgba(0, 0, 0, 0.3);
}

/* Cabinet Screen Section */
.cabinet-screen {
    width: 600px;
    background: linear-gradient(145deg, #aa5522, var(--cabinet-wood));
    border: 4px solid var(--cabinet-dark);
    padding: 40px;
    box-shadow:
        0 0 40px rgba(0, 0, 0, 0.9),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.screen-bezel {
    background: #1a1a1a;
    border: 8px solid #0a0a0a;
    border-radius: 20px;
    padding: 20px;
    box-shadow:
        0 0 30px var(--retro-cyan),
        inset 0 0 40px rgba(0, 255, 255, 0.2);
}

.screen-display {
    background: #000;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--retro-yellow);
    box-shadow:
        0 0 20px var(--retro-yellow),
        inset 0 0 30px rgba(255, 255, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* CRT Scanlines */
.screen-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 255, 255, 0.03) 0px,
            rgba(0, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 3px
        );
    pointer-events: none;
    z-index: 1;
}

.screen-text {
    position: relative;
    z-index: 2;
    text-align: center;
}

.title-main {
    font-size: 24px;
    color: var(--retro-yellow);
    text-shadow:
        0 0 20px var(--retro-yellow),
        0 0 40px var(--retro-yellow),
        2px 2px 0 var(--retro-orange);
    margin-bottom: 40px;
    letter-spacing: 3px;
    animation: text-glow 2s ease-in-out infinite;
}

.coin-text {
    font-size: 14px;
    color: var(--retro-cyan);
    letter-spacing: 3px;
    text-shadow:
        0 0 10px var(--retro-cyan),
        0 0 20px var(--retro-cyan);
}

@keyframes text-glow {
    0%, 100% {
        text-shadow:
            0 0 20px var(--retro-yellow),
            0 0 40px var(--retro-yellow),
            2px 2px 0 var(--retro-orange);
    }
    50% {
        text-shadow:
            0 0 30px var(--retro-yellow),
            0 0 60px var(--retro-yellow),
            0 0 80px var(--retro-orange),
            2px 2px 0 var(--retro-orange);
    }
}

/* Blinking Animation */
.blink {
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Blow Up Animation */
.blow-up {
    animation: blow-up 0.5s ease-out forwards;
}

@keyframes blow-up {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Game List Styling */
.game-list-container {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
    animation: fade-in 0.5s ease-in;
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.game-list-title {
    font-size: 18px;
    color: var(--retro-yellow);
    text-shadow:
        0 0 20px var(--retro-yellow),
        0 0 40px var(--retro-yellow);
    margin-bottom: 20px;
    letter-spacing: 3px;
}

.game-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.game-item {
    font-size: 14px;
    color: var(--retro-cyan);
    letter-spacing: 2px;
    text-shadow:
        0 0 10px var(--retro-cyan),
        0 0 20px var(--retro-cyan);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 5px 10px;
}

.game-item:hover {
    color: var(--retro-yellow);
    text-shadow:
        0 0 15px var(--retro-yellow),
        0 0 30px var(--retro-yellow);
    transform: scale(1.1);
}

.game-separator {
    font-size: 10px;
    color: var(--retro-pink);
    opacity: 0.5;
    letter-spacing: 2px;
}

.player-two-text {
    animation: fade-in 0.8s ease-in;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 0 20px;
    gap: 20px;
}

.page-nav-btn {
    font-size: 12px;
    color: var(--retro-yellow);
    text-shadow: 0 0 10px var(--retro-yellow);
    cursor: pointer;
    padding: 8px 12px;
    border: 2px solid var(--retro-yellow);
    border-radius: 5px;
    transition: all 0.2s ease;
    user-select: none;
    background: rgba(255, 255, 0, 0.1);
}

.page-nav-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 0, 0.2);
    box-shadow: 0 0 15px var(--retro-yellow);
}

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

.page-nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.page-indicator {
    font-size: 11px;
    color: var(--retro-cyan);
    text-shadow: 0 0 5px var(--retro-cyan);
    letter-spacing: 2px;
}

.control-hint {
    font-size: 8px;
    color: var(--retro-green);
    text-shadow: 0 0 5px var(--retro-green);
    letter-spacing: 1px;
    text-align: center;
    margin-top: 10px;
    opacity: 0.8;
    animation: blink 2s step-start infinite;
}

.game-page {
    display: none;
}

.game-page.active {
    display: flex;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.3s ease-in;
}

.modal-container {
    background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
    border: 4px solid var(--retro-cyan);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow:
        0 0 30px var(--retro-cyan),
        0 0 60px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    animation: modal-pop 0.3s ease-out;
}

@keyframes modal-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border-bottom: 3px solid var(--retro-cyan);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 11px 11px 0 0;
}

.modal-title {
    font-size: 18px;
    color: var(--retro-yellow);
    text-shadow:
        0 0 10px var(--retro-yellow),
        0 0 20px var(--retro-yellow);
    letter-spacing: 3px;
}

.modal-close {
    font-size: 20px;
    color: var(--retro-red);
    cursor: pointer;
    text-shadow:
        0 0 10px var(--retro-red),
        0 0 20px var(--retro-red);
    transition: all 0.2s ease;
    padding: 5px 10px;
}

.modal-close:hover {
    transform: scale(1.2);
    text-shadow:
        0 0 15px var(--retro-red),
        0 0 30px var(--retro-red),
        0 0 45px var(--retro-red);
}

.modal-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.server-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

.info-label {
    font-size: 12px;
    color: var(--retro-pink);
    text-shadow: 0 0 5px var(--retro-pink);
    letter-spacing: 2px;
}

.info-value {
    font-size: 14px;
    color: var(--retro-cyan);
    text-shadow:
        0 0 10px var(--retro-cyan),
        0 0 20px var(--retro-cyan);
    letter-spacing: 1px;
}

.modpack-link {
    color: var(--retro-green);
    text-shadow:
        0 0 10px var(--retro-green),
        0 0 20px var(--retro-green);
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modpack-link:hover {
    color: var(--retro-yellow);
    text-shadow:
        0 0 15px var(--retro-yellow),
        0 0 30px var(--retro-yellow);
    transform: scale(1.05);
}

.server-message {
    margin-top: 10px;
    padding: 15px;
    background: rgba(255, 255, 0, 0.1);
    border: 2px solid var(--retro-yellow);
    border-radius: 8px;
    color: var(--retro-yellow);
    font-size: 11px;
    text-align: center;
    line-height: 1.6;
    text-shadow: 0 0 5px var(--retro-yellow);
    box-shadow:
        0 0 10px rgba(255, 255, 0, 0.2),
        inset 0 0 10px rgba(255, 255, 0, 0.1);
}

.modal-footer {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border-top: 3px solid var(--retro-cyan);
    padding: 15px;
    text-align: center;
    border-radius: 0 0 11px 11px;
}

.press-key-text {
    font-size: 10px;
    color: var(--retro-green);
    text-shadow: 0 0 5px var(--retro-green);
    letter-spacing: 2px;
    animation: blink 1.5s step-start infinite;
}

/* Cabinet Control Panel */
.cabinet-panel {
    width: 600px;
    height: 200px;
    background: linear-gradient(145deg, #666, #333);
    border: 4px solid var(--cabinet-dark);
    border-top: none;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 30px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.9),
        inset 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: perspective(500px) rotateX(-10deg);
}

.joystick-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
}

/* Base - stays fixed */
.joystick-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 15px;
    background: #222;
    border-radius: 50%;
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.8);
}

.joystick {
    width: 20px;
    height: 60px;
    background: linear-gradient(145deg, #444, #222);
    position: relative;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.7);
    transform-origin: bottom center;
    transition: transform 0.1s ease;
}

/* Ball top */
.joystick::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #ff6666, #ff0000, #cc0000);
    border-radius: 50%;
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.7),
        inset -5px -5px 10px rgba(0, 0, 0, 0.4),
        inset 5px 5px 10px rgba(255, 100, 100, 0.5);
}

.joystick.wiggle {
    animation: joystick-wiggle 0.3s ease-in-out;
}

@keyframes joystick-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.buttons {
    display: flex;
    gap: 20px;
}

.button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 5px solid #1a1a1a;
    box-shadow:
        0 8px 15px rgba(0, 0, 0, 0.7),
        inset 0 -8px 10px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.3);
    position: relative;
    cursor: pointer;
    transition: all 0.1s ease;
}

.button:active {
    transform: translateY(4px);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.7),
        inset 0 -4px 6px rgba(0, 0, 0, 0.4);
}

.btn-red {
    background: radial-gradient(circle at 30% 30%, #ff6666, var(--retro-red));
}

.btn-blue {
    background: radial-gradient(circle at 30% 30%, #6666ff, var(--retro-blue));
}

.btn-yellow {
    background: radial-gradient(circle at 30% 30%, #ffff66, var(--retro-yellow));
}

/* Cabinet Base */
.cabinet-base {
    width: 550px;
    height: 100px;
    background: linear-gradient(145deg, #aa5522, var(--cabinet-wood));
    border: 4px solid var(--cabinet-dark);
    border-top: none;
    box-shadow:
        0 30px 50px rgba(0, 0, 0, 0.9),
        inset 0 20px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Coin Door */
.coin-door {
    position: relative;
    width: 120px;
    height: 60px;
    background: linear-gradient(145deg, #555, #222);
    border: 3px solid #111;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.8),
        inset 0 2px 5px rgba(255, 255, 255, 0.1),
        inset 0 -2px 5px rgba(0, 0, 0, 0.5);
}

.coin-slot {
    width: 70px;
    height: 8px;
    background: #000;
    border: 2px solid #333;
    border-radius: 4px;
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.9),
        0 1px 2px rgba(255, 255, 255, 0.1);
    margin-bottom: 5px;
}

.coin-slot.active {
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.9),
        0 0 10px var(--retro-yellow),
        0 0 20px var(--retro-yellow);
    animation: slot-glow 0.5s ease-out;
}

@keyframes slot-glow {
    0% { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9), 0 0 30px var(--retro-yellow); }
    100% { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9), 0 0 5px var(--retro-yellow); }
}

.coin-label {
    font-size: 12px;
    color: var(--retro-yellow);
    text-shadow: 0 0 5px var(--retro-yellow);
    font-weight: bold;
}

/* Draggable Coin */
.coin {
    position: fixed;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 35% 35%, #ffd700, #ffaa00, #cc8800);
    border: 3px solid #cc8800;
    border-radius: 50%;
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.5),
        inset -3px -3px 8px rgba(0, 0, 0, 0.3),
        inset 3px 3px 8px rgba(255, 255, 150, 0.5);
    cursor: grab;
    z-index: 100;
    bottom: 50px;
    right: 100px;
    transition: transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.coin:hover {
    transform: scale(1.1);
}

.coin.dragging {
    cursor: grabbing;
    transform: scale(1.15) rotate(5deg);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.7),
        inset -3px -3px 8px rgba(0, 0, 0, 0.3),
        inset 3px 3px 8px rgba(255, 255, 150, 0.5),
        0 0 20px var(--retro-yellow);
}

.coin.inserted {
    animation: coin-insert 0.5s ease-out forwards;
}

@keyframes coin-insert {
    0% {
        transform: scale(1.15);
        opacity: 1;
    }
    50% {
        transform: scale(0.8);
    }
    100% {
        transform: scale(0.1);
        opacity: 0;
    }
}

.coin-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 14px;
    font-weight: bold;
    color: #8b4513;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .arcade-cabinet {
        width: 90vw;
        max-width: 500px;
    }

    .cabinet-top {
        width: 80%;
        height: 60px;
    }

    .cabinet-screen {
        width: 100%;
        padding: 20px;
    }

    .cabinet-panel {
        width: 100%;
        height: 150px;
        padding: 20px;
    }

    .cabinet-base {
        width: 90%;
    }

    .title-main {
        font-size: 20px;
    }

    .coin-text {
        font-size: 10px;
    }

    .joystick {
        width: 15px;
        height: 45px;
    }

    .joystick::before {
        width: 35px;
        height: 35px;
        top: -22px;
    }

    .joystick-container::after {
        width: 50px;
        height: 12px;
    }

    .button {
        width: 50px;
        height: 50px;
    }

    .sprite {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .title-main {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .coin-text {
        font-size: 8px;
        letter-spacing: 1px;
    }

    .cabinet-panel {
        height: 120px;
    }

    .joystick {
        width: 12px;
        height: 35px;
    }

    .joystick::before {
        width: 28px;
        height: 28px;
        top: -18px;
    }

    .joystick-container::after {
        width: 40px;
        height: 10px;
    }

    .button {
        width: 40px;
        height: 40px;
    }

    .buttons {
        gap: 10px;
    }

    .sprite {
        display: none;
    }
}
