body, html {
  background-color: #d1d1d1;
  margin:0;
  padding:0;
  height:100%;
  width:100%;
  overflow:hidden;
}
* {
  box-sizing:border-box;
  overscroll-behavior-y: contain;
  margin:0;
}

grid-system {
  display: grid;
  grid-template-columns: repeat(var(--columns, 50), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 50), minmax(0, 1fr));
  height: 100%;
  margin-inline: auto;
  container-type: size;
  overflow: hidden;
  gap:5px;
  cell {
    position: relative;
    grid-area: var(--landscape, var(--portrait));
    z-index:var(--layer);
    @container (max-aspect-ratio: 1/1) { grid-area: var(--portrait, var(--landscape)); }
  }
  cell > * {
      height:100%;
      width:100%;
      display: flex;
      flex-direction: column;
  }
  cell[data-locked="true"] {
    pointer-events:none;
  }
}

input, select {
  width: 100%;
  height: 100%;
}

@font-face {
  font-family: "singlex";
  src: url("Singlex.woff2") format("woff2");
}

body {
  font-family: "Singlex", sans-serif;
  line-height: 1.3;
  letter-spacing: 0.1em;
  overscroll-behavior-y: contain;
}

button {
  background:transparent;
  cursor:pointer;
  border:1px solid white;
  border-radius:5px;
  background:black;
  padding:0;
  color:white;
  &:hover:not(.active, [disabled]) {
    background:red;
  }
  &[disabled] {
    opacity:0.5;
  }
}
button.active {
  background:blue;
}
.stroke-width-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  flex-shrink: 0;
  label {
    font-size: 0.7em;
    color: rgba(255,255,255,0.6);
    flex-shrink: 0;
  }
}
input[type=number] {
  background: black;
  border:1px solid white;
  color: white;
}

.color-swatches {
  display: flex;
  position: relative;
}
.color-swatch-fill {
  flex: 1;
}
.color-swatch-stroke {
  flex: 1;
}
.active {
  rect {
    fill:transparent;
  }
}

.color-drag-ghost {
  position: fixed;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  top: 0;
  left: 0;
}

.colorpicker {
  list-style: none;
  display: flex;
  flex-direction: row;
  margin: 0;
  padding: 0;
  flex: 1;
  li {
    padding: 0;
    flex: 1;
    cursor: pointer;
    position: relative;
    &.selected-fill::after,
    &.selected-stroke::before {
      content: '';
      display:block;
      position: absolute;
      width:100%;
      height:100%;
      z-index:100;
      pointer-events:none;
      transform:translate(0%, -100%);
    }
    &.selected-fill::after {
      background: linear-gradient(to top right, red 0 25%, transparent 0 100%);
    }
    &.selected-stroke::before {
      background: linear-gradient(to top left, lime 0 25%, transparent 0 100%);
    }
  }
  template {
    display: contents;
  }
}

.texture-panel-label {
  color: rgba(255,255,255,0.5);
  font-size: 0.55em;
  letter-spacing: 0.12em;
  padding: 2px 4px 0;
  flex-shrink: 0;
}

.texturepicker {
  list-style: none;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0px;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  li {
    width: 24px;
    height: 24px;
    cursor: grab;
  }
}

.texture-panel {
  background: black;
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.texture-drag-ghost {
  position: fixed;
  width: 48px;
  height: 48px;
  border: 1px solid white;
  border-radius: 3px;
  pointer-events: none;
  z-index: 9999;
  top: 0;
  left: 0;
  opacity: 0.85;
}

.texture-preview {
  border-radius: 1rem;
  pointer-events: none;
}
#cell-texture-preview {
  pointer-events:none;
}

#help-modal {
  background:black;
  border:1px solid #aaa;
  resize:both;
  overflow:auto;
  color:#d1d1d1;
  position:relative;
  height:50dvh;
  width:min(500px, 50%);
  display:grid;
  grid-template-rows:50px 1fr;
  button {
    position:absolute;
    top:10px;
    right:10px;
    padding:10px;
  }
  .help-modal-inner {
    overflow:auto;
  }
  #help-modal-drag-handle {
    height:50px;
    border:1px solid #aaa;
    display:grid;
    place-content:center;
    background: radial-gradient(white,black);
    background-size: 5px 5px;
    -webkit-user-select: none;
    user-select: none;
  }
  section {
    margin-bottom:1rem;
  }
  h3 {
    color:yellow;
  }
  td, tr {
    padding:3px 5px;
    border-radius:5px;
  }
  td:nth-child(odd) {
    background:#333;
  }
}