:root {
  --bg: #1e1e1e;
  --accent: #1a547a;
  --trivia: #863d0c;
  --stem: #1a547a;
  --geo: #1d663c;
  --eng: #561f6d;
  --fg: rgba(50, 50, 50, 0.6);
  --primary: #34495e;
  --secondary: #aaa;
  --text: #fff;
  --antitext: #000;
  --correct: #2ecc71;
  --incorrect: #e74c3c;
}
html {
  --theme: #1a547a;
  display: flex;
  font-family: 'Roboto', sans-serif;
  font-weight: 900;
  min-height: 100lvh;
  background: #1e1e1e;
  background: radial-gradient(circle at center, var(--theme) 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: #fff;
  color: var(--text);
  text-align: center;
}
@media screen and (min-width: 80rem) {
  html {
    font-size: 1.5rem;
  }
}
input,select,button {
  font-size: 1em;
}
input[type=submit], button {
  border: none;
  font: inherit;
}
body {
  display: flex;
  width: 100%;
  height: auto;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0;
  box-sizing: border-box;
  overflow: auto;
}
body.keyboard {
  margin-bottom: calc(clamp(2.4rem, calc((100vw - 1rem) / 3), 16rem));
}
h1 {
  font-size: 2em;
}

/* Utilities */
.passthrough {
  display: contents;
}

/* Text decorators */
.correct {
  color: #2ecc71;
  color: var(--correct);
}
.incorrect {
  color: #e74c3c;
  color: var(--incorrect);
}
.squiggle {
  display: inline-block;
  position: relative;
  text-decoration: none;
  border-bottom: 2px dotted #e74c3c;
  border-bottom-color: var(--incorrect);
}
.squiggle:after {
  content: '';
  width: 100%;
  border-bottom:2px dotted #e74c3c;
  border-bottom-color: var(--incorrect);
  position: absolute;
  font-size: 1em;
  top: calc(1em - 1px);
  bottom: -1px;
  left: -2px;
  display: block;
}
.missing {
  opacity: 0.5;
}
.spoiler {
  display: inline-block;
  background: black;
  background: var(--antitext);
  padding: 0 0.25em;
  color: black;
  color: var(--antitext);
  transition: color 500ms;
}
.spoiler:hover {
  color: inherit;
  color: var(--text);
}

/* Elements */
.countdown {
  font-size: 1.5em;
  margin-bottom: 1rem;
}
.panel {
  display: flex;
  position: relative;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 25em;
  max-width: 80vw;
  height: 22em;
  padding: 2em;
  background: rgba(50, 50, 50, 0.6);
  background: var(--fg);
  border-radius: 2em;
  box-shadow: rgba(0,0,0,0.25) 0.25rem 0.25rem 0.25rem 0;
}
.panel-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  margin: 0;
}
.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #34495e;
  background: var(--primary);
  color: var(--text);
  padding: 0.5em;
  border-radius: 0.5em;
  text-decoration: none;
  box-shadow: rgba(0,0,0,0.25) 0.25rem 0.25rem 0.25rem 0;
  filter: brightness(1);
  cursor: pointer;
  transition: filter 0.25s;
}
.btn:hover {
  filter: brightness(1.25);
}
.btn.disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.btn.big-red {
  color: var(--antitext);
  width: 8rem;
  height: 8rem;
  background: var(--incorrect);
  font-size: 3em;
  border: 0.3rem solid var(--antitext);
  border-radius: 50%;
}
.btn h1 {
  margin: 0;
}
.btn p {
  margin-bottom: 0;
}
.options {
  display: flex;
  width: 19em;
  flex-direction: row;
  justify-content: space-around;
}
.multichoice {
  display: grid;
  grid-template: 1fr 1fr / 1fr 1fr;
  gap: 0.5rem;
}

