/* REMOTE KEYPAD STYLING */
#keypad {
  position: absolute;
  width: 100%;
  height: 100vh;
  height: 100dvh;

  display: grid;
  grid-template-columns: 1fr;
  /* Make header text as big as possible, keys take up as much space as needed, and control keys take up bottom space */
  grid-template-rows: max-content auto;

  align-items: center;
  justify-content: center;

  font-family: sans-serif;
}

#keypad-header {
  height: 100%;
  font-size: 1.5rem;
  font-weight: normal;
  text-align: center;

  grid-row: 1;
  overflow-y: auto;

  border-radius: 0.5em;

  box-shadow: inset 2px 2px 4px #888888,
              inset -2px -2px 4px #fff;
}

#keypad-footer {
  position: absolute;
  font-size: smaller;
  width: 100%;
  bottom: 0;
  right: 0;
}

/* Grid of main keys themselves */
#keypad-keys {
  /* Second row, within keypad grid (i.e., whole page) */
  grid-row: 2;
}

.response-button {
  /* border: 1px solid red; */
  cursor: pointer;

  /* Center text within button */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column; /* NEW: Enable vertical layout for wrapping */

  /* Curve corners of buttons */
  border-radius: min(25px, 15%);

  /* Style button text */
  /* font-size: 3rem; */
  font-size: xx-large;
  font-weight: 700;

  padding: 0;
  margin: 0;

  box-shadow: 1px 1px 2px #888888,
              -1px -1px 2px #fff;

  /* NEW: Enable flexible text layout */
  overflow: hidden;
  box-sizing: border-box;
}

.response-button:active {
  box-shadow: 1px 2px 2px 1px #999;
  background-color: #aaa;
}

/* Only do on a hover-enabled device, i.e., not a phone/tablet */
@media (hover: hover) {
  .response-button:hover {
    box-shadow: inset 1px 1px 2px #888888,
                inset -1px -1px 2px #fff;
  }
}

.response-button-label {
  text-align: center;
  color: black;

  /* NEW: Enable text wrapping and centering */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: normal;
  overflow: hidden;
  padding: 2px;
  box-sizing: border-box;
}

.noselect {
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Safari */
  -khtml-user-select: none; /* Konqueror HTML */
  -moz-user-select: none; /* Old versions of Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  user-select: none; /* Non-prefixed version, currently
                                    supported by Chrome, Edge, Opera and Firefox */
  touch-action: none;
}

.unpressable {
  background-color: #aaaaaa;
  box-shadow: inset 1px 1px 2px #888888,
              inset -1px -1px 2px #fff;
  pointer-events: none;
  user-select: none;
}

/* Control buttons maintain bottom alignment */
#keypad-control-keys .response-button {
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column; /* NEW: Enable vertical layout */
}
