@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

/* NIGHT SKY BACKGROUND */
body {
    font-family: 'Press Start 2P', monospace;
    color: #d8ffe6;

    padding: 10px;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: radial-gradient(circle at center,
            #0e1629 0%,
            #0a1120 40%,
            #050a14 70%,
            #000000 100%);
    background-attachment: fixed;
}

/*  Stars Container  */
.stars {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Small stars */
.star {
    position: absolute;
    background: white;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    opacity: 0.8;
    animation: twinkle 2s infinite ease-in-out;
}

/* Plus-shaped sparks */
.star.plus {
    width: 8px;
    height: 8px;
    background: white;
    clip-path: polygon(40% 0%, 60% 0%,
            60% 40%, 100% 40%,
            100% 60%, 60% 60%,
            60% 100%, 40% 100%,
            40% 60%, 0% 60%,
            0% 40%, 40% 40%);
    opacity: 0.9;
    animation: twinkle 1.4s infinite ease-in-out;
}

@keyframes twinkle {

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

    50% {
        opacity: 0.3;
        transform: scale(0.5);
    }
}

/* TITLE & TEXT */

.game-title {
    font-size: 25px;
    margin-bottom: 10px;
    color: #33f6ff;
    /* Minecraft diamond color */
    text-shadow: 4px 4px #0a4750, 0 0 15px #33f6ff;
    z-index: 5;
    position: relative;
    text-align: center;
}

.subtitle {
    color: #afffe3;
    margin-bottom: 10px;
    font-size: 15px;
    text-shadow: 2px 2px #005f47;
    position: relative;
    z-index: 5;
    text-align: center;
}

/* Optional typewriter (if JS uses it) */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid #33f6ff;
    width: 0;
    animation: typing 4s steps(40) forwards, blink .7s infinite;
}

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* Home Wrapper - Centers all content */
.home-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    z-index: 5;
    position: relative;
}

/* Dashboard */

.outer-box {
    width: 100%;
    max-width: 460px;
    background: rgba(20, 20, 20, 0.92);
    border: 6px solid #00c244;
    /* Minecraft emerald border */
    padding: 20px;
    box-shadow: 0 0 20px #00c244, inset 0 0 20px #00c244;
    animation: floatBox 3s ease-in-out infinite;
    z-index: 5;
    position: relative;
}

@keyframes floatBox {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.menu-box {
    border: 5px solid #33f6ff;
    padding: 20px;
    background: #111;
    box-shadow: inset 0 0 18px #33f6ff;
}

.menu-table {
    width: 100%;
    border-spacing: 12px;
    font-size: 12px;
}

.menu-table td {
    color: #caffef;
}

/* Buttons */

.menu-btn {
    width: 100%;
    padding: 14px;
    font-size: 14px;
    cursor: pointer;
    background: #00c244;
    color: #002910;
    border: 4px solid #002910;
    box-shadow: 4px 4px #001a0b;
    transition: 0.15s;
    position: relative;
    animation: pulse 1.3s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 6px #00c244;
    }

    50% {
        box-shadow: 0 0 20px #00c244;
    }

    100% {
        box-shadow: 0 0 6px #00c244;
    }
}

.menu-btn:hover {
    transform: translate(-3px, -3px);
    box-shadow: 7px 7px #001a0b, 0 0 25px #00ff66;
}

/* Pixel noise overlay */
.menu-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("https://i.ibb.co/n7WLRpX/pixel-noise.png");
    background-size: cover;
    opacity: 0;
    transition: 0.2s;
}

.menu-btn:hover::after {
    opacity: 0.2;
}

/* Drop-down menus */
.menu-select {
    width: 100%;
    padding: 8px;
    font-size: 12px;
    background: #0e0e0e;
    color: #afffdd;
    border: 4px solid #33f6ff;
    box-shadow: 3px 3px #001a0b;
    cursor: pointer;
}

.menu-select:hover {
    border-color: #ffffff;
}

/* Accessibility: Focus styles */
.menu-btn:focus-visible,
.menu-select:focus-visible,
.volume-slider:focus-visible,
.close-btn:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 15px #33f6ff;
}

