:root {
    --bg-top: #071325;
    --bg-bottom: #030913;
    --text: #d9ecff;
}

* {
    box-sizing: border-box;
}

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

body {
    color: var(--text);
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    background:
        radial-gradient(circle at 18% 15%, rgba(72, 161, 255, 0.34), transparent 36%),
        radial-gradient(circle at 82% 78%, rgba(40, 84, 255, 0.24), transparent 34%),
        linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

.canvas-wrapper {
    position: absolute;
    inset: 0;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(180deg, rgba(5, 16, 33, 0.98), rgba(6, 10, 19, 0.98));
}

.top-ui {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(980px, calc(100% - 28px));
    pointer-events: none;
    z-index: 12;
}

.game-title {
    margin: 0 0 8px;
    text-align: center;
    font-family: "Press Start 2P", cursive;
    font-size: clamp(0.72rem, 1.5vw, 1.06rem);
    color: #85dcff;
    text-shadow: 0 0 14px rgba(120, 220, 255, 0.72);
}

.hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.hud-card {
    border: 1px solid rgba(110, 185, 255, 0.42);
    border-radius: 10px;
    padding: 6px 8px;
    text-align: center;
    font-size: 0.68rem;
    background: rgba(7, 21, 40, 0.72);
    backdrop-filter: blur(2px);
}

.hud-card span {
    font-weight: 700;
    color: #a9f3ff;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    justify-content: center;
    background: rgba(1, 8, 16, 0.78);
    z-index: 20;
}

.hidden {
    display: none;
}

#overlay-message {
    margin: 0;
    font-family: "Press Start 2P", cursive;
    font-size: clamp(0.75rem, 2.7vw, 1.2rem);
    color: #b8f6ff;
    text-align: center;
    white-space: pre-line;
}

#restart-btn {
    border: 1px solid rgba(141, 217, 255, 0.66);
    background: linear-gradient(135deg, rgba(20, 90, 141, 0.92), rgba(43, 141, 175, 0.95));
    color: #fff;
    font-family: "Press Start 2P", cursive;
    font-size: 0.72rem;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
}

.back-link {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    z-index: 30;
    text-decoration: none;
    color: rgba(166, 217, 255, 0.9);
    font-family: "Press Start 2P", cursive;
    font-size: 0.52rem;
    letter-spacing: 0.02em;
    opacity: 0.82;
}

.back-link:hover {
    opacity: 1;
}

.game-meta {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 0.5rem;
    line-height: 1.25;
    color: rgba(185, 211, 237, 0.72);
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

@media (max-width: 760px) {
    .game-title {
        margin-bottom: 6px;
    }

    .hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hud-card {
        font-size: 0.6rem;
        padding: 5px 6px;
    }

    .back-link {
        font-size: 0.48rem;
    }

    .game-meta {
        font-size: 0.46rem;
    }
}
