:root {
    --pink: #ff2975;
    --magenta: #ff00ff;
    --cyan: #00ffff;
    --green: #00ff66;
    --yellow: #ffd319;
    --bg: #05030f;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    user-select: none;
    -webkit-user-select: none;
}

.crt {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 3px 100%;
}

.stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    touch-action: none;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    overflow: auto;
    text-align: center;
    background: rgba(0, 0, 0, 0.88);
}

.overlay-light {
    background: rgba(0, 0, 0, 0.55);
}

.hidden {
    display: none !important;
}

h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    color: var(--magenta);
    text-shadow: 0 0 20px var(--magenta);
}

.tagline {
    margin: 0;
    font-size: 0.75rem;
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan);
}

.hint {
    margin: 0 0 12px;
    font-size: 0.6rem;
    line-height: 1.6;
}

.note {
    margin: 0;
    max-width: 560px;
    font-size: 0.5rem;
    line-height: 1.8;
    color: #999;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.btn {
    padding: 15px 25px;
    font: inherit;
    font-size: 0.75rem;
    color: var(--cyan);
    background: none;
    border: 4px solid var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
    color: #000;
    background: var(--cyan);
}

.btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.btn:disabled {
    color: #444;
    border-color: #444;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-primary {
    color: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 10px var(--green);
}

.btn-primary:hover:not(:disabled) {
    background: var(--green);
}

.btn.active {
    color: #000;
    background: var(--yellow);
    border-color: var(--yellow);
}

.btn.done:not(.active) {
    border-color: var(--green);
    box-shadow: 0 0 10px var(--green);
}

.calibration {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.calibration-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.camera {
    position: relative;
    width: 320px;
    height: 240px;
    overflow: hidden;
    background: #111;
    border: 4px solid #fff;
}

/* The video element is only a frame source; the canvas draws the visible feed. */
.camera video {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.camera canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#avatar-canvas {
    width: 320px;
    height: 240px;
    background: #000;
    border: 2px solid rgba(255, 0, 255, 0.4);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.avatar-label {
    font-size: 0.55rem;
    letter-spacing: 2px;
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan);
}

.gesture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-wide {
    grid-column: span 2;
    margin-top: 12px;
    font-size: 1rem;
}

.status {
    min-height: 1.6em;
    max-width: 680px;
    margin: 0;
    font-size: 0.6rem;
    line-height: 1.6;
    color: var(--green);
}

.status.error {
    color: var(--pink);
}

.score-line {
    margin: 0;
    font-size: 0.9rem;
}

.score-line.best {
    font-size: 0.6rem;
    color: var(--yellow);
}

.hud {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.75rem;
    text-shadow: 0 0 8px var(--cyan);
    pointer-events: none;
}

.hud-value {
    color: var(--cyan);
}

@media (max-width: 760px) {
    h1 {
        font-size: 1.25rem;
    }

    .calibration {
        flex-direction: column;
        align-items: center;
    }

    .camera,
    #avatar-canvas {
        width: 240px;
        height: 180px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.6rem;
    }

    .hud {
        flex-wrap: wrap;
        font-size: 0.5rem;
    }
}