/*
   FOOTER
    */
footer {
    margin-top: 30px;
    font-size: 10px;
    opacity: 0.7;
    color: #55ffcc;
    text-shadow: 1px 1px #003f2c;
}

footer:hover {
    opacity: 1;
}

@keyframes walkAcross {
    0% {
        left: -60px;
    }

    100% {
        left: 110%;
    }
}

@keyframes spriteWalk {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -192px 0;
    }
}

/* 
   SCREEN TRANSITION
  */

#screen-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-out;
}

#screen-transition.active {
    opacity: 1;
}

/* RESPONSIVE UI */

@media (max-width: 600px) {
    .outer-box {
        width: 90%;
        padding: 15px;
    }

    .menu-box {
        padding: 12px;
    }

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

/* Knight Pixel Character */
/* Dust container FIXED (only one copy) */
#dust-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
    z-index: 5;
}

/* Dust particle */
/* Dust particle */
.dust {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    border-radius: 0;
    /* Square pixels */
    opacity: 1;
    image-rendering: pixelated;
    pointer-events: none;

    /* Variables for randomization */
    --drift-x: -10px;
    --drift-y: -10px;

    animation: dustFade 0.6s ease-out forwards;
}

/* Dust fade animation */
@keyframes dustFade {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(var(--drift-x), var(--drift-y)) scale(0);
    }
}

/* Knight Wrapper = movement + scaling */
/* Knight container handles movement + direction */
.knight-wrapper {
    position: fixed;
    bottom: 40px;
    left: -80px;
    width: 64px;
    height: 64px;
    z-index: 20;

    transform-origin: bottom left;
    animation: knightWalkAcross 14s linear infinite, knightBob 0.4s infinite alternate ease-in-out;
    --scale: 2.1;
    /* You can change size globally here */
}

@keyframes knightBob {
    from {
        margin-bottom: 0px;
    }

    to {
        margin-bottom: 4px;
    }
}

/* Knight sprite sheet frames */
.knight-sprite {
    width: 64px;
    height: 64px;

    background: url("./assets/sprites/blue_knight.png") no-repeat;
    background-size: 256px 64px;
    /* 4 walking frames */
    image-rendering: pixelated;

    animation: knightWalkFrames 0.8s steps(4) infinite;
}

/* Walking frames */
@keyframes knightWalkFrames {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -256px 0;
    }
}

/* WALK ACROSS + AUTOMATIC FLIP */
@keyframes knightWalkAcross {
    0% {
        left: -80px;
        transform: scale(var(--scale)) scaleX(1);
    }

    47% {
        left: calc(100% - 160px);
        transform: scale(var(--scale)) scaleX(1);
    }

    50% {
        transform: scale(var(--scale)) scaleX(-1);
    }

    97% {
        left: -80px;
        transform: scale(var(--scale)) scaleX(-1);
    }

    100% {
        transform: scale(var(--scale)) scaleX(1);
    }
}

/* Sword swing (2 frames only) */
@keyframes knightSwordSwing {
    from {
        background-position: 0 -64px;
    }

    to {
        background-position: -128px -64px;
    }

    /* 2 sword frames */
}

/* For better readability of the written content */
.storyline {
    max-width: 700px;
    margin: 0 auto 30px auto;
    font-size: 13px;
    line-height: 1.4;
    letter-spacing: 0.4px;
    text-shadow: 1px 1px #003f2c;
}

.how-to-play-box ul li {
    margin-bottom: 10px;
    line-height: 1;
}

.how-to-play-box h2 {
    margin-bottom: 10px;
}

.game-title {
    margin-bottom: 18px;
}

.subtitle {
    margin-bottom: 20px;
}

.shooting-star {
    position: absolute;
    width: 3px;
    height: 80px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
    border-radius: 2px;
    transform-origin: left top;
    transform: rotate(-35deg);
    opacity: 0.95;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.7));
    z-index: 2;
    animation: shooting 1.2s linear forwards;
}

