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

body {
    margin: 0;
    padding: 14px;
    background: #292929;
    color: #ddd;
    font-family: "Courier New", monospace;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* bg stuff */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
    z-index: 0;
}

#bg-canvas.active {
    opacity: .45;
}

.header {
    width: 100%;
    max-width: 470px;
    position: relative;
    z-index: 2;
    text-align: center;
}

h1 {
    margin: 3px 0 13px;
    color: #d6a928;
    font-size: 2.1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 3px 3px #111;
}

#ui-bar {
    display: flex;
    width: 100%;
    gap: 8px;
}

.stat-box {
    flex: 1;
    min-width: 0;
    background: #1c1c1c;
    border: 2px solid #444;
    padding: 7px 9px;
    box-shadow: 3px 3px #111;
}

.stat-label {
    color: #777;
    font-size: 11px;
    margin-bottom: 3px;
}

.stat-val {
    color: #eee;
    font-size: 18px;
    font-weight: bold;
}

.game-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
    position: relative;
    z-index: 1;
}

#board {
    height: 100%;
    max-height: 61vh;
    max-width: 94vw;
    aspect-ratio: 2 / 3;
    background: #101010;
    border: 4px solid #4b4b4b;
    box-shadow: 7px 7px 0 #111;
    cursor: pointer;
}

.shake {
    animation: boardShake .35s;
}

@keyframes boardShake {
    0% {
        transform: translate(0);
    }

    25% {
        transform: translate(-7px, 3px);
    }

    50% {
        transform: translate(6px, -4px);
    }

    75% {
        transform: translate(-3px, 2px);
    }

    100% {
        transform: translate(0);
    }
}

#tray {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 470px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 7px;
}

.tray-slot {
    width: 31%;
    max-width: 135px;
    aspect-ratio: 1;
    background: #202020;
    border: 2px dashed #555;
    box-shadow: 3px 3px #111;
    cursor: grab;
}

.tray-slot:hover {
    border-color: #777;
}

.tray-slot:active {
    background: #303030;
    cursor: grabbing;
}

#drag-canvas {
    display: none;
    position: absolute;
    pointer-events: none;
    z-index: 50;
    transform: translate(-50%, -50%);
}

#game-over {
    display: none;
    position: absolute;
    z-index: 200;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 260px;
    background: #151515;
    border: 3px solid #b83b3b;
    padding: 27px 25px;
    text-align: center;
    box-shadow: 8px 8px #090909;
}

#game-over.show {
    display: block;
}

#game-over h2 {
    margin: 0 0 8px;
    color: #d34a4a;
    font-size: 1.7rem;
}

#game-over p {
    color: #aaa;
}

#btn-restart {
    margin-top: 14px;
    padding: 9px 19px;
    background: #d6a928;
    border: 2px solid #eee;
    color: #111;
    font-family: inherit;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 3px 3px #000;
}

#btn-restart:hover {
    background: #eee;
}

#intro-overlay {
    position: fixed;
    z-index: 999;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(8, 8, 8, .86);
}

#intro-overlay.hidden {
    display: none;
}

.intro-title {
    color: #d6a928;
    font-size: 4.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 7px;
    text-shadow: 5px 5px #000;
    margin-bottom: 22px;
}

#btn-start {
    padding: 13px 43px;
    color: #ddd;
    background: #202020;
    border: 2px solid #777;
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

#btn-start:hover {
    background: #353535;
    border-color: #aaa;
    color: #fff;
}

@media (max-width: 500px) {
    body {
        padding: 9px;
    }

    h1 {
        font-size: 1.7rem;
        margin-bottom: 9px;
    }

    .stat-box {
        padding: 6px;
    }

    .stat-label {
        font-size: 9px;
    }

    .stat-val {
        font-size: 15px;
    }

    .intro-title {
        font-size: 3rem;
        letter-spacing: 4px;
    }

    #btn-start {
        font-size: 1.3rem;
        padding: 12px 30px;
    }

    #board {
        max-height: 58vh;
    }

    #tray {
        gap: 8px;
    }
}
