#container {
  --base-color: white;
  --highlight-color: red;
  --base-font-size: 16px;

  position: relative;
  color: var(--base-color);
  font-family: sans;
}

#container:-webkit-full-screen {
  width: 100%;
  height: 100%;
}

/* components {{{ */

/* background switcher {{{ */
#background {
  background-color: black;
}

#background div {
  position: absolute;
  height: 100%;
  width: 100%;
  opacity: 0;
  transition: opacity 0.5s linear;
  background-size: cover;
}

#background div.image {
  filter: brightness(70%) contrast(70%);
}

#background div.show {
  opacity: 1;
}
/* }}} */

/* progress bar {{{ */
.progress-bar {
  position: relative;
  height: 0.3125em;
}

.progress-bar .bg {
  position: absolute;
  width: 100%;
  height: 0.3125em;
  background-color: var(--base-color);
  opacity: 0.5;
}

.progress-bar .shade {
  position: absolute;
  height: 0.3125em;
  background-color: var(--base-color);
  animation-timing-function: linear;
  animation-play-state: paused;
}

@keyframes progress {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* }}} */

/* }}} */

/* main layout {{{ */

/* base {{{ */

#container {
  display: grid;
  grid-template-columns: [start] 18.75em [left] auto [right] 18.75em [end];
  grid-template-rows: [top] 3.125em [header] auto [game] 11.25em [bottom];

  font-size: var(--base-font-size);
  height: 450px;
  width: 800px;
  margin: 0 auto;
  overflow: hidden;
}

#container > div {
  overflow: hidden;
  position: relative;
  transition: top 0.5s, left 0.5s, opacity 0.5s;
  opacity: 0;
}

#container #background {
  opacity: 1;
  grid-column: start / end;
  grid-row: top / bottom;
}

#loading {
  grid-column: start / end;
  grid-row: top / bottom;
  align-self: center;
  justify-self: center;
}

#song-info {
  grid-column: start / right;
  grid-row: header / game;
  left: -31.25em;
}

#song-list {
  grid-column: right / end;
  grid-row: top / bottom;
  left: 18.75em;
}

#folder-info {
  grid-column: start / left;
  grid-row: top / header;
  left: -31.25em;
}

#game {
  top: 11.25em;
  grid-column: start / end;
  grid-row: game / bottom;
}

#score {
  grid-column: start / left;
  grid-row: header / bottom;
  left: -18.75em;
}

#loader {
  top: -3.125em;
  grid-column: right / end;
  grid-row: top / header;
}

#ready {
  grid-column: start / end;
  grid-row: top / bottom;
  align-self: center;
  justify-self: center;
}

/* }}} */

/* loading {{{ */

#container.loading #loading {
  opacity: 1;
}

#container.loading #loading.finished {
  opacity: 0;
}

#container.loading #song-info,
#container.loading #folder-info {
  top: 3.125em;
  left: 0;
}

#container.loading #song-list {
  left: 3.125em;
}

/* }}} */

/* select {{{ */

#container.select #song-info,
#container.select #folder-info {
  opacity: 1;
  top: 0;
  left: 0;
}

#container.select #song-list {
  opacity: 1;
  left: 0;
}

/* }}} */

/* game {{{ */

#container.game #folder-info {
  opacity: 1;
  top: 0;
  left: 0;
}

#container.game #song-info {
  opacity: 1;
  top: -9.375em;
  left: 0;
}

#container.game.game-loading #loader {
  opacity: 1;
  top: 0;
}

#container.game.game-loading #ready {
  opacity: 1;
}

#container.game.game-playing #game {
  opacity: 1;
  top: 0;
}

#container.game.game-finished #score {
  opacity: 1;
  left: 0;
}

/* }}} */

/* }}} */

/* sub layouts {{{ */

/* select-screen {{{ */

/* folder-info {{{ */

#folder-info {
  display: flex;
  flex-direction: row;
  align-items: center;
}

#folder-info .left:hover,
#folder-info .right:hover {
  text-shadow: 0em 0em 0.3125em var(--base-color);
}

#folder-info .material-icons {
  font-size: 1.5em;
}

/* }}} */

/* song-info {{{ */

#song-info {
  display: grid;
}

.song-info {
  align-self: end;
  margin-left: 1.25em;
  text-shadow: 0em 0em 0.3125em var(--base-color);
}

.song-info .genre {
  font-size: 0.75em;
}

.song-info .creator {
  font-size: 1.25em;
  line-height: 0.5;
}

.song-info .title {
  font-size: 1.875em;
}

/* }}} */

/* song-list {{{ */

.song-list {
  margin-left: 1.25em;
  transition: margin-top 0.2s;
}

.song-item {
  height: 2.5em;
  display: grid;
  grid-template-columns: 2.5em auto;
  grid-template-rows: 1em 1.5em;
  grid-template-areas:
    "diff creator"
    "diff title";
  transition: margin-left 0.2s;
}

.song-item div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.song-item .difficulty {
  grid-area: diff;
  align-self: end;
  justify-self: end;
  margin-bottom: 0.375em;
  margin-right: 0.375em;
  font-style: italic;
  font-weight: bold;
  text-shadow: none;
}

