/* squares.mehlhase.info */
/* (c) Sascha Mehlhase - kontakt@mehlhase.info */
/* game idea: Sascha Mehlhase */

:root {
  --spacing: 10px;
  --aspect-ratio: 1;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-variant-emoji: text;
  color: rgba(34, 14, 16, 1);
}

html {
  height: 100%;
}

body {
  background-color: rgba(0, 0, 0, 1);
  font-family: sans-serif;
  height: 100%;

  display: flex;
  flex-flow: row wrap;
  justify-content: safe center;
  align-content: center;
  align-items: center;
  gap: var(--spacing);
  padding: var(--spacing);
}

.frame {
  aspect-ratio: var(--aspect-ratio);
  width: calc((100vw - 3 * var(--spacing)) / 2);
  max-height: calc(100vh - 2 * var(--spacing));
  height: unset;
  max-width: unset;
  flex-grow: 1;
  align-self: stretch;
  display: flex;
  font-size: calc(100vw / 2 / 30);
}

.frame:has(.menu) {
  justify-content: flex-end;
}

.frame:has(.board) {
  justify-content: flex-start;
}

@media (max-aspect-ratio: 1) {
  .frame {
    max-width: calc(100vw - 2 * var(--spacing));
    height: calc((100vh - 3 * var(--spacing)) / 2);
    width: unset;
    max-height: unset;
    font-size: calc(100vh / 2 / 30);
  }

  .frame:has(.menu) {
    justify-content: center;
  }

  .frame:has(.board) {
    justify-content: center;
  }
  
  @media (max-aspect-ratio: 1/2) {
    .frame {
      width: calc(100vw - 2 * var(--spacing));
      max-height: calc((100vh - 3 * var(--spacing)) / 2);
      height: unset;
      max-width: unset;
      font-size: calc(100vw / 30);
    }
  }
}

.menu, .board, .instructions, .installInstr, .solved {
  aspect-ratio: var(--aspect-ratio);
  max-width: 100%;
  max-height: 100%;
  background: rgba(247, 245, 231, 1);
  border: 1px solid rgba(34, 14, 16, 1);
  border-radius: var(--spacing);
  padding: var(--spacing);
}

.menu {
  display: flex;
  gap: calc(var(--spacing) / 2);
  flex-flow: column nowrap;
  justify-content: flex-start;
  overflow: scroll;
}

.menu .title {
  cursor: pointer;
}

.menu hr {
  border: 1px solid rgba(34, 14, 16, 1);
}

.menu .row {
  display: flex;
  gap: var(--spacing);
  flex-flow: row nowrap;
  justify-content: flex-start;
  align-items: stretch;
  align-content: space-between;
}

.menu .label, .menu .value, .menu .plusminus, .menu .start {
  border: 1px solid rgba(34, 14, 16, 0.75);
  border-radius: calc(var(--spacing) / 2);
  line-height: 2rem;
  padding: 0 var(--spacing);
  display: flex;
  justify-content: center;
  align-items: center;
}

.menu .label, .menu .start {
  flex-grow: 1;
}

.menu .start {
  line-height: 300%;
}

.menu .value {
  width: 3rem;
  text-align: center;
  background: unset;
  -moz-appearance: textfield;
}
.menu .value::-webkit-outer-spin-button, .menu .value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.menu .plusminus, .menu .start, .menu .seed {
  font-weight: bold;
  background: rgba(34, 14, 16, 0.75);
  color: rgba(247, 245, 231, 1);
  cursor: pointer;
}

.menu .plusminus {
  aspect-ratio: var(--aspect-ratio);
}

.menu .credits {
  font-size: 80%;
}

.menu .version, .menu .boardurl, .menu .openInstructions, .menu .install, .menu .stats, .small {
  font-size: 70%;
}

.menu .boardurl, .menu .openInstructions, .menu .install {
  text-decoration: underline;
  cursor: pointer;
}

h1 {
  font-size: 300%;
}

h2 {
  font-size: 200%;
}

.board {
  display: grid;
  gap: var(--spacing);
  grid-template-columns: repeat(3, 1fr);
  transition: border 500ms, color 500ms;
  touch-action: none;
}

.element {
  aspect-ratio: var(--aspect-ratio);
  background: rgba(202, 60, 8, 0.5);
  border-radius: calc(var(--spacing) / 2);
  border: 2px solid rgba(34, 14, 16, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: border 500ms, color 500ms;
  font-size: 200%;
}

.selected {
  border: 2px solid rgba(202, 60, 8, 1);
  color: rgba(202, 60, 8, 1);
}

.moved {
  color: rgba(202, 60, 8, 0);
}

.instructions, .installInstr, .solved {
  display: flex;
  gap: var(--spacing);
  flex-flow: column nowrap;
  justify-content: flex-start;
  font-size: 80%;
  overflow: scroll;
  display: none;
}

.solved .solvedText {
  display: flex;
  gap: var(--spacing);
  flex-flow: column wrap;
  justify-content: flex-start;
}

.instructions .closeInstructions, .solved .closeSolved, .solved .copy {
  text-decoration: underline;
  cursor: pointer;
  font-size: 70%;
}

/*@media (display-mode: browser) {
  .installInstr {
    display: block
  }
}
*/