:root {
    --bg-color-start: #1f0033; /* Deep, dark purple */
    --bg-color-mid: #3a0ca3;   /* Magical purple */
    --bg-color-end: #000000;     /* Black */
    --bg-color-extra: #4b0082;  /* Indigo */
    --panel-bg-color: rgba(0, 0, 0, 0.2);
    --panel-border-color: rgba(220, 220, 220, 0.3);
    --glow-color-1: #dcdcdc; /* Silver */
    --glow-color-2: #4b0082; /* Indigo */
    --text-color: #ffffff;
    --text-shadow-color: rgba(220, 220, 220, 1); /* Silver */
    --button-bg-gradient: linear-gradient(145deg, rgba(75, 0, 130, 0.3), rgba(0, 0, 0, 0.4));
    --button-border-color: rgba(220, 220, 220, 0.4);
    --button-hover-bg: rgba(220, 220, 220, 0.2);

    --font-title: 'VT323', monospace;
    --font-ui: 'VT323', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    color: var(--text-color);
    background: #000;
}

body {
    background: linear-gradient(-45deg, var(--bg-color-end), var(--bg-color-mid), var(--bg-color-start), var(--bg-color-extra));
    background-size: 400% 400%;
    animation: gradient-animation 25s ease infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0,0,0,0.3) 50%, transparent 50%);
    background-size: 100% 3px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.4;
}

@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.background-effects::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="https://www.w3.org/2000/svg" width="100" height="100"><path d="M50 0 L53 47 L100 50 L53 53 L50 100 L47 53 L0 50 L47 47 Z" fill="rgba(220,220,220,0.3)"/></svg>');
    background-size: 70px 70px;
    opacity: 0;
    animation: sparkles 20s linear infinite;
}

@keyframes sparkles {
    0% { transform: rotate(0deg) translateY(-200px); opacity: 0; }
    50% { opacity: 0.3; }
    100% { transform: rotate(360deg) translateY(200px); opacity: 0; }
}

.stars {
    background-image: url('data:image/svg+xml,<svg viewBox="0 0 12 12" xmlns="https://www.w3.org/2000/svg"><path d="M2 2 H4 V4 H2 V2 M6 0 H8 V2 H6 V0 M0 6 H2 V8 H0 V6 M10 6 H12 V8 H10 V6 M2 10 H4 V12 H2 V10 M6 10 H8 V12 H6 V10" fill="white"/></svg>');
    background-size: 120px;
    animation: stars-animation 60s linear infinite;
    opacity: 0.5;
}

@keyframes stars-animation {
    from { background-position: 0 0; }
    to { background-position: 1000px 1000px; }
}

.gradient-glow {
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, var(--bg-color-mid), transparent 60%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    filter: blur(120px);
    animation: glow-pulse 15s ease-in-out infinite alternate;
}

.gradient-glow.two {
    background: radial-gradient(circle, var(--glow-color-2), transparent 70%);
    animation: glow-pulse-two 18s ease-in-out infinite alternate-reverse;
}

@keyframes glow-pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.25; }
}

@keyframes glow-pulse-two {
    0% { transform: translate(-20%, -60%) scale(1); opacity: 0.2; }
    100% { transform: translate(-80%, -40%) scale(1.3); opacity: 0.3; }
}

.main-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    animation: float-in 1.5s ease-out;
    font-family: var(--font-ui);
}

@keyframes float-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title {
    font-family: var(--font-title);
    font-size: 3rem;
    color: var(--text-shadow-color);
    text-shadow: 0 0 15px var(--glow-color-1), 2px 2px 0px var(--glow-color-2);
    margin-bottom: 1rem;
    letter-spacing: 4px;
}

.game-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.game-frame {
    background: var(--panel-bg-color);
    border: 1px solid var(--panel-border-color);
    border-radius: 4px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: 0 0 20px 0px var(--glow-color-1), inset 0 0 20px rgba(0,0,0,0.5);
    padding: 0.5rem;
    width: 80vw;
    max-width: 960px;
    aspect-ratio: 16/9;
}

#game-iframe {
    width: 100%;
    height: 100%;
    border-radius: 0;
    image-rendering: pixelated;
}

.controls-container {
    width: 100%;
    max-width: 800px;
    margin-top: 1.5rem;
}

.controls-panel {
    background: var(--panel-bg-color);
    border: 1px solid var(--panel-border-color);
    border-radius: 4px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: 0 0 15px -5px var(--glow-color-1);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
}

.control-group {
    text-align: center;
    margin: 0.5rem 1rem;
}

.control-label {
    font-size: 1.5rem;
    opacity: 0.7;
    text-shadow: 1px 1px 0px var(--glow-color-2);
}

.control-keys {
    font-size: 1.8rem;
    color: var(--text-shadow-color);
    text-shadow: 1px 1px 0px var(--glow-color-2);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 1rem;
}

.ui-button {
    background: var(--button-bg-gradient);
    border: 1px solid var(--button-border-color);
    color: var(--text-shadow-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, color 0.2s;
    text-shadow: 1px 1px 0 var(--glow-color-2);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.ui-button:hover {
    background: var(--button-hover-bg);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 0 10px var(--glow-color-1);
}

.ui-button:active {
    transform: translateY(0);
    background: rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }
    .game-title {
        font-size: 2rem;
    }
    .game-frame {
        width: 95vw;
        height: auto;
        aspect-ratio: 16/9;
    }
    .controls-panel {
        flex-direction: column;
        padding: 1rem;
    }
}
