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

:root {
    --orange: #D5360C;
    --ivory: #E6D5BD;
    --black: #101010;
    --shadow: #501708;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px 120px;
    overflow-x: hidden;
    position: relative;

    background-color: var(--black);
    background-image: radial-gradient(
        var(--orange) 1.5px,
        transparent 1.5px
    );
    background-size: 38px 38px;

    color: var(--ivory);
    font-family: 'Press Start 2P', monospace;
}

/* Pixel-art landscape layers */
body::before {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 160px;

    background:
        linear-gradient(
            135deg,
            transparent 42%,
            var(--shadow) 42% 51%,
            transparent 51%
        ) 0 0 / 120px 110px repeat-x,
        linear-gradient(
            45deg,
            transparent 42%,
            var(--orange) 42% 50%,
            transparent 50%
        ) 30px 35px / 150px 100px repeat-x;

    opacity: 0.85;
}

/* Blocky pixel ground */
body::after {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 38px;

    background: repeating-linear-gradient(
        90deg,
        var(--orange) 0 36px,
        var(--black) 36px 58px,
        var(--ivory) 58px 68px,
        var(--black) 68px 98px
    );

    clip-path: polygon(
        0 30%, 8% 30%, 8% 0, 16% 0,
        16% 45%, 25% 45%, 25% 15%,
        35% 15%, 35% 65%, 47% 65%,
        47% 25%, 58% 25%, 58% 75%,
        72% 75%, 72% 20%, 83% 20%,
        83% 45%, 100% 45%, 100% 100%,
        0 100%
    );
}

/* Main game panel */
.game-card {
    position: relative;
    z-index: 1;
    isolation: isolate;

    width: 100%;
    max-width: 565px;
    padding: 38px 28px;

    text-align: center;
    background: var(--black);
    border: 4px solid var(--orange);
    box-shadow:
        8px 8px 0 var(--shadow),
        0 0 0 4px var(--black);
}

/* Pixel corners */
.game-card::before,
.game-card::after {
    content: "";
    position: absolute;
    width: 17px;
    height: 17px;
    pointer-events: none;

    background: var(--orange);
    border: 4px solid var(--black);
}

.game-card::before {
    top: 5px;
    left: 5px;
    box-shadow:
        8px 0 0 -2px var(--orange),
        0 8px 0 -2px var(--orange);
}

.game-card::after {
    right: 5px;
    bottom: 5px;
    box-shadow:
        -8px 0 0 -2px var(--orange),
        0 -8px 0 -2px var(--orange);
}

/* Small heading */
.eyebrow {
    color: var(--orange);
    font-size: 11px;
    line-height: 1.8;
    letter-spacing: 3px;
    margin: 4px 0 24px;
}

/* Main title */
h1 {
    color: var(--ivory);
    font-size: clamp(17px, 3.6vw, 26px);
    line-height: 1.9;
    margin: 20px 0;
    text-shadow: 4px 4px 0 var(--shadow);
}

/* Intro text */
.subtitle {
    color: var(--ivory);
    font-size: 10px;
    line-height: 2.2;
    opacity: 0.85;
    margin-bottom: 28px;
}

/* Attempts counter */
.attempt-box {
    margin: 28px 0;
    padding: 22px 12px;
    border: 3px solid var(--orange);
    box-shadow: 4px 4px 0 var(--shadow);
    background: var(--black);
}

#attempts {
    display: block;
    margin-top: 16px;
    color: var(--orange);
    font-size: 42px;
    line-height: 1.4;
    text-shadow: 3px 3px 0 var(--shadow);
}

.attempt-box p {
    font-size: 10px;
    line-height: 2;
    margin-bottom: 4px;
}

/* Number input */
input {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 20px 12px;
    margin: 20px 0 0;

    background: var(--black);
    color: var(--ivory);
    border: 3px solid var(--ivory);
    border-radius: 0;
    outline: none;

    font: 11px 'Press Start 2P', monospace;
    text-align: center;
}

input::placeholder {
    color: var(--ivory);
    opacity: 0.55;
}

input:focus {
    border-color: var(--orange);
    box-shadow: 4px 4px 0 var(--shadow);
}

/* Arcade buttons */
button {
    display: block;
    width: 100%;
    padding: 20px 12px;
    margin-top: 20px;

    border: 3px solid var(--orange);
    border-radius: 0;
    background: var(--orange);
    color: var(--ivory);

    font: 10px/1.8 'Press Start 2P', monospace;
    cursor: pointer;

    box-shadow: 4px 4px 0 var(--shadow);
    transition:
        transform 0.1s ease,
        box-shadow 0.1s ease,
        background 0.1s ease,
        color 0.1s ease;
}

button:hover:not(:disabled) {
    background: var(--ivory);
    color: var(--black);
}

button:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--shadow);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback message */
#feedback {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;

    margin: 28px 0 18px;
    padding: 16px 10px;

    border: 2px dashed var(--orange);
    font-size: 10px;
    line-height: 2.2;
    overflow-wrap: anywhere;
}

/* Restart button */
.restart {
    max-width: 300px;
    margin: 24px auto 0;
    background: var(--black);
    color: var(--ivory);
    box-shadow: none;
}

.restart:hover:not(:disabled) {
    background: var(--ivory);
    color: var(--black);
    box-shadow: 4px 4px 0 var(--shadow);
}

/* Keyboard focus */
button:focus-visible,
input:focus-visible {
    outline: 3px dashed var(--ivory);
    outline-offset: 5px;
}

/* Mobile layout */
@media (max-width: 480px) {
    body {
        padding: 20px 14px 85px;
        background-size: 30px 30px;
    }

    body::before {
        height: 100px;
        background-size: 90px 75px, 110px 70px;
    }

    .game-card {
        padding: 28px 17px;
        border-width: 3px;
        box-shadow: 5px 5px 0 var(--shadow);
    }

    .eyebrow {
        font-size: 9px;
    }

    h1 {
        font-size: 17px;
        line-height: 1.8;
    }

    .subtitle {
        font-size: 9px;
    }

    .attempt-box {
        padding: 18px 8px;
    }

    #attempts {
        font-size: 34px;
    }

    .attempt-box p,
    #feedback {
        font-size: 9px;
    }

    input,
    button {
        font-size: 9px;
        padding: 17px 8px;
    }
}
