:root {
    --bg: #f6f6f6;
    --canvas-bg: #0000A5;
    --canvas-border: #555555;
    --warning: #ffd448;

    --text: #111;
    --link: #007acc;
    --border: color-mix(in srgb, var(--text), transparent 80%);

    --tab-bg-active: #007acc;

    --tile-selection-color: #ff0000;
    --tile-selection-width: 1;
    --grid-color: rgba(255,255,255,0.5);
    --grid-width: 0.5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #222;
        --canvas-bg: #0000A5;
        --canvas-border: #ddd;
        --warning: #ffc500;

        --text: #ffffff;
        --link: #60b1e8;

        --tile-selection-color: #ff0000;
    }
}


body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-align: center;
    color: var(--text);
    font-size: 1.0rem;
    line-height: 1.3em;

    margin: 0 auto;
}

a {
    color: var(--link);
    text-decoration: underline;
    &:hover {
        text-decoration: none;
    }
}

main {
    display: flex;
    flex-direction: column;
    gap: 1em;
    padding: 3em;
}

@media only screen and (max-width: 800px) {
    main {
        padding: 1em;
    }
}

canvas {
    image-rendering: pixelated;
}

.canvas-container {
    position: relative;
    overflow: hidden;
    overflow-x: scroll;
    display: flex;
}

button {
    font-family: inherit;
}

.tabs-container {
    display: flex;

    .tab {
        background-color: color-mix(in srgb, currentColor, transparent 80%);
        color: var(--text);
        padding: 6px;
        cursor: pointer;

        &:hover {
            background-color: color-mix(in srgb, currentColor, transparent 85%);
        }

        &.active {
            background-color: var(--tab-bg-active);
            color: white;
        }
    }
}

.section-grid {
    display: flex;
    flex-direction: row;
    gap: 1em;
}
@media only screen and (max-width: 1400px) {

    .section-grid {
        display: flex;
        flex-direction: column;
        gap: 1em;
    }
}


section#map16 {
    align-self: start;

    #map16-canvas {
        cursor: pointer;
        background-color: var(--canvas-bg);
    }
}

@media only screen and (max-width: 540px) {
    section#map16 {
        align-self: unset;
    }
}

section#editor {

    header {
        display: flex;
        align-items: center;
        flex-direction: row;
    }

    #contributor-counter {
        font-size: 10pt;
    }

    #save-button {
        margin-left: auto;
        padding: 2px 4px;
        min-height: 24px;
    }

    #level-canvas {
        cursor: crosshair;

        background-image: url('img/level_bg.png');
        background-size: 1024px;
        background-repeat: repeat-x;
        filter: none;

        &.locked {
            cursor: not-allowed;
            opacity: 0.8;
            pointer-events: none;
            filter: saturate(50%);
        }
    }
}

section#palette {
    align-self: start;

    #palette-canvas {
        cursor: pointer;
        background-color: var(--canvas-bg);
    }

    .flip-buttons {
        display: flex;
        flex-direction: row;
        gap: 0;

        button {
            padding: 4px;
            min-width: 48px;
            cursor: pointer;
        }
    }
}

@media only screen and (max-width: 300px) {
    section#palette {
        align-self: unset;
    }
}

section#overworld {
    align-self: start;

    header {
        display: flex;
        align-items: center;
        flex-direction: row;
    }


    #contributor-counter {
        font-size: 10pt;
    }

    #save-button {
        margin-left: auto;
        padding: 2px 4px;
        min-height: 24px;
    }

    #overworld-canvas {
        cursor: crosshair;

        background-image: url('img/overworld_bg.png');
        background-size: 16px;
        background-repeat: repeat;
        filter: none;

        &.locked {
            cursor: not-allowed;
            opacity: 0.8;
            pointer-events: none;
            filter: saturate(50%);
        }
    }
}

@media only screen and (max-width: 1100px) {
    section#overworld {
        align-self: unset;
    }
}

#contributor-counter {
    text-align: left;
    font-weight: bold;
}

#countdown-timer {
    position: fixed;
    bottom: 4%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 280px;
    z-index: 10;

    background-color: color-mix(in srgb, var(--bg), var(--warning) 40%);
    border: 1px solid var(--border);
    border-radius: 0.5em;
    padding: 0.6em 1.2em;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.05);
    backdrop-filter: blur(3px);

    font-weight: bold;
    font-feature-settings: "tnum";
    font-size: 1rem;
    color: var(--text);

    display: none;
    justify-content: center;
    align-items: center;
}

footer {
    font-size: 0.7rem;
    color: color-mix(in srgb, currentColor, transparent 50%);
    padding-bottom: 6em;
}