* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Prompt', sans-serif;
}

body {
    background-color: #1a1a2e;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    padding: 10px;
}

.game-container {
    position: relative;
    width: 800px;
    max-width: 100%;
    height: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #87CEEB;
    border-radius: 10px;
    overflow: hidden;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.hidden {
    display: none !important;
}

.game-ui-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 800px;
    z-index: 10;
    margin: 0 auto;
}

.hud {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    font-weight: 600;
    color: #333;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    box-sizing: border-box;
}

.score-info {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.score-info p,
.score-info span,
#heartDisplay {
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums;
}

#factOverlay {
    position: relative;
    z-index: 20;
    width: 90%;
    max-width: 600px;
    background-color: rgba(255, 255, 255, 0.98);
    padding: 15px 20px;
    border-radius: 12px;
    border: 3px solid transparent;
    box-shadow: none;
    text-align: center;
    min-height: 85px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#factOverlay.show-trick {
    opacity: 1;
    visibility: visible;
    border-color: #f37b21;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.fact-title {
    color: #f37b21;
    font-weight: 900;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.fact-desc {
    color: #333;
    font-weight: 500;
    white-space: nowrap;
    font-size: clamp(10px, 3.5vw, 16px);
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 10px;
}

.panel {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.quiz-panel {
    max-width: 600px;
}

h2 {
    color: #f37b21;
    margin-bottom: 10px;
}

button,
.btn-secondary {
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-block;
    margin: 5px;
    text-decoration: none;
}

.btn-primary {
    background-color: #f37b21;
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-choice {
    background-color: #e9ecef;
    color: #333;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: left;
}

.btn-choice:hover {
    background-color: #007bff;
    color: white;
}

.choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.table-container {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.leaderboard-table th,
.leaderboard-table td {
    border-bottom: 1px solid #dee2e6;
    padding: 8px;
    text-align: center;
}

.controls-hint {
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 14px;
    z-index: 10;
}

@keyframes flashWarning {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 0, 0, 1);
    }
}

.warning-pulse {
    animation: flashWarning 0.8s infinite;
}

@keyframes screenShake {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-8px, 4px);
    }

    40% {
        transform: translate(8px, -4px);
    }

    60% {
        transform: translate(-4px, 8px);
    }

    80% {
        transform: translate(4px, -8px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.shake-active {
    animation: screenShake 0.4s ease-in-out;
}

@keyframes glitchAnim {
    0% {
        transform: translate(0);
        opacity: 0.5;
        filter: hue-rotate(0deg) invert(0);
    }

    25% {
        transform: translate(-3px, 3px);
        opacity: 0.8;
        filter: hue-rotate(90deg) invert(0.2);
    }

    50% {
        transform: translate(3px, -3px);
        opacity: 0.6;
        filter: hue-rotate(180deg) invert(0.8);
    }

    75% {
        transform: translate(-3px, -3px);
        opacity: 0.9;
        filter: hue-rotate(270deg) invert(0.4);
    }

    100% {
        transform: translate(0);
        opacity: 0.5;
        filter: hue-rotate(360deg) invert(0);
    }
}

.glitch-active {
    display: block !important;
    animation: glitchAnim 0.2s infinite;
    background: rgba(0, 255, 0, 0.1);
}

body.dark-mode .panel,
body.dark-mode .panel h2,
body.dark-mode .panel h3,
body.dark-mode .panel p,
body.dark-mode .question-text,
body.dark-mode .leaderboard-table th,
body.dark-mode .leaderboard-table td {
    color: #333 !important;
}

body.dark-mode .choices-grid button {
    color: #222 !important;
}

body.dark-mode .controls-hint {
    color: #ffffff !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

body.dark-mode .leaderboard-table tr:nth-child(even) td {
    color: #333 !important;
}

@media screen and (max-width: 600px) {
    .hud {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 8px;
        padding: 10px;
        font-size: 14px;
    }

    .score-info {
        gap: 8px;
        font-size: 12px;
    }

    #heartDisplay {
        display: block;
        margin-left: 0 !important;
        margin-top: 5px;
    }

    #factOverlay {
        min-height: 75px;
        padding: 10px;
        font-size: 14px;
        width: 95%;
    }
}

.controls-hint {
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 14px;
    z-index: 10;
    white-space: nowrap;
}

@media screen and (max-width: 600px) {
    .controls-hint {
        font-size: 11px;
        bottom: 5px;
    }
}

.player-info {
    display: flex;
    align-items: center;
    max-width: 35%;
}

#hudName {
    white-space: nowrap;
    overflow: hidden; 
    text-overflow: ellipsis;
    max-width: 100%; 
    display: inline-block;
}

#loginPanel h2,#loginPanel p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 100%;
    font-size: clamp(14px, 4vw, 24px);
}