.jsavcontainer {
    overflow:hidden;
    width: auto;
    padding: 0.7em;
    border: 1px solid black;
    background-color: white;
    position: relative;
    /* prevent text selection within container */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  .jsavcanvas {
    position: relative;
    background-color: inherit;
    overflow-x: auto;
  }
  
  .jsavnode {
    width: 45px;
    height: 45px;
    text-align: center;
    border: 1px solid black;
    background-color: white;
    color: black;
    opacity: 1;
    padding: 0;
    /* prevent text cursor on nodes*/
    cursor: default;
    /* add a subtle shadow to nodes */
    box-shadow: 2px 2px 5px rgba(120, 120, 120, 0.5);
  }
  .jsavcenter {
    margin-left: auto;
    margin-right: auto;
  }
  
  .jsavarray, .jsavlabel, .jsavcode, .jsavlist, .jsavtree, .jsavgraph, .jsavmatrix {
    margin-top: 1em;
    margin-bottom: 1em;
  }
  .jsavhighlight, .jsavarray.jsavbararray .jsavindex.jsavhighlight .jsavvalue, .jsavvariable.jsavhighlight .jsavvalue {
    background-color: yellow !important;
    color: black !important;
  }
  
  .jsavvalue {
    /* FF doesn't respect 100% here when using display: table so have to fix the height */
    height: 45px;
    width: 100%;
    min-height: inherit;
    min-width: inherit;
    background-color: transparent;
    display: table;
    border-radius: inherit;
  }
  
  .jsavvaluelabel {
    display: table-cell;
    vertical-align: middle;
  }
  
  .jsavautoresize .jsavnode {
    width: auto;
    min-width: 45px;
    height: auto;
    min-height: 45px;
  }
  
  /***** STYLING OF THE ARRAY DATA STRUCTURE *****/
  .jsavarray {
    position: relative;
    list-style: none;
    min-height: 50px;
    padding: 0;
    clear:both;
    white-space: nowrap;
    -webkit-transform-style: preserve-3d;
  }
  .jsavarray * {
    -webkit-transform-style: preserve-3d;
  }
  .jsavarray:after {
    content: "";
    clear: both;
    display: block;
  }
  .jsavindexlabel {
    width: 100%;
    height: 25px;
    line-height: 25px;
    color: black;
    position: absolute;
    vertical-align: middle;
  }
  .jsavindex {
    box-sizing: border-box;
  }
  .jsavindex span {
    z-index: 99;
  }
  .jsavhorizontalarray .jsavindex {
    display: inline-block;
    position: relative;
  }
  /* remove right borders from everything but the last index */
  .jsavhorizontalarray .jsavindex:not(:last-of-type) {
    border-right: none;
  }
  .jsavhorizontalarray .jsavindexlabel {
    bottom: -25px;
    left: 0;
  }
  .jsavhorizontalarray .jsavindex:first-of-type {
    -ms-border-top-left-radius: 8px;
    -ms-border-bottom-left-radius: 8px;
    -moz-border-top-left-radius: 8px;
    -moz-border-bottom-left-radius: 8px;
    -o-border-top-left-radius: 8px;
    -o-border-bottom-left-radius: 8px;
    -webkit-border-top-left-radius: 8px;
    -webkit-border-bottom-left-radius: 8px;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
  }
  .jsavhorizontalarray .jsavindex:last-of-type {
    -ms-border-top-right-radius: 8px;
    -ms-border-bottom-right-radius: 8px;
    -moz-border-top-right-radius: 8px;
    -moz-border-bottom-right-radius: 8px;
    -o-border-top-right-radius: 8px;
    -o-border-bottom-right-radius: 8px;
    -webkit-border-top-right-radius: 8px;
    -webkit-border-bottom-right-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
  }
  
  .jsavbararray {
    height: 150px;
    overflow: visible;
    padding-bottom: 30px;
  }
  .jsavbararray .jsavnode {
    /* remove shadow from the white bars */
    box-shadow: none;
  } 
  .jsavbararray .jsavindex {
    height: 100%;
    vertical-align: bottom;
    border: none;
    background-color: #ddd;
    margin-left: 2px;
    float: left;
    position: relative;
  }
  .jsavbararray .jsavvalue {
    z-index: 100;
    bottom: 0;
    background-color: inherit;
    min-height: 0;
    -moz-border-radius: 0;
    -o-border-radius: 0;
    -ms-border-radius: 0;
    -webkit-border-radius: 0;
    border-radius: 0;
    /* add a subtle shadow to bars */
    box-shadow: 2px 2px 5px rgba(120, 120, 120, 0.5);
  }
  .jsavbararray .jsavvalue span {
    position: absolute;
    width: inherit;
    bottom: 0;
    left: 0;
  }
  .jsavbararray .jsavvalue, .jsavbararray .jsavvaluebar {
    display: block;
    padding: 0;
    position: absolute;
    width: 100%;
  }
  .jsavbararray .jsavvaluebar {
    height: 100%;
    top: 0;
    background-color: #fff;
  }
  .jsavbararray .jsavindexlabel {
    font-size: 90%;
    position: relative;
    top: 100%;
      vertical-align: middle;
  }
  
  /* vertical array */
  .jsavverticalarray.jsavindexed .jsavindex {
    position: relative;
  }
  .jsavverticalarray .jsavindex {
    margin-bottom: -1px;
    float: left;
    clear: left;
  }
  .jsavverticalarray .jsavindexlabel {
    position: absolute;
    text-align: right;
    width: auto;
    left: -17px;
  }
  .jsavverticalarray .jsavindex:first-of-type, .jsavverticalarray .jsavindex:first-of-type .jsavvalue {
    -ms-border-top-left-radius: 8px;
    -moz-border-top-left-radius: 8px;
    -o-border-top-left-radius: 8px;
    -webkit-border-top-left-radius: 8px;
    border-top-left-radius: 8px;
    -ms-border-top-right-radius: 8px;
    -moz-border-top-right-radius: 8px;
    -o-border-top-right-radius: 8px;
    -webkit-border-top-right-radius: 8px;
    border-top-right-radius: 8px;
  }
  .jsavverticalarray .jsavindex:last-of-type, .jsavverticalarray .jsavindex:last-of-type .jsavvalue {
    -ms-border-bottom-left-radius: 8px;
    -moz-border-bottom-left-radius: 8px;
    -o-border-bottom-left-radius: 8px;
    -webkit-border-bottom-left-radius: 8px;
    border-bottom-left-radius: 8px;
    -ms-border-bottom-right-radius: 8px;
    -moz-border-bottom-right-radius: 8px;
    -o-border-bottom-right-radius: 8px;
    -webkit-border-bottom-right-radius: 8px;
    border-bottom-right-radius: 8px;
  }
  
  /* bar array marker line */
  .jsavmark {
    position: absolute;
    display: none;
    background-color: #FF6464;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    -ms-border-radius: 10px;
    -o-border-radius: 10px;
    border-radius: 10px;
    width: 8px;
    height: 8px;
    z-index: 190;
  }
  .jsavmarkline {
    position: absolute;
    display: none;
    height:1px;
    background-color: #FF6464;
    background-color: rgba(255, 100, 100, 0.6);
    z-index: 190;
  }
  
  /***** END STYLING OF THE ARRAY DATA STRUCTURE *****/
  
  /*** OUTPUT STYLING ***/
  .jsavline {
    overflow: visible;
    border: none;
    background-color: inherit;
    height:50px;
  }
  .jsavscroll {
    overflow: auto; 
    background-color: white; 
    border: 1px solid black;
    height:220px;
  }
  .jsavoutput .jsavtitle {
    display:block;
    margin-top:2.5em;
    font-size:300%;
    text-align:center;
  }
  
  .jsavindex.jsavarrow:before {
    content: "";
    background-color: transparent;
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top: 6px solid black;
    top: -10px;
    left: 17px;
  }
  
  /**** END OUTPUT STYLING ***/
  
  .jsavcanvas svg {
    position: absolute;
    height: 100%;
    width: 100%;
    z-index: 110;
  }
  
  .jsavcontainer svg {
    pointer-events: none;
  }
  .jsavcontainer svg * {
    pointer-events: visible;
  }
  
  /**** STYLING THE CONTROLS ****/
  .jsavcontrols {
    text-align: center;
  }
  .jsavcontrols span {
    display: inline-block;
    color: #777;
    font-family: 'Times New Roman';
    font-size: 20px;
    font-weight: bolder;
    line-height: 45px;
    width: 45px;
    height: 45px;
    margin: 15px 40px;
    background-color: #fff;
    border: 1px solid #777;
    -o-border-radius: 50%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    -ms-border-radius: 50%;
    border-radius: 50%;
    cursor: pointer;
  }
  .jsavplaying span {
    cursor: default;
  }
  .jsavbegin, .jsavend {
    letter-spacing: -2px;
  }
  /**** END STYLING THE CONTROLS ****/
  
  /**** STYLING THE DIALOG ****/
  .jsavdialog {
    border: 1px solid #aaa;
    background-color: #fff;
    z-index: 1000;
    position: absolute;
    top: 0; 
    left: 0;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
  }
  .jsavsettings-dialog {
    border-radius: 10px;
  }
  .jsavsettings-dialog.arrow-top-left {
    border-top-left-radius: 0;
  }
  .jsavsettings-dialog.arrow-top-right {
    border-top-right-radius: 0;
  }
  .jsavsettings-dialog.arrow-bottom-left {
    border-bottom-left-radius: 0;
  }
  .jsavsettings-dialog.arrow-bottom-right {
    border-bottom-right-radius: 0;
  }
  .jsavsettings-dialog:after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    position: absolute;
    border: 8px solid transparent;
    border-left-color: #eee;
    transform: rotate(-90deg);
  }
  .jsavsettings-dialog.arrow-top-left:after {
    top: -16px;
    left: 0;
  }
  .jsavsettings-dialog.arrow-top-right:after {
    top: -16px;
    right: 0;
  }
  .jsavsettings-dialog.arrow-bottom-left:after,
  .jsavsettings-dialog.arrow-bottom-right:after {
    border-left-color: #fff;
    transform: rotate(90deg);
    bottom: -16px;
  }
  .jsavsettings-dialog.arrow-bottom-left:after {
    left: 0;
  }
  .jsavsettings-dialog.arrow-bottom-right:after {
    right: 0;
  }
  .jsavsettings-dialog h2 {
    border-radius: 10px 10px 0 0;
  }
  .jsavsettings-dialog.arrow-top-left h2 {
    border-radius: 0 10px 0 0;
  }
  .jsavsettings-dialog.arrow-top-right h2 {
    border-radius: 10px 0 0 0;
  }
  .jsavmodal {
    z-index: 999;
    background-color: rgb(120, 120, 120);
    background-color: rgba(0, 0, 0, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
  }
  .jsavdialog h2 {
    background-color: #eee;
    color: black;
    font-family: Helvetica, Arial;
    font-size: 1.5em;
    font-weight: bold;
    margin: 0;
    padding: 7px 15px;
    cursor: -moz-grab;
    cursor: -webkit-grab;
    cursor: grab;
  }
  .jsavdialog.ui-draggable-dragging, .jsavdialog.ui-draggable-dragging h2 {
    cursor: -moz-grabbing;
    cursor: -webkit-grabbing;
    cursor: grabbing;
  }
  a.jsavdialogclose {
    border: 1px solid #777;
    -ms-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    -o-border-radius: 20px;
    border-radius: 20px;
    color: #777;
    float: right;
    font-family: monospace;
    font-size: 30px;
    font-weight: normal;
    height: 20px;
    padding: 3px;
    text-align: center;
    text-decoration: none;
    width: 20px;
    line-height: 22px;
  }
  a.jsavdialogclose:hover {
    background-color: #ccc;
  }
  
  .jsavsettings {
    padding: 15px;
    font-family: Helvetica, Arial
  }
  a.jsavsettings {
    background-image: url(images/settings.png);
    width: 20px;
    height: 20px;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-color: #aaa;
    text-indent: 120%;
    padding: 2px;
    border: 1px solid #777;
    -o-border-radius: 3px;
    -ms-border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 50%;
    float:right; 
    margin-right:10px; 
    display:block;
    white-space: nowrap;
    overflow: hidden;
  }
  a.jsavsettings:hover {
    background-color: #888;
  }
  .jsavsettings .jsavhelp {
    font-size: 80%;
    margin-left: 40px;
  }
  .jsavsettings .jsavversion {
    float: right;
    font-size: smaller;
  }
  .jsavrow {
    margin: 15px 8px 4px 8px;
  }
  .jsavsettings label {
    display: inline;
  }
  /**** END STYLING THE DIALOG ****/
  
  /**** MODEL ANSWER ********/
  .jsavmodelanswer.jsavcontainer {
    padding: 0;
    padding-bottom: 5px;
    background-color: white;
    border-width: 0;
    border-radius: 8px;
    position: relative;
  }
  .jsavmodelanswer .jsavcounter {
    float: left;
    left: 10px;
    position: absolute;
    top: 15px;
  }
  .jsavmodelanswer .jsavcontrols span {
    margin: 5px 20px 0 0;
  }
  .jsavmodelanswer .jsavcontrols .jsavend {
    margin-right: 0;
  }
  /* move the (model answer) dialog outside of view when preparing it */
  .jsavdialog.jsavmodelpreparing {
    left: -110% !important;
  }
  
  .jsavexercisecontrols {
    position: relative;
  }
  
  .jsavexercisecontrols .actionIndicator {
    display: inline-block;
    width: 15px;
    height: 15px;
    position: absolute;
  }
  .jsavexercisecontrols.active .actionIndicator {
    background-image: url(images/spinner.gif);
  }
  /* Customized buttons */
  .jsavexercisecontrols input[type="button"] {
    background-color: #eee;
    background: linear-gradient(#fff, #ccc);
    border: 1px solid #777;
    margin: 0;
    padding: 3px 10px;
    cursor: pointer;
  }
  .jsavexercisecontrols input[type="button"]:hover {
    background-color: #ddd;
    background: linear-gradient(#fff, #bbb);
  }
  .jsavexercisecontrols input[type="button"]:last-of-type {
    border-top-right-radius: 7px;
    border-bottom-right-radius: 7px;
  }
  .jsavexercisecontrols input[type="button"]:first-of-type {
    border-top-left-radius: 7px;
    border-bottom-left-radius: 7px;
  }
  .jsavexercisecontrols input[type="button"]:not(:last-of-type) {
    border-right: none;
  }
  /********* TREE / GRAPH DATA STRUCTURE *******/
  
  .jsavtree, .jsavgraph, .jsavlist {
    position: relative;
    background-color: inherit;
  }
  .jsavtreenode, .jsavgraphnode {
    border-radius: 23px;
    position: absolute;
  }
  .jsavnullnode {
    min-width: 20px;
    border-color: #eee;
    opacity: 0;
  }
  .jsavnulledge {
    stroke: transparent;
    opacity: 0;
  }
  
  .jsavedgelabel {
    background-color: inherit;
    z-index: 700;
    position: absolute;
    display: inline-block;
    margin: 0;
  }
  
  /******** LINKED LIST STRUCTURE ******/
  .jsavpointerarea {
    background-color: #eee;
    display: block;
  }
  .jsavhorizontallist .jsavpointerarea {
    border-left: 1px solid black;
    position: absolute;
    right: 0;
    top: 0;
    width: 10px;
    height: 100%;
  }
  
  .jsavverticallist .jsavpointerarea {
    border-top: 1px solid black;
    bottom: 0;
    height: 10px;
    position: absolute;
    width: 100%;
  }
  .jsavhorizontallist.jsavautoresize .jsavnode {
    min-width: 33px;
    min-height: 45px;
    padding-right: 12px;
  }
  .jsavverticallist.jsavautoresize .jsavnode {
    min-width: 45px;
    min-height: 33px;
  }
  .jsavlistnode {
    position: absolute;
    border-radius: 3px;
  }
  .jsavverticallist .jsavlistnode .jsavpointerarea {
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
  }
  .jsavhorizontallist .jsavlistnode .jsavpointerarea {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
  }
  .jsavhorizontallist .jsavnonext .jsavpointerarea:after {
      display: inline-block;
      content: "";
      height: 104%;
      width: 1px;
      background-color: #000;
      transform: rotate(12deg);
  }
  .jsavlist .jsavedge {
    stroke-width: 2;
  }
  
  /******** PSEUDOCODE VIEW *******/
  .jsavcode {
    font-family: monospace;
  }
  ul.jsavcode {
    list-style: none;
    padding: 0;
  }
  .jsavcodeline {
    background-color: #FAFAFA;
    padding: 2px 10px;
    white-space: pre;
  }
  .jsavcodeline.jsavpreviousline {
    background-color: #eee;
  }
  .jsavcodeline.jsavcurrentline {
    background-color: #ccc;
  }
  .jsavcodeline.jsavhighlight {
    background-color: yellow;
  }
  .jsavhiddencode {
    display: none !important;
  }
  
  /******** POINTER STRUCTURE ****/
  .jsavpointer .jsavpointerarea {
    border: 1px solid black;
    height: 10px;
    width: 10px;
    margin: 0 auto;
    position: relative;
  }
  .jsavnullpointer .jsavpointerarea:after {
    content: "";
    display: block;
    width: 14px; /* sqrt(width^2+height^2) */
    height: 1px;
    position: absolute;
    right: 0;
    top: 0;
    background-color: red;
    -webkit-transform: rotate(-45deg);
    -webkit-transform-origin: right top;
    -ms-transform: rotate(-45deg);
    -ms-transform-origin: right top;
    -o-transform: rotate(-45deg);
    -o-transform-origin: right top;
    -moz-transform: rotate(-45deg);
    -moz-transform-origin: right top;
    transform: rotate(-45deg);
    transform-origin: right top;
  }
  .jsavpointer .jsavlabel {
    margin-top: 0;
    margin-bottom: 0;
  }
  
  /******** MATRIX DATA STRUCTURE ****/
  .jsavmatrix .jsavarray {
    margin: 0 auto;
    height: 30px;
    min-height: 30px;
  }
  .jsavmatrix .jsavarray li.jsavnode {
    border-radius: 0;
    width: 30px;
    height: 30px;
    font-size: 14px;
    border-top: none;
  }
  .jsavmatrix .jsavarray.jsavautoresize li.jsavnode {
    min-height: 30px;
    min-width: 30px;
    height: auto;
    width: auto;
  }
  .jsavmatrix .jsavarray .jsavvalue {
    height: 30px;
  }
  .jsavmatrix .jsavarray:first-child li {
    border-top: 1px solid black;
  }
  
  .jsavmatrix.jsavmatrixplain .jsavarray li.jsavnode, 
  .jsavmatrix.jsavmatrixmatrix .jsavarray li.jsavnode {
    border: none;
    box-shadow: none;
  }
  .jsavmatrix.jsavmatrixmatrix {
    border-left: 2px solid black;
    border-right: 2px solid black;
    border-radius: 10px;
    padding: 10px;
  }
  
  
  /******** Event prevention DIV shutter ******/
  .jsavshutter {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
  }
  .jsavplaying .jsavshutter {
    display: block;
    /* prevent text selection when playing */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  .jsavquestionframe {
    width: 100%;
    height: 100%;
  }
  
  .jsavswap, .jsavswap .jsavvalue {
    background-color: pink !important;
    color: red !important;
  }
  
  .jsavdisabled {
    pointer-events: none;
  }
  
  /******** KEY-VALUE PAIR DATA STRUCTURE ****/
  .jsav-pair-section {
    display: flex;
    margin-top: 5px;
  }
  
  .jsav-pair {
    min-width: 70%;
    position: relative;
    display: inline-block;
    text-align: center;
    margin: 0 auto;
    list-style: none;
    border: 2px solid black;
    font-size: 1.1em;
    font-family: monospace;
    box-shadow: 2px 2px 5px rgba(120, 120, 120, 0.5);
  }
  
  .jsav-pair.jsav-pair-highlight {
    background-color: green;
  }
  
  .jsav-pair-key,
  .jsav-pair-values {
    line-height: 40px;
    display: inline-block;
    box-sizing: border-box;
  }
  
  .jsav-pair-key {
    width: 40%;
    float: left;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
  }
  
  .jsav-pair-key.jsav-pair-key-highlight {
    background-color: cornflowerblue;
  }
  
  .jsav-pair-values {
    width: 60%;
    float: right;
    border-left: 2px solid black;
  }
  
  .jsav-pair-values.jsav-pair-values-highlight {
    background-color: yellow;
  }
  
  .jsav-pair:hover {
    background-color: rgba(0, 0, 0, 0.2);
    cursor: pointer;
  }
  
  .idContainer {
    width: 100px;
    height: 44px;
    color: black;
    display: inline-block;
    text-align: center;
    margin: 0 auto;
    box-sizing: border-box;
    border: 2px solid black;
  }
  
  .jsavsound {
    position:relative;
    width: 26px;
    height: 26px;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-color: #aaa;
    text-indent: 120%;
    padding: 2px;
    border: 1px solid #777;
    -o-border-radius: 3px;
    -ms-border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 50%;
    float:right;
    margin-right:10px;
    display:block;
    white-space: nowrap;
    overflow: hidden;
    z-index:500;
    outline: 0;
  }
  .jsavsound.sound {
    background-image: url(images/sound-icon.png);
  }
  .jsavsound.soundOff {
    background-image: url(images/sound-off.png);
  }
  .jsavsound.sound:hover,
  .jsavsound.soundOff:hover {
    background-color: #888;
  }
  