html, body {
  touch-action: manipulation; /* Prevents double-tap zoom */
  box-sizing: border-box;
  height: 100%;
}

body {
  user-select: none; /* Prevents text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  background-color: #edeef3;
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  margin: 0;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex-grow: 1;
  overflow: hidden;
}

.frame {
  position: relative;
  width: 320px;
  height: 420px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  position: absolute;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-radius: 12px;
  user-select: none;
  cursor: pointer;
  overflow: hidden;
  background-color: blue;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  touch-action: none;
}

.card .card-overlay {
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  color: white;
  font-size: 3em;
  font-weight: 600;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.card .right {
  background-color: #008751;
}

.card .left {
  background-color: #BE1250;
}

.card .up {
  background-color: #83769C;
}

.card-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.card-content div {
  margin-bottom: 8px;
}

.flashcard {
  padding: 20px;
  width: 280px;
  height: 380px;
  background-color: #E2EBF0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.5rem;
}

#buttons {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

#buttons button {
  color: white;
  border: none;
  padding: 10px 20px;
  margin: 5px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

#buttons #again {
  background-color: #BE1250;
}

#buttons #good {
  background-color: #83769C;
}

#buttons #easy {
  background-color: #008751;
}

#settings-panel, #letter-selection-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 100;
  max-height: 80vh;
  overflow-y: auto;
}

.left {
  text-align: left;
}

.indent {
  margin-left: 20px;
}

.center {
  display: flex;
  align-items: center;
  text-align: center;
  justify-content: center;
}

#settings-panel h2, #letter-selection-panel h2 {
  margin: 0;
  margin-bottom: 20px;
  font-size: 1.1rem;
  text-align: center;
}

#settings-panel button, #letter-selection-panel button {
  display: block;
}

#save-settings, #apply-letter-selection {
  margin-top: 20px;
  margin-bottom: 10px;
}

#reset-progress {
  margin-top: 3px;
}

#reset-count {
  margin-top: 3px;
}

.invisible {
  /* Change this to `display: none;` to lay card out without leaving space for hidden info */
  visibility: hidden;
}

#settings-panel.hidden, #letter-selection-panel.hidden {
  display: none;
}

#settings-btn, #letter-selection-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: white;
  padding: 0 5px;
}

#settings-btn {
  padding: 0;
}

#letter-selection-btn {
  font-size: 1rem;
  border: 1px solid white;
  border-radius: 5px;
  padding: 5px 10px;
}

.stats {
  margin-top: 10px;
  font-size: 0.7rem;
}

.tapToReveal {
  color: #C6D4D4;
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
}

.cardsHeader {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
}

h1 {
  position: relative;
  margin: 0;
  white-space: nowrap;
}

#about-link {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  white-space: nowrap;
  color: white;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.8;
}

.cardsHeader > h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#letter-checkboxes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

#letter-checkboxes label {
  display: flex;
  align-items: center;
}

.letter-panel-buttons {
  display: flex;
  justify-content: space-around;
  margin-bottom: 10px;
}

.letter-panel-buttons button {
  font-size: 0.8rem;
  padding: 5px 10px;
}

.letter-only .invisible {
  display: none;
}

.letter-only .letter {
  font-size: 10rem;
}

.revealed .letter {
  display: none;
}

.revealed .image {
  font-size: 400px;
}

.revealed .word {
  font-size: 3rem;
}

@media (max-width: 340px) {
  .frame {
    width: 300px;
    height: 380px;
  }

  .flashcard {
    width: 240px;
    height: 340px;
  }
}

/* Handle skinny screens */
@media (max-width: 500px) {
  h1 {
    font-size: 1rem;
  }
  
  #letter-selection-btn {
    font-size: 0.7rem;
  }
}

@media (min-width: 768px) {
  .frame {
    width: 600px;
    height: 65vh;
  }

  .flashcard {
    width: 540px;
    height: 60vh;
    font-size: 2.5rem;
  }

  h1 {
    font-size: 2.5rem;
  }

  .letter-only .letter {
    font-size: 15rem;
  }

  #letter-checkboxes {
    grid-template-columns: repeat(8, 1fr);
  }

  .revealed .word {
    font-size: 5rem;
  }

  .revealed .emojiImageLarge {
    font-size: 10rem;
  }

  .revealed .wordImageLarge {
    height: 176px;
    width: 176px;
  }

  #settings-panel {
    max-width: 600px;
  }

  #buttons button {
    padding: 20px 40px;
    font-size: 1.5rem;
  }
}
