html,
body {
    margin: 0;
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    flex-shrink: 0;
}

input[type="text"],
input[type="search"] {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 24px;
    accent-color: var(--accent-color);
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: var(--text-color);
}

input[type="range"]::-moz-range-progress {
    background: var(--accent-color);
}

input[type="range"]::-moz-range-track {
    height: 8px;
    background: var(--text-color);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    background-image: url('/img/ui/range-thumb.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    margin-top: -12px;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    background-image: url('/img/ui/range-thumb.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    cursor: pointer;
}

.clr-field input {
    width: 2rem;
    height: 2rem;
}

.clr-field button {
    background: transparent !important;
    image-rendering: pixelated;
    width: 100% !important;
    height: 100% !important;
    border: 8px solid transparent !important;
    border-image: url('/img/ui/color-picker-background.png') 3 !important;
    border-radius: 0;
}

.clr-field input {
    padding-right: 0.5rem;
}

#content {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    justify-content: center;
    align-items: stretch;
}

#content > div {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px;
    border-radius: 8px;
    box-sizing: border-box;
    max-width: 100%;
}

#content h1 {
    margin: 0 0 10px;
    flex-shrink: 0;
}

#category-container {
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    /* flex: 0 0 min(7.5%, 110px); */
}

#catalog-container {
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    flex: 0 0 min(20%, 260px);
}

.category-card {
    grid-column: span 2; 
    display: flex;
    flex-direction: column;
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    padding: 0.5rem;
    align-items: center;
    width: stretch;
    width: -moz-available;
    background: var(--bg-color);
    color: var(--text-color);
}

.category-card:nth-child(odd):last-child {
  grid-column: 2 / span 2;
}

.category-card:hover {
    background: #e4ac47;
}

.category-card img {
    width: stretch;
    width: -moz-available;
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
}


#controls-container {
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row !important;
    gap: 15px;
    align-items: stretch;
    max-width: calc(100% - 2 * min(7.5%, 110px) - 2 * min(20%, 260px) - 80px);
}

#selection-container {
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    flex: 0 0 min(20%, 360px);
}

.scroll {
    flex: 1;

    background: var(--bg-color);
    /* border: 1px solid #888; */
    border-radius: 6px;

    overflow-y: auto;
    min-height: 0;
    padding: 0.5rem;
    scrollbar-gutter: auto;

    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#controls-left {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: min(100%, min(54vw, calc((100vh - 220px) / 2)));
    max-width: 100%;
    aspect-ratio: 1 / 2;
    background: transparent;
    border-radius: 6px;
    overflow: hidden;
}

#canvas_warp {
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: flex;
}

#skin_container {
    width: 100%;
    height: 100%;
    display: block;
}

#controls-right {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

#controls-right > div {
    background: var(--bg-color);;
    border-radius: 6px;
    padding: 10px;
}

#character-controls {
    flex: 6;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#character-controls h2 {
    flex-shrink: 0;
}

#rotation-controls {
    flex: 0.5;
}

#layer-controls {
    flex: 1.5;
}

#controls-right.hidden {
    display: none;
}

#selection-scroll {
    font-size: clamp(.7rem, 1vw, 1rem);
}

#media-controls {
    flex-shrink: 0;

    margin-top: 10px;

    background: var(--bg-color);;
    border-radius: 6px;
    padding: 10px;
}

label {
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 10px;
}

label p {
    min-width: 0;
}

label input,
label select,
label .clr-field {
    min-width: 0;
}

#auto_rotate_speed {
    width: 100%;
}

.catalog-item {
    border: 1px solid var(--accent-color);
    border-radius: 0.5rem;
    display: grid;
    grid-template-columns:
        auto 
        1fr
        auto
        auto;

    gap: .5rem;
    align-items: center;
    padding: 0.5rem;
}

.selection-item {
    border: 1px solid var(--accent-color);
    border-radius: 0.5rem;
    display: grid;
    grid-template-columns:
        auto 
        1fr
        auto
        auto;

    gap: .5rem;
    align-items: center;
    padding: 0.5rem;
}

.col-display-div {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    gap:0.25rem;
}

