* {
  margin: 0;
  padding: 0;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

button {
  padding: revert;
}

canvas {
  image-rendering: pixelated;
}

.zoomed-in {
  zoom: 2;
}

.zoomed-out {
  zoom: 0.5;
}

.zoomed-in.zoomed-out {
  zoom: 1;
}

body {
  margin: 10px 15px;
  font-size: 10pt;
  font-family: monospace;
}

.sticky {
  position: sticky;
  top: 0;
  left: 0;
  margin-top: -10px;
  padding-top: 10px;
  width: 100%;
  display: flex;
  background-color: white;
  opacity: 1;
  z-index: 4;
}

#header-left {
  flex-direction: column;
  order: 0;
}

#preview-animations {
  padding-top: 15px;
  padding-left: 30px;
  order: 1;
}

h1 {
  margin: 10px 0px;
}

h2 {
  margin: 10px 0px;

}

h3 {
  margin: 4px 0px 0px 0px;
}

p {
  margin: 10px 0px;
}

.subtitle {
  padding-left: 50px;
}

#save {
  width: 60%;
  min-width: 832px;
  margin: 40px 0;
  float: right;
  padding-left: 15px;
}

#credits {
  width: 100%;
  clear: both;
  max-width: calc(100vw - 80px);
}

input[type=button], input[type=reset] {
  padding: 2px 1em;
}

#previewAnimationsBox > * {
  vertical-align: top;
}

#controls {
  margin-top: 10px;
  padding-top: 10px;
  order: 2;
}

#controls > * {
  background-color: white;
  opacity: 1;
  z-index: 2;
}

#chooser {
  overflow-y: auto;
  min-width: 200px;
  max-height: calc(100vh - 320px);
  margin-left: 15px;
  order: 4;
}

#preview {
  min-width: 832px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  margin-top: 0;
  position: relative;
  order: 3;
  left: 15px;
  grid-row: span 2;
}

#customizeChar {
  display: grid;
  grid-template-columns: 40% auto;
}

#credits, #advanced {
  margin-top: 15px;
  padding-top: 15px;
  margin-left: 15px;
}

summary {
  display: none;
}

.ZPOS {
  white-space: nowrap;
}

/* smaller screens width < 1280 px */
@media screen and (max-width: 1280px) {
  body {
    max-width: calc(100vw - 30px);
  }

  #header-left {
    width: calc(100vw - 140px);
    overflow-y: auto;
    order: 0;
  }

  #customizeChar {
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 30px);
  }

  #preview {
    order: 0;
    padding-top: 50px;
    margin-bottom: -60px;
    max-height: none;
    min-width: unset;
  }

  #customizeChar > section {
    width: calc(100vw - 80px);
  }

  #chooser {
    order: 0;
    height: auto;
    max-height: none;
    margin-top: -70px;
  }

  #controls {
    z-index: 3;
    order: 0;
    margin-top: -10px;
    padding-top: 20px;
    padding-left: 20px;
  }

  #controls>details[open] {
    margin-left: -10px;
    margin-bottom: -40px;
    padding-left: 10px;
    padding-bottom: 60px;
  }

  /* override #customizeChar > section */
  #customizeChar > #controls {
    width: calc(100vw - 80px);
  }

  #preview-animations {
    order: 0;
    margin-left: 15px;
    padding-left: 0;
    padding-top: 40px;
    padding-bottom: 40px;
    width: calc(100vw - 80px);
  }

  summary {
    display: list-item;
  }

  details {
    position: relative;
    top: -32px;
  }

  #preview:has(>details:not(open)) {
    padding-bottom: 120px;
  }
  
  #preview:has(>details:not(open))+#chooser {
    padding-top: 50px;
  }
}

/* high dpi (retina) screens */
@media screen and (max-width: 1280px) and (min-resolution:1.5x) {
  #preview,
  #credits, 
  #advanced,
  #chooser
  {
    font-size: 1.25rem;
  }

  #creditsText,
  #chooser h3,
  #chooser span,
  #chooser label {
    font-size: 1.5rem;
  }
}

/* portrait mode 800 - 1280 px width, > 1200 px height */
@media screen and (max-width: 1280px) and (min-height: 1200px) {
  .sticky {
    position: fixed;
    left: 15px;
  }

  #controls {
    top: 170px;
    padding-left: 0;
    margin-top: -50px;
    padding-top: 50px;
  }

  #preview-animations {
    top: 300px;
    padding-left: 0;
  }

  #preview {
    margin-top: 470px;
  }
}

/* tablet view 800 - 1280 px, <= 1200 px height */
@media screen and (max-width: 1280px) and (max-height: 1200px) {
  .sticky {
    position: static;
  }

  #controls {
    z-index: 2;
    padding-left: 0;
    margin-top: 20px;
  }

  #preview-animations.controls-open {
    top: 300px;
  }

  #preview {
    min-width: unset;
  }
}

#chooser p.instr {
  padding: 10px 0;
  margin: 10px 0;
}

#preview p.instr {
  padding: 10px;
  margin: 12px 6px;
}

ul {
  list-style-type: none;
}

#chooser>details>ul {
  border-left: solid 1px silver;
  padding-left: 0.5em;
  margin-left: 0.5em;
}

#chooser ul>li>span {
  cursor: pointer;
}

#chooser ul>li>.condensed:after {
  padding-left: 10px;
  content: '\25B6';
}

#chooser ul>li>.expanded:after, #chooser .condensed:hover:after {
  padding-left: 10px;
  content:  '\25BC';
}

.condensed:hover, .expanded:hover {
  text-decoration: underline;
}

.search-result {
  background-color: yellow;
}

#chooser>details>ul ul {
  display: none;
  margin-left: 0.5em;
  border-left:  solid 1px silver;
  padding-left: 0.5em;
}

#chooser ul.hasPreview {
  text-indent: 0;
}

#chooser li.hasPreview {
  display: inline-block;
  padding-left: 5px;
  padding-right: 5px;
  padding-bottom: 3px;
  margin-left: 0;
  margin-right: 0;
  text-indent: 0;
  border: solid 1px transparent;
  border-radius: 3px;
}

#chooser li.hasPreview:hover {
  border-color: silver;
}

li.hasPreview canvas {
  display: block;
}

#chooser.compact canvas {
  display:  inline-block;
  width: 32px;
  vertical-align:  middle;
}

#customizeChar .buttons {
  display: block;
  margin: 50px 0;
}

.control-label {
  font-weight: bold;
}

label[for="displayMode-compact"] {
  display: inline-block;
}

#creditsText {
  width: calc(100vw - 80px);
}

a {
  border: 0;
}
