Feature: In-game timer, anonymous leaderboard, witty tiered finale results, legal pages, button renames

This commit is contained in:
kobold-ai
2026-09-21 13:23:29 +02:00
parent 16bffa3be8
commit 26ff0660d3
12 changed files with 1508 additions and 74 deletions
+238
View File
@@ -604,6 +604,15 @@ body {
white-space: nowrap;
}
.timer-badge {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
background: rgba(243, 156, 18, 0.15);
border: 1px solid #f39c12;
color: #ffd700;
font-weight: 700;
letter-spacing: 0.5px;
}
.question-text {
font-size: clamp(1.15rem, 4.5vw, 1.45rem);
line-height: 1.4;
@@ -847,6 +856,172 @@ body {
font-size: 1rem;
}
.time-highlight {
margin-top: 8px;
font-size: clamp(0.9rem, 3.2vw, 1.05rem);
color: var(--text-muted);
}
/* Tiered evaluation styling */
.tier-box {
position: relative;
border-radius: 14px;
padding: 24px 18px;
margin: 20px 0;
border: 2px solid var(--border-gold);
background: radial-gradient(circle at top, rgba(201, 168, 106, 0.12) 0%, rgba(15, 17, 30, 0.85) 100%);
text-align: center;
}
.tier-badge-container {
display: flex;
justify-content: center;
margin-bottom: 14px;
}
.tier-grade-badge {
display: inline-flex;
align-items: center;
justify-content: center;
width: 64px;
height: 64px;
border-radius: 50%;
font-size: 2rem;
font-weight: 900;
text-shadow: 0 2px 4px rgba(0,0,0,0.6);
box-shadow: 0 4px 15px rgba(0,0,0,0.5);
border: 3px solid;
}
.tier-outstanding {
background: radial-gradient(circle, #ffd700, #b8860b);
color: #0b0b16;
border-color: #fff275;
box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}
.tier-exceeds {
background: radial-gradient(circle, #2ecc71, #27ae60);
color: #0b0b16;
border-color: #a8f5cc;
box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}
.tier-acceptable {
background: radial-gradient(circle, #3498db, #2980b9);
color: #ffffff;
border-color: #a0d3f8;
box-shadow: 0 0 20px rgba(52, 152, 219, 0.5);
}
.tier-poor {
background: radial-gradient(circle, #e67e22, #d35400);
color: #ffffff;
border-color: #f7b278;
box-shadow: 0 0 20px rgba(230, 126, 34, 0.5);
}
.tier-troll {
background: radial-gradient(circle, #7f8c8d, #34495e);
color: #ff7675;
border-color: #e74c3c;
box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}
.tier-subtitle {
font-style: italic;
color: var(--gold-soft);
margin-bottom: 12px;
font-size: 1rem;
}
/* Leaderboard entry card & form on finale */
.leaderboard-entry-card {
background: rgba(14, 16, 32, 0.85);
border: 1px dashed var(--gold);
padding: 20px;
margin-top: 20px;
text-align: center;
}
.input-with-btn {
display: flex;
gap: 10px;
max-width: 480px;
margin: 0 auto;
width: 100%;
}
.input-with-btn .input-text {
flex: 1;
text-align: left;
}
/* Leaderboard tables & filters */
.diff-filter-tabs {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin: 15px 0;
}
.diff-filter-tabs .tab-btn {
border-radius: 20px;
padding: 8px 16px;
font-size: 0.88rem;
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-gold);
color: var(--text-muted);
}
.diff-filter-tabs .tab-btn.active {
background: rgba(201, 168, 106, 0.25);
border-color: var(--gold);
color: var(--gold-bright);
box-shadow: 0 0 10px rgba(201, 168, 106, 0.35);
}
.table-responsive {
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.lb-table {
width: 100%;
border-collapse: collapse;
text-align: left;
font-size: 0.9rem;
}
.lb-table th {
background: rgba(201, 168, 106, 0.12);
color: var(--gold-soft);
padding: 10px 12px;
border-bottom: 2px solid var(--border-gold);
white-space: nowrap;
}
.lb-table td {
padding: 10px 12px;
border-bottom: 1px solid rgba(201, 168, 106, 0.15);
color: var(--text-main);
}
.lb-table tr:hover td {
background: rgba(201, 168, 106, 0.05);
}
.lb-rank {
font-weight: bold;
color: var(--gold);
}
.lb-rank-1 { color: #ffd700; font-size: 1.1rem; }
.lb-rank-2 { color: #c0c0c0; font-size: 1.05rem; }
.lb-rank-3 { color: #cd7f32; font-size: 1.05rem; }
/* =========================================
FORMS & INPUTS
========================================= */
@@ -1069,6 +1244,69 @@ body {
margin-top: auto;
}
.footer-links {
margin-top: 8px;
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
}
.footer-link {
color: var(--text-muted);
text-decoration: none;
font-size: 0.8rem;
transition: color 0.2s ease;
}
.footer-link:hover {
color: var(--gold-bright);
text-decoration: underline;
}
.footer-sep {
color: rgba(255, 255, 255, 0.2);
}
.legal-card {
text-align: left;
max-width: 760px;
margin: 0 auto;
}
.legal-content {
margin-top: 20px;
line-height: 1.65;
color: var(--text-main);
}
.legal-content h3 {
color: var(--gold-soft);
margin-top: 22px;
margin-bottom: 8px;
font-size: 1.15rem;
border-bottom: 1px solid rgba(201, 168, 106, 0.2);
padding-bottom: 4px;
}
.legal-content p, .legal-content ul {
margin-bottom: 14px;
color: var(--text-muted);
font-size: 0.95rem;
}
.legal-content ul {
padding-left: 20px;
}
.legal-content code {
background: rgba(0, 0, 0, 0.35);
padding: 2px 6px;
border-radius: 4px;
color: var(--gold-bright);
font-size: 0.88em;
}
.hidden {
display: none !important;
}
+29 -5
View File
@@ -6,6 +6,9 @@ let attemptsUsed = 0;
const maxAttempts = 3;
let selectedDifficulty = "all";
let lastQuestionData = null;
let timerStartTime = null;
let timerInterval = null;
let elapsedSeconds = 0;
const UI_TEXT = {
de: {
@@ -24,8 +27,8 @@ const UI_TEXT = {
questionLabel: "Frage",
ofLabel: "von",
attemptLabel: "Versuch",
checkBtn: "✨ Zauber prüfen",
hintBtn: "💡 Zaubertipp",
checkBtn: "✨ Antwort prüfen",
hintBtn: "💡 Hinweis anzeigen",
hintHeading: "📜 Notiz aus der verbotenen Abteilung:",
placeholder: "Deine Antwort hier eingeben...",
noHint: "Kein Tipp vorhanden.",
@@ -53,8 +56,8 @@ const UI_TEXT = {
questionLabel: "Question",
ofLabel: "of",
attemptLabel: "Attempt",
checkBtn: "✨ Check Spell",
hintBtn: "💡 Magic Hint",
checkBtn: "✨ Check Answer",
hintBtn: "💡 Show Hint",
hintHeading: "📜 Note from the Restricted Section:",
placeholder: "Type your answer here...",
noHint: "No hint available.",
@@ -203,6 +206,7 @@ async function startGame() {
setTimeout(() => {
document.getElementById("introCard").classList.add("hidden");
document.getElementById("gameCard").classList.remove("hidden");
startTimer();
renderQuestion(data);
}, 1100);
@@ -214,6 +218,25 @@ async function startGame() {
}
}
function startTimer() {
timerStartTime = Date.now();
elapsedSeconds = 0;
if (timerInterval) clearInterval(timerInterval);
timerInterval = setInterval(updateTimer, 1000);
updateTimer();
}
function updateTimer() {
if (!timerStartTime) return;
elapsedSeconds = Math.floor((Date.now() - timerStartTime) / 1000);
const m = Math.floor(elapsedSeconds / 60);
const s = elapsedSeconds % 60;
const badge = document.getElementById("timerBadge");
if (badge) {
badge.innerText = `⏱️ ${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
}
}
function renderQuestion(qData) {
lastQuestionData = qData;
const t = UI_TEXT[currentLang] || UI_TEXT.de;
@@ -424,8 +447,9 @@ async function requestHint() {
}
function finishGame() {
if (timerInterval) clearInterval(timerInterval);
document.getElementById("progressBar").style.width = "100%";
window.location.href = `/finale?score=${currentScore}&total=${totalQuestions}&lang=${currentLang}`;
window.location.href = `/finale?score=${currentScore}&total=${totalQuestions}&time=${elapsedSeconds}&lang=${currentLang}`;
}
// Enter key to submit