body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* prevent scrollbars from appearing when canvas is larger than viewport */
    background-image: url(../Assets/tilemaps/bg/idle.png);
    background-size: 11.11dvh 11.11dvh;
    image-rendering: pixelated;
}

/* Mobile hardening: disable long-press selection and double-tap zoom across page */
html,
body,
a,
button,
canvas {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    z-index: -1;
    /* keep pointer events so canvas still receives input where it is visible */
    pointer-events: auto;
    image-rendering: pixelated;
    user-select: none; /* prevent text selection on drag */
    display: block;
}
h1 {
    position: fixed;
    top: 0%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 8dvh;
    z-index: 2;

    background:linear-gradient(to bottom, #38e1de, #4f71fb);
    background-clip: text; 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
}
table {
    position: fixed;
    top: 58%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-collapse: collapse;
    z-index: 2;
}

/* Back button styled like other UI */
#backBtn {
    position: fixed;
    top: 5%;
    left: 5%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 3.2dvh;
    color: #FFFFFF;
    padding: 0.8dvh 1.4dvh;
    border: 0.5dvh solid #888888FF;
    border-radius: 0.5dvh;
    background-color: #444444FF;
    z-index: 3;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}
#darken {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: radial-gradient(circle at 50% 50%,#11001177, #110011CC); /* semi-transparent black */
    z-index: 1;
}
#backBtn:hover { 
    background-color: #999999FF; 
    transform: scale(1.03) rotate(-0.5deg); 
}
#backBtn:active { 
    background-color: #225522FF; 
    transform: scale(0.98) 
    rotate(0.5deg); 
    cursor: grabbing; 
}

/* Level buttons: large, consistent with title UI */
#levels td {
    padding: 0.8dvh;
}
#levels button {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 3.4dvh;
    width: 15dvh;
    height: 8dvh;
    text-align: center;
    color: #FFFFFF;
    padding: 0.4dvh 1.2dvh;
    border: 0.5dvh solid #888888FF;
    border-radius: 0.6dvh;
    background-color: #444444FF;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.12s;
    box-sizing: border-box;
    white-space: nowrap;
    line-height: 1;
}
#levels button:hover { background-color: #999999FF; transform: scale(1.05) rotate(1deg); }
#levels button:active { background-color: #222255FF; transform: scale(0.96) rotate(-1deg); }

/* Completed level visual style */
#levels button.completed {
    background-color: #2e8b57; /* sea green */
    border-color: #267148;
    color: #FFFFFF;
}
#levels button.completed:hover {
    background-color: #34a354;
}

/* Missing levels: darken, not clickable, no hover effects */
#levels button.missing,
#levels button[disabled] {
    background-color: #2b2b2b !important;
    border-color: #1f1f1f !important;
    color: #666666 !important;
    opacity: 0.85;
    cursor: not-allowed !important;
    transform: none !important;
}
#levels button.missing:hover,
#levels button[disabled]:hover {
    transform: none !important;
}

/* global grabbing state */
.is-grabbing, .is-grabbing * {
    cursor: grabbing !important;
}
#levels button.completed:active {
    background-color: #114820;
}

@media (orientation: portrait) {
    body {
        background-size: 11.11vw 11.11vw;
    }

    canvas,
    #darken {
        height: 100dvh;
    }

    h1 {
        font-size: 8vw;
    }

    #backBtn {
        top: 5vw;
        left: 5vw;
        font-size: 3.2vw;
        padding: 0.8vw 1.4vw;
        border-width: 0.5vw;
    }

    #levels td {
        padding: 0.8vw;
    }

    #levels button {
        font-size: 3.4vw;
        width: 15vw;
        height: 8vw;
        padding: 0.4vw 1.2vw;
        border-width: 0.5vw;
        border-radius: 0.6vw;
    }
}

@media (orientation: portrait) and (max-height: 70vw) {
    #levels button { font-size: 2.8vw; width: 12vw; height: 6.4vw; }
    h1 { font-size: 6vw; }
}

/* Ensure table stays readable on short screens */
@media (max-height: 70dvh) {
    #levels button { font-size: 2.8dvh; width: 12dvh; height: 6.4dvh; }
    h1 { font-size: 6dvh; }
}

/* Mobile UX: prevent selecting UI text and double-tap zoom on controls */
h1,
#backBtn,
#levels button {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}