.song-item .difficulty-bg {
  grid-area: diff;
  align-self: center;
  justify-self: center;
  height: 1.875em;
  width: 1.875em;
  background: radial-gradient(circle at 10% 10%, rgba(0, 255, 255, 1), transparent);
  border-radius: 20%;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.song-item .difficulty-bg.normal {
  background: radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.6), transparent);
  opacity: 1;
}

.song-item:hover {
  text-shadow: 0em 0em 0.3125em var(--base-color);
}

.song-item.selected {
  margin-left: -0.625em;
  text-shadow: 0em 0em 0.3125em var(--base-color);
}

.song-item.selected .difficulty-bg {
  opacity: 1;
  box-shadow: -0.0625em -0.0625em 0.625em -0.125em var(--base-color);
}

.song-item.selected .difficulty-bg.normal {
  opacity: 0;
}

.song-item .creator {
  grid-area: creator;
  font-size: 0.75em;
}

.song-item .title {
  grid-area: title;
  font-size: 1.25em;
}

/* }}} */

/* }}} */

/* game-screen {{{ */

/* loading-screen {{{ */

#loader {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#loader .progress-bar {
  width: 80%;
}

#loader .progress-bar .shade {
  transition: width 0.2s;
}

#ready {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#ready .status {
  font-size: 1.875em;
}

#ready .message {
  font-size: 0.875em;
}

/* }}} */

/* track-progress {{{ */

.track-progress {
  display: grid;
  grid-template-columns: max-content auto;
  grid-template-rows: 50% 50%;
  grid-template-areas:
    "tl tb"
    "il ib";
  grid-gap: 0em 0.625em;
  align-items: center;
  align-self: end;
}

.track-progress .total-label,
.track-progress .interval-label {
  justify-self: right;
  font-variant-caps: small-caps;
  font-size: 0.75em;
}

.track-progress .total-label {
  grid-area: tl;
}

.track-progress .interval-label {
  grid-area: il;
  justify-self: right;
}

.track-progress .total {
  grid-area: tb;
}

.track-progress .interval {
  grid-area: ib;
}


/* }}} */

/* typing area {{{ */

#game {
  display: grid;
  grid-template-columns: 3.125em 3.125em auto;
  grid-template-rows: 2.5em 1.5em 0.75em 1.875em auto 1.375em;
  grid-template-areas:
    ". . track"
    "score score score"
    ". . kana"
    ". . kanji"
    "romaji-first romaji romaji"
    ". . stats";
  grid-row-gap: 0.125em;
  padding: 0.125em 1.25em;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

#game .track-progress {
  grid-area: track;
}

#game .score-line {
  grid-area: score;
}

#game .kana-line {
  grid-area: kana;
  margin-left: 0.9375em;
}

#game .kanji-line {
  grid-area: kanji;
  padding-left: 0.3125em;
  border-bottom: solid 0.125em rgba(255, 255, 255, 0.5);
  border-left: solid 0.625em rgba(255, 255, 255, 0.5);
  border-radius: 0em 0em 0em 0.625em;
}

#game .stats-line {
  grid-area: stats;
}

#game .romaji-first,
#game .romaji-line {
  text-transform: uppercase;
  align-self: baseline;
  line-height: 1;
}

#game .romaji-first {
  grid-area: romaji-first;
  justify-self: right;
  font-size: 2.25em;
  padding: 0em 0.05ex;
}

#game .romaji-line {
  grid-area: romaji;
  font-size: 1.25em;
}

#game .romaji-first.error {
  animation: pulse 0.2s;
}


/* }}} */

/* score area {{{ */

.score-line {
  display: flex;
}

.score-line .pair,
.stats-line .pair {
  margin: 0em 0.25em;
  border-bottom: solid 0.125em rgba(255, 255, 255, 0.5);
  border-radius: 0.125em;
}

.score-line .pair span,
.stats-line .pair span {
  text-align: right;
  padding: 0em 0.25em;
}

.score-line .combo {
  flex: none;
  width: 6.25em;
  text-align: left;
}

.score-line .pair {
  flex: 1;
  display: flex;
}

.stats-line {
  display: flex;
  justify-content: flex-end;
}

.stats-line .pair span {
  font-size: 0.875em;
}

.stats-line .pair .value {
  display: inline-block;
  min-width: 3.125em;
}

/* }}} */

/* score screen {{{ */

#score {
  display: grid;
  grid-template-columns: max-content auto;
  align-items: baseline;
  align-content: end;
  grid-gap: 0.3125em;
  padding: 1.25em;
}

#score .class,
#score .score {
  text-shadow: 0em 0em 0.3125em var(--highlight-color);
}

#score .class {
  font-size: 2.5em;
}

#score .score {
  font-size: 1.5em;
}

/* }}} */

.kana {
  display: inline-block;
  position: relative;
  white-space: pre;
  font-size: 0.75em;
}

.kana::after {
  display: inline-block;
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--highlight-color);
  font-weight: bold;
  overflow: hidden;
  width: 0em;
  transition: width 0.1s;
}

.kana.half::after {
  width: 50%;
}

.kana.full::after {
  width: 100%;
}

@keyframes pulse {
  0% {
    color: var(--base-color);
  }
  50% {
    color: red;
  }
  100% {
    color: var(--base-color);
  }
}

#game.waiting .kana-line,
#game.waiting .kanji-line {
  opacity: 0.5;
}

#game.waiting .romaji-first,
#game.waiting .romaji-line {
  color: transparent;
}

/* }}} */

/* }}} */