@font-face {
  font-family: "Roboto Slab";
  src: url("/assets/RobotoSlab-Regular.ttf?v=1.5.3");
}

@font-face {
  font-family: "Roboto Mono";
  src: url("/assets/RobotoMono-Regular.ttf?v=1.5.3");
}

:root {
  --color-bg: #fff;
  --color-bg-trans: rgba(255, 255, 255, 0.9);
  --color-text: #4a4a4a;
  --color-grey: #878787;
  --color-button: hsl(0, 0%, 95%);
  --color-button-hover: hsl(0, 0%, 88%);
  --color-tab-hover: rgba(0, 0, 0, 0.05);
  --color-clock-hand: #e50000;
  --color-gold: hsl(47, 100%, 65%);
  --color-gold-light: hsl(48, 100%, 80%);
  --color-silver: hsl(0, 0%, 80%);
  --color-silver-light: hsl(0, 0%, 90%);
  --color-bronze: hsl(18deg 89% 70%);
  --color-bronze-light: hsl(14deg 100% 82%);

  --color-scrollbar-track: #f0f0f0;
  --color-scrollbar-thumb: #cdcdcd;
  --color-scrollbar-thumb-hover: #a6a6a6;
  --color-scrollbar-thumb-active: #606060;
}

:root.dark {
  --color-bg: #242424;
  --color-bg-trans: rgba(36, 36, 36, 0.95);
  --color-text: #dfdfdf;
  --color-grey: #a7a7a7;
  --color-button: hsl(0, 0%, 20%);
  --color-button-hover: hsl(0, 0%, 30%);
  --color-tab-hover: rgba(255, 255, 255, 0.1);
  --color-clock-hand: #f36565;
  --color-gold: hsl(47, 100%, 65%);
  --color-gold-light: hsl(48, 100%, 80%);
  --color-silver: hsl(0, 0%, 80%);
  --color-silver-light: hsl(0, 0%, 90%);
  --color-bronze: hsl(18deg 89% 70%);
  --color-bronze-light: hsl(14deg 100% 82%);

  --color-scrollbar-track: #272520;
  --color-scrollbar-thumb: #7b7a77;
  --color-scrollbar-thumb-hover: #686765;
  --color-scrollbar-thumb-active: #474543;
}

* {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 16px;
  font-family: "Roboto Slab", sans-serif;
  box-sizing: border-box;
}

*:not(svg *) {
  color: var(--color-text);
}

html {
  color-scheme: light dark;
}

body {
  background-color: var(--color-bg);
  overflow-y: scroll;
}

header {
  position: relative;
  margin: 50px auto 30px;
  padding-inline: 10px;
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-between;
}

header .group {
  display: flex;
  align-items: center;
  gap: 10px;
}

header button {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 50px;
  height: 40px;
  padding: 9px 20px 10px;
  font-weight: bold;
  letter-spacing: 0.5px;
  word-spacing: 2px;
  text-decoration: none;
  background-color: var(--color-button);
  border-radius: 4px;
  cursor: pointer;
}

header button svg {
  flex-shrink: 0;
  width: 20px;
  fill: var(--color-text);
  transition:
    fill 0.2s,
    rotate 0.2s;
}

header button svg.reload-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

header button input[type="checkbox"] {
  display: none;
}

header button input[type="checkbox"]:checked ~ svg {
  rotate: 360deg;
}

header button:disabled {
  cursor: auto;
}

header a:hover,
button:not(:disabled):hover,
button.open {
  background-color: var(--color-button-hover);
}

header .group h1.title,
header .group h1.leaderboard {
  position: absolute;
  left: 50%;
  translate: -50% 0;
}

header .group h1.title .alternating {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  width: max-content;
  background-color: var(--color-bg);
  opacity: 0;
  animation: blink 5s 2s infinite steps(1) alternate;
}

@keyframes blink {
  0%,
  50% {
    opacity: 0;
  }
  50%,
  100% {
    opacity: 1;
  }
}

header .group h1.leaderboard {
  display: none;
}

.turns-box,
.time-box {
  display: none;
  gap: 7px;
}

.turns-box {
  margin-right: 40px;
}

#turns {
  min-width: 20px;
  text-align: right;
  font-weight: bold;
}

#turns-keyword {
  width: 35px;
}

.time-box {
  margin-top: 2px;
}

