JS-Games/space-drifter/styles.css

298 lines
4.4 KiB
CSS
Raw Normal View History

2023-12-02 19:45:57 +01:00
@import url("https://fonts.googleapis.com/css2?family=Audiowide&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Audiowide", serif;
line-height: 1;
}
html,
body {
width: 100%;
height: 100%;
}
body {
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background-color: hsl(0, 0%, 5%);
color: hsl(0, 0%, 95%);
user-select: none;
}
.canvasWrapper {
max-width: 95%;
max-height: 95%;
aspect-ratio: 16 / 9;
border: 2px solid hsl(0, 0%, 10%);
background-color: black;
position: relative;
display: flex;
background-image: url(assets/stars.png);
background-position: center center;
background-size: 50vmin;
}
canvas {
width: 100%;
height: 100%;
}
#score {
position: absolute;
top: 0;
right: 0;
color: white;
padding: 1.5vmin;
font-size: 3vmin;
line-height: 1;
}
#splash,
#gameOver,
#paused {
position: fixed;
width: 100%;
height: 100%;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background-image: url(assets/stars.png);
background-position: center center;
background-size: 50vmin;
z-index: 1;
transition: opacity 0.5s;
}
#splash.hidden,
#gameOver.hidden,
#paused.hidden {
opacity: 0;
pointer-events: none;
}
.innerWrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 3vmin;
}
#splash h1,
#gameOver h2,
#paused h2 {
font-size: 10vmin;
}
#paused h2 {
animation: twinkle 2s linear infinite;
}
@keyframes twinkle {
from {
opacity: 1;
}
45% {
opacity: 0.3333;
}
90% {
opacity: 1;
}
to {
opacity: 1;
}
}
#gameOver h3 {
font-size: 3vmin;
}
#paused p {
font-size: 3vmin;
}
button {
padding: 1.5vmin;
background-color: transparent;
color: inherit;
font-size: 1.5vmin;
outline: 0;
border: 2px solid hsl(0, 0%, 25%);
cursor: pointer;
position: relative;
margin-top: 1em;
}
button span {
opacity: 0.5;
transition: opacity 0.5s;
text-transform: uppercase;
}
button .line {
position: absolute;
background-color: white;
transition: transform 1s;
}
button .top,
button .bottom {
width: calc(100% + 4px);
height: 2px;
transform: scaleX(0);
}
button .left,
button .right {
width: 2px;
height: calc(100% + 4px);
transform: scaleY(0);
}
button .top {
top: -2px;
left: -2px;
transform-origin: left;
}
button .bottom {
bottom: -2px;
right: -2px;
transform-origin: right;
}
button .left {
left: -2px;
bottom: -2px;
transform-origin: bottom;
}
button .right {
right: -2px;
top: -2px;
transform-origin: top;
}
button:is(:hover, :focus, :active) .top,
button:is(:hover, :focus, :active) .bottom {
transform: scaleX(1);
}
button:is(:hover, :focus, :active) .left,
button:is(:hover, :focus, :active) .right {
transform: scaleY(1);
}
button:is(:hover, :focus, :active) span {
opacity: 1;
}
button:is(:hover, :focus, :active) span,
button:is(:hover, :focus, :active) .line {
transition-delay: 0.25s;
}
.controls {
margin-top: 5vmin;
border: 1px solid hsl(0, 0%, 50%);
background-color: hsl(0, 0%, 7.5%);
padding: 2vmin 4vmin 3vmin;
}
.controls h3 {
margin-bottom: 3vmin;
text-align: center;
font-size: 3vmin;
}
dl {
display: grid;
grid-template-columns: 1fr auto;
font-size: 2vmin;
gap: 3vmin 1.5vmin;
}
dt,
dd {
display: flex;
align-items: center;
gap: 1.5vmin;
}
dt {
justify-content: flex-start;
}
dd {
justify-content: center;
}
.wasd {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
gap: 0.5vmin;
grid-template-areas:
". w ."
"a s d";
}
.wasd kbd:nth-child(1) {
grid-area: w;
}
.wasd kbd:nth-child(2) {
grid-area: a;
}
.wasd kbd:nth-child(3) {
grid-area: s;
}
.wasd kbd:nth-child(4) {
grid-area: d;
}
kbd {
display: inline-block;
vertical-align: middle;
white-space: nowrap;
line-height: 1;
padding: 0.2em 0.4em;
font-size: 0.9em;
color: hsl(0, 0%, 20%);
background-color: hsl(0, 0%, 90%);
border: 1px solid hsl(0, 0%, 80%);
border-radius: 0.25em;
box-shadow: 0 0.05em 0 hsla(0, 0%, 0%, 20%),
0 0.1em 0 hsla(0, 0%, 100%, 50%) inset;
}
#splash footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
padding: 2vmin;
color: hsl(0, 0%, 60%);
}
a {
color: inherit;
outline: 0;
transition: color 0.5s;
}
a:hover,
a:active,
a:focus {
color: hsl(0, 0%, 100%);
}