270 lines
9.8 KiB
HTML
270 lines
9.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login & Register - Memory Game</title>
|
|
|
|
<style>
|
|
/* --- 1. RESET & BACKGROUND UTAMA --- */
|
|
* { box-sizing: border-box; }
|
|
|
|
body {
|
|
margin: 0;
|
|
font-family: Arial, sans-serif;
|
|
background: linear-gradient(135deg, #d9a7ff, #fbc2eb, #a1c4fd);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
overflow-x: hidden;
|
|
}
|
|
|
|
/* --- 2. CONTAINER KARTU --- */
|
|
.auth-card {
|
|
width: 380px;
|
|
background: rgba(255, 255, 255, 0.9); /* Dibuat lebih solid sedikit */
|
|
backdrop-filter: blur(12px);
|
|
border-radius: 25px;
|
|
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
overflow: hidden;
|
|
position: relative;
|
|
z-index: 10;
|
|
/* Animasi Tinggi agar mulus saat resize */
|
|
transition: height 0.4s cubic-bezier(0.25, 1, 0.5, 1);
|
|
}
|
|
|
|
.form-wrapper {
|
|
width: 100%;
|
|
}
|
|
|
|
/* --- PERBAIKAN UTAMA ADA DI SINI --- */
|
|
.forms-container {
|
|
display: flex;
|
|
width: 200%;
|
|
transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
|
|
/* PENTING: Agar form Login tidak dipaksa setinggi form Register */
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.auth-card.active .forms-container {
|
|
transform: translateX(-50%);
|
|
}
|
|
|
|
/* --- 3. STYLING FORM INDIVIDUAL --- */
|
|
form {
|
|
width: 50%;
|
|
flex-shrink: 0;
|
|
padding: 40px; /* Padding ini menentukan jarak dalam */
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
/* Hapus justify-content: center agar tinggi dihitung dari konten asli */
|
|
}
|
|
|
|
/* Typography & Inputs */
|
|
h2 {
|
|
margin: 0 0 10px;
|
|
text-align: center;
|
|
font-size: 26px;
|
|
background: linear-gradient(45deg, purple, hotpink);
|
|
-webkit-background-clip: text;
|
|
background-clip: text;
|
|
color: transparent;
|
|
}
|
|
|
|
.subtitle {
|
|
text-align: center; color: gray; font-size: 14px; margin-bottom: 25px;
|
|
}
|
|
|
|
label {
|
|
font-size: 14px; color: #444; width: 100%; margin-bottom: 6px; font-weight: bold;
|
|
}
|
|
|
|
input {
|
|
width: 100%; padding: 12px; border-radius: 12px;
|
|
border: 2px solid #ccc; background: #fafafa;
|
|
margin-bottom: 15px; font-size: 14px; transition: 0.3s;
|
|
}
|
|
|
|
input:focus { outline: none; border-color: purple; background: #fff; box-shadow: 0 0 8px rgba(128, 0, 128, 0.1); }
|
|
|
|
/* Tombol */
|
|
.btn-submit {
|
|
width: 100%; padding: 14px;
|
|
background: linear-gradient(45deg, purple, hotpink);
|
|
color: white; border-radius: 15px; border: none;
|
|
cursor: pointer; font-size: 16px; font-weight: bold;
|
|
transition: 0.25s ease; margin-top: 10px;
|
|
box-shadow: 0 4px 15px rgba(128, 0, 128, 0.2);
|
|
}
|
|
.btn-submit:hover { transform: scale(1.02); }
|
|
|
|
/* Link Switch */
|
|
.switch-text { margin-top: 20px; font-size: 14px; color: #555; }
|
|
.switch-text a { color: purple; text-decoration: none; font-weight: bold; cursor: pointer; }
|
|
.switch-text a:hover { text-decoration: underline; }
|
|
|
|
/* Error Box */
|
|
.error-box {
|
|
width: 100%; color: #d8000c; background: #ffbaba;
|
|
padding: 10px; border-radius: 10px; margin-bottom: 15px;
|
|
font-size: 13px; text-align: center; display: none;
|
|
}
|
|
|
|
/* Dekorasi (Buah & Glitter) */
|
|
.fruit { position: absolute; width: 90px; opacity: 0.85; animation: float 6s infinite ease-in-out, drift 15s infinite linear; pointer-events: none; z-index: 1; }
|
|
.f1 { top: 8%; left: 10%; width: 80px; } .f2 { top: 65%; right: 12%; } .f3 { top: 22%; right: 55%; width: 60px; }
|
|
.f4 { bottom: 15%; left: 28%; } .f5 { bottom: 10%; right: 30%; width: 70px; } .f6 { top: 40%; left: 50%; }
|
|
.f7 { bottom: 30%; left: 15%; width: 50px; } .f8 { top: 75%; right: 40%; } .f9 { top: 50%; left: 80%; width: 85px; }
|
|
.f10 { bottom: 20%; right: 5%; }
|
|
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px) rotate(6deg); } }
|
|
@keyframes drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(15px); } }
|
|
.glitter { position: absolute; width: 4px; height: 4px; background: purple; border-radius: 50%; opacity: 0; animation: glitter-burst 2s infinite ease-out; pointer-events: none; z-index: 11; }
|
|
@keyframes glitter-burst { 0% { transform: scale(0.4); opacity: 0.9; } 100% { transform: scale(1) translate(var(--x), var(--y)); opacity: 0; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<img src="images/fruit1.png" class="fruit f1"><img src="images/fruit2.png" class="fruit f2">
|
|
<img src="images/fruit3.png" class="fruit f3"><img src="images/fruit4.png" class="fruit f4">
|
|
<img src="images/fruit5.png" class="fruit f5"><img src="images/fruit6.png" class="fruit f6">
|
|
<img src="images/fruit7.png" class="fruit f7"><img src="images/fruit8.png" class="fruit f8">
|
|
<img src="images/fruit9.png" class="fruit f9"><img src="images/fruit10.png" class="fruit f10">
|
|
|
|
<div class="auth-card" id="authCard">
|
|
<div class="form-wrapper">
|
|
<div class="forms-container">
|
|
|
|
<form id="loginForm" action="auth.php" method="POST">
|
|
<h2>Selamat Datang! ✨</h2>
|
|
<p class="subtitle">Login untuk bermain</p>
|
|
|
|
<div id="loginError" class="error-box"></div>
|
|
|
|
<label>Username</label>
|
|
<input type="text" id="loginUser" name="username" placeholder="Masukan Username" required>
|
|
|
|
<label>Password</label>
|
|
<input type="password" id="loginPass" name="password" placeholder="Masukan Password" required>
|
|
|
|
<button type="submit" class="btn-submit" name="btn-login">Login Sekarang</button>
|
|
|
|
<p class="switch-text">
|
|
Belum punya akun? <a onclick="toggleAuth('register')">Daftar Sekarang</a>
|
|
</p>
|
|
</form>
|
|
|
|
<form id="registerForm" action="auth.php" method="POST">
|
|
<h2>Buat Akun Baru ✨</h2>
|
|
<p class="subtitle">Daftar petualangan baru</p>
|
|
|
|
<div id="regError" class="error-box"></div>
|
|
|
|
<label>Username</label>
|
|
<input type="text" id="regUser" name="username" placeholder="Pilih Username" required>
|
|
|
|
<label>Email</label>
|
|
<input type="email" id="regEmail" name="email" placeholder="Masukan Email" required>
|
|
|
|
<label>Password</label>
|
|
<input type="password" id="regPass" name="password" placeholder="Minimal 6 karakter" required>
|
|
|
|
<label>Konfirmasi Password</label>
|
|
<input type="password" id="regConfirm" name="confirm_password" placeholder="Ulangi Password" required>
|
|
|
|
<button type="submit" class="btn-submit" name="btn-register">Daftar Sekarang</button>
|
|
|
|
<p class="switch-text">
|
|
Sudah punya akun? <a onclick="toggleAuth('login')">Login Sekarang</a>
|
|
</p>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
/* --- LOGIC RESIZE OTOMATIS --- */
|
|
const card = document.getElementById("authCard");
|
|
const loginForm = document.getElementById("loginForm");
|
|
const registerForm = document.getElementById("registerForm");
|
|
|
|
function setHeight() {
|
|
const isActive = card.classList.contains("active");
|
|
|
|
// Hitung tinggi form yang sedang aktif
|
|
// offsetHeight akan mengambil tinggi asli konten + padding
|
|
const formHeight = isActive ? registerForm.offsetHeight : loginForm.offsetHeight;
|
|
|
|
// Terapkan tinggi ke kartu utama
|
|
card.style.height = formHeight + "px";
|
|
}
|
|
|
|
function toggleAuth(mode) {
|
|
// Hilangkan error saat pindah
|
|
document.getElementById("loginError").style.display = "none";
|
|
document.getElementById("regError").style.display = "none";
|
|
|
|
if (mode === 'register') {
|
|
card.classList.add("active");
|
|
} else {
|
|
card.classList.remove("active");
|
|
}
|
|
|
|
// Tunggu transisi slide sedikit, lalu resize
|
|
setTimeout(setHeight, 50);
|
|
}
|
|
|
|
// Jalankan saat pertama kali loading
|
|
window.addEventListener("load", setHeight);
|
|
// Jalankan jika ukuran layar browser diubah
|
|
window.addEventListener("resize", setHeight);
|
|
|
|
|
|
/* --- LOGIC SUBMIT (PHP) --- */
|
|
loginForm.addEventListener("submit", function(e) {
|
|
const username = document.getElementById("loginUser").value.trim();
|
|
const password = document.getElementById("loginPass").value.trim();
|
|
if (!username || !password) {
|
|
e.preventDefault();
|
|
showMsg(document.getElementById("loginError"), "Isi semua data!");
|
|
}
|
|
});
|
|
|
|
registerForm.addEventListener("submit", function(e) {
|
|
const pass = document.getElementById("regPass").value.trim();
|
|
const confirm = document.getElementById("regConfirm").value.trim();
|
|
if (pass.length < 6) {
|
|
e.preventDefault();
|
|
showMsg(document.getElementById("regError"), "Password minimal 6 karakter!");
|
|
} else if (pass !== confirm) {
|
|
e.preventDefault();
|
|
showMsg(document.getElementById("regError"), "Password tidak cocok!");
|
|
}
|
|
});
|
|
|
|
function showMsg(element, msg) {
|
|
element.innerText = msg;
|
|
element.style.display = "block";
|
|
setHeight(); // Resize ulang jika pesan error muncul
|
|
}
|
|
|
|
/* Glitter Effect */
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const card = document.querySelector(".auth-card");
|
|
for (let i = 0; i < 15; i++) {
|
|
const g = document.createElement("div");
|
|
g.className = "glitter";
|
|
g.style.setProperty("--x", (Math.random() * 200 - 100) + "px");
|
|
g.style.setProperty("--y", (Math.random() * 200 - 100) + "px");
|
|
g.style.left = (Math.random() * 100) + "%";
|
|
g.style.top = (Math.random() * 100) + "%";
|
|
g.style.animationDelay = (Math.random() * 2) + "s";
|
|
card.appendChild(g);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |