html {
  box-sizing: border-box;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: #ffffff url('../img/geometry2.png'); /* Background pattern from Subtle Patterns */
  font-family: 'Coda', cursive;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

h1 {
  font-family: 'Open Sans', sans-serif;
  font-weight: 300;
}

/*
 * Styles for the deck of cards
 */

.deck {
  width: 660px;
  min-height: 680px;
  background: linear-gradient(160deg, #02ccba 0%, #aa7ecd 100%);
  padding: 32px;
  -webkit-border-radius: 10px;
     -moz-border-radius: 10px;
          border-radius: 10px;
  -webkit-box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.5);
     -moz-box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.5);
          box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 3em;
  list-style: none;

  /* keep perspective on entire container, needed for flip effect */
  -webkit-perspective: 1000px;
     -moz-perspective: 1000px;
          perspective: 1000px;
}

/* flipper idea and implementation obtained from David Walsh's blog */
/* see https://davidwalsh.name/css-flip */
/* flip the card when JS says so */
.flipper.flip {
  -webkit-transform: rotateY(180deg);
      -ms-transform: rotateY(180deg);
       -o-transform: rotateY(180deg);
          transform: rotateY(180deg);
}

.flipper {
  -webkit-transition: 0.3s;
    -moz-transition: 0.3s;
      -o-transition: 0.3s;
         transition: 0.3s;
  -webkit-transform-style: preserve-3d;
     -moz-transform-style: preserve-3d;
          transform-style: preserve-3d;
  position: relative;
}

.front,
.back {
  /* hide back of pane during flip */
  -webkit-backface-visibility: hidden;
     -moz-backface-visibility: hidden;
          backface-visibility: hidden;

  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  -webkit-border-radius: inherit;
     -moz-border-radius: inherit;
          border-radius: inherit;
}

.front {
  /* front pane, placed above back pane */
  z-index: 2;

  /* for firefox 31 */
  -webkit-transform: rotateY(0deg);
     -moz-transform: rotateY(0deg);
          transform: rotateY(0deg);

  background: #2e3d49;
  cursor: pointer;
}

.back {
  /* back, initially hidden */
  -webkit-transform: rotateY(180deg);
     -moz-transform: rotateY(180deg);
          transform: rotateY(180deg);

  background: #02b3e4;
  cursor: default;
  font-size: 33px;
  color: #ffffff;

  /* display contents centrally */
  display: flex;
  justify-content: center;
  align-items: center;
}

.back.match {
  background: #02ccba;
}

.deck .card {
  height: 125px;
  width: 125px;
  -webkit-border-radius: 8px;
     -moz-border-radius: 8px;
          border-radius: 8px;
  -webkit-box-shadow: 5px 2px 20px 0 rgba(46, 61, 73, 0.5);
     -moz-box-shadow: 5px 2px 20px 0 rgba(46, 61, 73, 0.5);
          box-shadow: 5px 2px 20px 0 rgba(46, 61, 73, 0.5);
}

/*
 * Styles for Difficulty Choice
 */

legend {
  text-align: center;
}

input,
label {
  cursor: pointer;
}

fieldset[disabled="true"],
fieldset[disabled="true"] input,
fieldset[disabled="true"] label {
  cursor: not-allowed;
}

/*
 * Styles for the Score Panel
 */

.score-panel {
  /* 80% of deck width */
  width: 528px;

  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  font-size: 1.5em;
}

.stars {
  /* player starts with 3 gold stars */
  color: gold;

  margin: 0;
  padding: 0;
  display: inline-block;
}

.stars.silver {
  color: silver;
}

.stars.silver .third-star {
  /* make the third star invisible */
  color: rgba(255, 255, 255, 0);
}

.stars.bronze {
  color: #a57164;
}

.stars.bronze .second-star {
  /* make the second star invisible */
  color: rgba(255, 255, 255, 0);
}

.stars li {
  list-style: none;
  display: inline-block;
}

.score-panel .move-display,
.score-panel .time-display {
  font-family: monospace;
  margin: 0;
}

.score-panel .restart {
  cursor: pointer;
}

/*
 * Styles for congrats modal
 */

.overlay {
  /* cover screen */
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;

  /* place it above all its siblings */
  z-index: 1;

  /* horizontally center the contents */
  display: flex;
  justify-content: center;

  /* initial invisible state */
  background: rgba(0,0,0,0);
  visibility: hidden;

  -webkit-transition: visibility 0.3s, background 0.3s;
     -moz-transition: visibility 0.3s, background 0.3s;
       -o-transition: visibility 0.3s, background 0.3s;
          transition: visibility 0.3s, background 0.3s;
}

.overlay.shown {
  /* when shown */
  visibility: visible;
  background: rgba(0,0,0,0.8);
}

.congrats-modal {
  text-align: center;
  border: 5px solid #09bd09;
  -webkit-border-radius: 10px;
     -moz-border-radius: 10px;
          border-radius: 10px;
  background: white;
  width: 400px;
  max-width: 80%;
  position: absolute;

  /* initially out of view */
  top: -999px;

  -webkit-transition: top 0.3s;
     -moz-transition: top 0.3s;
       -o-transition: top 0.3s;
          transition: top 0.3s;
}

.overlay.shown .congrats-modal {
  top: 100px;
}

.modal-heading {
  color: #09bd09;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.metric-title,
.metric-value {
  margin: 0.5em;

  /* vertically center the contents */
  display: flex;
  align-items: center;
}

.metric-title {
  /* the flexbox-approved version of justify-self: right */
  margin-left: auto;

  font-size: 1.3em;
}

.metric-value {
  /* the flexbox-approved version of justify-self: left */
  margin-right: auto;
}

.buttons {
  margin: 0 auto 10px;
}

.button {
  font-size: 1.1em;
}

footer {
  text-align: center;
  margin-bottom: 20px;
}
