html,
body {
  min-height: 100%;
}

html {
  box-sizing: border-box;
  font-size: 16px;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  margin: 0;
  line-height: 1.5;
  font-family: "IBM Plex Mono", serif;
  background-color: #000;
  color: #fff;
}

img,
video {
  height: auto;
  max-width: 100%;
  object-fit: cover;
}

button {
  padding: 0.3em 0.5em;
  border: 1px solid;
  border-radius: 3px;
  background-color: transparent;
  font-family: inherit;
  font-size: 1.2em;
  color: inherit;
  cursor: pointer;
}

header {
  display: flex;
  gap: 0.5em;
  padding: 1em;
  user-select: none;
}

header .start-score {
  flex: 0 1 5em;
  min-width: 0;
  padding: 0 0.7em;
  border: 1px solid;
  border-radius: 4px;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 1em;
  -moz-appearance: textfield;
}

header .start-score::-webkit-outer-spin-button,
header .start-score::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

header .undo {
  margin-left: auto;
}

main {
  overflow-y: auto;
  flex: 1;
  display: flex;
  gap: 1px;
  padding: 1px 0;
}

main:empty:before {
  display: block;
  content: '^ Add a player';
  padding: 0 1.7em;
}

main:not(:empty) {
  background-color: #fff;
}

main section {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #fff #000;
  flex: 1;
  height: auto;
  padding: 1em;
  background-color: #000;
}

main section .score {
  margin: 0 0 0.25em;
  font-size: 2.6em;
  font-size: max(1em, min(5em, calc(((100vw / var(--player-count)) - 2em) / 1.8)));
  line-height: 1;
  text-align: center;
}

main section.current .score {
  text-decoration: underline;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 50%, 100% { opacity: 1; }
  25% { opacity: 0.75; }
}

main section .score-history {
  display: flex;
  flex-direction: column-reverse;
  text-align: right;
  white-space: pre;
}

main section .score-history div {
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
}

aside {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.3em;
  position: relative;
  padding: 1em;
  user-select: none;
}

aside button {
  padding: 0.2em;
  font-size: 1.7em;
  font-weight: bold;
}

aside > button {
  background-color: #fff;
  color: #000;
}

aside .action-buttons {
  grid-column: span 2;
  display: flex;
}

aside .action-buttons button {
  flex: 1;
}

button[data-num="plus"] {
  margin-left: 0.2em;
  border-right: none;
  border-radius: 5px 0 0 5px;
}

button[data-num="submit"] {
  border-radius: 0 5px 5px 0;
}

aside:has(.sum:placeholder-shown) .action-buttons button[data-num="delete"],
aside:has(.sum:placeholder-shown) .action-buttons button[data-num="plus"] {
  opacity: 0.4;
  pointer-events: none;
}

aside .sum {
  position: absolute;
  bottom: calc(100% - 0.15em);
  left: 0.25em;
  width: calc(100% - 0.5em);
  padding: 0.2em;
  border: 1px solid;
  border-radius: 4px;
  box-shadow: 0 0 10px #000;
  background-color: #111;
  text-align: center;
  font-size: 4em;
  color: inherit;
  font-family: inherit;
}

button[data-num="submit"] span {
  pointer-events: none;
}

button[data-num="submit"] .next-label {
  position: relative;
  top: -0.1em;
}

aside:has(.sum:placeholder-shown) button[data-num="submit"] .next-label {
  display: block;
}

aside button[data-num="submit"] .next-label,
aside:has(.sum:placeholder-shown) button[data-num="submit"] .submit-label,
aside .sum:placeholder-shown + .total,
aside .total:empty,
aside .sum:placeholder-shown {
  display: none;
}

aside .total {
  position: absolute;
  bottom: calc(100% + 3.2em);
  left: 0.5em;
  width: calc(100% - 1em);
  border: none;
  background: linear-gradient(to top, #000e 50%, transparent);
  text-align: right;
  font-size: 2em;
  color: inherit;
  font-family: inherit;
  pointer-events: none;
}

aside .total::before {
/*   content: '='; */
  font-size: 0.6em;
  vertical-align: middle;
}

aside .total span {
  opacity: 0.8;
  display: inline-block;
  margin-left: 1ch;
  text-align: right;
  font-size: 0.7em;
  font-weight: 300;
}

@media (orientation: landscape) {
  aside {
    grid-template-columns: repeat(7, 1fr);
  }

  aside .action-buttons {
    grid-column: 6 / span 2;
    grid-row: 1 / span 2;
  }
}
