<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>MAGIC CAMERA</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
background: #080810;
color: white;
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
padding: 15px;
letter-spacing: 4px;
color: #e6c46c;
}
#camera {
width: 100%;
height: 65vh;
object-fit: cover;
background: #222;
}
.scene {
position: absolute;
top: 40%;
left: 50%;
width: 190px;
height: 270px;
transform: translate(-50%, -50%);
perspective: 900px;
pointer-events: none;
}
.half {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
left: 0;
top: 0;
}
.card {
width: 190px;
height: 270px;
border-radius: 12px;
background: white;
color: #d71935;
border: 2px solid #ddd;
position: relative;
box-shadow: 0 0 35px #fff8;
transform-origin: center;
}
.card.black {
color: #111;
}
.corner {
position: absolute;
top: 12px;
left: 12px;
font-size: 27px;
font-weight: bold;
}
.bottom {
top: auto;
left: auto;
right: 12px;
bottom: 12px;
transform: rotate(180deg);
}
.symbol {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 90px;
}
.hidden {
display: none;
}
.appear {
animation: appear 1.5s ease-out forwards;
}
@keyframes appear {
0% {
opacity: 0;
transform: scale(0.1) rotate(-35deg);
filter: blur(15px);
}
70% {
opacity: 1;
transform: scale(1.12) rotate(5deg);
filter: blur(0);
}
100% {
opacity: 1;
transform: scale(1) rotate(0);
}
}
.flip {
animation: flip 1s ease-in-out;
}
@keyframes flip {
0% {
transform: rotateY(0);
}
50% {
transform: rotateY(90deg);
}
100% {
transform: rotateY(0);
}
}
button {
display: block;
width: 85%;
max-width: 340px;
margin: 13px auto;
padding: 17px;
border: 0;
border-radius: 12px;
background: #d5ae55;
color: #111;
font-size: 16px;
font-weight: bold;
}
#status {
color: #e6c46c;
padding: 10px;
}
</style>
</head>
<body>
<h1>MAGIC CAMERA 🃏</h1>
<div style="position: relative">
<video id="camera" autoplay muted playsinline></video>
<div class="scene hidden" id="scene">
<div class="half">
<div class="card" id="card">
<div class="corner" id="top">7<br />♦</div>
<div class="symbol" id="symbol">♦</div>
<div class="corner bottom" id="bottom">7<br />♦</div>
</div>
</div>
</div>
</div>
<button onclick="startCamera()">ACTIVAR CÁMARA</button>
<button onclick="materialize()">✨ MATERIALIZAR</button>
<button onclick="transformCard()">♠ TRANSFORMAR</button>
<p id="status">MAGIC CAMERA PREPARADA</p>
<script>
const video = document.getElementById("camera");
const scene = document.getElementById("scene");
const card = document.getElementById("card");
const status = document.getElementById("status");
async function startCamera() {
try {
const stream = await navigator.mediaDevices.getUserMedia({
video: {
facingMode: { ideal: "environment" },
},
audio: false,
});
video.srcObject = stream;
status.textContent = "CÁMARA ACTIVADA";
} catch (e) {
status.textContent = "No se pudo abrir la cámara. Revisá los permisos y HTTPS.";
}
}
function materialize() {
scene.classList.remove("hidden");
scene.classList.remove("appear");
card.classList.remove("black");
document.getElementById("top").innerHTML = "7<br>♦";
document.getElementById("bottom").innerHTML = "7<br>♦";
document.getElementById("symbol").textContent = "♦";
void scene.offsetWidth;
scene.classList.add("appear");
status.textContent = "¡EL 7 DE DIAMANTES APARECIÓ!";
}
function transformCard() {
if (scene.classList.contains("hidden")) {
status.textContent = "Primero materializá la carta";
return;
}
card.classList.remove("flip");
void card.offsetWidth;
card.classList.add("flip");
setTimeout(() => {
card.classList.add("black");
document.getElementById("top").innerHTML = "A<br>♠";
document.getElementById("bottom").innerHTML = "A<br>♠";
document.getElementById("symbol").textContent = "♠";
status.textContent = "¡TRANSFORMACIÓN MÁGICA!";
}, 500);
}
</script>
</body>
</html>