/* Toasty */
.toasty {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 20em;
  width: max-content;
  max-width: 20em;
  margin: 0 auto;
  margin-bottom: calc((100vh - 100dvh) / 2);
  padding: 1em 2em;
  background: var(--primary);
  box-shadow: rgba(0,0,0,0.25) 0 0 0.5rem 0;
  z-index: 100;
  z-index: calc(var(--id, 0) + 100);
  animation: toast-popin 250ms;
}
.toasty.error {
  background: var(--incorrect);
}
.toasty.finite {
  animation: toast-popin 250ms,
    toast-popout 250ms calc(var(--expiry, 5s) - 250ms) forwards;
}
.toasty.finite::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 100%;
  height: 0.25em;
  background: var(--accent);
  animation: toast-progress var(--expiry, 5s) forwards;
}
.toasty .close {
  position: absolute;
  color: var(--incorrect);
  cursor: pointer;
  top: 0.5em;
  right: 0.5em;
}
.toasty.error .close {
  color: var(--antitext);
}
@keyframes toast-popin {
  0% {
    transform: translateY(110%);
  }
  100% {
    transform: translateY(0%);
  }
}
@keyframes toast-popout {
  0% {
    transform: translateY(0%);
  }
  100% {
    transform: translateY(110%);
  }
}
@keyframes toast-progress {
  0% {
    right: 100%;
  }
  100% {
    right: 0%;
  }
}

/* On-screen popup keyboard */
#keyboard {
  display: none;
  position: fixed;
  top: 100vh;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: clamp(0.8rem, calc((100vw - 1rem) / 21), 2rem);
  background: rgba(50, 50, 50, 0.6);
  background: var(--fg);
  border: #aaa 1px solid;
  border-color: var(--secondary);
  flex-direction: column;
  align-items: center;
}
body.keyboard #keyboard {
  top: unset;
}
#keyboard, #keyboard > .row {
  display: flex;
}
#keyboard > .action-toggle-keyboard {
  position: absolute;
  top: -2.5rem;
  right: 1rem;
  font-size: 1rem;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
#keyboard > .row > .btn {
  position: relative;
  width: 2.0em;
  height: 2.2em;
  margin: 0.1em;
}

/* Fractional representation - https://codepen.io/yiays/pen/dyQweVg */
.fraction {
  display: inline-block;
  position: relative;
  text-indent: -100vw;
  white-space: nowrap;
  vertical-align: bottom;
  overflow: hidden;
}
.fraction::before, .fraction::after {
  position: absolute;
  text-indent: 0;
  font-size: 0.5em;
  left: 10%;
  right: 10%;
  text-align: center;
}
.fraction::before {
  content: attr(data-num);
  top: 0;
  border-bottom: 1px solid #fff;
  border-bottom-color: var(--text);
}
.fraction::after {
  content: attr(data-denom);
  bottom: 0;
}

/* Dynamic media loading */
.media-loader {
  margin-bottom: 1em;
  background: var(--text);
  animation: fadeloop 1s infinite;
}
.media-loader > * {
  opacity: 0;
  transition: 250ms;
}
.media-loader.loaded {
  background: none;
  animation: none;
}
.media-loader.loaded > * {
  opacity: 1;
}
@keyframes fadeloop {
  0% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.125;
  }
  100% {
    opacity: 0.25;
  }
}

/* Loading animation */
.loader,
.loader:before,
.loader:after {
  border-radius: 50%;
}
.loader {
  color: #fff;
  color: var(--text);
  font-size: 11px;
  text-indent: -99999em;
  margin: 55px auto;
  position: relative;
  width: 10em;
  height: 10em;
  box-shadow: inset 0 0 0 1em;
  -webkit-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
}
.loader:before,
.loader:after {
  position: absolute;
  content: '';
}
.loader:before {
  width: 5.2em;
  height: 10.2em;
  background: #2A2A2A;
  background: var(--antitext);
  border-radius: 10.2em 0 0 10.2em;
  top: -0.1em;
  left: -0.1em;
  -webkit-transform-origin: 5.1em 5.1em;
  transform-origin: 5.1em 5.1em;
  -webkit-animation: load2 2s infinite ease 1.5s;
  animation: load2 2s infinite ease 1.5s;
}
.loader:after {
  width: 5.2em;
  height: 10.2em;
  background: #2A2A2A;
  background: var(--antitext);
  border-radius: 0 10.2em 10.2em 0;
  top: -0.1em;
  left: 4.9em;
  -webkit-transform-origin: 0.1em 5.1em;
  transform-origin: 0.1em 5.1em;
  -webkit-animation: load2 2s infinite ease;
  animation: load2 2s infinite ease;
}
@-webkit-keyframes load2 {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes load2 {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}