@keyframes shooting {
    from {
        transform: translate(0, 0) rotate(-35deg) scaleY(1);
        opacity: 1;
    }

    to {
        transform: translate(240px, 150px) rotate(-35deg) scaleY(0.2);
        opacity: 0;
    }
}

/* Multiline Typewriter Cursor */
.type-cursor {
    display: inline-block;
    color: #33f6ff;
    font-weight: bold;
    font-size: 16px;
    margin-left: 5px;
    animation: cursorBlink 0.7s infinite;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.hidden {
    display: none !important;
}

#story-text {
    white-space: pre-line;
}

.type-cursor {
    position: relative;
    top: -2px;
}

/* ===== ABOUT POPUP STYLING ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.popup-overlay.hidden {
    display: none !important;
}

.popup-box {
    background: rgba(14, 22, 41, 0.95);
    border: 3px solid #00eaff;
    border-radius: 12px;
    padding: 30px;
    max-width: 900px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 0 25px rgba(0, 234, 255, 0.4),
        inset 0 0 15px rgba(0, 234, 255, 0.1);
    position: relative;
}

.popup-box h2 {
    color: #00eaff;
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
    text-shadow: 0 0 10px rgba(0, 234, 255, 0.6);
}

.popup-box h3 {
    color: #00ff88;
    margin-top: 16px;
    margin-bottom: 10px;
    font-size: 12px;
}

.about-content {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #d8ffe6;
    line-height: 1.6;
}

.about-content p {
    margin-bottom: 12px;
    text-align: justify;
}

.about-content p strong {
    color: #00eaff;
}

.about-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.about-content li {
    margin-bottom: 6px;
    color: #d8ffe6;
}

.about-content li strong {
    color: #00ff88;
}

/* Close button (X) */
.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: 2px solid #ff4747;
    color: #ff4747;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 71, 71, 0.2);
    box-shadow: 0 0 10px rgba(255, 71, 71, 0.5);
    transform: scale(1.1);
}

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

/* ===== VOLUME CONTENT STYLING ===== */
.volume-content {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #d8ffe6;
}

.volume-control {
    margin-bottom: 25px;
}

.volume-control label {
    display: block;
    margin-bottom: 8px;
    color: #00eaff;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
}

.volume-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.volume-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right,
            #00eaff 0%,
            #00ff88 50%,
            #00eaff 100%);
    border: 2px solid rgba(0, 234, 255, 0.4);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ff88;
    border: 2px solid #00eaff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    width: 20px;
    height: 20px;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ff88;
    border: 2px solid #00eaff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    width: 20px;
    height: 20px;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
}

.volume-percentage {
    min-width: 45px;
    text-align: right;
    color: #00ff88;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.volume-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.volume-btn {
    background: rgba(0, 234, 255, 0.15);
    border: 2px solid #00eaff;
    color: #00eaff;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 234, 255, 0.3);
}

.volume-btn:hover:not(.hidden) {
    background: rgba(0, 234, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.6);
    transform: translateY(-2px);
}

.volume-btn:active:not(.hidden) {
    transform: translateY(0);
}

.volume-btn.hidden {
    display: none;
}

.volume-note {
    margin-top: 15px;
    text-align: center;
    color: #afffe3;
    font-size: 11px;
    font-style: italic;
}

/* Controls Content Styling */
.controls-content {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #d8ffe6;
    line-height: 1.8;
}

.controls-content p {
    margin-bottom: 12px;
    color: #00eaff;
    font-weight: bold;
}

.controls-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.controls-table tr {
    border-bottom: 1px solid rgba(0, 234, 255, 0.3);
}

.controls-table td {
    padding: 10px 8px;
    text-align: left;
}

.controls-table td:first-child {
    width: 40%;
    text-align: center;
}

.controls-table kbd {
    background: rgba(0, 234, 255, 0.2);
    border: 2px solid #00eaff;
    border-radius: 4px;
    padding: 4px 8px;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0, 234, 255, 0.2);
}

.controls-table td:last-child {
    color: #d8ffe6;
}

/* ========== PROFILE AVATAR BUTTON (TOP RIGHT) ========== */

