from pathlib import Path
import re
src = Path("/mnt/data/wb-school-hunt-exact.html")
html = src.read_text(encoding="utf-8")
# Add CSS for restart screen before closing
restart_css = r"""
.restart-screen {
position:absolute;
inset:0;
z-index:30;
display:flex;
align-items:center;
justify-content:center;
padding:8%;
background:
radial-gradient(circle at 22% 18%, rgba(249,4,121,.14), transparent 24%),
radial-gradient(circle at 78% 30%, rgba(127,48,227,.16), transparent 28%),
linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,248,253,.98));
opacity:0;
visibility:hidden;
pointer-events:none;
transition:opacity .25s ease, visibility .25s ease;
}
.restart-screen.show {
opacity:1;
visibility:visible;
pointer-events:auto;
}
.restart-card {
width:100%;
max-width:700px;
text-align:center;
background:rgba(255,255,255,.96);
border-radius:38px;
padding:8% 7%;
box-shadow:0 18px 48px rgba(83,49,139,.16);
border:1px solid rgba(127,48,227,.08);
}
.restart-badge {
display:inline-grid;
place-items:center;
width:94px;
aspect-ratio:1/1;
border-radius:50%;
margin-bottom:22px;
color:#fff;
font-weight:900;
font-size:42px;
background:linear-gradient(145deg,#7F30E3,#F90479);
box-shadow:0 12px 26px rgba(127,48,227,.24);
}
.restart-card h2 {
margin:0;
color:#5A43A4;
font-size:clamp(34px,6vw,64px);
line-height:1;
letter-spacing:-.035em;
}
.restart-card p {
margin:18px auto 28px;
max-width:520px;
color:#514B70;
font-size:clamp(18px,2.7vw,26px);
line-height:1.35;
}
.restart-btn {
border:0;
width:min(560px,100%);
border-radius:999px;
padding:20px 28px;
color:#fff;
font-size:clamp(22px,3.4vw,32px);
font-weight:900;
cursor:pointer;
background:linear-gradient(90deg,#D60083,#F90479);
box-shadow:0 12px 28px rgba(249,4,121,.28);
}
"""
html = html.replace("", restart_css + "\n")
# Insert restart screen before closing main
restart_markup = r"""
✓
Готово!
Хотите пройти WB School Hunt ещё раз?
"""
html = html.replace(" ", restart_markup + "\n ")
# Replace GAME_URL constant and final button behavior
html = re.sub(r'\s*// Вставьте сюда фактическую ссылку на игру:\s*const GAME_URL = "/game";\s*', '\n', html)
html = html.replace(
' const toast = document.getElementById("toast");',
' const toast = document.getElementById("toast");\n'
' const restartScreen = document.getElementById("restartScreen");\n'
' const restartButton = document.getElementById("restartButton");'
)
old = ''' gameLink.addEventListener("click", () => {
window.location.href = GAME_URL;
});
render();'''
new = ''' gameLink.addEventListener("click", () => {
restartScreen.classList.add("show");
restartScreen.setAttribute("aria-hidden", "false");
});
restartButton.addEventListener("click", () => {
for (let i = 0; i < state.length; i++) state[i] = false;
restartScreen.classList.remove("show");
restartScreen.setAttribute("aria-hidden", "true");
render();
window.scrollTo({ top: 0, behavior: "smooth" });
});
render();'''
html = html.replace(old, new)
out = Path("/mnt/data/wb-school-hunt-restart.html")
out.write_text(html, encoding="utf-8")
print(f"Created: {out}")