* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#game {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: none;
}

#hud {
    position: fixed;
    top: 16px;
    left: 16px;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

#best {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.85;
}

#invert-warning {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
    font-size: clamp(18px, 3.2vw, 30px);
    font-weight: 800;
    text-align: center;
    color: #fff;
    background: rgba(220, 38, 38, 0.92);
    padding: 10px 26px;
    border-radius: 10px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 10;
}

#invert-warning.hidden {
    display: none;
}

#mute-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

#mute-btn:hover {
    background: rgba(0, 0, 0, 0.75);
}

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    text-align: center;
    padding: 24px;
    padding-top: 8vh;
    padding-bottom: 8vh;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    overflow-y: auto;
}

.overlay.hidden {
    display: none;
}

.overlay h1 {
    font-size: clamp(28px, 6vw, 52px);
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

.overlay p {
    max-width: 480px;
    font-size: 16px;
    opacity: 0.9;
}

.overlay p.hint {
    font-size: 14px;
    opacity: 0.7;
}

.overlay button {
    margin-top: 10px;
    padding: 12px 32px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    background: #ffd23f;
    color: #1a1a1a;
    cursor: pointer;
}

.overlay button:hover {
    background: #ffdc66;
}

.overlay button:disabled {
    opacity: 0.5;
    cursor: default;
}

.overlay button:disabled:hover {
    background: #ffd23f;
}

.leaderboard {
    width: 100%;
    max-width: 340px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 14px 18px;
}

.leaderboard h2 {
    font-size: 15px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    text-align: left;
}

.leaderboard-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 6px;
    border-radius: 4px;
}

.leaderboard-list li:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}

.leaderboard-list .rank {
    opacity: 0.6;
    width: 20px;
    flex-shrink: 0;
}

.leaderboard-list .lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-list .lb-score {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.leaderboard-list .empty {
    opacity: 0.6;
    font-style: italic;
    justify-content: center;
}

.submit-form {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 340px;
}

#name-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 15px;
}

#name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#submit-form button {
    margin-top: 0;
    padding: 10px 18px;
    font-size: 15px;
    white-space: nowrap;
}

#submit-status {
    min-height: 18px;
    margin-top: -6px;
}