.profile-avatar-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 234, 255, 0.2);
    border: 3px solid #00eaff;
    font-size: 32px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.5);
}

.profile-avatar-btn:hover {
    background: rgba(0, 234, 255, 0.4);
    box-shadow: 0 0 25px rgba(0, 234, 255, 0.8);
    transform: scale(1.1);
}

.profile-avatar-btn:active {
    transform: scale(0.95);
}

#avatarDisplay {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* ========== USER PROFILE POPUP ========== */

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-section label {
    color: #00eaff;
    font-weight: bold;
    font-size: 12px;
}

.profile-input {
    padding: 10px;
    background: rgba(0, 234, 255, 0.1);
    border: 2px solid #00eaff;
    color: #00ff88;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    border-radius: 4px;
    text-align: center;
}

.profile-input::placeholder {
    color: rgba(0, 255, 136, 0.5);
}

.profile-input:focus {
    outline: none;
    background: rgba(0, 234, 255, 0.2);
    box-shadow: 0 0 10px #00eaff;
}

.error-msg {
    color: #ff6b6b;
    font-size: 10px;
    text-align: center;
}

.error-msg.hidden {
    display: none;
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.avatar-btn {
    background: rgba(0, 234, 255, 0.1);
    border: 2px solid rgba(0, 234, 255, 0.4);
    font-size: 28px;
    padding: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s ease;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-btn:hover {
    background: rgba(0, 234, 255, 0.3);
    border-color: #00eaff;
    box-shadow: 0 0 10px rgba(0, 234, 255, 0.5);
    transform: scale(1.05);
}

.avatar-btn.selected {
    background: #00eaff;
    border-color: #00ff88;
    box-shadow: 0 0 15px #00eaff;
    transform: scale(1.1);
}

/* Profile Stats Display */
.stats-display {
    background: rgba(0, 234, 255, 0.1);
    border: 1px solid rgba(0, 234, 255, 0.3);
    border-radius: 4px;
    padding: 12px;
    font-size: 11px;
}

.stats-display p {
    margin: 6px 0;
    color: #d8ffe6;
}

.stats-display strong {
    color: #00ff88;
}

/* Profile Buttons */
.profile-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.profile-buttons button {
    flex: 1;
    padding: 10px;
    border: 2px solid;
    border-radius: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s ease;
}

.confirm-btn {
    background: #00ff88;
    color: #000;
    border-color: #00ff88;
}

.confirm-btn:hover {
    background: #00dd66;
    box-shadow: 0 0 10px #00ff88;
}

.cancel-btn {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6b6b;
    border-color: #ff6b6b;
}

.cancel-btn:hover {
    background: rgba(255, 100, 100, 0.4);
    box-shadow: 0 0 10px rgba(255, 100, 100, 0.5);
}

/* ===== ACHIEVEMENTS GRID STYLING ===== */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.achievement-badge {
    background: linear-gradient(135deg, rgba(0, 255, 200, 0.15) 0%, rgba(0, 200, 150, 0.15) 100%);
    border: 2px solid #00ffcc;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    color: #00ffcc;
    font-weight: bold;
    letter-spacing: 0.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
    position: relative;
    overflow: hidden;
}

.achievement-badge::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 255, 204, 0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

.achievement-badge:hover {
    background: linear-gradient(135deg, rgba(0, 255, 200, 0.25) 0%, rgba(0, 200, 150, 0.25) 100%);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.4);
    transform: translateY(-2px);
}

.achievement-badge.locked {
    background: rgba(100, 100, 100, 0.15);
    border-color: #666;
    color: #999;
    opacity: 0.6;
}

.achievement-badge.locked:hover {
    background: rgba(100, 100, 100, 0.2);
    transform: none;
}

.achievement-emoji {
    font-size: 24px;
    margin-bottom: 4px;
    display: block;
}

.achievement-name {
    font-size: 11px;
    display: block;
    position: relative;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        transform: translate(-50%, -50%);
    }
    100% {
        transform: translate(50%, 50%);
    }
}