@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --bg-color: #0a0510;
    --moon-color: #3d234d;
    --btn-bg: rgba(65, 40, 95, 0.85);
    --btn-border: #9b72cf;
    --btn-border-dark: #4a2a75;
    --btn-hover: rgba(90, 60, 130, 0.95);
    --text-color: #ffffff;
    --text-shadow: #2a1540;
    --accent-pink: #e86a92;
    --accent-pink-dark: #b53d65;
    --star-color: #f9e5a3;
}

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

body,
html {
    height: 100%;
    width: 100%;
    background-color: var(--bg-color);
    font-family: 'VT323', monospace;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
}

/* --- Background Art --- */
#environment {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.moon {
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--moon-color) 0%, transparent 70%);
    position: absolute;
    opacity: 0.6;
    /* Pixelated dither effect simulation */
    background-image: radial-gradient(var(--moon-color) 20%, transparent 20%), radial-gradient(var(--moon-color) 20%, transparent 20%);
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
}

.star {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--star-color);
    box-shadow: 0 0 5px var(--star-color);
    animation: twinkle linear infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* --- Video Background --- */
#video-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5;
    opacity: 0;
    transition: opacity 2s ease-in-out;
    pointer-events: none;
}

#video-bg.loaded {
    opacity: 1;
}

/* --- Game State Overlays --- */
#rules-screen,
#share-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 17, 17, 0.95);
    z-index: 20;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    text-shadow: 2px 2px 0 #000;
    padding: 20px;
}

#rules-screen h2,
#share-screen h2 {
    font-size: 48px;
    color: var(--accent-pink);
    margin-bottom: 20px;
    text-shadow: 4px 4px 0 #000;
}

#rules-screen ul {
    list-style-position: inside;
    margin-bottom: 30px;
    max-width: 600px;
    line-height: 1.5;
    text-align: left;
}

#rules-screen li {
    margin-bottom: 15px;
}

/* --- Main Menu UI --- */
#ui-layer {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 20px;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    position: relative;
}

.title {
    font-size: 64px;
    color: var(--text-color);
    text-shadow: 4px 4px 0 var(--text-shadow);
    margin-bottom: 30px;
    letter-spacing: 2px;
}

/* --- Buttons --- */
.btn {
    background: var(--btn-bg);
    border: 4px solid var(--btn-border);
    border-bottom-color: var(--btn-border-dark);
    border-right-color: var(--btn-border-dark);
    color: var(--text-color);
    font-family: 'VT323', monospace;
    font-size: 28px;
    padding: 12px 20px;
    cursor: pointer;
    text-shadow: 2px 2px 0 var(--text-shadow);
    transition: all 0.1s;
    position: relative;
    outline: none;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    image-rendering: pixelated;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn:hover {
    background: var(--btn-hover);
    border-color: #b58ce6;
    border-bottom-color: var(--btn-border);
    border-right-color: var(--btn-border);
    transform: translateY(-2px);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4), 0 6px 8px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(2px);
    border-color: var(--btn-border-dark);
    border-bottom-color: var(--btn-border);
    border-right-color: var(--btn-border);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8);
}

.btn.wide {
    grid-column: span 2;
}

.btn-link {
    background: rgba(80, 50, 120, 0.9);
    border-color: #a37bd6;
}

/* --- Decorations (CSS/SVG based) --- */
.decor {
    position: absolute;
    pointer-events: none;
    z-index: 15;
}

.tree-right {
    top: -30px;
    right: -40px;
    width: 120px;
    height: 120px;
}

.tree-left {
    bottom: 30px;
    left: -50px;
    width: 100px;
    height: 100px;
    transform: scaleX(-1);
}

.cloud-mid {
    top: 20%;
    left: 0;
    width: 80px;
    height: 80px;
    transform: translateY(-50%);
    z-index: 11;
}

.px-pink {
    fill: var(--accent-pink);
}

.px-pink-dark {
    fill: var(--accent-pink-dark);
}

.px-stem {
    fill: #5c3a21;
}

.px-vine {
    fill: var(--accent-pink);
    stroke: var(--accent-pink);
    stroke-width: 2;
}

/* --- Footer --- */
.watermark {
    margin-top: 40px;
    text-align: center;
    font-size: 24px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 2px;
    line-height: 1.2;
}

.footer-watermark {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    z-index: 50;
    font-family: 'VT323', monospace;
    text-shadow: 1px 1px 0 #000;
    transition: color 0.2s;
}

.footer-watermark:hover {
    color: var(--accent-pink);
}

/* --- Toasts --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--btn-border);
    color: white;
    padding: 10px 20px;
    margin-top: 10px;
    font-size: 20px;
    animation: slideUp 0.3s ease-out, fadeOut 0.5s ease-in 2s forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
    .title {
        font-size: 42px;
        margin-bottom: 16px;
    }

    .btn {
        font-size: 20px;
        padding: 10px 10px;
        border-width: 3px;
    }

    .menu-grid {
        gap: 8px;
    }

    #ui-layer {
        padding: 10px;
    }

    .watermark {
        margin-top: 20px;
        font-size: 18px;
    }

    #rules-screen,
    #share-screen {
        font-size: 20px;
    }

    #rules-screen h2,
    #share-screen h2 {
        font-size: 36px;
    }

    .footer-watermark {
        font-size: 13px;
    }

    .toast {
        font-size: 16px;
        padding: 8px 14px;
    }
}

@media (max-width: 360px) {
    .title {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .btn {
        font-size: 17px;
        padding: 8px 6px;
    }

    .menu-grid {
        gap: 6px;
    }

    .watermark {
        font-size: 16px;
    }
}