.time-box .clock {
  width: 20px;
  height: 20px;
  fill: var(--color-text);
}

.time-box .clock circle {
  fill: none;
  stroke: var(--color-text);
  stroke-width: 1.5px;
}

.time-box .clock .hand {
  fill: none;
  stroke: var(--color-clock-hand);
  stroke-width: 1px;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: bottom;
}

.time-box .clock .hand-dot {
  fill: var(--color-clock-hand);
  stroke: none;
}

#time {
  width: 70px;
  font-family: "Roboto Mono", monospace;
}

#playground {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 680px;
  aspect-ratio: 1 / 1;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: calc(100vh - 120px);
  height: calc(100dvh - 120px);
  background-color: var(--color-bg-trans);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#leaderboard-tabs {
  width: 100%;
  max-width: 470px;
  margin: auto;
  margin-bottom: 30px;
  padding-inline: 10px;
  display: flex;
}

#leaderboard-tabs li {
  width: 100%;
  list-style: none;
}

#leaderboard-tabs button {
  width: 100%;
  padding: 10px;
  word-spacing: 2px;
  font-size: 14px;
  background-color: transparent;
  cursor: pointer;
}

#leaderboard-tabs button span {
  font-size: 14px;
}

#leaderboard-tabs button:hover {
  background-color: var(--color-tab-hover);
}

#leaderboard-tabs button[aria-selected="true"] {
  box-shadow: inset 0 -3px var(--color-text);
}

#leaderboard {
  padding: 15px 15px 15px 10px;
  display: none;
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  list-style-type: none;
  width: 455px;
  margin: 20px auto 30px;
  height: calc(100vh - 280px);
  height: calc(100dvh - 280px);
  overflow-y: auto;
  scrollbar-gutter: stable;
  --scrollbar-width: 10px;
  --mask-height: 15px;
  mask-image: linear-gradient(
      to bottom,
      transparent,
      black var(--mask-height),
      black calc(100% - var(--mask-height)),
      transparent
    ),
    linear-gradient(black, black);
  mask-size:
    calc(100% - var(--scrollbar-width)) 100%,
    var(--scrollbar-width) 100%;
  mask-position:
    0 0,
    100% 0;
  mask-repeat: no-repeat, no-repeat;
  @-moz-document url-prefix() {
    scrollbar-width: thin;
  }
}

#leaderboard::-webkit-scrollbar {
  width: 8px;
  height: initial;
}

#leaderboard::-webkit-scrollbar-track {
  background-color: var(--color-scrollbar-track);
}

#leaderboard::-webkit-scrollbar-thumb {
  background-color: var(--color-scrollbar-thumb);
}

#leaderboard::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-scrollbar-thumb-hover);
}

#leaderboard::-webkit-scrollbar-thumb:active {
  background-color: var(--color-scrollbar-thumb-active);
}

#leaderboard li {
  display: grid;
  grid-template-columns: 30px 140px 80px auto;
  align-items: baseline;
  gap: 20px;
  padding: 0 15px 10px 0;
}

#leaderboard li:not(:last-child) {
  border-bottom: 1px solid var(--color-button-hover);
}

#leaderboard li span:first-child {
  position: relative;
  text-align: right;
}

#leaderboard li:first-child span:first-child {
  margin-right: 1px;
}

#leaderboard li span:first-child::after {
  content: ".";
  position: absolute;
  left: 12px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  z-index: -1;
}

#leaderboard li:nth-child(-n + 3) span:first-child {
  color: #4a4a4a;
  text-shadow: 0 0 6px white;
}

#leaderboard li:first-child span:first-child::after {
  content: "";
  top: -3px;
  background-color: var(--color-gold);
  border: 2px solid var(--color-gold-light);
  box-shadow:
    inset 1px 1px rgba(0, 0, 0, 0.1),
    2px 2px 2px 0 rgba(0, 0, 0, 0.1),
    1px 1px var(--color-gold);
}

#leaderboard li:nth-child(2) span:first-child::after {
  content: "";
  top: -3px;
  background-color: var(--color-silver);
  border: 2px solid var(--color-silver-light);
  box-shadow:
    inset 1px 1px rgba(0, 0, 0, 0.1),
    2px 2px 2px rgba(0, 0, 0, 0.05),
    1px 1px var(--color-silver);
}

