← Public packages
@kentcdodds/space-shooter
Vertical scrolling spaceship shooter built with Three.js, playable on phone or desktop
public/style.css
153 lines · 2.5 KB · CSS:root {
color-scheme: dark;
--bg: #04050d;
--text: #e0f2fe;
--accent: #7dd3fc;
--accent-2: #f0abfc;
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
height: 100%;
background: var(--bg);
color: var(--text);
overflow: hidden;
overscroll-behavior: none;
user-select: none;
-webkit-user-select: none;
-webkit-tap-highlight-color: transparent;
}
body {
display: grid;
place-items: center;
height: 100dvh;
}
#stage {
position: relative;
width: min(100vw, calc(100dvh * 9 / 16));
aspect-ratio: 9 / 16;
overflow: hidden;
background: #05060f;
}
#game {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#stage.playing #game {
cursor: none;
}
.hud {
position: absolute;
inset: 0 0 auto;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: start;
padding: max(12px, env(safe-area-inset-top)) 14px 0;
font-size: clamp(14px, 2.4dvh, 20px);
letter-spacing: 0.05em;
pointer-events: none;
text-shadow: 0 0 8px rgb(125 211 252 / 0.6);
}
#lives {
color: var(--accent);
letter-spacing: 0.3em;
}
#high-score {
text-align: right;
opacity: 0.75;
}
.hud-buttons {
position: absolute;
top: calc(max(12px, env(safe-area-inset-top)) + 2.2em);
right: 14px;
display: flex;
gap: 8px;
}
.hud-buttons button {
padding: 6px 10px;
font-size: 12px;
opacity: 0.7;
}
button {
font: inherit;
color: var(--text);
background: rgb(125 211 252 / 0.12);
border: 1px solid rgb(125 211 252 / 0.5);
border-radius: 8px;
cursor: pointer;
}
button:hover,
button:focus-visible {
background: rgb(125 211 252 / 0.25);
outline: none;
}
.overlay {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
padding: 24px;
text-align: center;
background: rgb(4 5 13 / 0.55);
backdrop-filter: blur(2px);
animation: fade-in 0.5s ease-out;
}
.overlay[hidden] {
display: none;
}
.overlay h1 {
margin: 0;
font-size: clamp(28px, 6dvh, 48px);
letter-spacing: 0.08em;
text-transform: uppercase;
background: linear-gradient(90deg, var(--accent), var(--accent-2));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.overlay p {
margin: 0;
max-width: 36ch;
line-height: 1.6;
white-space: pre-line;
opacity: 0.85;
}
.overlay button {
padding: 12px 32px;
font-size: 18px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
@keyframes fade-in {
from {
opacity: 0;
}
}