* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

code {
    background-color: #d3d3d3;
}

:root {
    --vp: min(100dvw, 100dvh);
    --scale-a: calc(0.5px + (var(--vp) - 300px) / 600);
    --scale-b: calc(1.0px + (var(--vp) - 600px) / 1600);
    --scale: clamp(0.5px, min(var(--scale-a), var(--scale-b)), 1.25px);
    --base2: calc(2 * var(--scale));
    --base4: calc(4 * var(--scale));
    --base8: calc(8 * var(--scale));
    --base16: calc(16 * var(--scale));
    --base32: calc(32 * var(--scale));
    --base64: calc(64 * var(--scale));
    --base128: calc(128 * var(--scale));
    --swatch-size: calc((var(--base64) - (3 * var(--base4))) / 2);
    --color-picker: calc((8 * var(--swatch-size)) + (9 * var(--base4)));
    --modal-offset: calc(var(--base128) + var(--base32));
    --prog-percent: 0%;
}

body h3 {
    font-size: var(--base32);
    margin: var(--base4) 0 var(--base4) 0;
}

body p {
    font-size: calc(var(--base16) + var(--base8));
    margin: var(--base4) 0 var(--base4) 0;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Roboto", sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    background-color: rgb(75, 75, 75);
    width: 100dvw;
    height: 100dvh;
    touch-action: none;
    overflow: hidden;
}

body img {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    width: 100%;
    height: 100%;
}

body a:visited {
    color: blue;
}

#container {
    position: relative;
    width: 100%;
    height: 100%;
}

#zoom {
    position: absolute;
    left: 0;
    top: 0;
}

#zoom canvas {
    position: absolute;
    left: 0;
    top: 0;
    image-rendering: pixelated;
}

#board {
    pointer-events: none;
}

#view {
    cursor: grab;
}

#ui-container {
    display: flex;
    height: 100%;
    width: 100%;
    align-items: flex-start;
    flex-direction: row-reverse;
    background-color: transparent;
}

#ui-container.show {
    z-index: 2;
    position: absolute;
    background-color: #fff;
}

#batch-container {
    display: flex;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    padding: var(--base32) 0px var(--base32) var(--base32);
    gap: var(--base32);
}

#draw-container {
    display: flex;
    height: 100%;
    flex-direction: column;
    align-items: center;
    padding: var(--base32);
    gap: var(--base32);
}

#draw-btn,
#zoom-btn,
#info-btn,
#rotate-btn,
#submit-btn,
#clear-btn,
#progress-container,
#disclaimer-btn {
    position: relative;
    min-width: var(--base64);
    max-width: var(--base64);
    min-height: var(--base64);
    max-height: var(--base64);
    z-index: 2;
    background-color: white;
    outline: var(--base4) solid black;
    border-radius: var(--base8);
}

#clear-btn {
    --lower-bound: calc(50% - var(--base2));
    --upper-bound: calc(50% + var(--base2));
}

#progress-container {
    flex: 1;
    max-width: unset;
}

#progress-bar {
    width: var(--prog-percent);
    min-height: inherit;
    background: #FF0000;
    background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, 0.5) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.5) 75%, transparent 75%, transparent);
    background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.5) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.5) 75%, transparent 75%, transparent);
    background-size: 35px 35px;
    -webkit-animation: progressAnim 3s linear infinite, progressBG 20s infinite linear;
    animation: progressAnim 3s linear infinite, progressBG 20s infinite linear;
}

#draw-btn,
#rotate-btn,
#info-btn,
#clear-btn,
#submit-btn,
#disclaimer-btn {
    padding: var(--base8);
    cursor: pointer;
}

#zoom-btn {
    --lower-bound: calc(50% - var(--base2));
    --upper-bound: calc(50% + var(--base2));
    background-image: linear-gradient(to bottom left, transparent var(--lower-bound), #000 var(--lower-bound), #000 var(--upper-bound), transparent var(--upper-bound));
}

#zoom-in,
#zoom-out {
    position: absolute;
    cursor: pointer;
    width: calc(var(--base32) + var(--base4));
    height: calc(var(--base32) + var(--base4));
    padding: var(--base4);
    border-radius: var(--base32);
}

#zoom-in {
    top: 0px;
    right: 0px;
}

#zoom-out {
    bottom: 0px;
    left: 0px;
}

#color-picker {
    overflow: hidden;
    position: relative;
    display: none;
    flex-wrap: wrap;
    flex-direction: column;
    min-width: var(--base64);
    height: var(--color-picker);
    z-index: 2;
    gap: var(--base4);
    padding: var(--base4);
    background-color: #fff;
    outline: var(--base4) solid black;
    border-radius: var(--base8);
}

.color-swatch {
    width: var(--swatch-size);
    height: var(--swatch-size);
    border: var(--base2) solid #444;
    border-radius: var(--base4);
    box-sizing: border-box;
    cursor: pointer;
}

.sw-selected {
    border-width: var(--base4);
}

#brush-cursor {
    position: fixed;
    pointer-events: none;
    border: 2px solid #444;
    background-color: #fff;
    box-sizing: border-box;
    z-index: 1;
    display: none;
}

#loading {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    background-color: white;
    display: flex;
    height: 100%;
    width: 100%;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

#loading img {
    height: max(15dvw, 15dvh);
    width: auto;
    max-height: 400px;
}

#info-modal {
    position: absolute;
    display: none;
    flex-direction: column;
    width: calc(100dvw - var(--modal-offset));
    height: calc(100dvh - var(--modal-offset));
    top: var(--base128);
    right: var(--base128);
    outline: var(--base4) solid black;
    border-radius: var(--base8);
    background-color: #fff;
    padding: 0;
    z-index: 2;
}

#info-modal.show {
    display: flex;
    justify-content: flex-start;
}

#info-text {
    padding: var(--base16);
    overflow-y: auto;
}

#disclaimer-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#disclaimer-btn {
    min-width: fit-content;
    max-width: fit-content;
    min-height: fit-content;
    max-height: fit-content;
    margin: var(--base32) 0 var(--base32) 0;
}

#ui-container.u-c-toggled {
    flex-direction: column;
    align-items: flex-end;
}

#draw-container.d-c-toggled {
    flex-direction: row-reverse;
    height: auto;
    width: 100%;
}

#batch-container.b-c-toggled {
    flex-direction: column-reverse;
    padding: 0px var(--base32) var(--base32) var(--base32);
    width: fit-content;
    height: 100%;
}

#progress-container.p-c-toggled {
    max-height: unset;
}

#progress-bar.p-b-toggled {
    width: 100%;
    height: var(--prog-percent);
    min-height: 0px;
}

#color-picker.c-p-toggled {
    justify-content: flex-end;
    width: var(--color-picker);
    height: var(--base64);
}

.clickable.play-animation {
    -webkit-animation: buttonAnim 0.5s linear;
    animation: buttonAnim 0.5s linear;
}

@-webkit-keyframes buttonAnim {
    0%   { background-color: #b1b1b1; }
    100% { background-color: #fff; }
}

@keyframes buttonAnim {
    0%   { background-color: #b1b1b1; }
    100% { background-color: #fff; }
}

@-webkit-keyframes progressBG {
    12.5% { background-color: #FFA500; }
    25%   { background-color: #FFFF00; }
    37.5% { background-color: #7FFF00; }
    50%   { background-color: #00FFFF; }
    62.5% { background-color: #0000FF; }
    75%   { background-color: #9932CC; }
    87.5% { background-color: #FF1493; }
    100%  { background-color: #FF0000; }
}

@keyframes progressBG {
    12.5% { background-color: #FFA500; }
    25%   { background-color: #FFFF00; }
    37.5% { background-color: #7FFF00; }
    50%   { background-color: #00FFFF; }
    62.5% { background-color: #0000FF; }
    75%   { background-color: #9932CC; }
    87.5% { background-color: #FF1493; }
    100%  { background-color: #FF0000; }
}

@-webkit-keyframes progressAnim {
    0%   { background-position: 0 0; }
    100% { background-position: 35px 35px; }
}

@keyframes progressAnim {
    0%   { background-position: 0 0; }
    100% { background-position: 35px 35px; }
}

@media(max-width: 300px), (max-height: 300px) {
    #batch-container { display: none !important; }
    #color-picker    { display: none !important; }
    #draw-btn        { display: none !important; }
}

@media(hover: none) {
    #brush-cursor { display: none !important; }
}