#leaderboard li:nth-child(3) span:first-child::after {
  content: "";
  top: -3px;
  background-color: var(--color-bronze);
  border: 2px solid var(--color-bronze-light);
  box-shadow:
    inset 1px 1px rgba(0, 0, 0, 0.15),
    2px 2px 2px rgba(0, 0, 0, 0.1),
    1px 1px var(--color-bronze);
}

#leaderboard li span.username {
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#leaderboard li span.moves,
#leaderboard li span.time {
  text-align: right;
}

#leaderboard li b {
  text-align: right;
}

#leaderboard li span.time .clock {
  width: 14px;
  height: 14px;
  vertical-align: -1px;
  margin-inline: 8px 4px;
  color: var(--color-grey);
}

#leaderboard li span.time span {
  font-size: 15px;
  font-family: "Roboto Mono", monospace;
  text-align: right;
}

#leaderboard .empty {
  margin-inline: auto;
}

#overlay #loading {
  position: absolute;
  inset: 50%;
  translate: -50% -50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--color-grey);
  border-top-color: transparent;
  pointer-events: none;
  rotate: 0deg;
  animation: rotate 1s infinite linear;
}

@keyframes rotate {
  to {
    rotate: 360deg;
  }
}

#overlay #note {
  display: none;
  text-align: center;
  font-size: 13px;
  color: var(--color-grey);
}

#cards {
  width: 100%;
  height: 100%;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.card {
  display: inline-block;
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 400px;
  transition: opacity 0.5s;
}

html.dark .card {
  filter: brightness(0.9);
}

.card-inner {
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  border: 6px solid white;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  overflow: hidden;
  background-color: #fdce2d;
  background-size: 105% 105%;
  background-position: center;
  background-repeat: no-repeat;
}

.card-face.back {
  background-image: url("/assets/img/PEX3_balet.png?v=1.5.3");
}

.card-face.front {
  transform: rotateY(180deg);
  box-shadow: inset 0 0 100px transparent;
  transition: box-shadow 0.3s;
}

.credit {
  margin: 40px auto 20px;
  text-align: center;
  width: 100%;
  max-width: 680px;
  letter-spacing: 0px;
  word-spacing: 6px;
}

.credit a {
  text-decoration: none;
}

.credit a:hover {
  text-decoration: underline;
}

@media screen and (max-width: 700px) {
  header {
    margin-block: 10px 20px;
  }
  .wide {
    display: none;
  }
  .credit {
    margin-block: 30px 20px;
  }
  #overlay {
    height: calc(100vh - 70px);
    height: calc(100dvh - 70px);
  }
  #leaderboard-tabs {
    margin-block: 10px 30px;
  }
}

@media screen and (max-width: 600px) {
  .alternating {
    display: none;
  }
  #cards {
    gap: 10px;
  }
  .card-inner {
    border-width: 4px;
    border-radius: 2px;
  }
}

@media screen and (max-width: 500px) {
  header button {
    padding: 9px 10px 10px;
    min-width: unset;
  }
  .turns-box {
    margin-right: 0;
  }
  .turns-box #turns,
  .turns-box #turns-keyword,
  .time-box #time {
    font-size: 14px;
  }
  .time-box #time {
    width: 60px;
  }
  .time-box {
    align-items: center;
  }
  .time-box .clock {
    width: 16px;
    height: 16px;
  }
  #cards {
    gap: 5px;
  }
  .card-inner {
    border-width: 3px;
    border-radius: 0;
  }
  #leaderboard-tabs {
    margin-block: 10px 20px;
  }
  #leaderboard-tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  #leaderboard {
    width: calc(100% - 20px);
    padding-inline: 0;
  }
  #leaderboard * {
    font-size: 14px !important;
  }
  #leaderboard li {
    width: calc(100% - 10px);
    grid-template-columns: 20px auto 65px 80px;
    gap: 10px;
    padding-right: 5px;
  }
  #leaderboard li:first-child span:first-child::after,
  #leaderboard li:nth-child(2) span:first-child::after,
  #leaderboard li:nth-child(3) span:first-child::after {
    top: -2px;
  }
  #leaderboard li span:first-child::after {
    left: 5px;
    width: 18px;
    height: 18px;
  }
  #leaderboard li span.username {
    margin-left: 5px;
  }
  #leaderboard li span.time .clock {
    margin-inline: 0 2px;
  }
}
