<style>
#age-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.85);
z-index: 99999;
display: flex;
align-items: center;
justify-content: center;
}
#age-box {
background: #1f1f1f;
color: #fff;
padding: 30px;
max-width: 420px;
width: 90%;
text-align: center;
border-radius: 10px;
box-shadow: 0 0 30px rgba(0,0,0,.6);
}
#age-box h2 {
margin-bottom: 15px;
}
#age-box button {
margin: 10px;
padding: 10px 20px;
font-size: 15px;
cursor: pointer;
border: none;
border-radius: 6px;
}
#age-yes {
background: #2ecc71;
color: #000;
}
#age-no {
background: #e74c3c;
color: #fff;
}
</style>
<div id="age-overlay" style="display:none;">
<div id="age-box">
<h2>Подтвердите возраст</h2>
<p>Данный форум предназначен для пользователей старше 18 лет.</p>
<button id="age-yes">Мне есть 18</button>
<button id="age-no">Мне нет 18</button>
</div>
</div>
<script>
(function () {
if (localStorage.getItem('age_verified') === 'yes') return;
var overlay = document.getElementById('age-overlay');
overlay.style.display = 'flex';
document.getElementById('age-yes').onclick = function () {
localStorage.setItem('age_verified', 'yes');
overlay.remove();
};
document.getElementById('age-no').onclick = function () {
window.location.href = 'https://www.google.com';
};
})();
</script>