.item-layer-controls-div{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.item-controls{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drag-handle {
    cursor: grab;
    display: flex;
}

.drag-handle img {
    image-rendering: pixelated;
    aspect-ratio: 11 / 8;
    width: clamp(24px, 10vw, 44px);
}

.image-button{
    image-rendering: pixelated;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    padding: 0;
    transition: none;
    border-radius: 0;
}

.remove-item{
    width: clamp(24px, 10vw, 44px);
    min-width: 24px;
    aspect-ratio: 11 / 17;
    background-image: url('/img/ui/page-backward.png');
}

.remove-item:hover {
    background-image: url('/img/ui/page-backward-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.add-item{
    width: clamp(24px, 10vw, 44px);
    min-width: 24px;
    aspect-ratio: 11 / 17;
    background-image: url('/img/ui/page-forward.png');
}

.add-item:hover {
    background-image: url('/img/ui/page-forward-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.move-up{
    image-rendering: pixelated;
    width: clamp(24px, 10vw, 44px);
    min-width: 24px;
    aspect-ratio: 11 / 7;
    background-image: url('/img/ui/move-up.png');
}

.move-up:hover {
    background-image: url('/img/ui/move-up-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.move-down{
    image-rendering: pixelated;
    width: clamp(24px, 10vw, 44px);
    min-width: 24px;
    aspect-ratio: 11 / 7;
    background-image: url('/img/ui/move-down.png');
}

.move-down:hover {
    background-image: url('/img/ui/move-down-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.item-renderlayer {
    image-rendering: pixelated;
    transition: none;
    min-width: 14ch;
    aspect-ratio: 35 / 13;
    color: white;
    border-radius: 0;
    background-image: url('/img/ui/button.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.item-renderlayer:hover {
    background-image: url('/img/ui/button-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.color-picker {
    cursor: pointer;
    border: 0 !important;
}

.pixel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.pixel-toggle input {
    display: none;
}

.pixel-toggle span {
    width: clamp(2rem, 15vw, 4rem);
    image-rendering: pixelated;
    aspect-ratio: 30 / 16;
    background: url('/img/ui/toggle-off.png') no-repeat center;
    background-size: contain;
}

.pixel-toggle:hover input:not(:checked) + span {
    background: url('/img/ui/toggle-off-hover.png') no-repeat center;
    background-size: contain;
}


.pixel-toggle input:checked + span {
    background-image: url('/img/ui/toggle-on.png');
}

.pixel-toggle:hover input:checked + span {
    background-image: url('/img/ui/toggle-on-hover.png');
}

.selection-image,
.catalog-image {
    max-width: 50%;
}

.selection-color {
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
    border-radius: 0;
    background-image: url('/img/ui/color-button.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    transition: none;
}

.selection-color:hover {
    background-image: url('/img/ui/color-button-highlighted.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

#catalog-search-input{
    width: stretch;
    width: -moz-available;
    background-color: var(--bg-color);
    border: none;
    color: var(--text-color);
}

#category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 0.5rem;
}

.mc-button {
    image-rendering: pixelated;
    transition: none;
    color: white;
    border-radius: 0;
    background-image: url('/img/ui/button.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.mc-button:hover {
    background-image: url('/img/ui/button-highlighted.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

table {
    border-collapse: collapse
}

table td,table th {
    border: 1px solid var(--accent-color);
    text-align: left
}

thead th {
    border-top: unset
}

tbody tr:last-child td,tbody tr:last-child th {
    border-bottom: unset
}

table th:first-child,table td:first-child {
    border-left: unset
}

table th:last-child,table td:last-child {
    border-right: unset
}

table td, table th {
    padding: 5px;
    text-align: center;
}

table td input[type=checkbox] {
    /* vertical-align: middle;
    margin: 0;
    width: 100% */
}

.pixel-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.pixel-checkbox input {
    display: none;
}

.pixel-checkbox span {
    width: clamp(0.5rem, 15vw, 1.5rem);
    image-rendering: pixelated;
    aspect-ratio: 1 / 1;
    background: url('/img/ui/checkbox.png') no-repeat center;
    background-size: contain;
}

.pixel-checkbox:hover input:not(:checked) + span {
    background: url('/img/ui/highlighted-checkbox.png') no-repeat center;
    background-size: contain;
}


.pixel-checkbox input:checked + span {
    background-image: url('/img/ui/selected-checkbox.png');
}

.pixel-checkbox:hover input:checked + span {
    background-image: url('/img/ui/highlighted-selected-checkbox.png');
}
